Class Morphing2D
- java.lang.Object
-
- org.jdesktop.swingx.geom.Morphing2D
-
- All Implemented Interfaces:
java.awt.Shape
public class Morphing2D extends java.lang.Object implements java.awt.ShapeA 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 Classes Modifier and Type Class Description private static classMorphing2D.Geometryprivate static classMorphing2D.Iterator
-
Field Summary
Fields Modifier and Type Field Description private Morphing2D.GeometryendGeometryprivate doublemorphprivate Morphing2D.GeometrystartGeometry
-
Constructor Summary
Constructors Constructor Description Morphing2D(java.awt.Shape startShape, java.awt.Shape endShape)Creates a new morphing shape.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(double x, double y)booleancontains(double x, double y, double w, double h)booleancontains(java.awt.geom.Point2D p)booleancontains(java.awt.geom.Rectangle2D r)java.awt.RectanglegetBounds()java.awt.geom.Rectangle2DgetBounds2D()doublegetMorphing()Returns the morphing value between the two shapes.java.awt.geom.PathIteratorgetPathIterator(java.awt.geom.AffineTransform at)java.awt.geom.PathIteratorgetPathIterator(java.awt.geom.AffineTransform at, double flatness)private static doubleinterp(double v0, double v1, double t)booleanintersects(double x, double y, double w, double h)booleanintersects(java.awt.geom.Rectangle2D r)private static double[]mergeTvals(double[] tvals0, double[] tvals1)voidsetMorphing(double morph)Sets the morphing value between the two shapes.
-
-
-
Field Detail
-
morph
private double morph
-
startGeometry
private Morphing2D.Geometry startGeometry
-
endGeometry
private Morphing2D.Geometry endGeometry
-
-
Constructor Detail
-
Morphing2D
public Morphing2D(java.awt.Shape startShape, java.awt.Shape endShape)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:
java.awt.geom.IllegalPathStateException- if the shapes do not have the same winding rule- See Also:
getMorphing(),setMorphing(double)
-
-
Method Detail
-
getMorphing
public double getMorphing()
Returns the morphing value between the two shapes.
- Returns:
- the morphing value between the two shapes
- See Also:
setMorphing(double)
-
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:
getMorphing()
-
interp
private static double interp(double v0, double v1, double t)
-
mergeTvals
private static double[] mergeTvals(double[] tvals0, double[] tvals1)
-
getBounds
public java.awt.Rectangle getBounds()
- Specified by:
getBoundsin interfacejava.awt.Shape
-
getBounds2D
public java.awt.geom.Rectangle2D getBounds2D()
- Specified by:
getBounds2Din interfacejava.awt.Shape
-
contains
public boolean contains(double x, double y)- Specified by:
containsin interfacejava.awt.Shape
-
contains
public boolean contains(java.awt.geom.Point2D p)
- Specified by:
containsin interfacejava.awt.Shape
-
intersects
public boolean intersects(double x, double y, double w, double h)- Specified by:
intersectsin interfacejava.awt.Shape
-
intersects
public boolean intersects(java.awt.geom.Rectangle2D r)
- Specified by:
intersectsin interfacejava.awt.Shape
-
contains
public boolean contains(double x, double y, double w, double h)- Specified by:
containsin interfacejava.awt.Shape
-
contains
public boolean contains(java.awt.geom.Rectangle2D r)
- Specified by:
containsin interfacejava.awt.Shape
-
getPathIterator
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
- Specified by:
getPathIteratorin interfacejava.awt.Shape
-
getPathIterator
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at, double flatness)- Specified by:
getPathIteratorin interfacejava.awt.Shape
-
-