Class ImageBean
java.lang.Object
org.deltava.beans.DatabaseBean
org.deltava.beans.DatabaseBlobBean
org.deltava.beans.ImageBean
- All Implemented Interfaces:
Serializable
,Comparable<Object>
,IDBean
,Cacheable
An abstract bean class to store common image code.
- Since:
- 1.0
- Version:
- 10.6
- Author:
- Luke
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class org.deltava.beans.DatabaseBlobBean
_buffer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
checkParam
(int param, String msg) Helper method to check for negative numeric parameters.Returns the type of image.boolean
Queries if the bean has an associated Image.int
Returns the height of the image.abstract ImageType
Returns the database image type.int
getSize()
Returns the size of the image.int
getWidth()
Returns the width of the image.final void
load
(byte[] buffer) Updates the image buffer.final void
load
(InputStream is) Loads an image into the buffer.void
Updates the image format.void
setHeight
(int y) Updates the height of this image.void
setSize
(int newSize) Updates the size of this image.void
setWidth
(int x) Updates the width of this image.Methods inherited from class org.deltava.beans.DatabaseBlobBean
clear, getInputStream, isLoaded
Methods inherited from class org.deltava.beans.DatabaseBean
cacheKey, compareTo, equals, getHexID, getID, hashCode, setID, validateID, validateID
-
Constructor Details
-
ImageBean
public ImageBean()
-
-
Method Details
-
getFormat
Returns the type of image. This uses constants found in ImageInfo.- Returns:
- the image type code
- See Also:
-
getImageType
-
getWidth
public int getWidth()Returns the width of the image.- Returns:
- the width of the image, in pixels
- See Also:
-
getHeight
public int getHeight()Returns the height of the image.- Returns:
- the height of the image, in pixels
- See Also:
-
getSize
public int getSize()Returns the size of the image.- Overrides:
getSize
in classDatabaseBlobBean
- Returns:
- the size of the image, in bytes
- See Also:
-
getHasImage
public boolean getHasImage()Queries if the bean has an associated Image.- Returns:
- TRUE if the bean has an image, otherwise FALSE
-
load
Loads an image into the buffer. The image data should be available at the specified input stream, and the stream is not closed when this method completes. This method populates the size, X, Y and type properties if the stream is loaded successfully.- Overrides:
load
in classDatabaseBlobBean
- Parameters:
is
- the stream containing the image data- Throws:
IOException
- if an error occurs loading the dataUnsupportedOperationException
- if ImageInfo cannot identify the image format- See Also:
-
load
public final void load(byte[] buffer) Updates the image buffer. This method populates the size, X, Y and type properties.- Overrides:
load
in classDatabaseBlobBean
- Parameters:
buffer
- an array containing the image data- Throws:
UnsupportedOperationException
- if ImageInfo cannot identify the image format- See Also:
-
checkParam
Helper method to check for negative numeric parameters.- Parameters:
param
- the parameter valuemsg
- the field description- Throws:
IllegalArgumentException
- if param is negative
-
setWidth
public void setWidth(int x) Updates the width of this image. Note that this method does not change the image date (ie. resize the image)- Parameters:
x
- the new width of the image, in pixels- Throws:
IllegalArgumentException
- if the image width has already been set- See Also:
-
setHeight
public void setHeight(int y) Updates the height of this image. Note that this method does not change the image date (ie. resize the image)- Parameters:
y
- the new height of the image, in pixels- Throws:
IllegalArgumentException
- if the image height has already been set- See Also:
-
setSize
public void setSize(int newSize) Updates the size of this image.- Parameters:
newSize
- the size of the image, in bytes- Throws:
IllegalStateException
- if the size of the image has already been setIllegalArgumentException
- if the image size is negative- See Also:
-
setFormat
Updates the image format. Note that this method does not change the image data (ie. convert formats).- Parameters:
t
- an ImageFormat- Throws:
IllegalStateException
- if the image type has already been set- See Also:
-