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 ToolTipPainter 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("nimbusBorder", 0.0f, 0.0f, 0.0f, 0); 38 private Color color2 = decodeColor("info", 0.0f, 0.0f, 0.0f, 0); 39 40 41 private Object [] componentColors; 43 44 public ToolTipPainter(PaintContext ctx, int state) { 45 super(); 46 this.state = state; 47 this.ctx = ctx; 48 } 49 50 @Override 51 protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object [] extendedCacheKeys) { 52 componentColors = extendedCacheKeys; 54 switch(state) { 57 case BACKGROUND_ENABLED: paintBackgroundEnabled(g); break; 58 59 } 60 } 61 62 63 64 @Override 65 protected final PaintContext getPaintContext() { 66 return ctx; 67 } 68 69 private void paintBackgroundEnabled(Graphics2D g) { 70 rect = decodeRect1(); 71 g.setPaint(color1); 72 g.fill(rect); 73 rect = decodeRect2(); 74 g.setPaint(color1); 75 g.fill(rect); 76 rect = decodeRect3(); 77 g.setPaint(color1); 78 g.fill(rect); 79 rect = decodeRect4(); 80 g.setPaint(color1); 81 g.fill(rect); 82 rect = decodeRect5(); 83 g.setPaint(color2); 84 g.fill(rect); 85 86 } 87 88 89 90 private Rectangle2D decodeRect1() { 91 rect.setRect(decodeX(2.0f), decodeY(1.0f), decodeX(3.0f) - decodeX(2.0f), decodeY(2.0f) - decodeY(1.0f)); return rect; 96 } 97 98 private Rectangle2D decodeRect2() { 99 rect.setRect(decodeX(0.0f), decodeY(1.0f), decodeX(1.0f) - decodeX(0.0f), decodeY(2.0f) - decodeY(1.0f)); return rect; 104 } 105 106 private Rectangle2D decodeRect3() { 107 rect.setRect(decodeX(0.0f), decodeY(2.0f), decodeX(3.0f) - decodeX(0.0f), decodeY(3.0f) - decodeY(2.0f)); return rect; 112 } 113 114 private Rectangle2D decodeRect4() { 115 rect.setRect(decodeX(0.0f), decodeY(0.0f), decodeX(3.0f) - decodeX(0.0f), decodeY(1.0f) - decodeY(0.0f)); return rect; 120 } 121 122 private Rectangle2D decodeRect5() { 123 rect.setRect(decodeX(1.0f), decodeY(1.0f), decodeX(2.0f) - decodeX(1.0f), decodeY(2.0f) - decodeY(1.0f)); return rect; 128 } 129 130 131 132 133 } 134 | Popular Tags |