Class DrawingEditorProxy
- java.lang.Object
-
- org.jhotdraw.beans.AbstractBean
-
- org.jhotdraw.draw.DrawingEditorProxy
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, DrawingEditor
public class DrawingEditorProxy extends AbstractBean implements DrawingEditor
DrawingEditorProxy.
Design PatternsProxy
To remove the need for null-handling,AbstractToolmakes use of a proxy forDrawingEditor. Subject:DrawingEditor; Proxy:DrawingEditorProxy; Client:AbstractTool.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.jhotdraw.draw.DrawingEditor
ACTION_MAP_PROPERTY, ACTIVE_VIEW_PROPERTY, DEFAULT_ATTRIBUTE_PROPERTY_PREFIX, INPUT_MAP_PROPERTY, TOOL_PROPERTY
-
-
Constructor Summary
Constructors Constructor and Description DrawingEditorProxy()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(DrawingView view)Adds a drawing view to the editor.voidapplyDefaultAttributesTo(Figure f)Applies the default attributes to the specified figure.DrawingViewfindView(java.awt.Container c)Finds a drawing view.javax.swing.ActionMapgetActionMap()Gets the action map used by the tool of this drawing editor as a fall back for performing actions.DrawingViewgetActiveView()Gets the editor's active drawing view.<T> TgetDefaultAttribute(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.DrawingViewgetFocusedView()<T> TgetHandleAttribute(AttributeKey<T> key)Gets a handle attribute from the editor.javax.swing.InputMapgetInputMap()Sets the input map used by the tool of this drawing editor as a fall back for handling keyboard events.DrawingEditorgetTarget()Gets the target of the proxy.ToolgetTool()Gets the current tool.booleanisEnabled()Gets the enabled state of the drawing editor.voidremove(DrawingView view)Removes a drawing view from the editor.voidsetActionMap(javax.swing.ActionMap newValue)Sets the action map used by the tool of this drawing editor as a fall back for performing actions.voidsetActiveView(DrawingView newValue)Sets the editor's active drawing view.voidsetCursor(java.awt.Cursor c)Sets the cursor on the view(s) of the drawing editor.<T> voidsetDefaultAttribute(AttributeKey<T> key, T value)Sets a default attribute of the editor.voidsetEnabled(boolean newValue)Sets the enabled state of the drawing editor.<T> voidsetHandleAttribute(AttributeKey<T> key, T value)Sets a handle attribute of the editor.voidsetInputMap(javax.swing.InputMap newValue)Sets the input map used by the tool of this drawing editor as a fall back for handling keyboard events.voidsetTarget(DrawingEditor newValue)Sets the target of the proxy.voidsetTool(Tool t)Calls deactivate on the previously active tool of this drawing editor.-
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jhotdraw.draw.DrawingEditor
addPropertyChangeListener, removePropertyChangeListener
-
-
-
-
Method Detail
-
setTarget
public void setTarget(@Nullable DrawingEditor newValue)
Sets the target of the proxy.
-
getTarget
@Nullable public DrawingEditor getTarget()
Gets the target of the proxy.
-
add
public void add(DrawingView view)
Description copied from interface:DrawingEditorAdds 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:
addin interfaceDrawingEditor
-
remove
public void remove(DrawingView view)
Description copied from interface:DrawingEditorRemoves a drawing view from the editor. The editor invokes removeNotify on the view, and it unregisters its tool on the view.- Specified by:
removein interfaceDrawingEditor
-
getDrawingViews
public java.util.Collection<DrawingView> getDrawingViews()
Description copied from interface:DrawingEditorGets all drawing views associated with this editor.- Specified by:
getDrawingViewsin interfaceDrawingEditor
-
getActiveView
public DrawingView getActiveView()
Description copied from interface:DrawingEditorGets the editor's active drawing view. This can be null, if the editor has no views.- Specified by:
getActiveViewin interfaceDrawingEditor
-
setActiveView
public void setActiveView(DrawingView newValue)
Description copied from interface:DrawingEditorSets the editor's active drawing view. This can be set to null, if the editor has no views.- Specified by:
setActiveViewin interfaceDrawingEditor
-
getFocusedView
@Nullable public DrawingView getFocusedView()
-
setTool
public void setTool(Tool t)
Description copied from interface:DrawingEditorCalls 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:
setToolin interfaceDrawingEditor
-
getTool
public Tool getTool()
Description copied from interface:DrawingEditorGets the current tool.This is a bound property.
- Specified by:
getToolin interfaceDrawingEditor
-
setCursor
public void setCursor(java.awt.Cursor c)
Description copied from interface:DrawingEditorSets the cursor on the view(s) of the drawing editor.- Specified by:
setCursorin interfaceDrawingEditor
-
findView
public DrawingView findView(java.awt.Container c)
Description copied from interface:DrawingEditorFinds a drawing view. This is used by Tool to identify the view of which it has received an event.- Specified by:
findViewin interfaceDrawingEditor
-
setDefaultAttribute
public <T> void setDefaultAttribute(AttributeKey<T> key, T value)
Description copied from interface:DrawingEditorSets 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.".- Specified by:
setDefaultAttributein interfaceDrawingEditor
-
getDefaultAttribute
public <T> T getDefaultAttribute(AttributeKey<T> key)
Description copied from interface:DrawingEditorGets a default attribute from the editor. The default attribute will be used by creation tools, to create a new figure.- Specified by:
getDefaultAttributein interfaceDrawingEditor
-
applyDefaultAttributesTo
public void applyDefaultAttributesTo(Figure f)
Description copied from interface:DrawingEditorApplies the default attributes to the specified figure.- Specified by:
applyDefaultAttributesToin interfaceDrawingEditor
-
getDefaultAttributes
public java.util.Map<AttributeKey,java.lang.Object> getDefaultAttributes()
Description copied from interface:DrawingEditorReturns an immutable Map with the default attributes of this editor.- Specified by:
getDefaultAttributesin interfaceDrawingEditor
-
setEnabled
public void setEnabled(boolean newValue)
Description copied from interface:DrawingEditorSets the enabled state of the drawing editor. This is a bound property.- Specified by:
setEnabledin interfaceDrawingEditor
-
isEnabled
public boolean isEnabled()
Description copied from interface:DrawingEditorGets the enabled state of the drawing editor.- Specified by:
isEnabledin interfaceDrawingEditor
-
setHandleAttribute
public <T> void setHandleAttribute(AttributeKey<T> key, T value)
Description copied from interface:DrawingEditorSets a handle attribute of the editor. The default attribute will be used by creation tools, to create a new figure.- Specified by:
setHandleAttributein interfaceDrawingEditor- Parameters:
key- AttributeKey.value- Attribute value.
-
getHandleAttribute
public <T> T getHandleAttribute(AttributeKey<T> key)
Description copied from interface:DrawingEditorGets a handle attribute from the editor. The default attribute will be used by creation tools, to create a new figure.- Specified by:
getHandleAttributein interfaceDrawingEditor- 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:DrawingEditorSets 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:
setInputMapin interfaceDrawingEditor
-
getInputMap
public javax.swing.InputMap getInputMap()
Description copied from interface:DrawingEditorSets 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:
getInputMapin interfaceDrawingEditor
-
setActionMap
public void setActionMap(javax.swing.ActionMap newValue)
Description copied from interface:DrawingEditorSets 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:
setActionMapin interfaceDrawingEditor
-
getActionMap
public javax.swing.ActionMap getActionMap()
Description copied from interface:DrawingEditorGets 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:
getActionMapin interfaceDrawingEditor
-
-
DataMelt 3.0 © DataMelt by jWork.ORG