Class AbstractDesignTool
- java.lang.Object
-
- com.inductiveautomation.ignition.designer.designable.tools.AbstractDesignTool
-
- All Implemented Interfaces:
IDesignTool
- Direct Known Subclasses:
AbstractLayoutTool
,AbstractShapeTool
,EyedropperTool
,GradientTool
,InstantiationTool
,LineTool
,NullTool
,PasteTool
,PencilTool
public abstract class AbstractDesignTool extends java.lang.Object implements IDesignTool
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.inductiveautomation.ignition.designer.designable.IDesignTool
IDesignTool.ToolbarInitializer
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.swing.ActionMap
actionMap
protected java.beans.PropertyChangeSupport
changeSupport
protected DesignableContainer
designable
static java.lang.String
HANDLES_PROPERTY
protected javax.swing.InputMap
inputMap
protected InteractionLayer
interactionLayer
protected DesignPanel
panel
protected AbstractDesignableWorkspace
workspace
-
Constructor Summary
Constructors Constructor Description AbstractDesignTool()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAction(java.lang.Object key, javax.swing.Action action)
Adds an action with a given key (usually a string).protected void
addKeyBinding(int keyCode, int modifiers, java.lang.Object actionKey)
Adds a key binding, creating the KeyStroke from the given keyCode (on press) and modifiers, and associates it with an action key.protected void
addKeyBinding(javax.swing.KeyStroke keyStroke, java.lang.Object actionKey)
void
addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Adds a property change listener to this design tool.static java.awt.Cursor
createCursor(javax.swing.ImageIcon image, java.lang.String name, int anchorX, int anchorY)
Creates a new cursor using the given image and name.protected javax.swing.JComponent
findDropContainer(java.awt.geom.Point2D point)
Finds the top-most object under the given spot that the delegate designates as a container.javax.swing.Action
getAction(java.lang.Object key)
Provides a way for external objects to get a hold of Actions that the tool defines.java.awt.Cursor
getCursor(java.awt.Point point, int inputEventMask)
The cursor to use given the current event mask, which can be used to detect what keys are being held downIHighlight
getDragHighlight()
Called while dragging as an easy way for a tool to install a highlight while dragging.protected java.awt.geom.Rectangle2D
getOffsettingBounds(DesignableDelegate delegate, javax.swing.JComponent dropContainer)
protected java.util.Map<javax.swing.JComponent,java.awt.geom.Rectangle2D>
getOriginalBounds(java.util.List<javax.swing.JComponent> items)
Returns a map of Object to Rectangle.java.lang.String
getStatusBarText(java.util.List<javax.swing.JComponent> selection, java.awt.Point point, int inputMask)
Calculates the currently applicable status bar text for this toolIDesignTool.ToolbarInitializer
getToolbarInitializer()
void
install(DesignPanel panel)
Installs the tool for the given panel.boolean
isInstalled()
boolean
isRelevantFor(javax.swing.JComponent component)
protected boolean
itemMovable(javax.swing.JComponent item)
Returns true if the item is non-null and the delegate claims that it is movable and unlocked.static boolean
movable(DesignableDelegate delegate, java.util.List<javax.swing.JComponent> objects)
Checks to see if the selection is non-empty and all items are movableISelectionControl
newSelectionControl()
Gives the tool a chance to create a new selection control object to install handles on the selection.protected javax.swing.JSpinner
newToolbarSpinner()
Creates a JSpinner that is appropriate for the toolbar.protected javax.swing.JSpinner
newToolbarSpinner(javax.swing.SpinnerModel model)
protected javax.swing.JSpinner
newToolbarSpinner(javax.swing.SpinnerModel model, int width)
void
onClick(java.awt.Point p, int modifiers)
Called when the user clicks in the design space.protected void
onClickAlterSelection(java.awt.Point p, int modifiers)
Performs selection alteration from clicking.void
onDoubleClick(java.awt.Point p, int mofidiers)
Called when the user double-clicksvoid
onDrag(java.awt.Point startPoint, java.awt.Point lastPoint, java.awt.Rectangle r, int modifiers)
Called while the user is dragging.void
onDragEnd(java.awt.Point startPoint, java.awt.Point lastPoint, java.awt.Rectangle r, int modifiers)
Called when the user stops dragging.void
onDragStart(java.awt.Point startPoint, java.awt.Point lastPoint, java.awt.Rectangle r, int modifiers)
Called when the user start's dragging while this tool is active.void
onKeyEvent(java.awt.event.KeyEvent e, boolean pressed)
Delegates the key event using field AbstractDesignTool.inputMap field.void
onMove(java.awt.Point p, int modifiers)
void
onPopupTrigger(java.awt.Point p, int modifiers)
Called when the user issues a click that matches the current system's notion of a popup-menu triggervoid
onPress(java.awt.Point p, int modifiers)
Called when the user presses the mouse in the design space.void
onRelease(java.awt.Point p, int modifiers)
Called when the user presses the mouse in the design space.protected boolean
onRightClickSwitchToSelectionTool(int modifiers)
Use on onPress to test for a right click.void
removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
void
uninstall()
Uninstalls the tool.
-
-
-
Field Detail
-
HANDLES_PROPERTY
public static final java.lang.String HANDLES_PROPERTY
- See Also:
- Constant Field Values
-
panel
protected DesignPanel panel
-
workspace
protected AbstractDesignableWorkspace workspace
-
interactionLayer
protected InteractionLayer interactionLayer
-
designable
protected DesignableContainer designable
-
inputMap
protected javax.swing.InputMap inputMap
-
actionMap
protected javax.swing.ActionMap actionMap
-
changeSupport
protected java.beans.PropertyChangeSupport changeSupport
-
-
Method Detail
-
findDropContainer
protected javax.swing.JComponent findDropContainer(java.awt.geom.Point2D point)
Finds the top-most object under the given spot that the delegate designates as a container. Point should be specified in unzoomed (logical) coordinates.
-
getToolbarInitializer
public IDesignTool.ToolbarInitializer getToolbarInitializer()
- Specified by:
getToolbarInitializer
in interfaceIDesignTool
-
newToolbarSpinner
protected javax.swing.JSpinner newToolbarSpinner()
Creates a JSpinner that is appropriate for the toolbar.
-
newToolbarSpinner
protected javax.swing.JSpinner newToolbarSpinner(javax.swing.SpinnerModel model)
-
newToolbarSpinner
protected javax.swing.JSpinner newToolbarSpinner(javax.swing.SpinnerModel model, int width)
-
getCursor
public java.awt.Cursor getCursor(java.awt.Point point, int inputEventMask)
Description copied from interface:IDesignTool
The cursor to use given the current event mask, which can be used to detect what keys are being held down- Specified by:
getCursor
in interfaceIDesignTool
-
onPopupTrigger
public void onPopupTrigger(java.awt.Point p, int modifiers)
Description copied from interface:IDesignTool
Called when the user issues a click that matches the current system's notion of a popup-menu trigger- Specified by:
onPopupTrigger
in interfaceIDesignTool
-
onClick
public void onClick(java.awt.Point p, int modifiers)
Description copied from interface:IDesignTool
Called when the user clicks in the design space.- Specified by:
onClick
in interfaceIDesignTool
- Parameters:
p
- The point at which they clicked. Relative to the designable container.modifiers
- A bitmask of modifiers. Comes fromInputEvent.getModifiersEx()
-
onDoubleClick
public void onDoubleClick(java.awt.Point p, int mofidiers)
Description copied from interface:IDesignTool
Called when the user double-clicks- Specified by:
onDoubleClick
in interfaceIDesignTool
-
onMove
public void onMove(java.awt.Point p, int modifiers)
- Specified by:
onMove
in interfaceIDesignTool
-
onPress
public void onPress(java.awt.Point p, int modifiers)
Description copied from interface:IDesignTool
Called when the user presses the mouse in the design space.- Specified by:
onPress
in interfaceIDesignTool
- Parameters:
p
- The point at which they pressed. Relative to the designable container.modifiers
- A bitmask of modifiers. Comes fromInputEvent.getModifiersEx()
-
onRelease
public void onRelease(java.awt.Point p, int modifiers)
Description copied from interface:IDesignTool
Called when the user presses the mouse in the design space.- Specified by:
onRelease
in interfaceIDesignTool
- Parameters:
p
- The point at which they pressed. Relative to the designable container.modifiers
- A bitmask of modifiers. Comes fromInputEvent.getModifiersEx()
-
onDragStart
public void onDragStart(java.awt.Point startPoint, java.awt.Point lastPoint, java.awt.Rectangle r, int modifiers)
Called when the user start's dragging while this tool is active. All coordinates are relative to the interaction panel and are in zoomed space.- Specified by:
onDragStart
in interfaceIDesignTool
-
onDrag
public void onDrag(java.awt.Point startPoint, java.awt.Point lastPoint, java.awt.Rectangle r, int modifiers)
Called while the user is dragging. All coordinates are relative to the interaction panel and are in zoomed space.- Specified by:
onDrag
in interfaceIDesignTool
-
onDragEnd
public void onDragEnd(java.awt.Point startPoint, java.awt.Point lastPoint, java.awt.Rectangle r, int modifiers)
Called when the user stops dragging. All coordinates are relative to the interaction panel and are in zoomed space.- Specified by:
onDragEnd
in interfaceIDesignTool
-
onRightClickSwitchToSelectionTool
protected boolean onRightClickSwitchToSelectionTool(int modifiers)
Use on onPress to test for a right click. If it is a right click, then the selection tool will be activated and true will be returned.
-
onClickAlterSelection
protected void onClickAlterSelection(java.awt.Point p, int modifiers)
Performs selection alteration from clicking. Handles multi-selection and alt-based z-order walkdown selection.
-
isRelevantFor
public boolean isRelevantFor(javax.swing.JComponent component)
-
onKeyEvent
public void onKeyEvent(java.awt.event.KeyEvent e, boolean pressed)
Delegates the key event using field AbstractDesignTool.inputMap field. Add key bindings using theaddKeyBinding(int, int, Object)
methods.- Specified by:
onKeyEvent
in interfaceIDesignTool
-
addKeyBinding
protected void addKeyBinding(int keyCode, int modifiers, java.lang.Object actionKey)
Adds a key binding, creating the KeyStroke from the given keyCode (on press) and modifiers, and associates it with an action key. The action should be added first.- Parameters:
keyCode
- an int specifying the numeric code for a keyboard keymodifiers
- Note that these are the basic modifiers, not the "DOWN" modifiers, from InputEvent. For example:InputEvent.ALT_MASK
actionKey
- the actionMapKey to apply to the modifier. If null, will remove a mapping.
-
addKeyBinding
protected void addKeyBinding(javax.swing.KeyStroke keyStroke, java.lang.Object actionKey)
-
addAction
protected void addAction(java.lang.Object key, javax.swing.Action action)
Adds an action with a given key (usually a string). Actions should be added before their keystrokes.
-
getAction
public javax.swing.Action getAction(java.lang.Object key)
Description copied from interface:IDesignTool
Provides a way for external objects to get a hold of Actions that the tool defines. For example, theSelectionTool
defines a number of alignment and z-order actions.- Specified by:
getAction
in interfaceIDesignTool
-
newSelectionControl
public ISelectionControl newSelectionControl()
Description copied from interface:IDesignTool
Gives the tool a chance to create a new selection control object to install handles on the selection. Called on the active tool when the selection changes or after a tool is first installed.- Specified by:
newSelectionControl
in interfaceIDesignTool
-
getStatusBarText
public java.lang.String getStatusBarText(java.util.List<javax.swing.JComponent> selection, java.awt.Point point, int inputMask)
Description copied from interface:IDesignTool
Calculates the currently applicable status bar text for this tool- Specified by:
getStatusBarText
in interfaceIDesignTool
-
getDragHighlight
public IHighlight getDragHighlight()
Description copied from interface:IDesignTool
Called while dragging as an easy way for a tool to install a highlight while dragging.- Specified by:
getDragHighlight
in interfaceIDesignTool
-
install
public void install(DesignPanel panel)
Description copied from interface:IDesignTool
Installs the tool for the given panel. Tools are built to be re-used by repeatedly being installed and then uninstalled as tools get switched out.- Specified by:
install
in interfaceIDesignTool
-
uninstall
public void uninstall()
Description copied from interface:IDesignTool
Uninstalls the tool.- Specified by:
uninstall
in interfaceIDesignTool
-
isInstalled
public boolean isInstalled()
-
movable
public static boolean movable(DesignableDelegate delegate, java.util.List<javax.swing.JComponent> objects)
Checks to see if the selection is non-empty and all items are movable
-
itemMovable
protected boolean itemMovable(javax.swing.JComponent item)
Returns true if the item is non-null and the delegate claims that it is movable and unlocked.
-
getOriginalBounds
protected java.util.Map<javax.swing.JComponent,java.awt.geom.Rectangle2D> getOriginalBounds(java.util.List<javax.swing.JComponent> items)
Returns a map of Object to Rectangle. Each rectangle is the bounds (relative to its parent) of the object for each object in the items list.
-
getOffsettingBounds
protected java.awt.geom.Rectangle2D getOffsettingBounds(DesignableDelegate delegate, javax.swing.JComponent dropContainer)
-
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Description copied from interface:IDesignTool
Adds a property change listener to this design tool. The workspace will listen for these properties:- "handles": When this property changes,
IDesignTool.newSelectionControl()
will be called again and the handles will be updated.
- Specified by:
addPropertyChangeListener
in interfaceIDesignTool
- "handles": When this property changes,
-
removePropertyChangeListener
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
- Specified by:
removePropertyChangeListener
in interfaceIDesignTool
-
createCursor
public static java.awt.Cursor createCursor(javax.swing.ImageIcon image, java.lang.String name, int anchorX, int anchorY)
Creates a new cursor using the given image and name. The anchor point must be a point within the image that will be used as the actual "tip" of the cursor. The image canvas will be expanded so that it matches Toolkit.getBestCursorSize()
-
-