Class AffineTransformer
- java.lang.Object
-
- org.jungrapht.visualization.transform.AffineTransformer
-
- All Implemented Interfaces:
BidirectionalTransformer,ShapeTransformer
- Direct Known Subclasses:
MutableAffineTransformer
public class AffineTransformer extends Object implements BidirectionalTransformer, ShapeTransformer
Provides methods to map points from one coordinate system to another, by delegating to a wrapped AffineTransform (uniform) and its inverse.- Author:
- Tom Nelson
-
-
Field Summary
Fields Modifier and Type Field Description protected AffineTransforminverseprotected AffineTransformtransformThe AffineTransform to use; initialized to identity.
-
Constructor Summary
Constructors Constructor Description AffineTransformer()Create an instance that does not transform points.AffineTransformer(AffineTransform transform)Create an instance with the supplied transform.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AffineTransformgetInverse()doublegetRotation()doublegetScale()doublegetScaleX()doublegetScaleY()doublegetShearX()doublegetShearY()AffineTransformgetTransform()doublegetTranslateX()doublegetTranslateY()Point2DinverseTransform(double x, double y)Point2DinverseTransform(Point2D p)applies the inverse transform to the supplied pointShapeinverseTransform(Shape shape)Transform the supplied shape from screen (view) to graph (layout) coordinates.doublescale()voidsetTransform(AffineTransform transform)Point2Dtransform(double x, double y)Point2Dtransform(Point2D p)Applies the transform to the supplied point.Shapetransform(Shape shape)Transform the supplied shape from graph (layout) to screen (view) coordinates.
-
-
-
Field Detail
-
inverse
protected AffineTransform inverse
-
transform
protected AffineTransform transform
The AffineTransform to use; initialized to identity.
-
-
Constructor Detail
-
AffineTransformer
public AffineTransformer()
Create an instance that does not transform points.
-
AffineTransformer
public AffineTransformer(AffineTransform transform)
Create an instance with the supplied transform.- Parameters:
transform- the transform to use
-
-
Method Detail
-
getTransform
public AffineTransform getTransform()
- Returns:
- Returns the transform.
-
setTransform
public void setTransform(AffineTransform transform)
- Parameters:
transform- The transform to set.
-
inverseTransform
public Point2D inverseTransform(Point2D p)
applies the inverse transform to the supplied point- Specified by:
inverseTransformin interfaceBidirectionalTransformer- Parameters:
p- the point to transform- Returns:
- the transformed point
-
inverseTransform
public Point2D inverseTransform(double x, double y)
- Specified by:
inverseTransformin interfaceBidirectionalTransformer
-
getInverse
public AffineTransform getInverse()
-
getScaleX
public double getScaleX()
- Returns:
- the transform's x scale value
-
getScaleY
public double getScaleY()
- Returns:
- the transform's y scale value
-
getScale
public double getScale()
- Returns:
- the transform's overall scale magnitude
-
scale
public double scale()
-
getShearX
public double getShearX()
- Returns:
- the transform's x shear value
-
getShearY
public double getShearY()
- Returns:
- the transform's y shear value
-
getTranslateX
public double getTranslateX()
- Returns:
- the transform's x translate value
-
getTranslateY
public double getTranslateY()
- Returns:
- the transform's y translate value
-
transform
public Point2D transform(Point2D p)
Applies the transform to the supplied point.- Specified by:
transformin interfaceBidirectionalTransformer- Parameters:
p- the point to be transformed- Returns:
- the transformed point
-
transform
public Point2D transform(double x, double y)
- Specified by:
transformin interfaceBidirectionalTransformer
-
transform
public Shape transform(Shape shape)
Transform the supplied shape from graph (layout) to screen (view) coordinates.- Specified by:
transformin interfaceShapeTransformer- Parameters:
shape- the Shape to transform- Returns:
- the GeneralPath of the transformed shape
-
inverseTransform
public Shape inverseTransform(Shape shape)
Transform the supplied shape from screen (view) to graph (layout) coordinates.- Specified by:
inverseTransformin interfaceShapeTransformer- Returns:
- the GeneralPath of the transformed shape
-
getRotation
public double getRotation()
-
-