|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.rolemodelsoft.drawlet.basics.AbstractPaintable
|
+--com.rolemodelsoft.drawlet.basics.SimpleDrawingCanvas
This provides basic functionality necessary to provide a meaningful working version of a DrawingCanvas that can be tied to a Component in an AWT Application. It is expected that this would serve as the base for these sort of Components, but not required.
| Field Summary | |
protected static int |
buffer
The amount to add to drawings which are dynamically sized. |
protected static java.awt.datatransfer.Clipboard |
clipboard
A place to hold figures that are cut or copied. |
protected java.awt.Component |
component
The Component we are associated with. |
protected Drawing |
drawing
The drawing we are displaying/manipulating. |
protected java.util.Hashtable |
figureHandles
A mapping of figures to their associated handles. |
protected java.util.Vector |
handles
The handles that may take control of events. |
protected int |
height
The height of the canvas. |
protected java.util.Vector |
selections
The figures which are currently selected for further operations. |
protected DrawingStyle |
style
The style with which it is expected new figures will be drawn. |
protected InputEventHandler |
tool
The tool which is the first thing we look to in order to handle events. |
protected int |
width
The width of the canvas. |
| Constructor Summary | |
SimpleDrawingCanvas()
Default constructor |
|
SimpleDrawingCanvas(Drawing drawing)
|
|
| Method Summary | |
void |
addFigure(Figure figure)
Add the figure to the contents of the canvas. |
void |
addFigureBehind(Figure figure,
Figure existingFigure)
Add the figure to the contents of the canvas, sticking it behind an existingFigure which is already there. |
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 to the receiver, associating them the given figure. |
protected void |
addHandles(Handle[] handles)
Add the handles to the receiver. |
void |
addSelection(Figure figure)
Add the figure to the selections. |
protected void |
clearHandles()
Remove all the handles from the receiver. |
void |
clearSelections()
Remove all the selections of the receiver. |
void |
copySelections()
Copy the selections. |
void |
cutSelections()
Cut the selections |
protected java.awt.Color |
defaultComponentBackground()
Answer the default color for the Component background. |
protected static Drawing |
defaultDrawing()
Answer the default/initial Drawing to use. |
protected java.util.Hashtable |
defaultFigureHandles()
Answer the default/initial figureHandles to use. |
protected java.util.Vector |
defaultHandles()
Answer the default/initial handles to use. |
protected int |
defaultHeight()
Answer the default/initial height to use. |
protected java.util.Vector |
defaultSelections()
Answer the default/initial selections to use. |
protected DrawingStyle |
defaultStyle()
Answer the default/initial DrawingStyle to use. |
protected InputEventHandler |
defaultTool()
Answer the default/initial tool to use. |
protected int |
defaultWidth()
Answer the default/initial width to use. |
void |
deleteSelections()
Delete the selections |
protected void |
drawingSizeChange()
Called when the Drawing's size changes. |
protected java.util.Vector |
duplicateFigures(java.util.Vector toCopy)
Duplicate all of the figures and return a new Vector |
Figure |
figureAt(int x,
int y)
Answer the figure at a given point |
protected void |
figureChange(java.beans.PropertyChangeEvent evt)
Called when a figure changes. |
protected void |
figureLocationChange(java.beans.PropertyChangeEvent evt)
Called when a figure's location changes. |
FigureEnumeration |
figures()
Answer a FiguresEnumeration over the figures of the receiver. |
protected void |
figureShapeChange(java.beans.PropertyChangeEvent evt)
Called when a figure's shape changes. |
protected void |
figureSizeChange(java.beans.PropertyChangeEvent evt)
Called when a figure's size changes. |
java.awt.Rectangle |
getBounds()
Returns the current bounds of the receiver. |
protected java.awt.datatransfer.Clipboard |
getClipboard()
Answers the Clipboard for this canvas. |
java.awt.Component |
getComponent()
Answers the Component we are drawing/displaying. |
protected Figure |
getFigureFromString(java.lang.String string)
Answer a Figure (or null) created based on the string (e.g. |
protected java.util.Vector |
getFromClipboard()
Answer the stuff on the clipboard |
protected java.util.Vector |
getFromClipboard(java.awt.datatransfer.Clipboard clipboard)
Answer the stuff on the clipboard |
protected java.util.Vector |
getFromSystemClipboard()
Answer the stuff on the system clipboard |
protected java.awt.Color |
getHandleColor()
Answer the Color to use in displaying handles. |
Handle[] |
getHandles()
Answer the handles of the receiver. |
Locator |
getLocator(int x,
int y)
Answer the proper locator to be used for the given coordinates. |
Figure[] |
getSelections()
Answer the selections of the receiver. |
java.awt.Dimension |
getSize()
Returns the current size of the receiver. |
DrawingStyle |
getStyle()
Answer the style which defines how to paint on the canvas. |
protected java.awt.datatransfer.Clipboard |
getSystemClipboard()
Answer the system Clipboard. |
InputEventHandler |
getTool()
Answer the active tool |
Handle |
handleAt(int x,
int y)
Answer the handle at a given point |
protected void |
ignoreDrawing()
Stop listening to all of the figures of the drawing. |
protected void |
ignoreFigure(Figure figure)
Stop listening to the specified figure. |
void |
keyPressed(java.awt.event.KeyEvent e)
Invoked when a key has been pressed. |
void |
keyReleased(java.awt.event.KeyEvent e)
Invoked when a key has been released. |
void |
keyTyped(java.awt.event.KeyEvent e)
Invoked when a key has been typed. |
protected void |
listenToDrawing()
Begin listening to all of the figures of the drawing. |
protected void |
listenToFigure(Figure figure)
Begin listening to the specified figure. |
protected java.awt.Dimension |
minimumSize()
Returns the minimum size of the receiver. |
void |
mouseClicked(java.awt.event.MouseEvent e)
Invoked when the mouse has been clicked on a component. |
void |
mouseDragged(java.awt.event.MouseEvent e)
Invoked when a mouse button is pressed on a component and then dragged. |
void |
mouseEntered(java.awt.event.MouseEvent e)
Invoked when the mouse enters a component. |
void |
mouseExited(java.awt.event.MouseEvent e)
Invoked when the mouse exits a component. |
void |
mouseMoved(java.awt.event.MouseEvent e)
Invoked when the mouse button has been moved on a component (with no buttons no down). |
void |
mousePressed(java.awt.event.MouseEvent e)
Invoked when a mouse button has been pressed on a component. |
void |
mouseReleased(java.awt.event.MouseEvent e)
Invoked when a mouse button has been released on a component. |
void |
moveFigureBehind(Figure figure,
Figure existingFigure)
Move the figure behind an existingFigure if it is not already there. |
void |
moveFigureInFront(Figure figure,
Figure existingFigure)
Move the figure in front of an existingFigure if it is not already there. |
void |
moveFigureToBack(Figure figure)
Move the figure behind all other figures. |
void |
moveFigureToFront(Figure figure)
Move the figure in front of all other figures. |
void |
moveSelectionsToBack()
Move the selected figures behind all other figures. |
void |
moveSelectionsToFront()
Move the selected figures in front of all other figures. |
Figure |
otherFigureAt(Figure excludedFigure,
int x,
int y)
Answer the figure at a given point excluding the identified figure |
void |
paint(java.awt.Graphics g)
Paints the canvas. |
protected void |
paintBackground(java.awt.Graphics g)
Paints the background of the canvas. |
protected void |
paintForeground(java.awt.Graphics g)
Paints the foreground of the canvas. |
protected void |
paintHandles(java.awt.Graphics g)
Paints the handles on the canvas. |
void |
paste()
Paste from the clipboard. |
void |
pasteFromSystem()
Paste from the system clipboard. |
protected void |
processKey(java.awt.event.KeyEvent evt)
Called if a character is typed. |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
Called when a property changes. |
protected void |
putToClipboard(java.util.Vector stuff)
Add the stuff to the clipboard |
void |
removeFigure(Figure figure)
Remove the figure. |
void |
removeHandle(Handle handle)
Remove the handle from the receiver. |
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. |
protected void |
removeHandles(Handle[] handles)
Remove the handles to the receiver. |
void |
removeSelection(Figure figure)
Remove the figure from the selections. |
protected void |
repaint()
Repaint the canvas. |
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 |
setComponent(java.awt.Component component)
Set the Component to draw/display. |
void |
setDrawing(Drawing newDrawing)
Set the drawing associated with this canvas. |
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 newTool)
Set the active tool |
void |
toggleSelection(Figure figure)
Toggle whether or not the figure is selected Reflect the change if it's visible. |
void |
toolTaskCompleted(InputEventHandler tool)
Take appropriate action when the tool has completed its task. |
protected java.util.Vector |
validateOrder(java.util.Vector unordered)
Answer a Vector containing the figures in the same order they appear in the receiver. |
| Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractPaintable |
getBottom,
getHeight,
getLeft,
getRight,
getTop,
getWidth |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
protected static java.awt.datatransfer.Clipboard clipboard
protected static final int buffer
protected Drawing drawing
protected java.awt.Component component
protected InputEventHandler tool
protected java.util.Vector selections
protected java.util.Vector handles
protected java.util.Hashtable figureHandles
protected DrawingStyle style
protected int width
protected int height
| Constructor Detail |
public SimpleDrawingCanvas()
public SimpleDrawingCanvas(Drawing drawing)
drawing - the drawing to construct this canvas with| Method Detail |
public void addFigure(Figure figure)
figure - the figure to add
public void addFigureBehind(Figure figure,
Figure existingFigure)
figure - the figure to addexistingFigure - the figure to which the new figure should be behindpublic void addHandle(Handle handle)
handle - the handle to addprotected void addHandles(Handle[] handles)
handles - the array of handles to addpublic void addHandles(Figure figure)
figure - the figure for which handles should be added.
public void addHandles(Figure figure,
Handle[] handles)
figure - the figure for which handles are associated.handles - the handles to add.public void addSelection(Figure figure)
figure - the Figure to addprotected void clearHandles()
public void clearSelections()
public void copySelections()
public void cutSelections()
protected java.awt.Color defaultComponentBackground()
protected static Drawing defaultDrawing()
protected java.util.Hashtable defaultFigureHandles()
protected java.util.Vector defaultHandles()
protected int defaultHeight()
protected java.util.Vector defaultSelections()
protected DrawingStyle defaultStyle()
protected InputEventHandler defaultTool()
protected int defaultWidth()
public void deleteSelections()
protected void drawingSizeChange()
protected java.util.Vector duplicateFigures(java.util.Vector toCopy)
toCopy - the vector of figures to copy
public Figure figureAt(int x,
int y)
x - the x coordinatey - the y coordinateprotected void figureChange(java.beans.PropertyChangeEvent evt)
protected void figureLocationChange(java.beans.PropertyChangeEvent evt)
public FigureEnumeration figures()
protected void figureShapeChange(java.beans.PropertyChangeEvent evt)
protected void figureSizeChange(java.beans.PropertyChangeEvent evt)
public java.awt.Rectangle getBounds()
protected java.awt.datatransfer.Clipboard getClipboard()
public java.awt.Component getComponent()
protected Figure getFigureFromString(java.lang.String string)
string - the string to create the new figure fromprotected java.util.Vector getFromClipboard()
protected java.util.Vector getFromClipboard(java.awt.datatransfer.Clipboard clipboard)
clipboard - the Clipboard to get the data from.protected java.util.Vector getFromSystemClipboard()
protected java.awt.Color getHandleColor()
public Handle[] getHandles()
public Locator getLocator(int x,
int y)
x - the x coordinate to return a Locator for.y - the y coordinate to return a Locator for.public Figure[] getSelections()
public java.awt.Dimension getSize()
public DrawingStyle getStyle()
protected java.awt.datatransfer.Clipboard getSystemClipboard()
public InputEventHandler getTool()
public Handle handleAt(int x,
int y)
x - the x coordinatey - the y coordinateprotected void ignoreDrawing()
protected void ignoreFigure(Figure figure)
figure - the figure to stop listening topublic void keyPressed(java.awt.event.KeyEvent e)
e - the eventpublic void keyReleased(java.awt.event.KeyEvent e)
e - the eventpublic void keyTyped(java.awt.event.KeyEvent e)
e - the eventprotected void listenToDrawing()
protected void listenToFigure(Figure figure)
figure - the figure to begin listening toprotected java.awt.Dimension minimumSize()
public void mouseClicked(java.awt.event.MouseEvent e)
e - the eventpublic void mouseDragged(java.awt.event.MouseEvent e)
e - the eventpublic void mouseEntered(java.awt.event.MouseEvent e)
e - the eventpublic void mouseExited(java.awt.event.MouseEvent e)
e - the eventpublic void mouseMoved(java.awt.event.MouseEvent e)
e - the eventpublic void mousePressed(java.awt.event.MouseEvent e)
e - the eventpublic void mouseReleased(java.awt.event.MouseEvent e)
e - the event
public void moveFigureBehind(Figure figure,
Figure existingFigure)
figure - the figure to moveexistingFigure - the figure to which the new figure should be behind
public void moveFigureInFront(Figure figure,
Figure existingFigure)
figure - the figure to moveexistingFigure - the figure to which the new figure should be in frontpublic void moveFigureToBack(Figure figure)
figure - the figure to movepublic void moveFigureToFront(Figure figure)
figure - the figure to movepublic void moveSelectionsToBack()
public void moveSelectionsToFront()
public Figure otherFigureAt(Figure excludedFigure,
int x,
int y)
figure - the figure to exclude from the searchx - the x coordinatey - the y coordinatepublic void paint(java.awt.Graphics g)
g - the specified Graphics windowprotected void paintBackground(java.awt.Graphics g)
g - the specified Graphics windowprotected void paintForeground(java.awt.Graphics g)
g - the specified Graphics windowprotected void paintHandles(java.awt.Graphics g)
g - the specified Graphics windowpublic void paste()
public void pasteFromSystem()
protected void processKey(java.awt.event.KeyEvent evt)
evt - the eventkeyTyped(java.awt.event.KeyEvent)public void propertyChange(java.beans.PropertyChangeEvent evt)
evt - the eventprotected void putToClipboard(java.util.Vector stuff)
stuff - the vector to add to the clipboardpublic void removeFigure(Figure figure)
figure - the figure to removepublic void removeHandle(Handle handle)
handle - the handle to removeprotected void removeHandles(Handle[] handles)
handles - the array of handles to be removedpublic void removeHandles(Figure figure)
figure - the figure for which handles should be removed.public void removeSelection(Figure figure)
figure - the figure being deselectedprotected void repaint()
public void repaint(java.awt.Rectangle rectangle)
rectangle - is the region to be repaintedrepaint()public void select(Figure figure)
figure - the figure being deselectedpublic void setComponent(java.awt.Component component)
component - the component to draw/display.public void setDrawing(Drawing newDrawing)
newDrawing - the drawing to associate with
public void setSize(int width,
int height)
width - the new width of the receiver.width - the new height of the receiver.public void setSize(java.awt.Dimension size)
size - the new size of the receiver.public void setStyle(DrawingStyle style)
style - the specified DrawingStylepublic void setTool(InputEventHandler newTool)
newTool - the tool to make activepublic void toggleSelection(Figure figure)
figure - the figure of interestpublic void toolTaskCompleted(InputEventHandler tool)
tool - the tool which completed its taskprotected java.util.Vector validateOrder(java.util.Vector unordered)
unordered - the Vector of figures that need to be ordered
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||