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 ToolBarSeparatorPainter 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 = new Color(116, 120, 128, 255); 38 39 40 private Object [] componentColors; 42 43 public ToolBarSeparatorPainter(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 rect = decodeRect2(); 73 g.setPaint(color1); 74 g.fill(rect); 75 rect = decodeRect3(); 76 g.setPaint(color1); 77 g.fill(rect); 78 rect = decodeRect4(); 79 g.setPaint(color1); 80 g.fill(rect); 81 rect = decodeRect5(); 82 g.setPaint(color1); 83 g.fill(rect); 84 rect = decodeRect6(); 85 g.setPaint(color1); 86 g.fill(rect); 87 rect = decodeRect7(); 88 g.setPaint(color1); 89 g.fill(rect); 90 rect = decodeRect8(); 91 g.setPaint(color1); 92 g.fill(rect); 93 rect = decodeRect9(); 94 g.setPaint(color1); 95 g.fill(rect); 96 rect = decodeRect10(); 97 g.setPaint(color1); 98 g.fill(rect); 99 rect = decodeRect11(); 100 g.setPaint(color1); 101 g.fill(rect); 102 rect = decodeRect12(); 103 g.setPaint(color1); 104 g.fill(rect); 105 106 } 107 108 109 110 private Rectangle2D decodeRect1() { 111 rect.setRect(decodeX(1.0526316f), decodeY(1.4f), decodeX(1.0789473f) - decodeX(1.0526316f), decodeY(1.6f) - decodeY(1.4f)); return rect; 116 } 117 118 private Rectangle2D decodeRect2() { 119 rect.setRect(decodeX(1.1315789f), decodeY(1.4f), decodeX(1.1578947f) - decodeX(1.1315789f), decodeY(1.6f) - decodeY(1.4f)); return rect; 124 } 125 126 private Rectangle2D decodeRect3() { 127 rect.setRect(decodeX(1.2105263f), decodeY(1.4f), decodeX(1.2368422f) - decodeX(1.2105263f), decodeY(1.6f) - decodeY(1.4f)); return rect; 132 } 133 134 private Rectangle2D decodeRect4() { 135 rect.setRect(decodeX(1.2894737f), decodeY(1.4f), decodeX(1.3157895f) - decodeX(1.2894737f), decodeY(1.6f) - decodeY(1.4f)); return rect; 140 } 141 142 private Rectangle2D decodeRect5() { 143 rect.setRect(decodeX(1.3684211f), decodeY(1.4f), decodeX(1.3947369f) - decodeX(1.3684211f), decodeY(1.6f) - decodeY(1.4f)); return rect; 148 } 149 150 private Rectangle2D decodeRect6() { 151 rect.setRect(decodeX(1.4473684f), decodeY(1.4f), decodeX(1.4736842f) - decodeX(1.4473684f), decodeY(1.6f) - decodeY(1.4f)); return rect; 156 } 157 158 private Rectangle2D decodeRect7() { 159 rect.setRect(decodeX(1.5263158f), decodeY(1.4f), decodeX(1.5526316f) - decodeX(1.5263158f), decodeY(1.6f) - decodeY(1.4f)); return rect; 164 } 165 166 private Rectangle2D decodeRect8() { 167 rect.setRect(decodeX(1.6052632f), decodeY(1.4f), decodeX(1.6315789f) - decodeX(1.6052632f), decodeY(1.6f) - decodeY(1.4f)); return rect; 172 } 173 174 private Rectangle2D decodeRect9() { 175 rect.setRect(decodeX(1.6842105f), decodeY(1.4f), decodeX(1.7105262f) - decodeX(1.6842105f), decodeY(1.6f) - decodeY(1.4f)); return rect; 180 } 181 182 private Rectangle2D decodeRect10() { 183 rect.setRect(decodeX(1.7631578f), decodeY(1.4f), decodeX(1.7894738f) - decodeX(1.7631578f), decodeY(1.6f) - decodeY(1.4f)); return rect; 188 } 189 190 private Rectangle2D decodeRect11() { 191 rect.setRect(decodeX(1.8421053f), decodeY(1.4f), decodeX(1.8684211f) - decodeX(1.8421053f), decodeY(1.6f) - decodeY(1.4f)); return rect; 196 } 197 198 private Rectangle2D decodeRect12() { 199 rect.setRect(decodeX(1.9210527f), decodeY(1.4f), decodeX(1.9473684f) - decodeX(1.9210527f), decodeY(1.6f) - decodeY(1.4f)); return rect; 204 } 205 206 207 208 209 } 210 | Popular Tags |