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 MenuBarMenuPainter extends AbstractRegionPainter { 18 static final int BACKGROUND_DISABLED = 1; 23 static final int BACKGROUND_ENABLED = 2; 24 static final int BACKGROUND_SELECTED = 3; 25 26 27 private int state; private PaintContext ctx; 29 30 private Path2D path = new Path2D.Float(); 32 private Rectangle2D rect = new Rectangle2D.Float(0, 0, 0, 0); 33 private RoundRectangle2D roundRect = new RoundRectangle2D.Float(0, 0, 0, 0, 0, 0); 34 private Ellipse2D ellipse = new Ellipse2D.Float(0, 0, 0, 0); 35 36 private Color color1 = decodeColor("nimbusBase", -0.010750473f, -0.04875779f, -0.007843137f, 0); 40 41 42 private Object [] componentColors; 44 45 public MenuBarMenuPainter(PaintContext ctx, int state) { 46 super(); 47 this.state = state; 48 this.ctx = ctx; 49 } 50 51 @Override 52 protected void doPaint(Graphics2D g, JComponent c, int width, int height, Object [] extendedCacheKeys) { 53 componentColors = extendedCacheKeys; 55 switch(state) { 58 case BACKGROUND_SELECTED: paintBackgroundSelected(g); break; 59 60 } 61 } 62 63 64 65 @Override 66 protected final PaintContext getPaintContext() { 67 return ctx; 68 } 69 70 private void paintBackgroundSelected(Graphics2D g) { 71 rect = decodeRect1(); 72 g.setPaint(color1); 73 g.fill(rect); 74 75 } 76 77 78 79 private Rectangle2D decodeRect1() { 80 rect.setRect(decodeX(1.0f), decodeY(1.0f), decodeX(2.0f) - decodeX(1.0f), decodeY(2.0f) - decodeY(1.0f)); return rect; 85 } 86 87 88 89 90 } 91 | Popular Tags |