org.apache.pivot.wtk.effects
Class ScaleDecorator

java.lang.Object
  extended by org.apache.pivot.wtk.effects.ScaleDecorator
All Implemented Interfaces:
Decorator

public class ScaleDecorator
extends Object
implements Decorator

Decorator that scales the painting of a component along the X and/or Y axes.

Generally speaking, decorators don't force a repaint of the component(s) they are attached to when their parameters are changed. So, if this decorator is changed after being applied to a particular component (e.g., to do a dynamic resize) then either the component.repaint() method must be called or the decorator should be removed and added again to force a repaint with the new scale.


Constructor Summary
ScaleDecorator()
          Creates a new ScaleDecorator with the default scaleX scaleY values of 1.
ScaleDecorator(float scaleX, float scaleY)
          Creates a new ScaleDecorator with the specified scaleX and scaleY values.
 
Method Summary
 Bounds getBounds(Component component)
          Returns the bounding area of the decorator.
 HorizontalAlignment getHorizontalAlignment()
          Gets the horizontal alignment of the decorator.
 float getScaleX()
          Gets the amount by which drawing operations will be scaled along the x-axis.
 float getScaleY()
          Gets the amount by which drawing operations will be scaled along the y-axis.
 AffineTransform getTransform(Component component)
          Returns the transformation the decorator applies to the component's coordinate space.
 VerticalAlignment getVerticalAlignment()
          Gets the vertical alignment of the decorator.
 Graphics2D prepare(Component component, Graphics2D graphics)
          Prepares the graphics context into which the component or prior decorator will paint.
 void repaint(Component component, int x, int y, int width, int height)
           
 void setHorizontalAlignment(HorizontalAlignment horizontalAlignment)
          Sets the horizontal alignment of the decorator.
 void setScale(float scale)
          Sets the amount by which drawing operations will be scaled along both the x and y axes.
 void setScale(float scaleX, float scaleY)
          Sets the amount by which drawing operations will be scaled along the x and y axes.
 void setScaleX(float scaleX)
          Sets the amount by which drawing operations will be scaled along the x-axis.
 void setScaleX(Number scaleX)
          Sets the amount by which drawing operations will be scaled along the x-axis.
 void setScaleY(float scaleY)
          Sets the amount by which drawing operations will be scaled along the y-axis.
 void setScaleY(Number scaleY)
          Sets the amount by which drawing operations will be scaled along the y-axis.
 void setVerticalAlignment(VerticalAlignment verticalAlignment)
          Sets the vertical alignment of the decorator.
 void update()
          Updates the graphics context into which the component or prior decorator was painted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScaleDecorator

public ScaleDecorator()
Creates a new ScaleDecorator with the default scaleX scaleY values of 1.


ScaleDecorator

public ScaleDecorator(float scaleX,
                      float scaleY)
Creates a new ScaleDecorator with the specified scaleX and scaleY values.

Parameters:
scaleX - The amount to scale the component's x-axis
scaleY - The amount to scale the component's y-axis
Method Detail

getScaleX

public float getScaleX()
Gets the amount by which drawing operations will be scaled along the x-axis.

Returns:
The amount to scale the component's x-axis

setScaleX

public void setScaleX(float scaleX)
Sets the amount by which drawing operations will be scaled along the x-axis.

Parameters:
scaleX - The amount to scale the component's x-axis

setScaleX

public void setScaleX(Number scaleX)
Sets the amount by which drawing operations will be scaled along the x-axis.

Parameters:
scaleX - The amount to scale the component's x-axis

getScaleY

public float getScaleY()
Gets the amount by which drawing operations will be scaled along the y-axis.

Returns:
The amount to scale the component's y-axis

setScaleY

public void setScaleY(float scaleY)
Sets the amount by which drawing operations will be scaled along the y-axis.

Parameters:
scaleY - The amount to scale the component's y-axis

setScaleY

public void setScaleY(Number scaleY)
Sets the amount by which drawing operations will be scaled along the y-axis.

Parameters:
scaleY - The amount to scale the component's y-axis

setScale

public void setScale(float scaleX,
                     float scaleY)
Sets the amount by which drawing operations will be scaled along the x and y axes.

Parameters:
scaleX - The amount to scale the component's x-axis.
scaleY - The amount to scale the component's y-axis.

setScale

public void setScale(float scale)
Sets the amount by which drawing operations will be scaled along both the x and y axes.

Parameters:
scale - The amount to scale the component's x and y axes.

getHorizontalAlignment

public HorizontalAlignment getHorizontalAlignment()
Gets the horizontal alignment of the decorator. A left alignment will paint the component's left edge at the component's x-coordinate. A right alignment will paint the component's right edge along the right side of the component's bounding box. A center or justified alignment will paint the scaled component centered with respect to the component's bounding box.

Returns:
The horizontal alignment

setHorizontalAlignment

public void setHorizontalAlignment(HorizontalAlignment horizontalAlignment)
Sets the horizontal alignment of the decorator. A left alignment will paint the component's left edge at the component's x-coordinate. A right alignment will paint the component's right edge along the right side of the component's bounding box. A center or justified alignment will paint the scaled component centered with respect to the component's bounding box.

Parameters:
horizontalAlignment - The horizontal alignment

getVerticalAlignment

public VerticalAlignment getVerticalAlignment()
Gets the vertical alignment of the decorator. A top alignment will paint the component's top edge at the component's y-coordinate. A bottom alignment will paint the component's bottom edge along the bottom side of the component's bounding box. A center or justified alignment will paint the scaled component centered with respect to the component's bounding box.

Returns:
The vertical alignment

setVerticalAlignment

public void setVerticalAlignment(VerticalAlignment verticalAlignment)
Sets the vertical alignment of the decorator. A top alignment will paint the component's top edge at the component's y-coordinate. A bottom alignment will paint the component's bottom edge along the bottom side of the component's bounding box. A center or justified alignment will paint the scaled component centered with respect to the component's bounding box.

Parameters:
verticalAlignment - The vertical alignment

prepare

public Graphics2D prepare(Component component,
                          Graphics2D graphics)
Description copied from interface: Decorator
Prepares the graphics context into which the component or prior decorator will paint. This method is called immediately prior to Component.paint(Graphics2D); decorators are called in descending order.

Specified by:
prepare in interface Decorator
Returns:
The graphics context that should be used by the component or prior decorators.

update

public void update()
Description copied from interface: Decorator
Updates the graphics context into which the component or prior decorator was painted. This method is called immediately after Component.paint(Graphics2D); decorators are called in ascending order.

Specified by:
update in interface Decorator

repaint

public void repaint(Component component,
                    int x,
                    int y,
                    int width,
                    int height)

getBounds

public Bounds getBounds(Component component)
Description copied from interface: Decorator
Returns the bounding area of the decorator.

Specified by:
getBounds in interface Decorator
Returns:
The decorator's bounds, relative to the component's origin.

getTransform

public AffineTransform getTransform(Component component)
Description copied from interface: Decorator
Returns the transformation the decorator applies to the component's coordinate space.

Specified by:
getTransform in interface Decorator
Returns:
The decorator's transform.