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 class
Image.LoadTask
BackgroundTask
that executes an image load operation.
-
Field Summary
Fields Modifier and Type Field Description protected ImageListener.Listeners
imageListeners
-
Constructor Summary
Constructors Constructor Description Image()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getBaseline()
Returns the visual's baseline.ListenerList<ImageListener>
getImageListeners()
static Image
load(java.net.URL location)
Load an image from the given URL location, but without any listener.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.static Image
loadFromCache(java.net.URL location)
Load an image.java.lang.String
toString()
void
update(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:Visual
Returns the visual's baseline.- Specified by:
getBaseline
in interfaceVisual
- Returns:
- The baseline relative to the origin of the visual, or
-1
if 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:
toString
in 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 theTaskExecutionException
that 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.
-
-