org.jdrawing
Interface DrawingModelCache

All Known Implementing Classes:
AbstractDrawingModelCache

public interface DrawingModelCache

The interface that defines a model cache for JDrawing. The model cache is responsible for selecting elements necessary for repainting a specific area, calculating a bounding rectangle of the model, and searching for elements containing a given point.

See Also:
DrawingModel, DrawingElementRenderer

Method Summary
 void addDrawingModelCacheListener(DrawingModelCacheListener listener)
          Adds a listener which will be notified about changes in this model cache.
 java.lang.Object[] getElementsForPoint(java.awt.geom.Point2D point)
          Returns elements which contain a given point.
 java.lang.Object[] getElementsForRectangle(java.awt.geom.Rectangle2D rectangle)
          Returns elements neccessary for repainting given area.
 java.awt.Rectangle getModelBounds()
          Returns the bounding box of all elements of the model.
 java.awt.geom.Rectangle2D getModelBounds2D()
          Returns the high precision bounding box of all elements of the model.
 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.
 

Method Detail

setModel

public void setModel(DrawingModel model)
Sets the DrawingModel that will be cached by this cache. If model is null, then set this DrawingModelCache to do not cache any DrawingModel.

Parameters:
model - the DrawingModel that is to be cached or null

setRenderer

public void setRenderer(DrawingRenderer renderer)
Sets the DrawingRenderer that will be used in this cache. If renderer is null, then set this DrawingModelCache to do not use any DrawingRenderer. Renderer is used to obtain the bounds of an element of the model.

Parameters:
renderer - the DrawingRenderer that is to be used

getModelBounds

public java.awt.Rectangle getModelBounds()
Returns the bounding box of all elements of the model.

Returns:
the bounding box of all elements of the model
Throws:
java.lang.IllegalStateException - if either drawing model, or drawing renderer is not set

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
Throws:
java.lang.IllegalStateException - if either drawing model, or drawing renderer is not set

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
Throws:
java.lang.IllegalStateException - if either drawing model, or drawing renderer is not set

getElementsForPoint

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

Parameters:
point - the Point2D return elements containing given point
Throws:
java.lang.IllegalStateException - if either drawing model, or drawing renderer is not set

addDrawingModelCacheListener

public void addDrawingModelCacheListener(DrawingModelCacheListener listener)
Adds a listener which will be notified about changes in this model cache.

Parameters:
listener - the DrawingModelCacheListener
Throws:
java.lang.IllegalArgumentException - if listener is null

removeDrawingModelCacheListener

public void removeDrawingModelCacheListener(DrawingModelCacheListener listener)
Removes a listener from the list that is notified about changes in this model cache. If the listener is not in the list of is null then this method does nothing.

Parameters:
listener - the DrawingModelCacheListener