Documentation of 'org.jhotdraw.draw.DrawingEditor' Java class
DrawingEditor
org.jhotdraw.draw

Interface DrawingEditor

  • All Known Implementing Classes:
    DefaultDrawingEditor, DrawingEditorProxy


    public interface DrawingEditor
    A drawing editor coordinates drawing tools and drawing views.

    Usage of drawing editor in conjunction with the JHotDraw application framework:

    • For Applications which provide a single document interface (SDI) there is typically one drawing editor instance per View. So that each view can have its own toolbars and drawing palettes.
    • For applications with a Windows-style multiple document interface (MDI) there is typically one drawing editor instance per parent window. All views within a parent window share the toolbars and drawing palettes provided be the parent window.
    • For applications with a Mac OS X-style application document interface (OSX) there is typically a single drawing editor instance for the application. All views within the application share a single set of toolbars and drawing palettes.

    Design Patterns

    Framework
    The following interfaces define the contracts of a framework for structured drawing editors:
    Contract: Drawing, Figure, DrawingView, DrawingEditor, Handle and Tool.

    Mediator
    DrawingEditor acts as a mediator for coordinating drawing tools and drawing views:
    Mediator: DrawingEditor; Colleagues: DrawingView, Tool.

    Mediator
    DrawingEditor acts as a mediator for coordinating keyboard input from Tools and Swing action objects:
    Mediator: DrawingEditor; Colleagues: Tool, javax.swing.Action.

    Model-View-Controller
    The following classes implement together the Model-View-Controller design pattern:
    Model: Drawing; View: DrawingView; Controller: DrawingEditor.

    Observer
    State changes of tools can be observed by other objects. Specifically DrawingEditor observes area invalidations of tools and repaints its active drawing view accordingly.
    Subject: Tool; Observer: ToolListener; Event: ToolEvent; Concrete Observer: DrawingEditor.

    Proxy
    To remove the need for null-handling, AbstractTool makes use of a proxy for DrawingEditor.
    Subject: DrawingEditor; Proxy: DrawingEditorProxy; Client: AbstractTool.


    • Field Detail

      • ACTIVE_VIEW_PROPERTY

        static final java.lang.String ACTIVE_VIEW_PROPERTY
        The property name for the active view property.
        See Also:
        Constant Field Values
      • TOOL_PROPERTY

        static final java.lang.String TOOL_PROPERTY
        The property name for the active tool property.
        See Also:
        Constant Field Values
      • INPUT_MAP_PROPERTY

        static final java.lang.String INPUT_MAP_PROPERTY
        The property name for the input map property.
        See Also:
        Constant Field Values
      • ACTION_MAP_PROPERTY

        static final java.lang.String ACTION_MAP_PROPERTY
        The property name for the action map property.
        See Also:
        Constant Field Values
      • DEFAULT_ATTRIBUTE_PROPERTY_PREFIX

        static final java.lang.String DEFAULT_ATTRIBUTE_PROPERTY_PREFIX
        The prefix for default attribute property changes.
        See Also:
        Constant Field Values
    • Method Detail

      • add

        void add(DrawingView view)
        Adds a drawing view to the editor. The editor invokes addNotify on the view, and it registers its tool as an event listener on the view.
      • remove

        void remove(DrawingView view)
        Removes a drawing view from the editor. The editor invokes removeNotify on the view, and it unregisters its tool on the view.
      • getDrawingViews

        java.util.Collection<DrawingView> getDrawingViews()
        Gets all drawing views associated with this editor.
      • getActiveView

        @Nullable
        DrawingView getActiveView()
        Gets the editor's active drawing view. This can be null, if the editor has no views.
      • setActiveView

        void setActiveView(@Nullable
                           DrawingView newValue)
        Sets the editor's active drawing view. This can be set to null, if the editor has no views.
      • setTool

        void setTool(Tool t)
        Calls deactivate on the previously active tool of this drawing editor. Calls activate on the provided tool. Forwards all mouse, mouse moation and keyboard events that occur on the DrawingView to the provided tool.

        This is a bound property.

      • getTool

        Tool getTool()
        Gets the current tool.

        This is a bound property.

      • setCursor

        void setCursor(java.awt.Cursor c)
        Sets the cursor on the view(s) of the drawing editor.
      • findView

        @Nullable
        DrawingView findView(java.awt.Container c)
        Finds a drawing view. This is used by Tool to identify the view of which it has received an event.
      • setDefaultAttribute

        <T> void setDefaultAttribute(AttributeKey<T> key,
                                     @Nullable
                                     T value)
        Sets a default attribute of the editor. The default attribute will be used by creation tools, to create a new figure.

        Fires a property change event with the name of the attribute key, and the prefix "defaultAttribute.".

      • getDefaultAttribute

        @Nullable
        <T> T getDefaultAttribute(AttributeKey<T> key)
        Gets a default attribute from the editor. The default attribute will be used by creation tools, to create a new figure.
      • applyDefaultAttributesTo

        void applyDefaultAttributesTo(Figure f)
        Applies the default attributes to the specified figure.
      • getDefaultAttributes

        java.util.Map<AttributeKey,java.lang.Object> getDefaultAttributes()
        Returns an immutable Map with the default attributes of this editor.
      • setHandleAttribute

        <T> void setHandleAttribute(AttributeKey<T> key,
                                    T value)
        Sets a handle attribute of the editor. The default attribute will be used by creation tools, to create a new figure.
        Parameters:
        key - AttributeKey.
        value - Attribute value.
      • getHandleAttribute

        <T> T getHandleAttribute(AttributeKey<T> key)
        Gets a handle attribute from the editor. The default attribute will be used by creation tools, to create a new figure.
        Parameters:
        key - AttributeKey.
        Returns:
        If the handle attribute has been set, returns the previously set value. If the handle attribute has not been set, returns key.getDefaultValue().
      • setInputMap

        void setInputMap(javax.swing.InputMap newValue)
        Sets the input map used by the tool of this drawing editor as a fall back for handling keyboard events.

        This is a bound property.

      • getInputMap

        javax.swing.InputMap getInputMap()
        Sets the input map used by the tool of this drawing editor as a fall back for handling keyboard events.

        Tools use the input map of the drawing editor to determine what to do when a key was pressed that the tool can not handle.

        This is a bound property.

      • setActionMap

        void setActionMap(javax.swing.ActionMap newValue)
        Sets the action map used by the tool of this drawing editor as a fall back for performing actions.

        This is a bound property.

      • getActionMap

        javax.swing.ActionMap getActionMap()
        Gets the action map used by the tool of this drawing editor as a fall back for performing actions.

        Tools use the action map of the drawing editor to determine what to do when an action needs to be invoked from the InputMap of the drawing editor.

        This is a bound property.

      • setEnabled

        void setEnabled(boolean newValue)
        Sets the enabled state of the drawing editor. This is a bound property.
      • isEnabled

        boolean isEnabled()
        Gets the enabled state of the drawing editor.
      • addPropertyChangeListener

        void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
        Adds a PropertyChangeListener.
        Parameters:
        listener -
      • removePropertyChangeListener

        void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
        Removes a PropertyChangeListener.
        Parameters:
        listener -

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.