Package ucar.nc2.ui.image
Class SourcePicture
- java.lang.Object
-
- ucar.nc2.ui.image.SourcePicture
-
-
Field Summary
Fields Modifier and Type Field Description static int
ERROR
status code used to signal that there was an errorprotected ucar.nc2.ui.image.SourcePicture.ImageProgressListener
imageProgressListener
reference to the inner class that listens to the image loading progressstatic int
LOADING
status code used to signal that the thread is loading the imagestatic int
LOADING_COMPLETED
status code used to tell that we have a finished loading but only used on notifySourceLoadProgressListenersstatic int
LOADING_PROGRESS
status code used to tell that we have a progress update but only used on notifySourceLoadProgressListenersstatic int
LOADING_STARTED
status code used to tell that we have started loading an image but only used on notifySourceLoadProgressListenersstatic int
READY
status code used to signal that the rotated image is available.static int
ROTATING
status code used to signal that the thread is rotating the imageBufferedImage
sourcePictureBufferedImage
the Buffered Image that this class protects and provides features for.static int
UNINITIALISED
status code used to signal that the picture is not loaded
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(SourcePictureListener listener)
method to register the listening object of the status eventsObject
clone()
creates a copy of the SourcePictureint
getHeight()
return the height of the image or Zero if there is noneint
getPercentLoaded()
Returns how much of the image has been loadeddouble
getRotation()
return the rotation of the imageDimension
getSize()
return the size of the image or Zero if there is noneBufferedImage
getSourceBufferedImage()
returns the buffered image that was loaded or null if there is no image.SourcePicture
getSourcePicture()
returns a reference to thisSourcePicture
objectint
getStatusCode()
Method that returns the status code of the picture loading.String
getStatusMessage()
Method that returns the status code of the picture loading.URL
getUrl()
return the URL of the original imageString
getUrlString()
return the URL of the original image as a stringint
getWidth()
return the width of the image or Zero if there is noneboolean
hasNoListeners()
method that says whether there are any listeners attached to this objectvoid
loadPicture()
loads a picture from the URL in the imageUrl object into the sourcePictureBufferedImage object and updates the status when done or failed.void
loadPicture(URL imageUrl, double rotation)
method to invoke with a filename or URL of a picture that is to be loaded in the main thread.void
loadPictureInThread(URL imageUrl, int priority, double rotation)
method to invoke with a filename or URL of a picture that is to be loaded a new thread.void
removeListener(SourcePictureListener listener)
method to register the listening object of the status eventsvoid
setSourceBufferedImage(BufferedImage img, String statusMessage)
sets the buffered image.void
showListeners()
void
stopLoading()
this method can be invoked to stop the current readerboolean
stopLoadingExcept(URL exemptionURL)
this method can be invoked to stop the current reader except if it is reading the desired file.
-
-
-
Field Detail
-
UNINITIALISED
public static final int UNINITIALISED
status code used to signal that the picture is not loaded- See Also:
- Constant Field Values
-
LOADING
public static final int LOADING
status code used to signal that the thread is loading the image- See Also:
- Constant Field Values
-
ROTATING
public static final int ROTATING
status code used to signal that the thread is rotating the image- See Also:
- Constant Field Values
-
READY
public static final int READY
status code used to signal that the rotated image is available.- See Also:
- Constant Field Values
-
ERROR
public static final int ERROR
status code used to signal that there was an error- See Also:
- Constant Field Values
-
LOADING_STARTED
public static final int LOADING_STARTED
status code used to tell that we have started loading an image but only used on notifySourceLoadProgressListeners- See Also:
- Constant Field Values
-
LOADING_PROGRESS
public static final int LOADING_PROGRESS
status code used to tell that we have a progress update but only used on notifySourceLoadProgressListeners- See Also:
- Constant Field Values
-
LOADING_COMPLETED
public static final int LOADING_COMPLETED
status code used to tell that we have a finished loading but only used on notifySourceLoadProgressListeners- See Also:
- Constant Field Values
-
sourcePictureBufferedImage
public BufferedImage sourcePictureBufferedImage
the Buffered Image that this class protects and provides features for.
-
imageProgressListener
protected ucar.nc2.ui.image.SourcePicture.ImageProgressListener imageProgressListener
reference to the inner class that listens to the image loading progress
-
-
Method Detail
-
loadPictureInThread
public void loadPictureInThread(URL imageUrl, int priority, double rotation)
method to invoke with a filename or URL of a picture that is to be loaded a new thread. This is handy to update the screen while the loading chuggs along in the background.- Parameters:
imageUrl
- The URL of the image to be loadedpriority
- The Thread priority for this thread.rotation
- The rotation 0-360 to be used on this picture
-
loadPicture
public void loadPicture(URL imageUrl, double rotation)
method to invoke with a filename or URL of a picture that is to be loaded in the main thread.
-
loadPicture
public void loadPicture()
loads a picture from the URL in the imageUrl object into the sourcePictureBufferedImage object and updates the status when done or failed.
-
stopLoading
public void stopLoading()
this method can be invoked to stop the current reader
-
stopLoadingExcept
public boolean stopLoadingExcept(URL exemptionURL)
this method can be invoked to stop the current reader except if it is reading the desired file. It returns true is the desired file is being loaded. Otherwise it returns false.
-
getSize
public Dimension getSize()
return the size of the image or Zero if there is none
-
getHeight
public int getHeight()
return the height of the image or Zero if there is none
-
getWidth
public int getWidth()
return the width of the image or Zero if there is none
-
getUrlString
public String getUrlString()
return the URL of the original image as a string
-
getUrl
public URL getUrl()
return the URL of the original image
-
getRotation
public double getRotation()
return the rotation of the image
-
addListener
public void addListener(SourcePictureListener listener)
method to register the listening object of the status events
-
removeListener
public void removeListener(SourcePictureListener listener)
method to register the listening object of the status events
-
showListeners
public void showListeners()
-
hasNoListeners
public boolean hasNoListeners()
method that says whether there are any listeners attached to this object
-
getStatusCode
public int getStatusCode()
Method that returns the status code of the picture loading.
-
getStatusMessage
public String getStatusMessage()
Method that returns the status code of the picture loading.
-
getPercentLoaded
public int getPercentLoaded()
Returns how much of the image has been loaded
-
getSourceBufferedImage
public BufferedImage getSourceBufferedImage()
returns the buffered image that was loaded or null if there is no image.- Returns:
- the
BufferedImage
that was loaded or null if there is no image.
-
setSourceBufferedImage
public void setSourceBufferedImage(BufferedImage img, String statusMessage)
sets the buffered image. Unusual method use with care.
-
getSourcePicture
public SourcePicture getSourcePicture()
returns a reference to thisSourcePicture
object- Returns:
- the reference to this
SourcePicture
object
-
-