01: package com.xoetrope.util;
02:
03: import java.awt.Color;
04: import java.awt.Graphics;
05:
06: /**
07: * Description: A collection of utility functions
08: v */
09: public class XGraphicUtils {
10: /**
11: * Draws a 3d object.
12: * @param g the graphics context
13: * @param focused true if the object is drawn in a pressed state
14: * @param left the left coordinate
15: * @param top the top coordinate
16: * @param width the width
17: * @param height the height
18: * @param bkClr the background color
19: * @param shadowClr the shadow color
20: * @param frameClr the frame color
21: * @param shadow3dClr the 3d shadow color
22: * @param highlight3dClr the 3d highlight
23: */
24: public static void draw3dObject(Graphics g, boolean focused,
25: int left, int top, int width, int height, Color bkClr,
26: Color shadowClr, Color frameClr, Color shadow3dClr,
27: Color highlight3dClr) {
28: // Draw the check background
29: g.setColor(bkClr);
30: g.fillRect(left + 2, top + 2, width - 2, height - 2);
31:
32: if (!focused) {
33: // Draw a button like object
34: g.setColor(bkClr);
35: g.fillRect(left + 1, top + 2, width - 1, height - 2);
36:
37: // Highlight the top and left
38: g.setColor(highlight3dClr);
39: g.drawLine(left + 1, top + 1, left + width - 2, top + 1);
40: g.drawLine(left + 2, top + 2, left + width - 3, top + 2);
41: g.drawLine(left + 1, top + 1, left + 1, top + height - 2);
42: g.drawLine(left + 2, top + 2, left + 2, top + height - 3);
43:
44: // Shadow the bottom and right
45: g.setColor(shadow3dClr);
46: g.drawLine(left + width - 1, top + 2, left + width - 1, top
47: + height - 1);
48: g.drawLine(left + width - 2, top + 3, left + width - 2, top
49: + height - 2);
50: g.drawLine(left + 2, top + height - 1, left + width - 1,
51: top + height - 1);
52: g.drawLine(left + 3, top + height - 2, left + width - 2,
53: top + height - 2);
54: } else {
55: // Draw the shadow
56: g.setColor(shadowClr);
57: g.drawRect(left + 1, top + 1, width - 2, height - 2);
58: }
59:
60: // Frame the check
61: g.setColor(frameClr);
62: g.drawRect(left, top, width, height);
63: }
64: }
|