40 |
* Draws a filled (possibly with several colors) background rectangle, |
* Draws a filled (possibly with several colors) background rectangle, |
41 |
* surrounded by a rectangle of the current foreground color. |
* surrounded by a rectangle of the current foreground color. |
42 |
*/ |
*/ |
43 |
public class RectBgVob extends AbstractVob { |
public class RectBgVob extends AbstractColorableVob { |
44 |
public static final String rcsid = "$Id$"; |
public static final String rcsid = "$Id$"; |
45 |
public static boolean dbg = false; |
public static boolean dbg = false; |
46 |
private static void pa(String s) { System.err.println(s); } |
private static void pa(String s) { System.err.println(s); } |
47 |
|
|
|
int NColors = 0; |
|
|
Color[] colors; |
|
|
|
|
48 |
/** Background color */ |
/** Background color */ |
49 |
protected final Color bgColor; |
protected final Color bgColor; |
50 |
|
|
89 |
if (mh > 14) g.fillRect(mx-2, my-2, mw+4, mh+4); |
if (mh > 14) g.fillRect(mx-2, my-2, mw+4, mh+4); |
90 |
else g.fillRect(mx-1, my-1, mw+2, mh+2); |
else g.fillRect(mx-1, my-1, mw+2, mh+2); |
91 |
|
|
92 |
if(colors == null || NColors == 0) { |
if(colors == null || colors.length == 0) { |
93 |
g.setColor(bgColor); |
g.setColor(bgColor); |
94 |
g.fillRect(mx, my, mw, mh); |
g.fillRect(mx, my, mw, mh); |
95 |
} else { |
} else { |
96 |
for(int i=0; i<NColors; i++) { |
for(int i=0; i<colors.length; i++) { |
97 |
g.setColor(colors[i]); |
g.setColor(colors[i]); |
98 |
g.fillRect(mx+(mw*i)/NColors, my, |
g.fillRect(mx+(mw*i)/colors.length, my, |
99 |
mw/NColors, mh); |
mw/colors.length, mh); |
100 |
} |
} |
101 |
} |
} |
102 |
|
|
118 |
if(dbg) pa("Addtolistgl rectbg "+coordsys1); |
if(dbg) pa("Addtolistgl rectbg "+coordsys1); |
119 |
if(glList == null) { |
if(glList == null) { |
120 |
String bgcall = ""; |
String bgcall = ""; |
121 |
if(colors != null && NColors > 0) { |
if(colors != null && colors.length > 0) { |
122 |
double w = 1.0 / NColors; |
double w = 1.0 / colors.length; |
123 |
|
|
124 |
for(int i=0; i<NColors; i++) { |
for(int i=0; i<colors.length; i++) { |
125 |
double x1 = i*w; |
double x1 = i*w; |
126 |
double x2 = x1 + w; |
double x2 = x1 + w; |
127 |
bgcall += ( |
bgcall += ( |
173 |
"End\n" ); |
"End\n" ); |
174 |
return glString; |
return glString; |
175 |
} |
} |
|
|
|
|
|
|
|
/** Adds one more solid color to be drawn inside |
|
|
* the cell. |
|
|
*/ |
|
|
public boolean addColor(Color c) { |
|
|
if(colors == null || NColors >= colors.length) { |
|
|
Color[] n= new Color[NColors + 10]; |
|
|
if(colors != null) System.arraycopy(colors, 0, n, 0, NColors); |
|
|
colors = n; |
|
|
} |
|
|
colors[NColors++] = c; |
|
|
return false; |
|
|
} |
|
|
/** The currently put solid colors. |
|
|
* null = none. There may be null references near the end |
|
|
* of the array. Mostly useful for checking for nullness. |
|
|
*/ |
|
|
public Color[] getSolidColors() { return colors; } |
|
176 |
} |
} |
177 |
|
|