Package ucar.nc2.ui.image
Class SourcePicture
- java.lang.Object
-
- ucar.nc2.ui.image.SourcePicture
-
-
Field Summary
Fields Modifier and Type Field Description static intERRORstatus code used to signal that there was an errorprotected ucar.nc2.ui.image.SourcePicture.ImageProgressListenerimageProgressListenerreference to the inner class that listens to the image loading progressstatic intLOADINGstatus code used to signal that the thread is loading the imagestatic intLOADING_COMPLETEDstatus code used to tell that we have a finished loading but only used on notifySourceLoadProgressListenersstatic intLOADING_PROGRESSstatus code used to tell that we have a progress update but only used on notifySourceLoadProgressListenersstatic intLOADING_STARTEDstatus code used to tell that we have started loading an image but only used on notifySourceLoadProgressListenersstatic intREADYstatus code used to signal that the rotated image is available.static intROTATINGstatus code used to signal that the thread is rotating the imageBufferedImagesourcePictureBufferedImagethe Buffered Image that this class protects and provides features for.static intUNINITIALISEDstatus code used to signal that the picture is not loaded
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(SourcePictureListener listener)method to register the listening object of the status eventsObjectclone()creates a copy of the SourcePictureintgetHeight()return the height of the image or Zero if there is noneintgetPercentLoaded()Returns how much of the image has been loadeddoublegetRotation()return the rotation of the imageDimensiongetSize()return the size of the image or Zero if there is noneBufferedImagegetSourceBufferedImage()returns the buffered image that was loaded or null if there is no image.SourcePicturegetSourcePicture()returns a reference to thisSourcePictureobjectintgetStatusCode()Method that returns the status code of the picture loading.StringgetStatusMessage()Method that returns the status code of the picture loading.URLgetUrl()return the URL of the original imageStringgetUrlString()return the URL of the original image as a stringintgetWidth()return the width of the image or Zero if there is nonebooleanhasNoListeners()method that says whether there are any listeners attached to this objectvoidloadPicture()loads a picture from the URL in the imageUrl object into the sourcePictureBufferedImage object and updates the status when done or failed.voidloadPicture(URL imageUrl, double rotation)method to invoke with a filename or URL of a picture that is to be loaded in the main thread.voidloadPictureInThread(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.voidremoveListener(SourcePictureListener listener)method to register the listening object of the status eventsvoidsetSourceBufferedImage(BufferedImage img, String statusMessage)sets the buffered image.voidshowListeners()voidstopLoading()this method can be invoked to stop the current readerbooleanstopLoadingExcept(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
BufferedImagethat 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 thisSourcePictureobject- Returns:
- the reference to this
SourcePictureobject
-
-