41 |
* Draws a filled (possibly with several colors) background circle, |
* Draws a filled (possibly with several colors) background circle, |
42 |
* surrounded by a circle of the current foreground color. |
* surrounded by a circle of the current foreground color. |
43 |
*/ |
*/ |
44 |
public class OvalBgVob extends AbstractVob { |
public class OvalBgVob extends AbstractColorableVob { |
45 |
public static final String rcsid = "$Id$"; |
public static final String rcsid = "$Id$"; |
46 |
public static boolean dbg = false; |
public static boolean dbg = false; |
47 |
private static final void p(String s) { if(dbg) System.out.println(s); } |
private static final void p(String s) { if(dbg) System.out.println(s); } |
48 |
|
|
|
int NColors = 0; |
|
|
Color[] colors; |
|
|
|
|
49 |
/** Background color */ |
/** Background color */ |
50 |
protected final Color bgColor; |
protected final Color bgColor; |
51 |
|
|
130 |
if(mh >= 14) g.fillOval(mx-2, my-2, mw+4, mh+4); |
if(mh >= 14) g.fillOval(mx-2, my-2, mw+4, mh+4); |
131 |
else g.fillOval(mx-1, my-1, mw+2, mh+2); |
else g.fillOval(mx-1, my-1, mw+2, mh+2); |
132 |
|
|
133 |
if(colors == null || NColors == 0) { |
if(colors == null || colors.length == 0) { |
134 |
g.setColor(bgColor); |
g.setColor(bgColor); |
135 |
g.fillOval(mx, my, mw, mh); |
g.fillOval(mx, my, mw, mh); |
136 |
} else { |
} else { |
147 |
*/ |
*/ |
148 |
g.setColor(colors[0]); |
g.setColor(colors[0]); |
149 |
g.fillArc(mx, my, mw, mh, -90, 180); |
g.fillArc(mx, my, mw, mh, -90, 180); |
150 |
g.setColor(colors[NColors-1]); |
g.setColor(colors[colors.length-1]); |
151 |
g.fillArc(mx, my, mw, mh, 90, 180); |
g.fillArc(mx, my, mw, mh, 90, 180); |
152 |
int lastColor = NColors-1; |
int lastColor = colors.length-1; |
153 |
int colorWidth = mw / NColors; |
int colorWidth = mw / colors.length; |
154 |
float a = mw/2; |
float a = mw/2; |
155 |
float b = mh/2; |
float b = mh/2; |
156 |
for(int i=1; i<lastColor; i++) { |
for(int i=1; i<lastColor; i++) { |
196 |
if(glList == null) { |
if(glList == null) { |
197 |
if (!circleGLReady) prepareCircleGL(0.5f); |
if (!circleGLReady) prepareCircleGL(0.5f); |
198 |
String bgcall = ""; |
String bgcall = ""; |
199 |
if(colors != null && NColors > 0) { |
if(colors != null && colors.length > 0) { |
200 |
bgcall += glColorsString(); |
bgcall += glColorsString(); |
201 |
} else bgcall += glRectBgString(); |
} else bgcall += glRectBgString(); |
202 |
|
|
290 |
} |
} |
291 |
|
|
292 |
protected String glColorsString() { |
protected String glColorsString() { |
293 |
double w = 1.0 / NColors; |
double w = 1.0 / colors.length; |
294 |
String glString = ""; |
String glString = ""; |
295 |
for(int i=0; i<NColors; i++) { |
for(int i=0; i<colors.length; i++) { |
296 |
double x1 = i*w; |
double x1 = i*w; |
297 |
double x2 = x1 + w; |
double x2 = x1 + w; |
298 |
Color c = colors[i]; |
Color c = colors[i]; |
311 |
} |
} |
312 |
return glString; |
return glString; |
313 |
} |
} |
|
|
|
|
/** 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; } |
|
314 |
} |
} |