1 7 package com.sun.java.swing.plaf.nimbus; 8 9 import java.awt.*; 10 import java.awt.geom.*; 11 import java.awt.image.*; 12 import javax.swing.*; 13 import com.sun.java.swing.Painter; 14 15 17 public final class SeparatorPainter extends AbstractRegionPainter { 18 static final int BACKGROUND_ENABLED = 1; 23 24 25 private int state; private PaintContext ctx; 27 28 private Path2D path = new Path2D.Float(); 30 private Rectangle2D rect = new Rectangle2D.Float(0, 0, 0, 0); 31 private RoundRectangle2D roundRect = new RoundRectangle2D.Float(0, 0, 0, 0, 0, 0); 32 private Ellipse2D ellipse = new Ellipse2D.Float(0, 0, 0, 0); 33 34 private Color color1 = decodeColor("nimbusBlueGrey", -0.008547008f, -0.03830409f, -0.039215684f, 0); 38 39 40 private Object [] componentColors; 42 43 public SeparatorPainter(PaintContext ctx, int state) { 44 super(); 45 this.state = state; 46 this.ctx = ctx; 47 } 48 49 @Override 50 protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object [] extendedCacheKeys) { 51 componentColors = extendedCacheKeys; 53 switch(state) { 56 case BACKGROUND_ENABLED: paintBackgroundEnabled(g); break; 57 58 } 59 } 60 61 62 63 @Override 64 protected final PaintContext getPaintContext() { 65 return ctx; 66 } 67 68 private void paintBackgroundEnabled(Graphics2D g) { 69 rect = decodeRect1(); 70 g.setPaint(color1); 71 g.fill(rect); 72 73 } 74 75 76 77 private Rectangle2D decodeRect1() { 78 rect.setRect(decodeX(0.0f), decodeY(1.3333334f), decodeX(3.0f) - decodeX(0.0f), decodeY(1.6666667f) - decodeY(1.3333334f)); return rect; 83 } 84 85 86 87 88 } 89 | Popular Tags |