01: package org.enhydra.jawe.components.graph.actions;
02:
03: import java.awt.Cursor;
04: import java.awt.Image;
05: import java.awt.Point;
06: import java.awt.event.ActionEvent;
07:
08: import javax.swing.ImageIcon;
09: import javax.swing.JFrame;
10:
11: import org.enhydra.jawe.ActionBase;
12: import org.enhydra.jawe.JaWEManager;
13: import org.enhydra.jawe.components.graph.GraphController;
14:
15: /**
16: * @author Sasa Bojanic
17: */
18: public abstract class SetToolboxMode extends ActionBase {
19:
20: protected Cursor cursor;
21:
22: protected String type;
23:
24: protected String subType;
25:
26: public SetToolboxMode(GraphController jawecomponent, String type,
27: String subType) {
28: super (jawecomponent);
29: this .type = type;
30: this .subType = subType;
31: }
32:
33: public void actionPerformed(ActionEvent e) {
34: GraphController gc = (GraphController) jawecomponent;
35:
36: if (cursor == null) {
37: ImageIcon curIc;
38: Point hotSpot;
39: Image curIm;
40:
41: JFrame fr = JaWEManager.getInstance().getJaWEController()
42: .getJaWEFrame();
43: try {
44: curIc = getIcon();
45: hotSpot = new Point(curIc.getIconWidth() / 2, curIc
46: .getIconHeight() / 2);
47: curIm = curIc.getImage();
48: cursor = fr.getToolkit().createCustomCursor(curIm,
49: hotSpot, "ToolboxMode" + subType + "20x20");
50: } catch (Exception ex) {
51: JaWEManager.getInstance().getLoggingManager().error(
52: "Missing cursor image for ToolboxMode[" + type
53: + "," + subType + "]!");
54: }
55: }
56:
57: gc.getGraphMarqueeHandler().setType(type, subType, cursor);
58: }
59:
60: protected ImageIcon getIcon() {
61: return JaWEManager.getInstance().getJaWEController()
62: .getJaWETypes().getType(subType).getIcon();
63: }
64: }
|