Class Morphing2D
- All Implemented Interfaces:
Shape
A morphing shape is a shape which geometry is constructed from two other shapes: a start shape and an end shape.
The morphing property of a morphing shape defines the amount of transformation applied to the start shape to turn it into the end shape.
Both shapes must have the same winding rule.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Morphing2D.Geometry
private double
private Morphing2D.Geometry
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(double x, double y) boolean
contains
(double x, double y, double w, double h) boolean
boolean
double
Returns the morphing value between the two shapes.getPathIterator
(AffineTransform at, double flatness) private static double
interp
(double v0, double v1, double t) boolean
intersects
(double x, double y, double w, double h) boolean
private static double[]
mergeTvals
(double[] tvals0, double[] tvals1) void
setMorphing
(double morph) Sets the morphing value between the two shapes.
-
Field Details
-
morph
private double morph -
startGeometry
-
endGeometry
-
-
Constructor Details
-
Morphing2D
Creates a new morphing shape. A morphing shape can be used to turn one shape into another one. The transformation can be controlled by the morph property.
- Parameters:
startShape
- the shape to morph fromendShape
- the shape to morph to- Throws:
IllegalPathStateException
- if the shapes do not have the same winding rule- See Also:
-
-
Method Details
-
getMorphing
public double getMorphing()Returns the morphing value between the two shapes.
- Returns:
- the morphing value between the two shapes
- See Also:
-
setMorphing
public void setMorphing(double morph) Sets the morphing value between the two shapes. This value controls the transformation from the start shape to the end shape. A value of 0.0 is the start shape. A value of 1.0 is the end shape. A value of 0.5 is a new shape, morphed half way from the start shape to the end shape.
The specified value should be between 0.0 and 1.0. If not, the value is clamped in the appropriate range.
- Parameters:
morph
- the morphing value between the two shapes- See Also:
-
interp
private static double interp(double v0, double v1, double t) -
mergeTvals
private static double[] mergeTvals(double[] tvals0, double[] tvals1) -
getBounds
-
getBounds2D
- Specified by:
getBounds2D
in interfaceShape
-
contains
public boolean contains(double x, double y) -
contains
-
intersects
public boolean intersects(double x, double y, double w, double h) - Specified by:
intersects
in interfaceShape
-
intersects
- Specified by:
intersects
in interfaceShape
-
contains
public boolean contains(double x, double y, double w, double h) -
contains
-
getPathIterator
- Specified by:
getPathIterator
in interfaceShape
-
getPathIterator
- Specified by:
getPathIterator
in interfaceShape
-