public class CalliperAnimation extends Animation
Modifier and Type | Field and Description |
---|---|
private static float |
DURATION
The number of milliseconds the animation runs for.
|
private ConvexObject |
first
The first object in the merge.
|
private double |
firstAngle
The angle of the first merge line.
|
private java.awt.geom.Line2D |
firstLine
The first merge line.
|
private int |
indexFirst
Cached current index in the first object's points list.
|
private int |
indexSecond
Cached current index in the second object's points list.
|
private ConvexObject |
second
The second object in the merge.
|
private double |
secondAngle
The angle of the second merge line.
|
private java.awt.geom.Line2D |
secondLine
The second merge line.
|
private long |
start
The epoch millisecond start time of the animation.
|
Constructor and Description |
---|
CalliperAnimation(ConvexObject first,
ConvexObject second)
Constructs a new calliper animation for the given objects.
|
Modifier and Type | Method and Description |
---|---|
private int |
drawCalliper(java.awt.Graphics2D g,
java.util.List<java.awt.geom.Point2D> points,
double angle,
int index)
Draws the calliper line for the given object at the given angle.
|
private void |
drawLine(java.awt.Graphics2D g,
double x1,
double y1,
double x2,
double y2)
Draws an 'infinite' line segment through the two given points.
|
protected boolean |
render(java.awt.Graphics2D g)
Renders the next frame of this animation.
|
private static final float DURATION
private long start
private int indexFirst
private int indexSecond
private ConvexObject first
private ConvexObject second
private java.awt.geom.Line2D firstLine
private java.awt.geom.Line2D secondLine
private double firstAngle
private double secondAngle
public CalliperAnimation(ConvexObject first, ConvexObject second)
first
- The first object from the merge.second
- The second object from the merge.protected boolean render(java.awt.Graphics2D g)
Animation
private int drawCalliper(java.awt.Graphics2D g, java.util.List<java.awt.geom.Point2D> points, double angle, int index)
g
- The graphics context to use.points
- The points of the convex object to draw a calliper for.angle
- The angle of the calliper line to draw.index
- The object point set index left off at during the previous animation frame.private void drawLine(java.awt.Graphics2D g, double x1, double y1, double x2, double y2)
g
- The graphics context to use.x1
- The x-coordinate of the first point.y1
- The y-coordinate of the first point.x2
- The x-coordinate of the second point.y2
- The y-coordinate of the second point.