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

Class CreationTool

  • 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
    Direct Known Subclasses:
    ImageTool, SVGCreateFromFileTool, TextAreaCreationTool, TextCreationTool


    public class CreationTool
    extends AbstractTool
    A Tool to create a new figure by drawing its bounds. The figure to be created is specified by a prototype.

    To create a figure using the CreationTool, the user does the following mouse gestures on a DrawingView:

    1. Press the mouse button over the DrawingView. This defines the start point of the Figure bounds.
    2. Drag the mouse while keeping the mouse button pressed, and then release the mouse button. This defines the end point of the Figure bounds.
    The CreationTool works well with most figures that fit into a rectangular shape or that concist of a single straight line. For figures that need additional editing after these mouse gestures, the use of a specialized creation tool is recommended. For example the TextTool allows to enter the text into a TextFigure after the user has performed the mouse gestures.

    Alltough the mouse gestures might be fitting for the creation of a connection, the CreationTool is not suited for the creation of a ConnectionFigure. Use the ConnectionTool for this type of figures instead.


    Design Patterns

    Prototype
    The creation tool creates new figures by cloning a prototype figure object. That's the reason why Figure extends the Cloneable interface.
    Prototype: Figure; Client: CreationTool.


    See Also:
    Serialized Form
    • Constructor Detail

      • CreationTool

        public CreationTool(java.lang.String prototypeClassName)
        Creates a new instance.
      • CreationTool

        public CreationTool(java.lang.String prototypeClassName,
                            @Nullable
                            java.util.Map<AttributeKey,java.lang.Object> attributes)
      • CreationTool

        public CreationTool(java.lang.String prototypeClassName,
                            @Nullable
                            java.util.Map<AttributeKey,java.lang.Object> attributes,
                            @Nullable
                            java.lang.String name)
      • CreationTool

        public CreationTool(Figure prototype)
        Creates a new instance with the specified prototype but without an attribute set. The CreationTool clones this prototype each time a new Figure needs to be created. When a new Figure is created, the CreationTool applies the default attributes from the DrawingEditor to it.
        Parameters:
        prototype - The prototype used to create a new Figure.
      • CreationTool

        public CreationTool(Figure prototype,
                            @Nullable
                            java.util.Map<AttributeKey,java.lang.Object> attributes)
        Creates a new instance with the specified prototype but without an attribute set. The CreationTool clones this prototype each time a new Figure needs to be created. When a new Figure is created, the CreationTool applies the default attributes from the DrawingEditor to it, and then it applies the attributes to it, that have been supplied in this constructor.
        Parameters:
        prototype - The prototype used to create a new Figure.
        attributes - The CreationTool applies these attributes to the prototype after having applied the default attributes from the DrawingEditor.
      • CreationTool

        public CreationTool(Figure prototype,
                            @Nullable
                            java.util.Map<AttributeKey,java.lang.Object> attributes,
                            @Nullable
                            java.lang.String name)
        Deprecated. This constructor might go away, because the name parameter is not used.
        Creates a new instance with the specified prototype and attribute set.
        Parameters:
        prototype - The prototype used to create a new Figure.
        attributes - The CreationTool applies these attributes to the prototype after having applied the default attributes from the DrawingEditor.
        name - The name parameter is currently not used.
    • Method Detail

      • getPrototype

        public Figure getPrototype()
      • 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
      • mousePressed

        public void mousePressed(java.awt.event.MouseEvent evt)
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
        Overrides:
        mousePressed in class AbstractTool
      • mouseDragged

        public void mouseDragged(java.awt.event.MouseEvent evt)
      • mouseReleased

        public void mouseReleased(java.awt.event.MouseEvent evt)
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Overrides:
        mouseReleased 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

You see the box below because you did not login.