public class ScalablePicture extends java.lang.Object implements SourcePictureListener
Modifier and Type | Field and Description |
---|---|
static int |
ERROR
status code used to signal that there was an error
|
static int |
GARBAGE_COLLECTION
status code used to signal that the picture is cleaning up memory
|
java.net.URL |
imageUrl
the URL of the picture
|
float |
jpgQuality
the quality with which the JPG pictures shall be written.
|
static int |
LOADED
status code used to signal that the thread has finished loading the image
|
static int |
LOADING
status code used to signal that the thread is loading the image
|
static int |
READY
status code used to signal that the image is available.
|
boolean |
scaleAfterLoad
flag that indicates that the image should be scaled after
a status message is received from the SourcePicture that the
picture was loaded.
|
java.awt.image.BufferedImage |
scaledPicture
The scaled version of the image
|
static int |
SCALING
status code used to signal that the thread has loaded the tread is scaling the image
|
SourcePicture |
sourcePicture
the source picture for the scalable picture
|
static int |
UNINITIALISED
status code used to signal that the picture is not loaded
|
Constructor and Description |
---|
ScalablePicture()
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addStatusListener(ScalablePictureListener listener)
method to register the listening object of the status events
|
void |
createScaledPictureInThread(int priority)
method that creates the scaled image in the background in it's own thread.
|
java.lang.String |
getFilename()
return the filename of the original image
|
int |
getOriginalHeight()
return the height of the original image or Zero if there is none
|
java.awt.image.BufferedImage |
getOriginalImage()
return the image in the original size
|
java.awt.Dimension |
getOriginalSize()
return the size of the original image or Zero if there is none
|
int |
getOriginalWidth()
return the width of the original image or Zero if there is none
|
int |
getScaledHeight()
return the height of the scaled image or Zero if there is none
|
java.awt.image.BufferedImage |
getScaledPicture()
return the scaled image
|
java.awt.Dimension |
getScaledSize()
return the size of the scaled image or Zero if there is none
|
java.lang.String |
getScaledSizeString()
return the size of the scaled image as a neatly formatted text or Zero if there is none
|
int |
getScaledWidth()
return the width of the scaled image or Zero if there is none
|
double |
getScaleFactor()
return the current scale factor
|
java.awt.Dimension |
getScaleSize()
return the current scale size.
|
SourcePicture |
getSourcePicture()
return the image in the original size
|
int |
getStatusCode()
Method that returns the status code of the picture loading.
|
java.lang.String |
getStatusMessage()
Method that returns the status code of the picture loading.
|
void |
loadAndScalePictureInThread(java.net.URL imageUrl,
int priority,
double rotation)
method to invoke with a filename or URL of a picture that is to be loaded and scaled in
a new thread.
|
void |
loadPictureImd(java.net.URL imageUrl,
double rotation)
Synchroneous method to load the image.
|
void |
removeStatusListener(ScalablePictureListener listener)
method to register the listening object of the status events
|
void |
scalePicture() |
void |
setJpgQuality(float quality)
accessor method to set the quality that should be used on jpg write operations.
|
void |
setScaleFactor(double newFactor)
set the scale factor to the new desired value.
|
void |
setScaleSize(java.awt.Dimension newSize)
invoke this method to tell the scale process to figure out the scal factor
so that the image fits either by height or by width into the indicated dimension.
|
SourcePicture |
setSourcePicture(SourcePicture source) |
void |
sourceLoadProgressNotification(int statusCode,
int percentage)
pass on the update on the loading Progress to the listening objects
|
void |
sourceStatusChange(int statusCode,
java.lang.String statusMessage,
SourcePicture sp)
method that is invoked by the SourcePictureListener interface.
|
void |
stopLoadingExcept(java.net.URL url)
stops all picture loading except if the Url we desire is being loaded
|
static void |
writeJpg(java.io.File writeFile,
java.awt.image.RenderedImage renderedImage,
float jpgQuality)
This static method writes the indicated renderedImage (BufferedImage)
to the indicated file.
|
void |
writeScaledJpg(java.io.File writeFile)
This method allows the ScalablePicture's scaled BufferedImage to be written
to the desired file.
|
public SourcePicture sourcePicture
public java.awt.image.BufferedImage scaledPicture
public java.net.URL imageUrl
public static final int UNINITIALISED
public static final int GARBAGE_COLLECTION
public static final int LOADING
public static final int LOADED
public static final int SCALING
public static final int READY
public static final int ERROR
public float jpgQuality
public boolean scaleAfterLoad
public void loadAndScalePictureInThread(java.net.URL imageUrl, int priority, double rotation)
priority
- The Thread priorityimageUrl
- The URL of the image you want to loadrotation
- The rotation 0-360 that the image should be put through
after loading.public void loadPictureImd(java.net.URL imageUrl, double rotation)
imageUrl
- The Url of the image to be loadedrotation
- The angle by which it is to be roated upon loading.public void stopLoadingExcept(java.net.URL url)
url
- The URL of the image which is to be loaded.public void sourceStatusChange(int statusCode, java.lang.String statusMessage, SourcePicture sp)
sourceStatusChange
in interface SourcePictureListener
public void sourceLoadProgressNotification(int statusCode, int percentage)
sourceLoadProgressNotification
in interface SourcePictureListener
public void createScaledPictureInThread(int priority)
priority
- The priority this image takes relative to the others.public void scalePicture()
public void setScaleFactor(double newFactor)
createScaledPictureInThread(int)
to
make anything happen.Example: Original is 3000 x 2000 --> Scale Factor 0.10 --> Target Picutre is 300 x 200
public void setScaleSize(java.awt.Dimension newSize)
public double getScaleFactor()
public java.awt.Dimension getScaleSize()
getScaledSize
that will return the size of the picture.public java.awt.image.BufferedImage getScaledPicture()
public java.awt.Dimension getScaledSize()
public java.lang.String getScaledSizeString()
public int getScaledHeight()
public int getScaledWidth()
public java.awt.image.BufferedImage getOriginalImage()
public SourcePicture getSourcePicture()
public SourcePicture setSourcePicture(SourcePicture source)
public java.awt.Dimension getOriginalSize()
public int getOriginalHeight()
public int getOriginalWidth()
public java.lang.String getFilename()
public void writeScaledJpg(java.io.File writeFile)
writeFile
- The File that shall receive the jpg datapublic static void writeJpg(java.io.File writeFile, java.awt.image.RenderedImage renderedImage, float jpgQuality)
writeFile
- The File that shall receive the jpg datarenderedImage
- The RenderedImage (BufferedImage) to be writtenjpgQuality
- The quality with which to compress to jpgpublic void addStatusListener(ScalablePictureListener listener)
public void removeStatusListener(ScalablePictureListener listener)
public int getStatusCode()
public java.lang.String getStatusMessage()
public void setJpgQuality(float quality)