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 Object implements IDesignTool
  • Field Details

  • Constructor Details

    • AbstractDesignTool

      public AbstractDesignTool()
  • Method Details

    • findDropContainer

      protected JComponent findDropContainer(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 interface IDesignTool
    • newToolbarSpinner

      protected JSpinner newToolbarSpinner()
      Creates a JSpinner that is appropriate for the toolbar.
    • newToolbarSpinner

      protected JSpinner newToolbarSpinner(SpinnerModel model)
    • newToolbarSpinner

      protected JSpinner newToolbarSpinner(SpinnerModel model, int width)
    • getCursor

      public Cursor getCursor(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 interface IDesignTool
    • onPopupTrigger

      public void onPopupTrigger(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 interface IDesignTool
    • onClick

      public void onClick(Point p, int modifiers)
      Description copied from interface: IDesignTool
      Called when the user clicks in the design space.
      Specified by:
      onClick in interface IDesignTool
      Parameters:
      p - The point at which they clicked. Relative to the designable container.
      modifiers - A bitmask of modifiers. Comes from InputEvent.getModifiersEx()
    • onDoubleClick

      public void onDoubleClick(Point p, int mofidiers)
      Description copied from interface: IDesignTool
      Called when the user double-clicks
      Specified by:
      onDoubleClick in interface IDesignTool
    • onMove

      public void onMove(Point p, int modifiers)
      Specified by:
      onMove in interface IDesignTool
    • onPress

      public void onPress(Point p, int modifiers)
      Description copied from interface: IDesignTool
      Called when the user presses the mouse in the design space.
      Specified by:
      onPress in interface IDesignTool
      Parameters:
      p - The point at which they pressed. Relative to the designable container.
      modifiers - A bitmask of modifiers. Comes from InputEvent.getModifiersEx()
    • onRelease

      public void onRelease(Point p, int modifiers)
      Description copied from interface: IDesignTool
      Called when the user presses the mouse in the design space.
      Specified by:
      onRelease in interface IDesignTool
      Parameters:
      p - The point at which they pressed. Relative to the designable container.
      modifiers - A bitmask of modifiers. Comes from InputEvent.getModifiersEx()
    • onDragStart

      public void onDragStart(Point startPoint, Point lastPoint, 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 interface IDesignTool
    • onDrag

      public void onDrag(Point startPoint, Point lastPoint, 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 interface IDesignTool
    • onDragEnd

      public void onDragEnd(Point startPoint, Point lastPoint, 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 interface IDesignTool
    • 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(Point p, int modifiers)
      Performs selection alteration from clicking. Handles multi-selection and alt-based z-order walkdown selection.
    • isRelevantFor

      public boolean isRelevantFor(JComponent component)
    • onKeyEvent

      public void onKeyEvent(KeyEvent e, boolean pressed)
      Delegates the key event using field AbstractDesignTool.inputMap field. Add key bindings using the addKeyBinding(int, int, Object) methods.
      Specified by:
      onKeyEvent in interface IDesignTool
    • addKeyBinding

      protected void addKeyBinding(int keyCode, int modifiers, 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 key
      modifiers - 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(KeyStroke keyStroke, Object actionKey)
    • addAction

      protected void addAction(Object key, Action action)
      Adds an action with a given key (usually a string). Actions should be added before their keystrokes.
    • getAction

      public Action getAction(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, the SelectionTool defines a number of alignment and z-order actions.
      Specified by:
      getAction in interface IDesignTool
    • 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 interface IDesignTool
    • getStatusBarText

      public String getStatusBarText(List<JComponent> selection, Point point, int inputMask)
      Description copied from interface: IDesignTool
      Calculates the currently applicable status bar text for this tool
      Specified by:
      getStatusBarText in interface IDesignTool
    • 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 interface IDesignTool
    • 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 interface IDesignTool
    • uninstall

      public void uninstall()
      Description copied from interface: IDesignTool
      Uninstalls the tool.
      Specified by:
      uninstall in interface IDesignTool
    • isInstalled

      public boolean isInstalled()
    • movable

      public static boolean movable(DesignableDelegate delegate, List<JComponent> objects)
      Checks to see if the selection is non-empty and all items are movable
    • itemMovable

      protected boolean itemMovable(JComponent item)
      Returns true if the item is non-null and the delegate claims that it is movable and unlocked.
    • getOriginalBounds

      protected Map<JComponent,Rectangle2D> getOriginalBounds(List<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 Rectangle2D getOffsettingBounds(DesignableDelegate delegate, JComponent dropContainer)
    • addPropertyChangeListener

      public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
      Description copied from interface: IDesignTool
      Adds a property change listener to this design tool. The workspace will listen for these properties:
      Specified by:
      addPropertyChangeListener in interface IDesignTool
    • removePropertyChangeListener

      public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
      Specified by:
      removePropertyChangeListener in interface IDesignTool
    • createCursor

      public static Cursor createCursor(ImageIcon image, 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()