< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/nimbus/LoweredBorder.java

Print this page




  49     private static final PaintContext PAINT_CONTEXT = new PaintContext(INSETS,
  50             new Dimension(IMG_SIZE,IMG_SIZE),false,
  51             PaintContext.CacheMode.NINE_SQUARE_SCALE,
  52             Integer.MAX_VALUE, Integer.MAX_VALUE);
  53 
  54     // =========================================================================
  55     // Painter Methods
  56 
  57     @Override
  58     protected Object[] getExtendedCacheKeys(JComponent c) {
  59         return (c != null)
  60                 ? new Object[] { c.getBackground() }
  61                 : null;
  62     }
  63 
  64     /**
  65      * Actually performs the painting operation. Subclasses must implement this
  66      * method. The graphics object passed may represent the actual surface being
  67      * rendered to, or it may be an intermediate buffer. It has also been
  68      * pre-translated. Simply render the component as if it were located at 0, 0
  69      * and had a width of <code>width</code> and a height of
  70      * <code>height</code>. For performance reasons, you may want to read the
  71      * clip from the Graphics2D object and only render within that space.
  72      *
  73      * @param g      The Graphics2D surface to paint to
  74      * @param c      The JComponent related to the drawing event. For example,
  75      *               if the region being rendered is Button, then <code>c</code>
  76      *               will be a JButton. If the region being drawn is
  77      *               ScrollBarSlider, then the component will be JScrollBar.
  78      *               This value may be null.
  79      * @param width  The width of the region to paint. Note that in the case of
  80      *               painting the foreground, this value may differ from
  81      *               c.getWidth().
  82      * @param height The height of the region to paint. Note that in the case of
  83      *               painting the foreground, this value may differ from
  84      *               c.getHeight().
  85      */
  86     protected void doPaint(Graphics2D g, JComponent c, int width, int height,
  87             Object[] extendedCacheKeys) {
  88         Color color = (c == null) ? Color.BLACK : c.getBackground();
  89         BufferedImage img1 = new BufferedImage(IMG_SIZE,IMG_SIZE,
  90                     BufferedImage.TYPE_INT_ARGB);
  91         BufferedImage img2 = new BufferedImage(IMG_SIZE,IMG_SIZE,
  92                     BufferedImage.TYPE_INT_ARGB);
  93         // draw shadow shape
  94         Graphics2D g2 = (Graphics2D)img1.getGraphics();
  95         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,




  49     private static final PaintContext PAINT_CONTEXT = new PaintContext(INSETS,
  50             new Dimension(IMG_SIZE,IMG_SIZE),false,
  51             PaintContext.CacheMode.NINE_SQUARE_SCALE,
  52             Integer.MAX_VALUE, Integer.MAX_VALUE);
  53 
  54     // =========================================================================
  55     // Painter Methods
  56 
  57     @Override
  58     protected Object[] getExtendedCacheKeys(JComponent c) {
  59         return (c != null)
  60                 ? new Object[] { c.getBackground() }
  61                 : null;
  62     }
  63 
  64     /**
  65      * Actually performs the painting operation. Subclasses must implement this
  66      * method. The graphics object passed may represent the actual surface being
  67      * rendered to, or it may be an intermediate buffer. It has also been
  68      * pre-translated. Simply render the component as if it were located at 0, 0
  69      * and had a width of {@code width} and a height of
  70      * {@code height}. For performance reasons, you may want to read the
  71      * clip from the Graphics2D object and only render within that space.
  72      *
  73      * @param g      The Graphics2D surface to paint to
  74      * @param c      The JComponent related to the drawing event. For example,
  75      *               if the region being rendered is Button, then {@code c}
  76      *               will be a JButton. If the region being drawn is
  77      *               ScrollBarSlider, then the component will be JScrollBar.
  78      *               This value may be null.
  79      * @param width  The width of the region to paint. Note that in the case of
  80      *               painting the foreground, this value may differ from
  81      *               c.getWidth().
  82      * @param height The height of the region to paint. Note that in the case of
  83      *               painting the foreground, this value may differ from
  84      *               c.getHeight().
  85      */
  86     protected void doPaint(Graphics2D g, JComponent c, int width, int height,
  87             Object[] extendedCacheKeys) {
  88         Color color = (c == null) ? Color.BLACK : c.getBackground();
  89         BufferedImage img1 = new BufferedImage(IMG_SIZE,IMG_SIZE,
  90                     BufferedImage.TYPE_INT_ARGB);
  91         BufferedImage img2 = new BufferedImage(IMG_SIZE,IMG_SIZE,
  92                     BufferedImage.TYPE_INT_ARGB);
  93         // draw shadow shape
  94         Graphics2D g2 = (Graphics2D)img1.getGraphics();
  95         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,


< prev index next >