JHotDraw 7.1

org.jhotdraw.draw
Class DefaultDrawingEditor

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

public class DefaultDrawingEditor
extends AbstractBean
implements DrawingEditor, ToolListener

DefaultDrawingEditor.

Version:
3.2 2007-04-22 Keep last focus view, even if we lost focus permanently.
3.1 2007-04-16 Added method getDefaultAttributes.
3.0 2006-02-13 Revised to handle multiple drawing views.
1.0 2003-12-01 Derived from JHotDraw 5.4b1.
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
ACTIVE_VIEW_PROPERTY
 
Constructor Summary
DefaultDrawingEditor()
          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.
 void areaInvalidated(ToolEvent evt)
          Sent when an area of the drawing view needs to be repainted.
 DrawingView findView(java.awt.Container c)
          Finds a drawing view.
 DrawingView getActiveView()
          Gets the editor's active drawing view.
 java.lang.Object getDefaultAttribute(AttributeKey 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.
 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 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.
 void setDefaultAttribute(AttributeKey key, java.lang.Object newValue)
          Sets a default attribute of the editor.
 void setEnabled(boolean newValue)
          Sets the enabled state of the drawing editor.
 void setTool(Tool t)
          Calls deactivate on the previously active tool of this drawing editor.
 void toolDone(ToolEvent evt)
          Informs the listener that a tool has done its interaction.
 void toolStarted(ToolEvent evt)
          Informs the listener that a tool has starteds interacting with a specific drawing view.
 
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, 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

DefaultDrawingEditor

public DefaultDrawingEditor()
Creates a new instance.

Method Detail

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.

Specified by:
setTool in interface DrawingEditor

areaInvalidated

public void areaInvalidated(ToolEvent evt)
Description copied from interface: ToolListener
Sent when an area of the drawing view needs to be repainted.

Specified by:
areaInvalidated in interface ToolListener

toolStarted

public void toolStarted(ToolEvent evt)
Description copied from interface: ToolListener
Informs the listener that a tool has starteds interacting with a specific drawing view.

Specified by:
toolStarted in interface ToolListener

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

toolDone

public void toolDone(ToolEvent evt)
Description copied from interface: ToolListener
Informs the listener that a tool has done its interaction. This method can be used to switch back to the default tool.

Specified by:
toolDone in interface ToolListener

getTool

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

Specified by:
getTool 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

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

getDefaultAttribute

public java.lang.Object getDefaultAttribute(AttributeKey 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

setDefaultAttribute

public void setDefaultAttribute(AttributeKey key,
                                java.lang.Object newValue)
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

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

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

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

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

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

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

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

Copyright 1996-2007 (c) JHotDraw.org.
Some rights reserved.