org.apache.batik.ext.awt.image.renderable
Class DeferRable

java.lang.Object
  extended by org.apache.batik.ext.awt.image.renderable.DeferRable
All Implemented Interfaces:
RenderableImage, Filter

public class DeferRable
extends Object
implements Filter

This class allows for the return of a proxy object quickly, while a heavy weight object is constrcuted in a background Thread. This proxy object will then block if any methods are called on it that require talking to the source object. This is actually a particular instance of a very general pattern this is probably best represented using the Proxy class in the Reflection APIs.


Field Summary
 
Fields inherited from interface java.awt.image.renderable.RenderableImage
HINTS_OBSERVED
 
Constructor Summary
DeferRable()
          Constructor takes nothing
 
Method Summary
 RenderedImage createDefaultRendering()
          Forward the call (blocking until source is set if need be).
 RenderedImage createRendering(RenderContext rc)
          Forward the call (blocking until source is set if need be).
 RenderedImage createScaledRendering(int w, int h, RenderingHints hints)
          Forward the call (blocking until source is set if need be).
 Rectangle2D getBounds2D()
          Implement the baseclass method to call getSource() so it will block until we have a real source.
 Shape getDependencyRegion(int srcIndex, Rectangle2D outputRgn)
          Forward the call (blocking until source is set if need be).
 Shape getDirtyRegion(int srcIndex, Rectangle2D inputRgn)
          Forward the call (blocking until source is set if need be).
 float getHeight()
           
 float getMinX()
           
 float getMinY()
           
 Object getProperty(String name)
          Forward the call (blocking until source is set if need be).
 String[] getPropertyNames()
          Forward the call (blocking until source is set if need be).
 Filter getSource()
          Key method that blocks if the src has not yet been provided.
 Vector getSources()
           
 long getTimeStamp()
          Returns the current modification timestamp on this Renderable node.
 float getWidth()
           
 boolean isDynamic()
          Forward the call (blocking until source is set if need be).
 void setBounds(Rectangle2D bounds)
           
 void setProperties(Map props)
           
 void setSource(Filter src)
          Key method that sets the src.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeferRable

public DeferRable()
Constructor takes nothing

Method Detail

getSource

public Filter getSource()
Key method that blocks if the src has not yet been provided.


setSource

public void setSource(Filter src)
Key method that sets the src. The source can only be set once (this makes sense given the intent of the class is to stand in for a real object, so swaping that object isn't a good idea. This will wake all the threads that might be waiting for the source to be set.


setBounds

public void setBounds(Rectangle2D bounds)

setProperties

public void setProperties(Map props)

getTimeStamp

public long getTimeStamp()
Description copied from interface: Filter
Returns the current modification timestamp on this Renderable node. This value will change whenever cached output data becomes invalid.

Specified by:
getTimeStamp in interface Filter
Returns:
Current modification timestamp value.

getSources

public Vector getSources()
Specified by:
getSources in interface RenderableImage

isDynamic

public boolean isDynamic()
Forward the call (blocking until source is set if need be).

Specified by:
isDynamic in interface RenderableImage

getBounds2D

public Rectangle2D getBounds2D()
Implement the baseclass method to call getSource() so it will block until we have a real source.

Specified by:
getBounds2D in interface Filter

getMinX

public float getMinX()
Specified by:
getMinX in interface RenderableImage

getMinY

public float getMinY()
Specified by:
getMinY in interface RenderableImage

getWidth

public float getWidth()
Specified by:
getWidth in interface RenderableImage

getHeight

public float getHeight()
Specified by:
getHeight in interface RenderableImage

getProperty

public Object getProperty(String name)
Forward the call (blocking until source is set if need be).

Specified by:
getProperty in interface RenderableImage

getPropertyNames

public String[] getPropertyNames()
Forward the call (blocking until source is set if need be).

Specified by:
getPropertyNames in interface RenderableImage

createDefaultRendering

public RenderedImage createDefaultRendering()
Forward the call (blocking until source is set if need be).

Specified by:
createDefaultRendering in interface RenderableImage

createScaledRendering

public RenderedImage createScaledRendering(int w,
                                           int h,
                                           RenderingHints hints)
Forward the call (blocking until source is set if need be).

Specified by:
createScaledRendering in interface RenderableImage

createRendering

public RenderedImage createRendering(RenderContext rc)
Forward the call (blocking until source is set if need be).

Specified by:
createRendering in interface RenderableImage

getDependencyRegion

public Shape getDependencyRegion(int srcIndex,
                                 Rectangle2D outputRgn)
Forward the call (blocking until source is set if need be).

Specified by:
getDependencyRegion in interface Filter
Parameters:
srcIndex - The source to do the dependency calculation for.
outputRgn - The region of output you are interested in generating dependencies for. The is given in the user coordiate system for this node.
Returns:
The region of input required. This is in the user coordinate system for the source indicated by srcIndex.

getDirtyRegion

public Shape getDirtyRegion(int srcIndex,
                            Rectangle2D inputRgn)
Forward the call (blocking until source is set if need be).

Specified by:
getDirtyRegion in interface Filter
Parameters:
srcIndex - The input that inputRgn reflects changes in.
inputRgn - the region of input that has changed, used to calculate the returned shape. This is given in the user coordinate system of the source indicated by srcIndex.
Returns:
The region of output that would be invalid given a change to inputRgn of the source selected by srcIndex. this is in the user coordinate system of this node.


Copyright © 2008 Apache Software Foundation. All Rights Reserved.