01: /*
02: * Gruntspud
03: *
04: * Copyright (C) 2002 Brett Smith.
05: *
06: * Written by: Brett Smith <t_magicthize@users.sourceforge.net>
07: *
08: * This program is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Library General Public License
10: * as published by the Free Software Foundation; either version 2 of
11: * the License, or (at your option) any later version.
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU Library General Public License for more details.
16: *
17: * You should have received a copy of the GNU Library General Public
18: * License along with this program; if not, write to the Free Software
19: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20: */
21: package gruntspud.ui.icons;
22:
23: import java.awt.Component;
24: import java.awt.Graphics;
25:
26: import javax.swing.Icon;
27:
28: /**
29: * Description of the Class
30: *
31: *@author magicthize
32: *@created 26 May 2002
33: */
34: public class OverlayIcon implements Icon {
35: private Icon icon;
36: private Icon overlayIcon;
37: private int position;
38:
39: /**
40: * Constructor for the OverlayIcon object
41: *
42: *@param overlayIcon Description of the Parameter
43: *@param icon Description of the Parameter
44: *@param position Description of the Parameter
45: */
46: public OverlayIcon(Icon overlayIcon, Icon icon, int position) {
47: this .icon = icon;
48: this .overlayIcon = overlayIcon;
49: this .position = position;
50: }
51:
52: public Icon getOverlayIcon() {
53: return overlayIcon;
54: }
55:
56: /**
57: * Gets the iconHeight attribute of the OverlayIcon object
58: *
59: *@return The iconHeight value
60: */
61: public int getIconHeight() {
62: return (icon == null) ? 16 : icon.getIconHeight();
63: }
64:
65: /**
66: * Gets the iconWidth attribute of the OverlayIcon object
67: *
68: *@return The iconWidth value
69: */
70: public int getIconWidth() {
71: return (icon == null) ? 16 : icon.getIconWidth();
72: }
73:
74: /**
75: * Description of the Method
76: *
77: *@param c Description of the Parameter
78: *@param g Description of the Parameter
79: *@param x Description of the Parameter
80: *@param y Description of the Parameter
81: */
82: public void paintIcon(Component c, Graphics g, int x, int y) {
83: if (icon != null) {
84: icon.paintIcon(c, g, x, y);
85:
86: switch (position) {
87: /**
88: *@todo implement all the compass positions
89: */
90: default:
91: overlayIcon.paintIcon(c, g, (x + icon.getIconWidth())
92: - overlayIcon.getIconWidth(), (y + icon
93: .getIconHeight())
94: - overlayIcon.getIconHeight());
95: }
96: }
97: }
98: }
|