org.jdrawing
Class AbstractDrawingModelCache

java.lang.Object
  extended byorg.jdrawing.AbstractDrawingModelCache
All Implemented Interfaces:
DrawingModelCache, DrawingModelListener, java.util.EventListener
Direct Known Subclasses:
DefaultDrawingModelCache, GridDrawingModelCache, QuadTreeDrawingModelCache

public abstract class AbstractDrawingModelCache
extends java.lang.Object
implements DrawingModelCache, DrawingModelListener

This abstract class provides default implementations for most of the methods in the DrawingModelCache interface. It takes care of the management of listeners and provides some conveniences for generating DrawingModelCacheEvents and dispatching them to the listeners. Also it provides some default handling of drawing model events.


Constructor Summary
AbstractDrawingModelCache()
           
 
Method Summary
 void addDrawingModelCacheListener(DrawingModelCacheListener listener)
          Adds a listener which will be notified about changes in this model cache.
 void elementsAdded(DrawingModelEvent event)
          Invoked after elements have been inserted into the model.
 void elementsChanged(DrawingModelEvent event)
          Invoked after elements have been changed in some way.
 void elementsRemoved(DrawingModelEvent event)
          Invoked after elements have been removed from the model.
protected  void fireAreaChanged(java.awt.Rectangle area)
          Notifies all listeners that the area has changed in some way.
protected  void fireDrawingChanged()
          Notifies all listeners that the drawing has changed in some way.
 DrawingModelCacheListener[] getDrawingModelCacheListeners()
          Returns an array of all the drawing model cache listeners registered on this model cache.
 DrawingModel getModel()
          Returns the DrawingModel that is cached by this cache.
 java.awt.Rectangle getModelBounds()
          Returns the bounding box of all elements of the model.
 DrawingRenderer getRenderer()
          Returns the DrawingRenderer that is used by this cache.
 void modelChanged(DrawingModelEvent event)
          Invoked after the model has drastically changed in some way.
 void removeDrawingModelCacheListener(DrawingModelCacheListener listener)
          Removes a listener from the list that is notified about changes in this model cache.
 void setModel(DrawingModel model)
          Sets the DrawingModel that will be cached by this cache.
 void setRenderer(DrawingRenderer renderer)
          Sets the DrawingRenderer that will be used in this cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jdrawing.DrawingModelCache
getElementsForPoint, getElementsForRectangle, getModelBounds2D
 

Constructor Detail

AbstractDrawingModelCache

public AbstractDrawingModelCache()
Method Detail

setModel

public void setModel(DrawingModel model)
Description copied from interface: DrawingModelCache
Sets the DrawingModel that will be cached by this cache.

Specified by:
setModel in interface DrawingModelCache
Parameters:
model - the DrawingModel that is to be cached

getModel

public DrawingModel getModel()
Returns the DrawingModel that is cached by this cache.

Returns:
the DrawingModel that is cached by this cache

setRenderer

public void setRenderer(DrawingRenderer renderer)
Description copied from interface: DrawingModelCache
Sets the DrawingRenderer that will be used in this cache. Renderer is used to obtain the bounds of an element of the model.

Specified by:
setRenderer in interface DrawingModelCache
Parameters:
renderer - the DrawingRenderer that is to be used

getRenderer

public DrawingRenderer getRenderer()
Returns the DrawingRenderer that is used by this cache.

Returns:
the DrawingRenderer that is used by this cache

getModelBounds

public java.awt.Rectangle getModelBounds()
Description copied from interface: DrawingModelCache
Returns the bounding box of all elements of the model.

Specified by:
getModelBounds in interface DrawingModelCache
Returns:
the bounding box of all elements of the model

addDrawingModelCacheListener

public void addDrawingModelCacheListener(DrawingModelCacheListener listener)
Description copied from interface: DrawingModelCache
Adds a listener which will be notified about changes in this model cache.

Specified by:
addDrawingModelCacheListener in interface DrawingModelCache
Parameters:
listener - the DrawingModelCacheListener

removeDrawingModelCacheListener

public void removeDrawingModelCacheListener(DrawingModelCacheListener listener)
Description copied from interface: DrawingModelCache
Removes a listener from the list that is notified about changes in this model cache.

Specified by:
removeDrawingModelCacheListener in interface DrawingModelCache
Parameters:
listener - the DrawingModelCacheListener

getDrawingModelCacheListeners

public DrawingModelCacheListener[] getDrawingModelCacheListeners()
Returns an array of all the drawing model cache listeners registered on this model cache.

Returns:
all of this model's DrawingModelCacheListeners or an empty array if no drawing model cache listeners are currently registered

fireAreaChanged

protected void fireAreaChanged(java.awt.Rectangle area)
Notifies all listeners that the area has changed in some way.

Parameters:
area - rectangular bounds of the changed area

fireDrawingChanged

protected void fireDrawingChanged()
Notifies all listeners that the drawing has changed in some way.


elementsAdded

public void elementsAdded(DrawingModelEvent event)
Invoked after elements have been inserted into the model. Notifies all listeners that the area occupied by the inserted element have been changed.

Specified by:
elementsAdded in interface DrawingModelListener
Parameters:
event - DrawingModelEvent object encapsulating event information

elementsRemoved

public void elementsRemoved(DrawingModelEvent event)
Invoked after elements have been removed from the model. Notifies all listeners that the area occupied by the removed element have been changed.

Specified by:
elementsRemoved in interface DrawingModelListener
Parameters:
event - DrawingModelEvent object encapsulating event information

elementsChanged

public void elementsChanged(DrawingModelEvent event)
Invoked after elements have been changed in some way. Notifies all listeners that drawing has changed.

Specified by:
elementsChanged in interface DrawingModelListener
Parameters:
event - DrawingModelEvent object encapsulating event information

modelChanged

public void modelChanged(DrawingModelEvent event)
Invoked after the model has drastically changed in some way. Notifies all listeners that drawing has changed.

Specified by:
modelChanged in interface DrawingModelListener
Parameters:
event - DrawingModelEvent object encapsulating event information