1 19 20 21 package org.netbeans.swing.tabcontrol.plaf; 22 23 import java.awt.Color ; 24 import java.awt.Dimension ; 25 import java.awt.Font ; 26 import java.awt.FontMetrics ; 27 import java.awt.Graphics ; 28 import java.awt.Graphics2D ; 29 import java.awt.Insets ; 30 import java.awt.Rectangle ; 31 import java.awt.geom.AffineTransform ; 32 import javax.swing.*; 33 import javax.swing.plaf.ComponentUI ; 34 import javax.swing.plaf.basic.BasicHTML ; 35 import javax.swing.text.View ; 36 import org.netbeans.swing.tabcontrol.SlideBarDataModel; 37 import org.netbeans.swing.tabcontrol.SlidingButton; 38 import org.netbeans.swing.tabcontrol.SlidingButtonUI; 39 import org.netbeans.swing.tabcontrol.plaf.GenericGlowingChiclet; 40 41 45 public class AquaSlidingButtonUI extends SlidingButtonUI { 46 47 private static AquaSlidingButtonUI AQUA_INSTANCE = null; 48 49 static Color [] rollover = new Color []{ 50 new Color (222, 222, 227), new Color (220, 238, 255), new Color (190, 247, 255), 51 new Color (205, 205, 205)}; 52 53 54 55 private AquaSlidingButtonUI() { 56 } 57 58 59 61 public static ComponentUI createUI(JComponent c) { 62 if (AQUA_INSTANCE == null) { 63 AQUA_INSTANCE = new AquaSlidingButtonUI(); 64 } 65 return AQUA_INSTANCE; 66 } 67 68 public void installUI(JComponent c) { 69 super.installUI(c); 70 c.setFont (UIManager.getFont("Tree.font")); 71 } 72 73 private ChicletWrapper chic = new ChicletWrapper(); 74 protected void paintBackground(Graphics2D graph, AbstractButton b) { 75 chic.setNotch(false, false); 76 77 chic.setState(((SlidingButton) b).isBlinkState() ? GenericGlowingChiclet.STATE_ATTENTION : 0); 78 chic.setArcs(0.5f, 0.5f, 0.5f, 0.5f); 79 chic.setBounds(0, 1, b.getWidth(), b.getHeight() - 2); 80 chic.setAllowVertical(true); 81 chic.draw(graph); 82 chic.setAllowVertical(false); 83 } 84 85 protected void paintButtonPressed(Graphics graph, AbstractButton b) { 86 chic.setNotch(false, false); 87 int state = 0; 88 state |= b.getModel().isSelected() ? GenericGlowingChiclet.STATE_SELECTED : 0; 89 state |= b.getModel().isPressed() ? GenericGlowingChiclet.STATE_PRESSED : 0; 90 state |= b.getModel().isRollover() ? GenericGlowingChiclet.STATE_ACTIVE : 0; 91 state |= ((SlidingButton) b).isBlinkState() ? GenericGlowingChiclet.STATE_ATTENTION : 0; 92 chic.setState(state); 93 chic.setArcs(0.5f, 0.5f, 0.5f, 0.5f); 94 chic.setBounds(0, 1, b.getWidth(), b.getHeight() - 2); 95 chic.setAllowVertical(true); 96 chic.draw((Graphics2D )graph); 97 chic.setAllowVertical(false); 98 } 99 100 public Dimension getPreferredSize(JComponent c) { 104 SlidingButton slide = (SlidingButton) c; 105 Dimension d = new Dimension (super.getPreferredSize(c)); 106 Insets i = c.getInsets(); 107 int orientation = slide.getOrientation(); 108 109 if (orientation == SlideBarDataModel.SOUTH) { 110 if (i.top + i.bottom < 5) 111 d.height += 5; 112 if (i.left + i.right < 7) 113 d.width += 7; 114 } 115 else { 116 if (i.top + i.bottom < 7) 117 d.height += 7; 118 if (i.left + i.right < 5) 119 d.width += 5; 120 } 121 122 return d; 123 } 124 } 125 | Popular Tags |