01: /**
02: * Wizard Framework
03: * Copyright 2004 - 2005 Andrew Pietsch
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: *
19: * $Id: ArrowIcon.java,v 1.8 2005/05/16 23:06:56 pietschy Exp $
20: */package org.pietschy.wizard;
21:
22: import javax.swing.*;
23: import java.awt.*;
24:
25: /**
26: * Created by IntelliJ IDEA.
27: * User: andrewp
28: * Date: 4/06/2004
29: * Time: 20:00:46
30: * To change this template use Options | File Templates.
31: */
32: class ArrowIcon implements Icon {
33:
34: private int direction;
35: private static final int LENGTH = 5;
36:
37: public ArrowIcon(int direction) {
38: this .direction = direction;
39: }
40:
41: public int getIconWidth() {
42: return direction == SwingConstants.EAST
43: || direction == SwingConstants.WEST ? LENGTH
44: : 2 * LENGTH;
45: }
46:
47: public int getIconHeight() {
48: return direction == SwingConstants.NORTH
49: || direction == SwingConstants.SOUTH ? LENGTH
50: : 2 * LENGTH;
51: }
52:
53: public void paintIcon(Component c, Graphics g, int x, int y) {
54: Color oldColor = g.getColor();
55: int mid = LENGTH;
56: int i = 0;
57: int j = 0;
58:
59: g.translate(x, y);
60:
61: if (c.isEnabled())
62: g.setColor(c.getForeground());
63: else
64: g.setColor(UIManager.getColor("Button.disabledForeground"));
65:
66: switch (direction) {
67: case SwingConstants.NORTH:
68: for (i = 0; i < LENGTH; i++) {
69: g.drawLine(mid - i, i, mid + i, i);
70: }
71: break;
72: case SwingConstants.SOUTH:
73: j = 0;
74: for (i = LENGTH - 1; i >= 0; i--) {
75: g.drawLine(mid - i, j, mid + i, j);
76: j++;
77: }
78: break;
79: case SwingConstants.WEST:
80: for (i = 0; i < LENGTH; i++) {
81: g.drawLine(i, mid - i, i, mid + i);
82: }
83: break;
84: case SwingConstants.EAST:
85: j = 0;
86: for (i = LENGTH - 1; i >= 0; i--) {
87: g.drawLine(j, mid - i, j, mid + i);
88: j++;
89: }
90: break;
91: }
92: g.translate(-x, -y);
93: g.setColor(oldColor);
94:
95: }
96:
97: }
|