de.enough.polish.ui.backgrounds
Class PolygonBackground

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

public class PolygonBackground
extends Background

Paints a filled polygon as a background in a specific color.

usage:

 .myItem {
                background {    
                        type: polygon;
                        color: green;
                        points: 0,50 50,0 100,50 50,100;
                        max-x: 100; 
                        max-y: 100;
                        scale-mode: proportional; // none, scale, proportional, expand 
                        expand: false;
                }
 }
 

Copyright Enough Software 2007 - 2008

Author:
Robert Virkus, robert@enough.de

Field Summary
static int MODE_NO_SCALE
          use this mode for not scaling the polygon at all
static int MODE_SCALE
          use this mode for scaling the polygon according to the width and height of the background - the given reference width and height are used for calculating the actual positions
static int MODE_SCALE_PROPORTIONAL
          use this mode for scaling the polygon proportional according to the minimum of width and height of the background - the given reference width and height are used for calculating the actual positions
static int MODE_SCALE_PROPORTIONAL_EXPAND
          use this mode for scaling the polygon proportional according to the maximum of width and height of the background - the given reference width and height are used for calculating the actual positions
 
Fields inherited from class de.enough.polish.ui.Background
borderWidth
 
Constructor Summary
PolygonBackground(Color color, Point[] points, int referenceWidth, int referenceHeight, int scalingMode, int anchor)
          Creates a new simple background.
PolygonBackground(int color, Point[] points, int referenceWidth, int referenceHeight, int scalingMode, int anchor)
          Creates a new simple background.
 
Method Summary
 void paint(int x, int y, int width, int height, javax.microedition.lcdui.Graphics g)
          Paints this background.
 
Methods inherited from class de.enough.polish.ui.Background
addRelativeToBackgroundRegion, animate, animate, hideNotify, releaseResources, 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 polygon at all

See Also:
Constant Field Values

MODE_SCALE

public static final int MODE_SCALE
use this mode for scaling the polygon according to the width and height of the background - the given reference width and height are used for calculating the actual positions

See Also:
Constant Field Values

MODE_SCALE_PROPORTIONAL

public static final int MODE_SCALE_PROPORTIONAL
use this mode for scaling the polygon proportional according to the minimum of width and height of the background - the given reference width and height are used for calculating the actual positions

See Also:
Constant Field Values

MODE_SCALE_PROPORTIONAL_EXPAND

public static final int MODE_SCALE_PROPORTIONAL_EXPAND
use this mode for scaling the polygon proportional according to the maximum of width and height of the background - the given reference width and height are used for calculating the actual positions

See Also:
Constant Field Values
Constructor Detail

PolygonBackground

public PolygonBackground(int color,
                         Point[] points,
                         int referenceWidth,
                         int referenceHeight,
                         int scalingMode,
                         int anchor)
Creates a new simple background.

Parameters:
color - the color of the background in RGB, e.g. 0xFFDD11
points - the points of the polygon
referenceWidth - the maximum horizontal position, 0 when the positions should not be scaled
referenceHeight - the maximum horizontal position, 0 when the positions should not be scaled
scalingMode - the scaling mode to be used
anchor - the anchor like Graphics.TOP | Graphics.RIGHT etc - only applicable in no-expanded proportional or non-scaling mode
See Also:
MODE_NO_SCALE, MODE_SCALE, MODE_SCALE_PROPORTIONAL, MODE_SCALE_PROPORTIONAL_EXPAND

PolygonBackground

public PolygonBackground(Color color,
                         Point[] points,
                         int referenceWidth,
                         int referenceHeight,
                         int scalingMode,
                         int anchor)
Creates a new simple background.

Parameters:
color - the color of the background in RGB, e.g. 0xFFDD11
points - the points of the polygon
referenceWidth - the maximum horizontal position, 0 when the positions should not be scaled
referenceHeight - the maximum horizontal position, 0 when the positions should not be scaled
scalingMode - the scaling mode to be used
anchor - the anchor like Graphics.TOP | Graphics.RIGHT etc - only applicable in no-expanded proportional or non-scaling mode
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.