01: /*
02: * $Id: JGraphEditorTool.java,v 1.2 2005/10/15 10:28:23 gaudenz Exp $
03: * Copyright (c) 2001-2005, Gaudenz Alder
04: *
05: * All rights reserved.
06: *
07: * See LICENSE file for license details. If you are unable to locate
08: * this file please contact info (at) jgraph (dot) com.
09: */
10: package com.jgraph.editor;
11:
12: import java.awt.event.MouseEvent;
13:
14: import org.jgraph.graph.BasicMarqueeHandler;
15:
16: /**
17: * The base class for all tools in a JGraph editor kit. Tools are used to
18: * temporary set a graphs marquee handler, ie. to take over all interactions on
19: * a graph. This is typically used to insert new cells in marquee-style (as
20: * opposed to dnd-style used in the library).
21: */
22: public class JGraphEditorTool extends BasicMarqueeHandler {
23:
24: /**
25: * Holds the name.
26: */
27: protected String name;
28:
29: /**
30: * Specifies whether this tool is always activated. Default is false. A
31: * value of true means the tool will always be called by the toolbox
32: * redirector if the tool is selected.
33: */
34: protected boolean isAlwaysActive = true;
35:
36: /**
37: * Constructs a tool with the specified name.
38: *
39: * @param name
40: * The name of the tool to be created.
41: */
42: public JGraphEditorTool(String name) {
43: this (name, true);
44: }
45:
46: /**
47: * Constructs a tool with the specified name.
48: *
49: * @param name
50: * The name of the tool to be created.
51: */
52: public JGraphEditorTool(String name, boolean isAlwaysActive) {
53: setName(name);
54: this .isAlwaysActive = isAlwaysActive;
55: }
56:
57: /**
58: * Returns the name of the tool.
59: *
60: * @return Returns the name.
61: */
62: public String getName() {
63: return name;
64: }
65:
66: /**
67: * Sets the name of the tool.
68: *
69: * @param name
70: * The name to set.
71: */
72: public void setName(String name) {
73: this .name = name;
74: }
75:
76: /**
77: * Returns true if this tool is always active, eg if it should return true
78: * whenever {@link #isForceMarqueeEvent(MouseEvent)} is called.
79: *
80: * @return Returns the isAlwaysActive.
81: */
82: public boolean isAlwaysActive() {
83: return isAlwaysActive;
84: }
85:
86: /**
87: * Sets whether the tool is always active.
88: *
89: * @param isAlwaysActive
90: * The isAlwaysActive to set.
91: */
92: public void setAlwaysActive(boolean isAlwaysActive) {
93: this.isAlwaysActive = isAlwaysActive;
94: }
95:
96: }
|