Package org.apache.pivot.wtk.effects
Class ScaleDecorator
- java.lang.Object
-
- org.apache.pivot.wtk.effects.ScaleDecorator
-
- All Implemented Interfaces:
Decorator
public class ScaleDecorator extends java.lang.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
Constructors Constructor Description ScaleDecorator()Creates a newScaleDecoratorwith the defaultscaleXscaleYvalues of1.0f.ScaleDecorator(float scale)Creates a newScaleDecoratorwith a "square" scaling of the given value in both directions.ScaleDecorator(float scaleX, float scaleY)Creates a newScaleDecoratorwith the specifiedscaleXandscaleYvalues.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BoundsgetBounds(Component component)Returns the bounding area of the decorator.HorizontalAlignmentgetHorizontalAlignment()Gets the horizontal alignment of the decorator.floatgetScaleX()Gets the amount by which drawing operations will be scaled along the x-axis.floatgetScaleY()Gets the amount by which drawing operations will be scaled along the y-axis.java.awt.geom.AffineTransformgetTransform(Component component)Returns the transformation the decorator applies to the component's coordinate space.VerticalAlignmentgetVerticalAlignment()Gets the vertical alignment of the decorator.java.awt.Graphics2Dprepare(Component component, java.awt.Graphics2D graphics)Prepares the graphics context into which the component or prior decorator will paint.voidrepaint(Component component, int x, int y, int width, int height)voidsetHorizontalAlignment(HorizontalAlignment horizontalAlignment)Sets the horizontal alignment of the decorator.voidsetScale(float scale)Sets the amount by which drawing operations will be scaled along both the x and y axes.voidsetScale(float scaleX, float scaleY)Sets the amount by which drawing operations will be scaled along the x and y axes.voidsetScaleX(float scaleX)Sets the amount by which drawing operations will be scaled along the x-axis.voidsetScaleX(java.lang.Number scaleX)Sets the amount by which drawing operations will be scaled along the x-axis.voidsetScaleY(float scaleY)Sets the amount by which drawing operations will be scaled along the y-axis.voidsetScaleY(java.lang.Number scaleY)Sets the amount by which drawing operations will be scaled along the y-axis.voidsetVerticalAlignment(VerticalAlignment verticalAlignment)Sets the vertical alignment of the decorator.voidupdate()Updates the graphics context into which the component or prior decorator was painted.
-
-
-
Constructor Detail
-
ScaleDecorator
public ScaleDecorator()
Creates a newScaleDecoratorwith the defaultscaleXscaleYvalues of1.0f.
-
ScaleDecorator
public ScaleDecorator(float scale)
Creates a newScaleDecoratorwith a "square" scaling of the given value in both directions.- Parameters:
scale- The scale to use for both X and Y directions.
-
ScaleDecorator
public ScaleDecorator(float scaleX, float scaleY)Creates a newScaleDecoratorwith the specifiedscaleXandscaleYvalues.- Parameters:
scaleX- The amount to scale the component's x-axisscaleY- 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(java.lang.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(java.lang.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 java.awt.Graphics2D prepare(Component component, java.awt.Graphics2D graphics)
Description copied from interface:DecoratorPrepares the graphics context into which the component or prior decorator will paint. This method is called immediately prior toComponent.paint(Graphics2D); decorators are called in descending order.
-
update
public void update()
Description copied from interface:DecoratorUpdates the graphics context into which the component or prior decorator was painted. This method is called immediately afterComponent.paint(Graphics2D); decorators are called in ascending order.This default version simply returns, without doing anything (often the appropriate thing to do).
-
repaint
public void repaint(Component component, int x, int y, int width, int height)
-
getBounds
public Bounds getBounds(Component component)
Description copied from interface:DecoratorReturns the bounding area of the decorator.This default simply returns the bounds of the component's size.
-
getTransform
public java.awt.geom.AffineTransform getTransform(Component component)
Description copied from interface:DecoratorReturns the transformation the decorator applies to the component's coordinate space.This default simply returns a new
AffineTransform.- Specified by:
getTransformin interfaceDecorator- Parameters:
component- The component the decorator is attached to.- Returns:
- The decorator's transform.
-
-