de.enough.polish.ui.backgrounds
Class LayerBackground

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

public class LayerBackground
extends Background

Provides a background consisting of several other backgrounds.

Usage example:

backgrounds {
        contentTop {
                type: partial-gradient;
                start: 0%;
                end: 10%;
                top-color: #ccc;
                bottom-color: #fff;
        }
        contentBottom {
                type: partial-gradient;
                start: 90%;
                end: 100%;
                top-color: #fff;
                bottom-color: #ccc;             
        }
        contentBg {
                type: image;
                image: url(logo.png);
                anchor: hcenter | vcenter;
                color: #fff;
        }
}

.myScreen {
        padding: 2%;
        background {
                type: layer;
                layers: contentTop, contentBottom, contentBg;
        }
}
 

Copyright Enough Software 2009

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
protected  Dimension[] margins
           
 
Fields inherited from class de.enough.polish.ui.Background
borderWidth
 
Constructor Summary
LayerBackground(Background[] layers)
          Creates a new layer background.
LayerBackground(Background[] layers, Dimension[] margins)
          Creates a new layer background.
 
Method Summary
 void animate(Screen screen, Item parent, long currentTime, ClippingRegion repaintRegion)
          Animates this background.
 void hideNotify()
          Informs the background that it is being hidden shortly.
 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 setStyle(Style style)
          Allows backgrounds to be animated using CSS attribute animations.
 void showNotify()
          Informs the background that it is being shown shortly or that it is now applied to a new visible item.
 
Methods inherited from class de.enough.polish.ui.Background
addRelativeToBackgroundRegion, animate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

margins

protected final Dimension[] margins
Constructor Detail

LayerBackground

public LayerBackground(Background[] layers)
Creates a new layer background.

Parameters:
layers - the nested backgrounds

LayerBackground

public LayerBackground(Background[] layers,
                       Dimension[] margins)
Creates a new layer background.

Parameters:
layers - the nested backgrounds
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.

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)

showNotify

public void showNotify()
Description copied from class: Background
Informs the background that it is being shown shortly or that it is now applied to a new visible item. The default implementation is empty.

Overrides:
showNotify in class Background

hideNotify

public void hideNotify()
Description copied from class: Background
Informs the background that it is being hidden shortly. The default implementation is empty.

Overrides:
hideNotify in class Background

releaseResources

public void releaseResources()
Description copied from class: Background
Releases all (memory intensive) resources such as images or RGB arrays of this background. The default implementation does not do anything.

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