CH.ifa.draw.framework
Interface Drawing

All Superinterfaces:
java.util.EventListener, FigureChangeListener, java.io.Serializable, Storable
All Known Implementing Classes:
BouncingDrawing, StandardDrawing

public interface Drawing
extends Storable, FigureChangeListener, java.io.Serializable

Drawing is a container for figures.

Drawing sends out DrawingChanged events to DrawingChangeListeners whenever a part of its area was invalidated.


Design Patterns

 o Observer
The Observer pattern is used to decouple the Drawing from its views and to enable multiple views.


See Also:
Figure, DrawingView, FigureChangeListener

Method Summary
 Figure add(Figure figure)
          Adds a figure and sets its container to refer to this drawing.
 void addAll(java.util.Vector newFigures)
          Adds a vector of figures.
 void addDrawingChangeListener(DrawingChangeListener listener)
          Adds a listener for this drawing.
 void bringToFront(Figure figure)
          Brings a figure to the front.
 void draw(java.awt.Graphics g)
          Draws all the figures back to front.
 java.util.Enumeration drawingChangeListeners()
          Gets the listeners of a drawing.
 void figureInvalidated(FigureChangeEvent e)
          Invalidates a rectangle and merges it with the existing damaged area.
 void figureRequestRemove(FigureChangeEvent e)
          Handles a removeFrfigureRequestRemove request that is passed up the figure container hierarchy.
 void figureRequestUpdate(FigureChangeEvent e)
          Forces an update of the drawing change listeners.
 FigureEnumeration figures()
          Returns an enumeration to iterate in Z-order back to front over the figures.
 FigureEnumeration figuresReverse()
          Returns an enumeration to iterate in Z-order front to back over the figures.
 Figure findFigure(int x, int y)
          Finds a top level Figure.
 Figure findFigure(java.awt.Rectangle r)
          Finds a top level Figure that intersects the given rectangle.
 Figure findFigure(java.awt.Rectangle r, Figure without)
          Finds a top level Figure that intersects the given rectangle.
 Figure findFigureInside(int x, int y)
          Finds a figure but descends into a figure's children.
 Figure findFigureInsideWithout(int x, int y, Figure without)
          Finds a figure but descends into a figure's children.
 Figure findFigureWithout(int x, int y, Figure without)
          Finds a top level Figure, but supresses the passed in figure.
 void lock()
          Acquires the drawing lock.
 Figure orphan(Figure figure)
          Removes a figure from the figure list, but doesn't release it.
 void orphanAll(java.util.Vector newFigures)
          Removes a vector of figures from the figure's list without releasing the figures.
 void release()
          Releases the drawing and its contained figures.
 Figure remove(Figure figure)
          Removes the figure from the drawing and releases it.
 void removeAll(java.util.Vector figures)
          Removes a vector of figures .
 void removeDrawingChangeListener(DrawingChangeListener listener)
          Removes a listener from this drawing.
 void replace(Figure figure, Figure replacement)
          Replaces a figure in the drawing without removing it from the drawing.
 void sendToBack(Figure figure)
          Sends a figure to the back of the drawing.
 void unlock()
          Releases the drawing lock.
 
Methods inherited from interface CH.ifa.draw.util.Storable
read, write
 
Methods inherited from interface CH.ifa.draw.framework.FigureChangeListener
figureChanged, figureRemoved
 

Method Detail

release

void release()
Releases the drawing and its contained figures.


figures

FigureEnumeration figures()
Returns an enumeration to iterate in Z-order back to front over the figures.


figuresReverse

FigureEnumeration figuresReverse()
Returns an enumeration to iterate in Z-order front to back over the figures.


findFigure

Figure findFigure(int x,
                  int y)
Finds a top level Figure. Use this call for hit detection that should not descend into the figure's children.


findFigure

Figure findFigure(java.awt.Rectangle r)
Finds a top level Figure that intersects the given rectangle.


findFigureWithout

Figure findFigureWithout(int x,
                         int y,
                         Figure without)
Finds a top level Figure, but supresses the passed in figure. Use this method to ignore a figure that is temporarily inserted into the drawing.

Parameters:
x - the x coordinate
y - the y coordinate
without - the figure to be ignored during the find.

findFigure

Figure findFigure(java.awt.Rectangle r,
                  Figure without)
Finds a top level Figure that intersects the given rectangle. It supresses the passed in figure. Use this method to ignore a figure that is temporarily inserted into the drawing.


findFigureInside

Figure findFigureInside(int x,
                        int y)
Finds a figure but descends into a figure's children. Use this method to implement click-through hit detection, that is, you want to detect the inner most figure containing the given point.


findFigureInsideWithout

Figure findFigureInsideWithout(int x,
                               int y,
                               Figure without)
Finds a figure but descends into a figure's children. It supresses the passed in figure. Use this method to ignore a figure that is temporarily inserted into the drawing.

Parameters:
x - the x coordinate
y - the y coordinate
without - the figure to be ignored during the find.

addDrawingChangeListener

void addDrawingChangeListener(DrawingChangeListener listener)
Adds a listener for this drawing.


removeDrawingChangeListener

void removeDrawingChangeListener(DrawingChangeListener listener)
Removes a listener from this drawing.


drawingChangeListeners

java.util.Enumeration drawingChangeListeners()
Gets the listeners of a drawing.


add

Figure add(Figure figure)
Adds a figure and sets its container to refer to this drawing.

Returns:
the figure that was inserted.

addAll

void addAll(java.util.Vector newFigures)
Adds a vector of figures.


remove

Figure remove(Figure figure)
Removes the figure from the drawing and releases it.


orphan

Figure orphan(Figure figure)
Removes a figure from the figure list, but doesn't release it. Use this method to temporarily manipulate a figure outside of the drawing.


orphanAll

void orphanAll(java.util.Vector newFigures)
Removes a vector of figures from the figure's list without releasing the figures.

See Also:
orphan(CH.ifa.draw.framework.Figure)

removeAll

void removeAll(java.util.Vector figures)
Removes a vector of figures .

See Also:
remove(CH.ifa.draw.framework.Figure)

replace

void replace(Figure figure,
             Figure replacement)
Replaces a figure in the drawing without removing it from the drawing.


sendToBack

void sendToBack(Figure figure)
Sends a figure to the back of the drawing.


bringToFront

void bringToFront(Figure figure)
Brings a figure to the front.


draw

void draw(java.awt.Graphics g)
Draws all the figures back to front.


figureInvalidated

void figureInvalidated(FigureChangeEvent e)
Invalidates a rectangle and merges it with the existing damaged area.

Specified by:
figureInvalidated in interface FigureChangeListener

figureRequestUpdate

void figureRequestUpdate(FigureChangeEvent e)
Forces an update of the drawing change listeners.

Specified by:
figureRequestUpdate in interface FigureChangeListener

figureRequestRemove

void figureRequestRemove(FigureChangeEvent e)
Handles a removeFrfigureRequestRemove request that is passed up the figure container hierarchy.

Specified by:
figureRequestRemove in interface FigureChangeListener
See Also:
FigureChangeListener

lock

void lock()
Acquires the drawing lock.


unlock

void unlock()
Releases the drawing lock.