de.enough.polish.ui.backgrounds
Class TiledImageBackground

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

public class TiledImageBackground
extends Background
implements ImageConsumer

Paints a tiled image as a background.

Following CSS parameters are supported:

Copyright Enough Software 2004 - 2009

 history
        14-Mar-2004 - rob creation
 

Author:
Robert Virkus, robert@enough.de

Field Summary
static int REPEAT
           
static int REPEAT_X
           
static int REPEAT_Y
           
 
Fields inherited from class de.enough.polish.ui.Background
borderWidth
 
Constructor Summary
TiledImageBackground(int color, Image image, int repeatMode, int anchor, int paddingHorizontal, int paddingVertical, boolean overlap, Dimension xOffset, Dimension yOffset)
          Creates a new image background.
TiledImageBackground(int color, String imageUrl, int repeatMode, int anchor, int paddingHorizontal, int paddingVertical, boolean overlap)
          Creates a new image background.
TiledImageBackground(int color, String imageUrl, int repeatMode, int anchor, int paddingHorizontal, int paddingVertical, boolean overlap, Dimension xOffset, Dimension yOffset)
          Creates a new image background.
TiledImageBackground(int color, String imageUrl, int repeatMode, int anchor, int paddingHorizontal, int paddingVertical, boolean overlap, int xOffset, int yOffset)
          Creates a new image background.
 
Method Summary
 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(String name, Image image)
          sets the image which has been loaded in the background.
 void setStyle(Style style)
          Allows backgrounds to be animated using CSS attribute animations.
 
Methods inherited from class de.enough.polish.ui.Background
addRelativeToBackgroundRegion, animate, animate, hideNotify, showNotify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPEAT

public static final int REPEAT
See Also:
Constant Field Values

REPEAT_X

public static final int REPEAT_X
See Also:
Constant Field Values

REPEAT_Y

public static final int REPEAT_Y
See Also:
Constant Field Values
Constructor Detail

TiledImageBackground

public TiledImageBackground(int color,
                            String imageUrl,
                            int repeatMode,
                            int anchor,
                            int paddingHorizontal,
                            int paddingVertical,
                            boolean overlap)
Creates a new image background.

Parameters:
color - the background color or Item.TRANSPARENT
imageUrl - the url of the image, e.g. "/bg.png", must not be null!
repeatMode - indicates whether the background image should be repeated, either ImageBackground.REPEAT, REPEAT_X or REPEAT_Y
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"
paddingHorizontal - the horizontal gap between tiles, can be negative for overlapping the tiles
paddingVertical - the horizontal gap between tiles, can be negative for overlapping the tiles
overlap - defines whether the tiles should overlap over the actual background-area when they don't fit exactly into the actual background-area.

TiledImageBackground

public TiledImageBackground(int color,
                            String imageUrl,
                            int repeatMode,
                            int anchor,
                            int paddingHorizontal,
                            int paddingVertical,
                            boolean overlap,
                            int xOffset,
                            int yOffset)
Creates a new image background.

Parameters:
color - the background color or Item.TRANSPARENT
imageUrl - the url of the image, e.g. "/bg.png", must not be null!
repeatMode - indicates whether the background image should be repeated, either ImageBackground.REPEAT, REPEAT_X or REPEAT_Y
anchor - the anchor of the image, either "left", "right", "center" (="horizontal-center"), "vertical-center", "top" or "bottom" or any combination of these values. Defaults to "horizontal-center | vertical-center"
paddingHorizontal - the horizontal gap between tiles, can be negative for overlapping the tiles
paddingVertical - the horizontal gap between tiles, can be negative for overlapping the tiles
overlap - defines whether the tiles should overlap over the actual background-area when they don't fit exactly into the actual background-area.
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.

TiledImageBackground

public TiledImageBackground(int color,
                            String imageUrl,
                            int repeatMode,
                            int anchor,
                            int paddingHorizontal,
                            int paddingVertical,
                            boolean overlap,
                            Dimension xOffset,
                            Dimension yOffset)
Creates a new image background.

Parameters:
color - the background color or Item.TRANSPARENT
imageUrl - the url of the image, e.g. "/bg.png", must not be null!
repeatMode - indicates whether the background image should be repeated, either ImageBackground.REPEAT, REPEAT_X or REPEAT_Y
anchor - the anchor of the image, either "left", "right", "center" (="horizontal-center"), "vertical-center", "top" or "bottom" or any combination of these values. Defaults to "horizontal-center | vertical-center"
paddingHorizontal - the horizontal gap between tiles, can be negative for overlapping the tiles
paddingVertical - the horizontal gap between tiles, can be negative for overlapping the tiles
overlap - defines whether the tiles should overlap over the actual background-area when they don't fit exactly into the actual background-area.
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.

TiledImageBackground

public TiledImageBackground(int color,
                            Image image,
                            int repeatMode,
                            int anchor,
                            int paddingHorizontal,
                            int paddingVertical,
                            boolean overlap,
                            Dimension xOffset,
                            Dimension yOffset)
Creates a new image background.

Parameters:
color - the background color or Item.TRANSPARENT
image - the image, must not be null!
repeatMode - indicates whether the background image should be repeated, either ImageBackground.REPEAT, REPEAT_X or REPEAT_Y
anchor - the anchor of the image, either "left", "right", "center" (="horizontal-center"), "vertical-center", "top" or "bottom" or any combination of these values. Defaults to "horizontal-center | vertical-center"
paddingHorizontal - the horizontal gap between tiles, can be negative for overlapping the tiles
paddingVertical - the horizontal gap between tiles, can be negative for overlapping the tiles
overlap - defines whether the tiles should overlap over the actual background-area when they don't fit exactly into the actual background-area.
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

setImage

public void setImage(String name,
                     Image image)
Description copied from interface: ImageConsumer
sets the image which has been loaded in the background.

Specified by:
setImage in interface ImageConsumer
Parameters:
name - the name of the image. This allows the image-consumer to differentiate between several images.
image - the image which was loaded in the background thread.

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.

releaseResources

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

Overrides:
releaseResources in class Background

setStyle

public void setStyle(Style style)
Description copied from class: Background
Allows backgrounds to be animated using CSS attribute animations.

Overrides:
setStyle in class Background
Parameters:
style - the style containing typically only one element