public class StandardDrawing extends CompositeFigure implements Drawing
Modifier and Type | Field and Description |
---|---|
protected StandardDrawingChangeListenerHandler |
listenerHandler
use a StandardDrawingChangeListenerHandler to handle all observer pattern
subject role behaviour
|
protected SelectionHandler |
selectionHandler
list of all figures currently selected
|
fFigures
listenerList
Constructor and Description |
---|
StandardDrawing() |
Modifier and Type | Method and Description |
---|---|
void |
addDrawingChangeListener(DrawingChangeListener listener)
Adds a listener for this drawing.
|
void |
addToSelection(Figure figure)
Adds a figure to the current selection.
|
(package private) void |
basicDisplayBox(int x,
int y)
should not be used by a drawing - the reason this method is defined is
because of the opportunistic reuse opportunities of the CompositeFigure
|
void |
clearSelection()
Clears the current selection.
|
java.awt.Rectangle |
displayBox()
Return the display box of this figure.
|
void |
figureChanged(FigureChangeEvent e)
Sent when a figure changed
|
void |
figureInvalidated(FigureChangeEvent e)
Invalidates a rectangle and merges it with the existing damaged area.
|
void |
lock()
Acquires a lock on the list of figures in this drawing.
|
void |
removeDrawingChangeListener(DrawingChangeListener listener)
Removes a listener from this drawing.
|
void |
removeFromSelection(Figure figure)
Removes a figure from the selection.
|
void |
requestUpdate()
Request update: force a "repaint" event to all associated listeners on this
drawing
|
java.util.List<Figure> |
selection()
Get a list of all selected figures
|
void |
toggleSelection(Figure figure)
If a figure isn't selected it is added to the selection.
|
void |
unlock()
Releases the drawing lock.
|
add, basicMoveBy, draw, figureRemoved, figureRequestRemove, figureRequestUpdate, findFigure, iterator, remove
addFigureChangeListener, changed, invalidate, moveBy, removeFigureChangeListener, willChange
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
add, findFigure, iterator, remove
figureRemoved, figureRequestRemove, figureRequestUpdate
protected SelectionHandler selectionHandler
protected StandardDrawingChangeListenerHandler listenerHandler
public void addDrawingChangeListener(DrawingChangeListener listener)
addDrawingChangeListener
in interface DrawingChangeListenerHandler
listener
- the listener to add to this handlerpublic void removeDrawingChangeListener(DrawingChangeListener listener)
removeDrawingChangeListener
in interface DrawingChangeListenerHandler
listener
- the listener to remove from this handlerpublic void figureInvalidated(FigureChangeEvent e)
figureInvalidated
in interface FigureChangeListener
figureInvalidated
in class CompositeFigure
e
- the event containing information about the changeFigureChangeListener
public void figureChanged(FigureChangeEvent e)
FigureChangeListener
figureChanged
in interface FigureChangeListener
figureChanged
in class CompositeFigure
e
- the event containing information about the changepublic void requestUpdate()
Drawing
requestUpdate
in interface Drawing
public java.util.List<Figure> selection()
selection
in interface SelectionHandler
public void addToSelection(Figure figure)
addToSelection
in interface SelectionHandler
figure
- the figure to add to the selectionpublic void removeFromSelection(Figure figure)
removeFromSelection
in interface SelectionHandler
figure
- the figure to removepublic void toggleSelection(Figure figure)
toggleSelection
in interface SelectionHandler
figure
- the figure to togglepublic void clearSelection()
clearSelection
in interface SelectionHandler
void basicDisplayBox(int x, int y)
x
- x coordinatey
- y coordinatepublic java.awt.Rectangle displayBox()
Figure
displayBox
in interface Figure
public void lock()
Drawing
From the book: Flexible, Reliable Software, © CRC Press 2010. Author: Henrik B. Christensen, Aarhus University, Denmark