View Javadoc

1   package org.glassbox.graphview;
2   
3   import java.awt.Color;
4   import java.awt.Component;
5   import java.awt.Graphics;
6   import javax.swing.Icon;
7   import javax.swing.Action;
8   
9   import de.fzi.wim.guibase.graphview.graph.*;
10  import de.fzi.wim.guibase.graphview.view.*;
11  
12  /***
13     An abstract implementation of <code>NodeButtonSet.Button</code> which supplies a button with an icon.
14   */
15  public abstract class IconButton2 implements NodeButtonSet.Button {
16      private Icon _default;
17      private Icon _rollover;
18      private Icon _pressed;
19      private Action _action;
20  
21      /***
22         Creates an <code>IconButton2</code> with the specified icons.
23       */
24      public IconButton2(Action action, Icon icon, Icon rollover, Icon pressed) {
25  	_action = action;
26  	_default = icon;
27  	_rollover = rollover;
28  	_pressed = pressed;
29      }
30  
31      public abstract boolean affectsNode(Node node);
32      
33      public abstract String getToolTipText(Node node);
34  
35      public Action getAction() {
36  	return _action;
37      }
38  
39      public int getIconWidth() {
40  	return _default.getIconWidth();
41      }
42  
43      public int getIconHeight() {
44  	return _default.getIconHeight();
45      }
46  
47      public void paintIcon(Component c, Graphics g, int x, int y) {
48  	_default.paintIcon(c, g, x, y);
49      }
50  
51      public void paintRolloverIcon(Component c, Graphics g, int x, int y) {
52  	_rollover.paintIcon(c, g, x, y);
53      }
54  
55      public void paintPressedIcon(Component c, Graphics g, int x, int y) {
56  	_pressed.paintIcon(c, g, x, y);
57      }
58  }