org.jdrawing
Class DefaultDrawingModelCache

java.lang.Object
  extended byorg.jdrawing.AbstractDrawingModelCache
      extended byorg.jdrawing.DefaultDrawingModelCache
All Implemented Interfaces:
DrawingModelCache, DrawingModelListener, java.util.EventListener

public class DefaultDrawingModelCache
extends AbstractDrawingModelCache

Default implementation of DrawingModelCache interface. This implementation does not do any optimizations, except for optimizations supported by IndexedDrawingModel interface.


Constructor Summary
DefaultDrawingModelCache()
           
 
Method Summary
 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.
 java.lang.Object[] getElementsForPoint(java.awt.geom.Point2D point)
          Returns elements which contains a given point.
 java.lang.Object[] getElementsForRectangle(java.awt.geom.Rectangle2D rectangle)
          Returns elements neccessary for repainting given area.
 java.awt.geom.Rectangle2D getModelBounds2D()
          Returns the high precision bounding box of all elements of the model.
 void modelChanged(DrawingModelEvent event)
          Invoked after the model has drastically changed in some way.
 void setElementRenderer(DrawingElementRenderer renderer)
          Sets the DrawingElementRenderer that will be used this cache.
 void setModel(DrawingModel model)
          Sets the DrawingModel that will be cached by this cache.
 
Methods inherited from class org.jdrawing.AbstractDrawingModelCache
addDrawingModelCacheListener, fireAreaChanged, fireDrawingChanged, getDrawingModelCacheListeners, getElementRenderer, getModel, getModelBounds, removeDrawingModelCacheListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDrawingModelCache

public DefaultDrawingModelCache()
Method Detail

setModel

public void setModel(DrawingModel model)
Sets the DrawingModel that will be cached by this cache.

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

setElementRenderer

public void setElementRenderer(DrawingElementRenderer renderer)
Sets the DrawingElementRenderer that will be used this cache. Renderer is user to obtain bounds of element of the model.

Specified by:
setElementRenderer in interface DrawingModelCache
Overrides:
setElementRenderer in class AbstractDrawingModelCache
Parameters:
renderer - the DrawingElementRenderer that is to be used

getModelBounds2D

public java.awt.geom.Rectangle2D getModelBounds2D()
Returns the high precision bounding box of all elements of the model.

Returns:
the high precision bounding box of all elements of the model

getElementsForRectangle

public java.lang.Object[] getElementsForRectangle(java.awt.geom.Rectangle2D rectangle)
Returns elements neccessary for repainting given area. Elements are returned in order suitable for painting.

Parameters:
rectangle - area that will be repainted
Returns:
elements neccessary for repainting

getElementsForPoint

public java.lang.Object[] getElementsForPoint(java.awt.geom.Point2D point)
Returns elements which contains a given point. Elements are returned in order, suitable for painting.

Parameters:
point - the Point2D
Returns:
elements containing given point

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
Overrides:
elementsAdded in class AbstractDrawingModelCache
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
Overrides:
elementsRemoved in class AbstractDrawingModelCache
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
Overrides:
elementsChanged in class AbstractDrawingModelCache
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
Overrides:
modelChanged in class AbstractDrawingModelCache
Parameters:
event - DrawingModelEvent object encapsulating event information