JHotDraw 7.2

org.jhotdraw.draw
Interface DrawingEditor

All Known Implementing Classes:
DefaultDrawingEditor, DrawingEditorProxy

public interface DrawingEditor

DrawingEditor defines the interface for coordinating the different objects that participate in a drawing editor.

For applications with a single document interface (SDI) there is typically one DrawingEditor instance per document window. So that each window can have its own toolbars and drawing palettes.

For applications with a Windows-style multiple document interface (MDI) there is typically one DrawingEditor instance per parent window. All document windows 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 DrawingEditor instance for the application. All document windows within the application share a single set of toolbars and drawing palettes.

Design pattern:
Name: Mediator.
Role: Mediator.
Partners: DrawingView as Colleague, Tool as Colleague.

Design pattern:
Name: Proxy.
Role: Subject.
Partners: DrawingEditorProxy as Proxy, DefaultDrawingEditor as Real Subject.

Version:
4.0 2009-04-18 Made set/getDefaultAttribute methods and set/getHandleAttribute methods type safe.
3.1 2008-05-23 Added TOOL_PROPERTY.
3.0 2008-05-11 Added methods setHandleAttribute, getHandleAttribute.
2.4 2007-12-25 Renamed PROP_CURRENT_VIEW to ACTIVE_VIEW_PROPERTY.
2.3 2007-05-26 Streamlined methods setActiveView, setFocusedView, getActiveView into setActiveView, getActiveView.
2.2 2007-04-16 Added method getDefaultAttributes
2.1 2006-03-15 Support for enabled state added.
2.0 2006-02-13 Revised to support multiple drawing views.
1.0 2003-12-01 Derived from JHotDraw 5.4b1.
Author:
Werner Randelshofer

Field Summary
static java.lang.String ACTIVE_VIEW_PROPERTY
          The property name for the active view property.
static java.lang.String TOOL_PROPERTY
          The property name for the active tool property.
 
Method Summary
 void add(DrawingView view)
          Adds a drawing view to the editor.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void applyDefaultAttributesTo(Figure f)
          Applies the default attributes to the specified figure.
 DrawingView findView(java.awt.Container c)
          Finds a drawing view.
 DrawingView getActiveView()
          Gets the editor's active drawing view.
<T> T
getDefaultAttribute(AttributeKey<T> key)
          Gets a default attribute from the editor.
 java.util.Map<AttributeKey,java.lang.Object> getDefaultAttributes()
          Returns an immutable Map with the default attributes of this editor.
 java.util.Collection<DrawingView> getDrawingViews()
          Gets all drawing views associated with this editor.
<T> T
getHandleAttribute(AttributeKey<T> key)
          Gets a handle attribute from the editor.
 Tool getTool()
          Gets the current tool.
 boolean isEnabled()
          Gets the enabled state of the drawing editor.
 void remove(DrawingView view)
          Removes a drawing view from the editor.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void setActiveView(DrawingView newValue)
          Sets the editor's active drawing view.
 void setCursor(java.awt.Cursor c)
          Sets the cursor on the view(s) of the drawing editor.
<T> void
setDefaultAttribute(AttributeKey<T> key, T value)
          Sets a default attribute of the editor.
 void setEnabled(boolean newValue)
          Sets the enabled state of the drawing editor.
<T> void
setHandleAttribute(AttributeKey<T> key, T value)
          Sets a handle attribute of the editor.
 void setTool(Tool t)
          Calls deactivate on the previously active tool of this drawing editor.
 

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
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

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


setActiveView

void setActiveView(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

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,
                             T value)
Sets a default attribute of the editor. The default attribute will be used by creation tools, to create a new figure.


getDefaultAttribute

<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().

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)

removePropertyChangeListener

void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

Copyright 1996-2009 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.