01: /*
02: * $Id: ColumnControlIcon.java,v 1.5 2006/05/14 08:19:44 dmouse Exp $
03: *
04: * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
05: * Santa Clara, California 95054, U.S.A. All rights reserved.
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library 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 GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20: */
21:
22: package org.jdesktop.swingx.icon;
23:
24: import java.awt.BorderLayout;
25: import java.awt.Color;
26: import java.awt.Component;
27: import java.awt.Graphics;
28:
29: import javax.swing.Icon;
30: import javax.swing.JFrame;
31: import javax.swing.JLabel;
32:
33: /**
34: * Icon class for rendering icon which indicates user control of
35: * column visibility.
36: * @author Amy Fowler
37: * @version 1.0
38: */
39: public class ColumnControlIcon implements Icon {
40: private int width = 10;
41: private int height = 10;
42:
43: /** TODO: need to support small, medium, large */
44: public ColumnControlIcon() {
45: }
46:
47: public int getIconWidth() {
48: return width;
49: }
50:
51: public int getIconHeight() {
52: return height;
53: }
54:
55: public void paintIcon(Component c, Graphics g, int x, int y) {
56: Color color = c.getForeground();
57: g.setColor(color);
58:
59: // draw horizontal lines
60: g.drawLine(x, y, x + 8, y);
61: g.drawLine(x, y + 2, x + 8, y + 2);
62: g.drawLine(x, y + 8, x + 2, y + 8);
63:
64: // draw vertical lines
65: g.drawLine(x, y + 1, x, y + 7);
66: g.drawLine(x + 4, y + 1, x + 4, y + 4);
67: g.drawLine(x + 8, y + 1, x + 8, y + 4);
68:
69: // draw arrow
70: g.drawLine(x + 3, y + 6, x + 9, y + 6);
71: g.drawLine(x + 4, y + 7, x + 8, y + 7);
72: g.drawLine(x + 5, y + 8, x + 7, y + 8);
73: g.drawLine(x + 6, y + 9, x + 6, y + 9);
74:
75: }
76:
77: public static void main(String args[]) {
78: JFrame frame = new JFrame();
79: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
80: JLabel label = new JLabel(new ColumnControlIcon());
81: frame.getContentPane().add(BorderLayout.CENTER, label);
82: frame.pack();
83: frame.setVisible(true);
84: }
85:
86: }
|