com.rolemodelsoft.drawlet
Interface DrawingCanvas

All Known Implementing Classes:
SimpleDrawingCanvas

public interface DrawingCanvas
extends SequenceOfFigures, Paintable

A generic DrawingCanvas on which Figures can be drawn and manipulated. It is expected that this will typically implemented by some sort of graphical Component but that is not necessary.


Method Summary
 void addHandle(Handle handle)
          Add the handle to the receiver.
 void addHandles(Figure figure)
          Add the handles corresponding to the figure to the receiver.
 void addHandles(Figure figure, Handle[] handles)
          Add the handles corresponding to the figure to the receiver.
 void addSelection(Figure figure)
          Add the figure to the selections.
 void clearSelections()
          Clear all the selections of the receiver.
 Handle[] getHandles()
          Answer the handles of the receiver.
 Locator getLocator(int x, int y)
          Answer the locator that should be used for the given coordinates
 Figure[] getSelections()
          Answer the selections of the receiver.
 DrawingStyle getStyle()
          Answer the style which defines how to paint on the canvas.
 InputEventHandler getTool()
          Answer the active tool
 Handle handleAt(int x, int y)
          Answer the handle at a given point
 void removeHandle(Handle handle)
          Remove the handle from the receiver.
 void removeHandles(Figure figure)
          Remove the handles corresponding to the figure to the receiver.
 void removeSelection(Figure figure)
          Remove the figure from the selections.
 void repaint(java.awt.Rectangle rectangle)
          Repaints part of the canvas.
 void select(Figure figure)
          Make the figure the only selection Reflect the change if it's visible.
 void setSize(java.awt.Dimension size)
          Set the size of the receiver.
 void setSize(int width, int height)
          Set the size of the receiver.
 void setStyle(DrawingStyle style)
          Set the style defining how to paint on the canvas.
 void setTool(InputEventHandler tool)
          Set the active tool
 void toggleSelection(Figure figure)
          Toggle whether or not the figure is selected.
 void toolTaskCompleted(InputEventHandler tool)
          Take appropriate action when the tool has completed its task.
 
Methods inherited from interface com.rolemodelsoft.drawlet.SequenceOfFigures
addFigure, addFigureBehind, figureAt, figures, moveFigureBehind, moveFigureInFront, moveFigureToBack, moveFigureToFront, otherFigureAt, removeFigure
 
Methods inherited from interface com.rolemodelsoft.drawlet.Paintable
getBottom, getBounds, getHeight, getLeft, getRight, getSize, getTop, getWidth, paint
 

Method Detail

addHandle

public void addHandle(Handle handle)
Add the handle to the receiver. Reflect the change if it's visible. NOTE: Although this is public, it is assumed that most handles will be added/removed automatically through the process of selection.
Parameters:
handle - the handle to add

addHandles

public void addHandles(Figure figure)
Add the handles corresponding to the figure to the receiver. NOTE: Although this is public, it is assumed that most handles will be added/removed automatically through the process of selection, but some tools may wish to be more selective.
Parameters:
figure - the figure for which handles should be added.

addHandles

public void addHandles(Figure figure,
                       Handle[] handles)
Add the handles corresponding to the figure to the receiver. NOTE: Although this is public, it is assumed that most handles will be added/removed automatically through the process of selection, but some tools may wish to be more selective.
Parameters:
figure - the figure for which handles are associated.
handles - the handles to add.

addSelection

public void addSelection(Figure figure)
Add the figure to the selections. Reflect the change if it's visible.
Parameters:
figure - the Figure to add

clearSelections

public void clearSelections()
Clear all the selections of the receiver. Reflect the change if it's visible.

getHandles

public Handle[] getHandles()
Answer the handles of the receiver. The returned array and its contents should be treated as read-only.
Returns:
the handles of the receiver in an array; should be treated as read-only

getLocator

public Locator getLocator(int x,
                          int y)
Answer the locator that should be used for the given coordinates
Parameters:
x - the horizontal coordinate
y - the vertical coordinate
Returns:
a Locator representing the proper posititioning for the specified x, y

getSelections

public Figure[] getSelections()
Answer the selections of the receiver. The returned array and its contents should be treated as read-only.
Returns:
an array of Figures that represent the selections of the receiver; should be treated as read-only

getStyle

public DrawingStyle getStyle()
Answer the style which defines how to paint on the canvas.
Returns:
the DrawingStyle which defines how to paint on the canvas

getTool

public InputEventHandler getTool()
Answer the active tool
Returns:
the InputEventHandler that is the active tool

handleAt

public Handle handleAt(int x,
                       int y)
Answer the handle at a given point
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
the Handle at the given point

removeHandle

public void removeHandle(Handle handle)
Remove the handle from the receiver. Reflect the change if it's visible. NOTE: Although this is public, it is assumed that most handles will be added/removed automatically through the process of selection. Since it is public, don't assume the handle asked for is actually present.
Parameters:
handle - the handle to remove

removeHandles

public void removeHandles(Figure figure)
Remove the handles corresponding to the figure to the receiver. NOTE: Although this is public, it is assumed that most handles will be added/removed automatically through the process of selection, but some tools may wish to be more selective.
Parameters:
figure - the figure for which handles should be removed.

removeSelection

public void removeSelection(Figure figure)
Remove the figure from the selections. Reflect the change if it's visible.
Parameters:
figure - the figure being deselected

repaint

public void repaint(java.awt.Rectangle rectangle)
Repaints part of the canvas.
Parameters:
rectangle - is the region to be repainted

select

public void select(Figure figure)
Make the figure the only selection Reflect the change if it's visible.
Parameters:
figure - the figure being deselected

setSize

public void setSize(int width,
                    int height)
Set the size of the receiver.
Parameters:
width - the horizontal size
height - the vertical size

setSize

public void setSize(java.awt.Dimension size)
Set the size of the receiver.
Parameters:
size - the new size

setStyle

public void setStyle(DrawingStyle style)
Set the style defining how to paint on the canvas.
Parameters:
style - the specified DrawingStyle

setTool

public void setTool(InputEventHandler tool)
Set the active tool
Parameters:
tool - the InputEventHandler to set as the active tool

toggleSelection

public void toggleSelection(Figure figure)
Toggle whether or not the figure is selected. Reflect the change if it's visible.
Parameters:
figure - the figure of interest

toolTaskCompleted

public void toolTaskCompleted(InputEventHandler tool)
Take appropriate action when the tool has completed its task.
Parameters:
tool - the tool which completed its task