de.enough.polish.ui.backgrounds
Class ScalingImageBackground

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

public class ScalingImageBackground
extends Background

Paints an image as a background.

Following CSS parameters are supported:

Copyright Enough Software 2004 - 2008

 history
        14-Mar-2004 - rob creation
 

Author:
Robert Virkus, robert@enough.de

Field Summary
static int MODE_NO_SCALE
          use this mode for not scaling the image at all
static int MODE_SCALE
          use this mode for scaling the image according to the width and height of the background
static int MODE_SCALE_PROPORTIONAL
          use this mode for scaling the image proportional according to the minimum of width and height of the background
static int MODE_SCALE_PROPORTIONAL_EXPAND
          use this mode for scaling the image proportional according to the maximum of width and height of the background
 
Fields inherited from class de.enough.polish.ui.Background
borderWidth
 
Constructor Summary
ScalingImageBackground(int color, javax.microedition.lcdui.Image image, int scalingMode, int anchor, int xOffset, int yOffset)
          Creates a new image background.
ScalingImageBackground(int color, java.lang.String imageUrl, int scalingMode, int anchor, int xOffset, int yOffset)
          Creates a new image background.
 
Method Summary
 javax.microedition.lcdui.Image getImage()
          Retrieves the image from this background.
 void paint(int x, int y, int width, int height, javax.microedition.lcdui.Graphics g)
          Paints this background.
 void releaseResources()
          Releases all (memory intensive) resources such as images or RGB arrays of this background.
 void setImage(javax.microedition.lcdui.Image image)
          Sets the image for this background.
 
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

MODE_NO_SCALE

public static final int MODE_NO_SCALE
use this mode for not scaling the image at all

See Also:
Constant Field Values

MODE_SCALE

public static final int MODE_SCALE
use this mode for scaling the image according to the width and height of the background

See Also:
Constant Field Values

MODE_SCALE_PROPORTIONAL

public static final int MODE_SCALE_PROPORTIONAL
use this mode for scaling the image proportional according to the minimum of width and height of the background

See Also:
Constant Field Values

MODE_SCALE_PROPORTIONAL_EXPAND

public static final int MODE_SCALE_PROPORTIONAL_EXPAND
use this mode for scaling the image proportional according to the maximum of width and height of the background

See Also:
Constant Field Values
Constructor Detail

ScalingImageBackground

public ScalingImageBackground(int color,
                              java.lang.String imageUrl,
                              int scalingMode,
                              int anchor,
                              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!
scalingMode - the scaling mode to be used
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"
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.
See Also:
MODE_NO_SCALE, MODE_SCALE, MODE_SCALE_PROPORTIONAL, MODE_SCALE_PROPORTIONAL_EXPAND

ScalingImageBackground

public ScalingImageBackground(int color,
                              javax.microedition.lcdui.Image image,
                              int scalingMode,
                              int anchor,
                              int xOffset,
                              int yOffset)
Creates a new image background.

Parameters:
color - the background color or Item.TRANSPARENT
image - the image, must not be null!
scalingMode - the scaling mode to be used
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"
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.
See Also:
MODE_NO_SCALE, MODE_SCALE, MODE_SCALE_PROPORTIONAL, MODE_SCALE_PROPORTIONAL_EXPAND
Method Detail

paint

public void paint(int x,
                  int y,
                  int width,
                  int height,
                  javax.microedition.lcdui.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(javax.microedition.lcdui.Image image)
Sets the image for this background.

Parameters:
image - the image

getImage

public javax.microedition.lcdui.Image getImage()
Retrieves the 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