org.jfree.report
Class ImageReference

java.lang.Object
  extended byorg.jfree.report.ImageReference
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class ImageReference
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

An image reference encapsulates the source of an image together with a java.awt.Image. The source is used to create a higher resolution version if needed. The source file/URL may also be inlined into the output target, to create better results.

An ImageReference is always used in conjunction with an ImageElement.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
ImageReference(java.awt.Image img)
          Creates a new ImageReference without an assigned URL for the Image.
ImageReference(int w, int h, java.awt.geom.Rectangle2D bounds)
          Creates a new image reference.
ImageReference(java.net.URL url)
          Creates a new ImageReference with an origin of 0,0 and the desired width.
 
Method Summary
 java.lang.Object clone()
          Clones this Element.
 boolean equals(java.lang.Object o)
          Checks for equality.
 java.awt.geom.Rectangle2D getBounds()
          Return the bounds of the image contained in that reference.
 java.awt.geom.Rectangle2D getBoundsScaled()
          Returns the scaled bounds.
 java.awt.Image getImage()
          Returns the current image instance.
 int getImageHeight()
          Returns the (unscaled) image height.
 int getImageWidth()
          Returns the (unscaled) image width.
 float getScaleX()
          Returns the x scale factor.
 float getScaleY()
          Returns the y scale factor.
 java.net.URL getSourceURL()
          Returns the source URL for the image.
 int hashCode()
          compute a hashcode for this imageReference.
 void setBounds(java.awt.geom.Rectangle2D bounds)
          Define the bounds of the image contained in that reference.
 void setBoundsScaled(java.awt.geom.Rectangle2D bounds)
          Sets the scaled bounds.
 void setScaleX(float scaleX)
          Sets the x scale factor.
 void setScaleY(float scaleY)
          Sets the y scale factor.
 java.lang.String toString()
          Returns a String representing this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImageReference

public ImageReference(java.net.URL url)
               throws java.io.IOException
Creates a new ImageReference with an origin of 0,0 and the desired width. The image data is read from the given URL.

Parameters:
url - the source url. The url must be readable while generating reports.
Throws:
java.io.IOException - if the url could not be read.

ImageReference

public ImageReference(java.awt.Image img)
Creates a new ImageReference without an assigned URL for the Image.

Parameters:
img - the image for this reference
Throws:
java.lang.NullPointerException - if the image is null

ImageReference

public ImageReference(int w,
                      int h,
                      java.awt.geom.Rectangle2D bounds)
Creates a new image reference.

Parameters:
w - the width of the unscaled image.
h - the height of the unscaled image.
bounds - the area of the unscaled image to draw.
Method Detail

getBounds

public java.awt.geom.Rectangle2D getBounds()
Return the bounds of the image contained in that reference. These bounds are the natural bounds of the raw image, no scaling applied. These bounds may define a sub-area of the real image contained in that Reference.

Returns:
the bounds.

setBounds

public void setBounds(java.awt.geom.Rectangle2D bounds)
Define the bounds of the image contained in that reference.

Parameters:
bounds - the bounds.

getScaleX

public float getScaleX()
Returns the x scale factor.

Returns:
the x scale factor.

setScaleX

public void setScaleX(float scaleX)
Sets the x scale factor.

Parameters:
scaleX - the new factor.

getScaleY

public float getScaleY()
Returns the y scale factor.

Returns:
the y scale factor.

setScaleY

public void setScaleY(float scaleY)
Sets the y scale factor.

Parameters:
scaleY - the y scale factor.

setBoundsScaled

public void setBoundsScaled(java.awt.geom.Rectangle2D bounds)
Sets the scaled bounds.

Parameters:
bounds - the bounds.

getBoundsScaled

public java.awt.geom.Rectangle2D getBoundsScaled()
Returns the scaled bounds.

Returns:
the scaled bounds.

getImage

public java.awt.Image getImage()
Returns the current image instance.

The image is not scaled in any way.

Returns:
The current image instance.

getSourceURL

public java.net.URL getSourceURL()
Returns the source URL for the image.

Returns:
The URL.

toString

public java.lang.String toString()
Returns a String representing this object. Useful for debugging.

Returns:
The string.

equals

public boolean equals(java.lang.Object o)
Checks for equality.

Parameters:
o - the object to test.
Returns:
true if the specified object is equal to this one.

hashCode

public int hashCode()
compute a hashcode for this imageReference.

Returns:
the hashcode

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones this Element.

Returns:
a clone of this element.
Throws:
java.lang.CloneNotSupportedException - this should never be thrown.

getImageWidth

public int getImageWidth()
Returns the (unscaled) image width.

Returns:
the image width.

getImageHeight

public int getImageHeight()
Returns the (unscaled) image height.

Returns:
the image height.