de.enough.polish.ui.backgrounds
Class SlideShowBackground

java.lang.Object
  extended by de.enough.polish.ui.Background
      extended by de.enough.polish.ui.backgrounds.SlideShowBackground
All Implemented Interfaces:
Serializable

public class SlideShowBackground
extends Background

Paints and exchanges several images in the background.

Following CSS parameters are supported:

Copyright Enough Software 2008

Author:
Robert Virkus, robert@enough.de

Field Summary
 
Fields inherited from class de.enough.polish.ui.Background
borderWidth
 
Constructor Summary
SlideShowBackground(int color, String imageUrls, int anchor, long interval)
          Creates a new image background.
SlideShowBackground(int color, String imageUrls, int anchor, long interval, int xOffset, int yOffset)
          Creates a new image background.
 
Method Summary
 void animate(Screen screen, Item parent, long currentTime, ClippingRegion repaintRegion)
          Animates this background.
 Image getImage()
          Retrieves the current image from this background.
 void paint(int x, int y, int width, int height, Graphics g)
          Paints this background.
 void releaseResources()
          Releases all (memory intensive) resources such as images or RGB arrays of this background.
 void setImage(Image image)
          Sets the current image for this background.
 
Methods inherited from class de.enough.polish.ui.Background
addRelativeToBackgroundRegion, animate, hideNotify, setStyle, showNotify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SlideShowBackground

public SlideShowBackground(int color,
                           String imageUrls,
                           int anchor,
                           long interval)
Creates a new image background.

Parameters:
color - the background color or Item.TRANSPARENT
imageUrls - comma separated list of image urls, e.g. "bg1.png,bg2.png,bg3.png"
anchor - the anchor of the image, either "left", "right", "center" (="horizontal-center"), "vertical-center", "top" or "bottom" or any combinationof these values. Defaults to "horizontal-center | vertical-center"
interval - the interval in milliseconds before the next image is loaded

SlideShowBackground

public SlideShowBackground(int color,
                           String imageUrls,
                           int anchor,
                           long interval,
                           int xOffset,
                           int yOffset)
Creates a new image background.

Parameters:
color - the background color or Item.TRANSPARENT
imageUrls - comma separated list of image urls, e.g. "bg1.png,bg2.png,bg3.png"
anchor - the anchor of the image, either "left", "right", "center" (="horizontal-center"), "vertical-center", "top" or "bottom" or any combinationof these values. Defaults to "horizontal-center | vertical-center"
interval - the interval in milliseconds before the next image is loaded
xOffset - The number of pixels to move the image horizontally, negative values move it to the left.
yOffset - The number of pixels to move the image vertically, negative values move it to the top.
Method Detail

paint

public void paint(int x,
                  int y,
                  int width,
                  int height,
                  Graphics g)
Description copied from class: Background
Paints this background.

Specified by:
paint in class Background
Parameters:
x - the horizontal start point
y - the vertical start point
width - the width of the background
height - the height of the background
g - the Graphics on which the background should be painted.

setImage

public void setImage(Image image)
Sets the current image for this background.

Parameters:
image - the image

getImage

public Image getImage()
Retrieves the current image from this background.

Returns:
the image

releaseResources

public void releaseResources()
Releases all (memory intensive) resources such as images or RGB arrays of this background.

Overrides:
releaseResources in class Background

animate

public void animate(Screen screen,
                    Item parent,
                    long currentTime,
                    ClippingRegion repaintRegion)
Description copied from class: Background
Animates this background. Subclasses can override this method to create animations. The default implementation calls the animate() method and adds the full content area to the repaint region.

Overrides:
animate in class Background
Parameters:
screen - the parent screen
parent - the parent item, can be null when the background belongs to a screen
currentTime - the current time in milliseconds
repaintRegion - the repaint area that needs to be updated when this item is animated
See Also:
Item.addRelativeToContentRegion(ClippingRegion, int, int, int, int)