Package org.apache.pivot.wtk.media
Class Image
- java.lang.Object
-
- org.apache.pivot.wtk.media.Image
-
- All Implemented Interfaces:
Visual
- Direct Known Subclasses:
Drawing,ListViewColorItemRenderer.ColorBadge,Picture,TerraExpanderSkin.ButtonImage,TerraFrameSkin.ButtonImage,TerraFrameSkin.ResizeImage,TerraMenuItemSkin.CheckmarkImage,TerraPaletteSkin.CloseImage,TerraPaletteSkin.ResizeImage,TerraPanoramaSkin.ScrollButtonImage,TerraScrollBarSkin.ScrollButtonImage,TerraSheetSkin.ResizeImage,TerraSpinnerSkin.SpinButtonImage
public abstract class Image extends java.lang.Object implements Visual
Abstract base class for images. An image is either a bitmapped "picture" or a vector "drawing".
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImage.LoadTaskBackgroundTaskthat executes an image load operation.
-
Field Summary
Fields Modifier and Type Field Description protected ImageListener.ListenersimageListeners
-
Constructor Summary
Constructors Constructor Description Image()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetBaseline()Returns the visual's baseline.ListenerList<ImageListener>getImageListeners()static Imageload(java.net.URL location)Load an image from the given URL location, but without any listener.static Image.LoadTaskload(java.net.URL location, TaskListener<Image> loadListener)Load an image from the given URL location, in the background, and return a reference to the background task.static ImageloadFromCache(java.net.URL location)Load an image.java.lang.StringtoString()voidupdate(int x, int y, int width, int height)
-
-
-
Field Detail
-
imageListeners
protected ImageListener.Listeners imageListeners
-
-
Method Detail
-
getBaseline
public int getBaseline()
Description copied from interface:VisualReturns the visual's baseline.- Specified by:
getBaselinein interfaceVisual- Returns:
- The baseline relative to the origin of the visual, or
-1if this visual does not have a baseline.
-
update
public void update(int x, int y, int width, int height)
-
getImageListeners
public ListenerList<ImageListener> getImageListeners()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
load
public static Image load(java.net.URL location) throws TaskExecutionException
Load an image from the given URL location, but without any listener. The load will be done synchronously, on the current thread. Any errors will be wrapped in theTaskExecutionExceptionthat is thrown.- Parameters:
location- The URL where the image can be found.- Returns:
- The loaded image.
- Throws:
TaskExecutionException- if there were problems loading the image.- See Also:
Image.LoadTask
-
load
public static Image.LoadTask load(java.net.URL location, TaskListener<Image> loadListener)
Load an image from the given URL location, in the background, and return a reference to the background task.- Parameters:
location- The URL where the image can be found.loadListener- A listener for completion of the background task.- Returns:
- A reference to the background task.
-
loadFromCache
public static Image loadFromCache(java.net.URL location)
Load an image. First try to find it in the resource cached kept by theApplicationContext. If not found, load it in the foreground and cache the result.- Parameters:
location- The URL where the image can be found.- Returns:
- The loaded image.
- Throws:
java.lang.IllegalArgumentException- wrapping the TaskExecutionException, which in turn will wrap the underlying problem.
-
-