56 |
* |
* |
57 |
* @author Sascha Brawer (brawer@dandelis.ch) |
* @author Sascha Brawer (brawer@dandelis.ch) |
58 |
*/ |
*/ |
59 |
public class EtchedBorder |
public class EtchedBorder extends AbstractBorder |
|
extends AbstractBorder |
|
60 |
{ |
{ |
61 |
/** |
/** |
62 |
* Determined using the <code>serialver</code> tool |
* Determined using the <code>serialver</code> tool |
198 |
* @param width the width of the available area for painting the border. |
* @param width the width of the available area for painting the border. |
199 |
* @param height the height of the available area for painting the border. |
* @param height the height of the available area for painting the border. |
200 |
*/ |
*/ |
201 |
public void paintBorder(Component c, Graphics g, |
public void paintBorder(Component c, Graphics g, int x, int y, int width, |
202 |
int x, int y, int width, int height) |
int height) |
203 |
{ |
{ |
204 |
switch (etchType) |
switch (etchType) |
205 |
{ |
{ |
269 |
*/ |
*/ |
270 |
public boolean isBorderOpaque() |
public boolean isBorderOpaque() |
271 |
{ |
{ |
272 |
/* If the colors are to be drived from the enclosed Component's |
// If the colors are to be derived from the enclosed Component's |
273 |
* background color, the border is guaranteed to be fully opaque |
// background color, the border is guaranteed to be fully opaque |
274 |
* because Color.brighten() and Color.darken() always return an |
// because Color.brighten() and Color.darken() always return an |
275 |
* opaque color. |
// opaque color. |
|
*/ |
|
276 |
return |
return |
277 |
((highlight == null) || (highlight.getAlpha() == 255)) |
((highlight == null) || (highlight.getAlpha() == 255)) |
278 |
&& ((shadow == null) || (shadow.getAlpha() == 255)); |
&& ((shadow == null) || (shadow.getAlpha() == 255)); |
279 |
} |
} |
|
|
|
280 |
|
|
281 |
/** |
/** |
282 |
* Returns the appearance of this EtchedBorder, which is either |
* Returns the appearance of this EtchedBorder, which is either |
307 |
else |
else |
308 |
return c.getBackground().brighter(); |
return c.getBackground().brighter(); |
309 |
} |
} |
310 |
|
|
|
|
|
311 |
/** |
/** |
312 |
* Returns the color that will be used for highlighted parts when |
* Returns the color that will be used for highlighted parts when |
313 |
* painting the border, or <code>null</code> if that color will be |
* painting the border, or <code>null</code> if that color will be |
355 |
* Paints a two-pixel etching in two colors. |
* Paints a two-pixel etching in two colors. |
356 |
* |
* |
357 |
* <pre> |
* <pre> |
358 |
* @@@@@@@@@@@. |
* +++++++++++. |
359 |
* @.........@. @ = color a |
* +.........+. + = color a |
360 |
* @. @. . = color b |
* +. +. . = color b |
361 |
* @. @. |
* +. +. |
362 |
* @@@@@@@@@@@. |
* +++++++++++. |
363 |
* ............</pre> |
* ............</pre> |
364 |
* |
* |
365 |
* @param g the graphics for painting. |
* @param g the graphics for painting. |
370 |
* @param a one of the two colors. |
* @param a one of the two colors. |
371 |
* @param b the second of the two colors. |
* @param b the second of the two colors. |
372 |
*/ |
*/ |
373 |
private static void paintEtchedBorder(Graphics g, |
private static void paintEtchedBorder(Graphics g, int x, int y, int width, |
374 |
int x, int y, int width, int height, |
int height, Color a, Color b) |
|
Color a, Color b) |
|
375 |
{ |
{ |
376 |
Color oldColor; |
Color oldColor; |
377 |
|
|
382 |
|
|
383 |
try |
try |
384 |
{ |
{ |
385 |
/* To understand this code, it might be helpful to look at the |
// To understand this code, it might be helpful to look at the |
386 |
* images that are included with the JavaDoc. They are located |
// images that are included with the JavaDoc. They are located |
387 |
* in the "doc-files" subdirectory. EtchedBorder-2.png might |
// in the "doc-files" subdirectory. EtchedBorder-2.png might |
388 |
* be especially informative. |
// be especially informative. |
|
*/ |
|
389 |
g.setColor(a); |
g.setColor(a); |
390 |
g.drawRect(0, 0, width - 1, height - 1); |
g.drawRect(0, 0, width - 1, height - 1); |
391 |
|
|
402 |
} |
} |
403 |
} |
} |
404 |
} |
} |
|
|
|