Documentation of 'org.jhotdraw.draw.tool.ConnectionTool' Java class
ConnectionTool
org.jhotdraw.draw.tool

Class ConnectionTool

  • All Implemented Interfaces:
    java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, Tool


    public class ConnectionTool
    extends AbstractTool
    A tool to create a connection between two figures. The ConnectionFigure to be created is specified by a prototype. The location of the start and end points are controlled by Connectors.

    To create a connection using the ConnectionTool, the user does the following mouse gestures on a DrawingView:

    1. Press the mouse button inside of a Figure. If the ConnectionTool can find a Connector at this location, it uses it as the starting point for the connection.
    2. Drag the mouse while keeping the mouse button pressed, and then release the mouse button. This defines the end point of the connection. If the ConnectionTool finds a Connector at this location, it uses it as the end point of the connection and creates a ConnectionFigure.
    See Also:
    Serialized Form
    • Constructor Detail

      • ConnectionTool

        public ConnectionTool(ConnectionFigure prototype)
        Creates a new instance.
      • ConnectionTool

        public ConnectionTool(java.lang.String prototypeClassName)
      • ConnectionTool

        public ConnectionTool(java.lang.String prototypeClassName,
                              @Nullable
                              java.util.Map<AttributeKey,java.lang.Object> attributes,
                              @Nullable
                              java.lang.String presentationName)
    • Method Detail

      • mouseMoved

        public void mouseMoved(java.awt.event.MouseEvent evt)
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
        Overrides:
        mouseMoved in class AbstractTool
      • repaintConnectors

        public void repaintConnectors(java.awt.event.MouseEvent evt)
        Updates the list of connectors that we draw when the user moves or drags the mouse over a figure to which can connect.
      • mousePressed

        public void mousePressed(java.awt.event.MouseEvent evt)
        Manipulates connections in a context dependent way. If the mouse down hits a figure start a new connection. If the mousedown hits a connection split a segment or join two segments.
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
        Overrides:
        mousePressed in class AbstractTool
      • mouseDragged

        public void mouseDragged(java.awt.event.MouseEvent e)
        Adjust the created connection.
      • mouseReleased

        public void mouseReleased(java.awt.event.MouseEvent e)
        Connects the figures if the mouse is released over another figure.
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Overrides:
        mouseReleased in class AbstractTool
      • activate

        public void activate(DrawingEditor editor)
        Description copied from interface: Tool
        Activates the tool for the given editor. This method is called whenever the user switches to this tool.
        Specified by:
        activate in interface Tool
        Overrides:
        activate in class AbstractTool
      • deactivate

        public void deactivate(DrawingEditor editor)
        Description copied from interface: Tool
        Deactivates the tool. This method is called whenever the user switches to another tool.
        Specified by:
        deactivate in interface Tool
        Overrides:
        deactivate in class AbstractTool
      • draw

        public void draw(java.awt.Graphics2D g)
        Description copied from interface: Tool
        Draws the tool.
        Specified by:
        draw in interface Tool
        Overrides:
        draw in class AbstractTool
      • setToolDoneAfterCreation

        public void setToolDoneAfterCreation(boolean newValue)
        If this is set to false, the CreationTool does not fire toolDone after a new Figure has been created. This allows to create multiple figures consecutively.
      • isToolDoneAfterCreation

        public boolean isToolDoneAfterCreation()
        Returns true, if this tool fires toolDone immediately after a new figure has been created.

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.