1 7 package com.sun.java.swing.plaf.gtk; 8 9 import javax.swing.plaf.synth.*; 10 import java.awt.*; 11 import java.util.*; 12 import javax.swing.*; 13 import javax.swing.plaf.*; 14 import sun.swing.plaf.synth.*; 15 16 20 class BluecurveStyle extends GTKStyle implements GTKConstants { 21 24 private static final GTKEngine BLUECURVE_ENGINE = new BluecurveEngine(); 25 26 private static final Color DEFAULT_COLOR = new ColorUIResource(0, 0, 0); 27 28 32 private Color[] blueColors; 33 34 37 public BluecurveStyle(DefaultSynthStyle style) { 38 super(style); 39 } 40 41 44 public BluecurveStyle(StateInfo[] states, 45 CircularIdentityList classSpecificValues, 46 Font font, 47 int xThickness, int yThickness, 48 GTKStockIconInfo[] icons) { 49 super(states, classSpecificValues, font, xThickness, yThickness,icons); 50 } 51 52 56 public DefaultSynthStyle addTo(DefaultSynthStyle s) { 57 if (!(s instanceof BluecurveStyle)) { 58 s = new BluecurveStyle(s); 59 } 60 BluecurveStyle style = (BluecurveStyle)super.addTo(s); 61 return style; 62 } 63 64 67 public Object clone() { 68 return super.clone(); 69 } 70 71 74 public GTKEngine getEngine(SynthContext context) { 75 return BLUECURVE_ENGINE; 76 } 77 78 Color getDefaultColor(JComponent c, Region id, int state, 79 ColorType type) { 80 int colorID = type.getID(); 81 if (colorID >= BluecurveColorType.MIN_ID && 82 colorID <= BluecurveColorType.MAX_ID) { 83 if (blueColors == null) { 84 int min = BluecurveColorType.MIN_ID; 85 Color base = getGTKColor(c, id, SynthConstants.SELECTED, 86 GTKColorType.TEXT_BACKGROUND); 87 Color bg = getGTKColor(c, id, SynthConstants.ENABLED, 88 GTKColorType.BACKGROUND); 89 90 blueColors = new Color[BluecurveColorType.MAX_ID - min + 1]; 91 blueColors[BluecurveColorType.OUTER.getID() - min] = 92 GTKColorType.adjustColor(base, 1.0f, .72f, .7f); 93 blueColors[BluecurveColorType.INNER_LEFT.getID() - min] = 94 GTKColorType.adjustColor(base, 1.0f, 1.63f, 1.53f); 95 blueColors[BluecurveColorType.TOP_GRADIENT.getID() - min] = 96 GTKColorType.adjustColor(base, 1.0f, .93f, .88f); 97 blueColors[BluecurveColorType.BOTTOM_GRADIENT.getID() - min] = 98 GTKColorType.adjustColor(base, 1f, 1.16f,1.13f); 99 blueColors[BluecurveColorType.INNER_RIGHT.getID() - min] = 100 GTKColorType.adjustColor(base, 1.0f, 1.06f, 1.08f); 101 102 blueColors[BluecurveColorType.OUTER2.getID() - min] = 103 GTKColorType.adjustColor(bg, 1.0f, .67f, .67f); 104 blueColors[BluecurveColorType.INNER_RIGHT2.getID() - min] = 105 GTKColorType.adjustColor(bg, 1.0f, .92f, .92f); 106 107 blueColors[BluecurveColorType.OUTER3.getID() - min] = 108 GTKColorType.adjustColor(bg, 1.0f, .4f, .4f); 109 110 blueColors[BluecurveColorType.OUTER4.getID() - min] = 111 GTKColorType.adjustColor(bg, 1.0f, .84f, .84f); 112 113 blueColors[BluecurveColorType.OUTER5.getID() - min] = 114 GTKColorType.adjustColor(bg, 1.0f, .245f, .192f); 115 } 116 return blueColors[colorID - BluecurveColorType.MIN_ID]; 117 } 118 return super.getDefaultColor(c, id, state, type); 119 } 120 121 public String toString() { 122 StringBuffer buf = new StringBuffer (super.toString()); 123 124 if (blueColors != null) { 125 buf.append("\t" + BluecurveColorType.OUTER + "=" + 126 blueColors[BluecurveColorType.OUTER.getID() - 127 BluecurveColorType.MIN_ID] + "\n"); 128 buf.append("\t" + BluecurveColorType.INNER_LEFT + "=" + 129 blueColors[BluecurveColorType.INNER_LEFT.getID() - 130 BluecurveColorType.MIN_ID] + "\n"); 131 buf.append("\t" + BluecurveColorType.INNER_RIGHT + "=" + 132 blueColors[BluecurveColorType.INNER_RIGHT.getID() - 133 BluecurveColorType.MIN_ID] + "\n"); 134 buf.append("\t" + BluecurveColorType.TOP_GRADIENT + "=" + 135 blueColors[BluecurveColorType.TOP_GRADIENT.getID() - 136 BluecurveColorType.MIN_ID] + "\n"); 137 buf.append("\t" + BluecurveColorType.BOTTOM_GRADIENT + "=" + 138 blueColors[BluecurveColorType.BOTTOM_GRADIENT.getID() - 139 BluecurveColorType.MIN_ID] + "\n"); 140 buf.append("\t" + BluecurveColorType.OUTER2 + "=" + 141 blueColors[BluecurveColorType.OUTER2.getID() - 142 BluecurveColorType.MIN_ID] + "\n"); 143 buf.append("\t" + BluecurveColorType.INNER_RIGHT2 + "=" + 144 blueColors[BluecurveColorType.INNER_RIGHT2.getID() - 145 BluecurveColorType.MIN_ID] + "\n"); 146 buf.append("\t" + BluecurveColorType.OUTER3 + "=" + 147 blueColors[BluecurveColorType.OUTER3.getID() - 148 BluecurveColorType.MIN_ID] + "\n"); 149 buf.append("\t" + BluecurveColorType.OUTER4 + "=" + 150 blueColors[BluecurveColorType.OUTER4.getID() - 151 BluecurveColorType.MIN_ID] + "\n"); 152 buf.append("\t" + BluecurveColorType.OUTER5 + "=" + 153 blueColors[BluecurveColorType.OUTER5.getID() - 154 BluecurveColorType.MIN_ID] + "\n"); 155 } 156 return buf.toString(); 157 } 158 } 159 | Popular Tags |