JHotDraw 7.4.1

org.jhotdraw.draw
Class DrawingEditorProxy

java.lang.Object
  extended by org.jhotdraw.beans.AbstractBean
      extended by org.jhotdraw.draw.DrawingEditorProxy
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, DrawingEditor

public class DrawingEditorProxy
extends AbstractBean
implements DrawingEditor

DrawingEditorProxy.


Design Patterns

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


Version:
$Id: DrawingEditorProxy.java 604 2010-01-09 12:00:29Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jhotdraw.beans.AbstractBean
propertySupport
 
Fields inherited from interface org.jhotdraw.draw.DrawingEditor
ACTION_MAP_PROPERTY, ACTIVE_VIEW_PROPERTY, INPUT_MAP_PROPERTY, TOOL_PROPERTY
 
Constructor Summary
DrawingEditorProxy()
          Creates a new instance.
 
Method Summary
 void add(DrawingView view)
          Adds a drawing view to the editor.
 void applyDefaultAttributesTo(Figure f)
          Applies the default attributes to the specified figure.
 DrawingView findView(java.awt.Container c)
          Finds a drawing view.
 javax.swing.ActionMap getActionMap()
          Gets the action map used by the tool of this drawing editor as a fall back for performing actions.
 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.
 DrawingView getFocusedView()
           
<T> T
getHandleAttribute(AttributeKey<T> key)
          Gets a handle attribute from the editor.
 javax.swing.InputMap getInputMap()
          Sets the input map used by the tool of this drawing editor as a fall back for handling keyboard events.
 DrawingEditor getTarget()
          Gets the target of the proxy.
 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 setActionMap(javax.swing.ActionMap newValue)
          Sets the action map used by the tool of this drawing editor as a fall back for performing actions.
 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 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.
 void setTarget(DrawingEditor newValue)
          Sets the target of the proxy.
 void setTool(Tool t)
          Calls deactivate on the previously active tool of this drawing editor.
 
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jhotdraw.draw.DrawingEditor
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

DrawingEditorProxy

public DrawingEditorProxy()
Creates a new instance.

Method Detail

setTarget

public void setTarget(DrawingEditor newValue)
Sets the target of the proxy.


getTarget

public DrawingEditor getTarget()
Gets the target of the proxy.


add

public void add(DrawingView view)
Description copied from interface: DrawingEditor
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.

Specified by:
add in interface DrawingEditor

remove

public void remove(DrawingView view)
Description copied from interface: DrawingEditor
Removes a drawing view from the editor. The editor invokes removeNotify on the view, and it unregisters its tool on the view.

Specified by:
remove in interface DrawingEditor

getDrawingViews

public java.util.Collection<DrawingView> getDrawingViews()
Description copied from interface: DrawingEditor
Gets all drawing views associated with this editor.

Specified by:
getDrawingViews in interface DrawingEditor

getActiveView

public DrawingView getActiveView()
Description copied from interface: DrawingEditor
Gets the editor's active drawing view. This can be null, if the editor has no views.

Specified by:
getActiveView in interface DrawingEditor

setActiveView

public void setActiveView(DrawingView newValue)
Description copied from interface: DrawingEditor
Sets the editor's active drawing view. This can be set to null, if the editor has no views.

Specified by:
setActiveView in interface DrawingEditor

getFocusedView

public DrawingView getFocusedView()

setTool

public void setTool(Tool t)
Description copied from interface: DrawingEditor
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.

Specified by:
setTool in interface DrawingEditor

getTool

public Tool getTool()
Description copied from interface: DrawingEditor
Gets the current tool.

This is a bound property.

Specified by:
getTool in interface DrawingEditor

setCursor

public void setCursor(java.awt.Cursor c)
Description copied from interface: DrawingEditor
Sets the cursor on the view(s) of the drawing editor.

Specified by:
setCursor in interface DrawingEditor

findView

public DrawingView findView(java.awt.Container c)
Description copied from interface: DrawingEditor
Finds a drawing view. This is used by Tool to identify the view of which it has received an event.

Specified by:
findView in interface DrawingEditor

setDefaultAttribute

public <T> void setDefaultAttribute(AttributeKey<T> key,
                                    T value)
Description copied from interface: DrawingEditor
Sets a default attribute of the editor. The default attribute will be used by creation tools, to create a new figure.

Specified by:
setDefaultAttribute in interface DrawingEditor

getDefaultAttribute

public <T> T getDefaultAttribute(AttributeKey<T> key)
Description copied from interface: DrawingEditor
Gets a default attribute from the editor. The default attribute will be used by creation tools, to create a new figure.

Specified by:
getDefaultAttribute in interface DrawingEditor

applyDefaultAttributesTo

public void applyDefaultAttributesTo(Figure f)
Description copied from interface: DrawingEditor
Applies the default attributes to the specified figure.

Specified by:
applyDefaultAttributesTo in interface DrawingEditor

getDefaultAttributes

public java.util.Map<AttributeKey,java.lang.Object> getDefaultAttributes()
Description copied from interface: DrawingEditor
Returns an immutable Map with the default attributes of this editor.

Specified by:
getDefaultAttributes in interface DrawingEditor

setEnabled

public void setEnabled(boolean newValue)
Description copied from interface: DrawingEditor
Sets the enabled state of the drawing editor. This is a bound property.

Specified by:
setEnabled in interface DrawingEditor

isEnabled

public boolean isEnabled()
Description copied from interface: DrawingEditor
Gets the enabled state of the drawing editor.

Specified by:
isEnabled in interface DrawingEditor

setHandleAttribute

public <T> void setHandleAttribute(AttributeKey<T> key,
                                   T value)
Description copied from interface: DrawingEditor
Sets a handle attribute of the editor. The default attribute will be used by creation tools, to create a new figure.

Specified by:
setHandleAttribute in interface DrawingEditor
Parameters:
key - AttributeKey.
value - Attribute value.

getHandleAttribute

public <T> T getHandleAttribute(AttributeKey<T> key)
Description copied from interface: DrawingEditor
Gets a handle attribute from the editor. The default attribute will be used by creation tools, to create a new figure.

Specified by:
getHandleAttribute in interface DrawingEditor
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

public void setInputMap(javax.swing.InputMap newValue)
Description copied from interface: DrawingEditor
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.

Specified by:
setInputMap in interface DrawingEditor

getInputMap

public javax.swing.InputMap getInputMap()
Description copied from interface: DrawingEditor
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.

Specified by:
getInputMap in interface DrawingEditor

setActionMap

public void setActionMap(javax.swing.ActionMap newValue)
Description copied from interface: DrawingEditor
Sets the action map used by the tool of this drawing editor as a fall back for performing actions.

This is a bound property.

Specified by:
setActionMap in interface DrawingEditor

getActionMap

public javax.swing.ActionMap getActionMap()
Description copied from interface: DrawingEditor
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.

Specified by:
getActionMap in interface DrawingEditor

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