Package com.nomagic.magicreport
Class Image
java.lang.Object
com.nomagic.magicreport.Image
- All Implemented Interfaces:
IObserverMessage,IVariable,Serializable,Cloneable
- Direct Known Subclasses:
ReportSVGIcon,SVGIcon
An bean represent image object for template. If dispose was set, the engine will dispose image data after image
has been exported to report.
- Since:
- Jul 2, 2007
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstants bit for image transformation (auto fit).static final intConstants bit for force rotatestatic final intConstants bit for force rotate (rotate left).static final intConstants bit for force rotate (rotate right).static final intstatic final intConstants for image type that is created as icon or imagestatic final intConstants bit for image transformation (perform operation only when image is large only).static final intConstants bit for image transformation (maintain ratio).static final intConstants bit for image transformation (rotate left).static final intConstants bit for image transformation (rotate right).static final intConstants bit for image transformation (physically transform image instead of use document feature). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates and returns a copy of this object.Create a new instance of original image.voiddispose()Disposes of this image buffer context and releases any system resources that it is using.voidbooleanIndicates whether some other object is "equal to" this one.voidflush()Flush current buffered image fromgetData()into file stream.voidFlush current buffered image fromgetData()into file stream.Returns the bounding Rectangle of this Image.getData()Return a data.intgetDpi()intReturn the height of image in pixels.getId()Return a id.Return a imageFile.Return an image format.intGet image type.getName()Return a name.Returns the original bounding Rectangle of this Image.intReturn a original height.Return an original image file.Return an original image format.intReturn a original width.getProperty(String key) Searches for the property with the specified key in this property list.intgetSize()Returns the size of image in pixels.intReturn a transformation flag.intgetWidth()Return the width of image in pixels.inthashCode()Returns a hash code value for the object.booleanReturn a changed.booleanReturn a dispose setting.booleanisTransformWithOption(int option) Test if image transformation option is set to given option.readData()Read a buffered image from this instance.voidrotate(boolean clockwise) Rotate image in clockwise or anti-clockwise.voidsetChanged(boolean changed) Iffalse, dispose image buffer and mark a status.voidsetData(BufferedImage data) Set a data.voidsetDisposeAfterUse(boolean disposeAfterUse) Set image data to be disposed after generating report.voidsetDpi(int dpi) voidsetHeight(int height) Set height of image in pixels.voidSet a id.voidsetImageFile(File imageFile) Set a imageFile.voidsetImageFormat(String imageFormat) Set an image format.voidsetImageType(int imageType) Set image type.voidSet a name.voidsetOriginalHeight(int originalHeight) voidsetOriginalImageFile(File originalImageFile) voidsetOriginalImageFormat(String originalImageFormat) Set an original image format.voidsetOriginalWidth(int originalWidth) voidsetProperties(Map<String, Object> properties) voidsetProperty(String key, Object value) Set an image property.voidsetTransformationOption(int transformationOption) Set a transformation option.voidsetWidth(int width) Set width of image in pixels.toString()Returns a string representation of the object.
-
Field Details
-
FIT_PAPER
public static final int FIT_PAPERConstants bit for image transformation (auto fit).- See Also:
-
MAINTAIN_RATIO
public static final int MAINTAIN_RATIOConstants bit for image transformation (maintain ratio).- See Also:
-
ROTATE_LEFT
public static final int ROTATE_LEFTConstants bit for image transformation (rotate left).- See Also:
-
ROTATE_RIGHT
public static final int ROTATE_RIGHTConstants bit for image transformation (rotate right).- See Also:
-
LARGE_ONLY
public static final int LARGE_ONLYConstants bit for image transformation (perform operation only when image is large only).- See Also:
-
IMAGE_TYPE_IMAGE
public static final int IMAGE_TYPE_IMAGEConstants for image type that is created as icon or image- See Also:
-
IMAGE_TYPE_ICON
public static final int IMAGE_TYPE_ICON- See Also:
-
TRUE_TRANSFORM
public static final int TRUE_TRANSFORMConstants bit for image transformation (physically transform image instead of use document feature).- See Also:
-
FORCE_ROTATE_LEFT
public static final int FORCE_ROTATE_LEFTConstants bit for force rotate (rotate left).- See Also:
-
FORCE_ROTATE_RIGHT
public static final int FORCE_ROTATE_RIGHTConstants bit for force rotate (rotate right).- See Also:
-
FORCE_ROTATE
public static final int FORCE_ROTATEConstants bit for force rotate- See Also:
-
-
Constructor Details
-
Image
Create a new image from file. IfdisposeAfterUseis true, image will be disposed immediately after print into report.Generally, same image will be used only once in the template, it's recommend to set
disposeAfterUseto true.- Parameters:
id- image idimageFile- image file.disposeAfterUse- if true, dispose an image after use.- Throws:
IllegalArgumentException- if image file is null
-
Image
Create a new image from buffered image. IfdisposeAfterUseis true, image will be disposed immediately after print into report.Generally, same image will be used only once in the template, it's recommend to set
disposeAfterUseto true.datacan be null.- Parameters:
id- image iddata- the image dataimageFormat- the image format.disposeAfterUse- if true, dispose an image after use.- Throws:
IllegalArgumentException- if image format is null
-
-
Method Details
-
getProperties
-
setProperties
-
setOriginalImageFile
-
setOriginalWidth
public void setOriginalWidth(int originalWidth) -
setOriginalHeight
public void setOriginalHeight(int originalHeight) -
getId
Return a id.- Returns:
- the id
-
setId
Set a id.- Parameters:
id- the id to set
-
getName
Return a name.- Specified by:
getNamein interfaceIObserverMessage- Returns:
- the name
-
setName
Set a name.- Parameters:
name- the name to set
-
getData
Return a data.- Returns:
- the data
-
setData
Set a data.- Parameters:
data- the data to set
-
getImageFormat
Return an image format.- Returns:
- the image format
-
setImageFormat
Set an image format.- Parameters:
imageFormat- the image format to set
-
getOriginalImageFormat
Return an original image format. For external image file, it may have real format that different to file extension- Returns:
- the original image format
-
setOriginalImageFormat
Set an original image format. For external image file, it may have real format that different to file extension- Parameters:
originalImageFormat- the original image format to set
-
setProperty
Set an image property.- Parameters:
key- the key to be placed into this property list.value- the value corresponding to key.
-
getProperty
Searches for the property with the specified key in this property list. The method returnsnullif the property is not found.- Parameters:
key- the property key.- Returns:
- the value in this property list with the specified key value.
- See Also:
-
isChanged
public boolean isChanged()Return a changed.- Returns:
- the changed
-
setChanged
public void setChanged(boolean changed) Iffalse, dispose image buffer and mark a status. Developer should detect an image status before retrieve a new buffer fromgetData().- Parameters:
changed- the changed to set- See Also:
-
readData
Read a buffered image from this instance. Return BufferedImage ifgetData()contains data or read fromgetImageFile().- Returns:
- a buffered image from
getData()orgetImageFile()
-
flush
Flush current buffered image fromgetData()into file stream. This method will set a new image file and dispose the data. The image file will be deleted when this object is garbage collected.- Throws:
IOException- when unable to flush the data.- See Also:
-
flush
Flush current buffered image fromgetData()into file stream. This method will set a new image file and dispose the data. The image file will be deleted when tracked object is garbage collected.- Parameters:
track- the marker object track flushed file, deleting the file when the marker instance is garbage collected.- Throws:
IOException- when unable to flush the data.- See Also:
-
dispose
public void dispose()Disposes of this image buffer context and releases any system resources that it is using. -
getSize
public int getSize()Returns the size of image in pixels.- Returns:
- the size of image in pixels.
-
getBounds
Returns the bounding Rectangle of this Image.If image contains no data buffer
readData()return null, the bounds will be calculated fromgetWidth()andgetHeight().
If image contains buffer data, calculate the bounds from buffer data.- Returns:
- the bounding box of this image.
-
setWidth
public void setWidth(int width) Set width of image in pixels.- Parameters:
width- width of image
-
getWidth
public int getWidth()Return the width of image in pixels.- Returns:
- the width of image in pixels
-
setHeight
public void setHeight(int height) Set height of image in pixels.- Parameters:
height- height of image in pixels
-
getHeight
public int getHeight()Return the height of image in pixels.- Returns:
- the height of image in pixels
-
getImageFile
Return a imageFile.- Returns:
- the imageFile
-
setImageFile
Set a imageFile.- Parameters:
imageFile- the imageFile to set
-
isDisposeAfterUse
public boolean isDisposeAfterUse()Return a dispose setting.- Returns:
- the dispose setting
-
setDisposeAfterUse
public void setDisposeAfterUse(boolean disposeAfterUse) Set image data to be disposed after generating report.- Parameters:
disposeAfterUse- set value to true to allow engine to dispose image data.
-
getOriginalImageFile
Return an original image file.- Returns:
- the original image file
-
getOriginalWidth
public int getOriginalWidth()Return a original width.- Returns:
- the original width
-
getOriginalHeight
public int getOriginalHeight()Return a original height.- Returns:
- the original height
-
getOriginalBounds
Returns the original bounding Rectangle of this Image.- Returns:
- the original bounding box of this image.
-
getTransformationOption
public int getTransformationOption()Return a transformation flag.- Returns:
- the transformation flag
-
setTransformationOption
public void setTransformationOption(int transformationOption) Set a transformation option.- Parameters:
transformationOption- the transformation option to set
-
isTransformWithOption
public boolean isTransformWithOption(int option) Test if image transformation option is set to given option.- Parameters:
option- test option- Returns:
- true if image transformation option is set to given option.
-
rotate
public void rotate(boolean clockwise) Rotate image in clockwise or anti-clockwise.- Parameters:
clockwise- true for clockwise; false for anti-clockwise
-
createOriginal
Create a new instance of original image.- Returns:
- a new instance of original image.
-
ensureOriginal
public void ensureOriginal() -
hashCode
public int hashCode()Returns a hash code value for the object. -
equals
Indicates whether some other object is "equal to" this one. -
clone
Creates and returns a copy of this object.- Overrides:
clonein classObject- Returns:
- a copy of this instance
- Throws:
CloneNotSupportedException- if the object's class does not support theCloneableinterface.- See Also:
-
toString
Returns a string representation of the object. -
getImageType
public int getImageType()Get image type. For example : icon image from $report.getIconFor(), image from $element.image- Returns:
- image type
-
setImageType
public void setImageType(int imageType) Set image type. For example : icon image from $report.getIconFor(), image from $element.image- Parameters:
imageType- image type
-
getImageFormatToWrite
-
getDpi
public int getDpi() -
setDpi
public void setDpi(int dpi)
-