de.enough.polish.ui
Class Background

java.lang.Object
  extended by de.enough.polish.ui.Background
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BallBackground, BorderedRoundRectBackground, BorderedRoundRectOpeningBackground, BorderedRoundTabBackground, BorderedSimpleBackground, CircleBackground, CombinedBackground, CombinedHorizontalBackground, CombinedVerticalBackground, DoubleGradientVerticalBackground, FadeInBackground, GradientHorizontalBackground, GradientRadialBackground, GradientVerticalBackground, HorizontalSplitBackground, HorizontalSplitRoundRectBackground, HorizontalStripesBackground, ImageBackground, ImageResourceBackground, LayerBackground, LayerVerticalBackground, MaskBackground, OpeningBackground, PartialGradientBackground, PartialSimpleBackground, PolygonBackground, ProcessingBackground, PulsatingBackground, PulsatingCircleBackground, PulsatingCirclesBackground, PulsatingRoundRectBackground, RepaintTestBackground, RoundRectBackground, RoundRectCorneredBackground, RoundTabBackground, ScalingImageBackground, SimpleBackground, SlideShowBackground, SmoothColorBackground, TextBackground, ThinSimpleBackground, TigerStripesBackground, TiledImageBackground, TranslucentRoundRectBackground, TranslucentSimpleBackground, TriangleBackground, VerticalSplitBackground, VerticalSplitRoundRectBackground, VerticalStripesBackground, VideoBackground, Web20RoundRectBackground, XmasSnowBackground

public abstract class Background
extends Object
implements Serializable

Background is the base class for any backgrounds of widgets or forms.

Author:
Robert Virkus, robert@enough.de

copyright Enough Software 2004 - 2009


Field Summary
 int borderWidth
          Defines the width of this Background.
 Item parent
          The Item which uses the background.
 
Constructor Summary
Background()
          Creates a new Background.
 
Method Summary
protected  void addRelativeToBackgroundRegion(ClippingRegion repaintRegion, Screen screen, Item parent, int left, int right, int top, int bottom)
          Adds an repaint area relative to this background
 boolean animate()
          Animates this background.
 void animate(Screen screen, Item parent, long currentTime, ClippingRegion repaintRegion)
          Animates this background.
 void hideNotify()
          Informs the background that it is being hidden shortly.
abstract  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 setParentItem(Item parent)
          Set the parent item.
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

borderWidth

public int borderWidth
Defines the width of this Background. Usually this is 0, but some backgrounds might have a border included.


parent

public transient Item parent
The Item which uses the background.

Constructor Detail

Background

public Background()
Creates a new Background. The width of this background is set to 0 here.

Method Detail

setParentItem

public void setParentItem(Item parent)
Set the parent item.

Parameters:
parent -

animate

public void animate(Screen screen,
                    Item parent,
                    long currentTime,
                    ClippingRegion repaintRegion)
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.

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)

addRelativeToBackgroundRegion

protected void addRelativeToBackgroundRegion(ClippingRegion repaintRegion,
                                             Screen screen,
                                             Item parent,
                                             int left,
                                             int right,
                                             int top,
                                             int bottom)
Adds an repaint area relative to this background

Parameters:
repaintRegion - the clipping rectangle
screen - the screen of this background
parent - the item of this background
left - left adjustment of the repaint region, use negative values to expand area
right - right adjustment of the repaint region, use positive values to expand area
top - top adjustment of the repaint region, use negative values to expand area
bottom - bottom adjustment of the repaint region, use positive values to expand area

animate

public boolean animate()
Animates this background. Subclasses can override this method to create animations.

Returns:
true when this background has been animated.
See Also:
animate(Screen, Item, long, ClippingRegion)

paint

public abstract void paint(int x,
                           int y,
                           int width,
                           int height,
                           Graphics g)
Paints this 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. The default implementation does not do anything.


hideNotify

public void hideNotify()
Informs the background that it is being hidden shortly. The default implementation is empty.


showNotify

public void showNotify()
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.


setStyle

public void setStyle(Style style)
Allows backgrounds to be animated using CSS attribute animations.

Parameters:
style - the style containing typically only one element