public class MergeAnimation extends ClaimAnimation
Modifier and Type | Field and Description |
---|---|
private java.util.List<ConvexObject> |
contained
A list of objects contained within the merge area.
|
private java.awt.geom.Path2D |
firstInner
Path for the inner (internal after the merge)
hull segment of the first (leftmost) object
|
private java.util.List<java.awt.geom.Point2D> |
firstInnerData
Points defining the inner hull segment of the first object.
|
private java.awt.geom.Path2D |
firstOuter
Path for the outer (not internal after the merge)
hull segment of the first (leftmost) object
|
private static float |
FLOW_DURATION
Number of milliseconds the body merge drawing
phase lasts for.
|
private static float |
LINE_DURATION
Number of milliseconds the merge line drawing
phase lasts for.
|
private java.awt.geom.Point2D[] |
mergeLines
The merge lines used to construct the result object.
|
private ConvexObject |
owned
The already owned object in the merge.
|
private java.awt.geom.Path2D |
secondInner
Path for the inner (internal after the merge)
hull segment of the second object
|
private java.util.List<java.awt.geom.Point2D> |
secondInnerData
Points defining the inner hull segment of the second object.
|
private java.awt.geom.Path2D |
secondOuter
Path for the outer (not internal after the merge)
hull segment of the second object
|
private long |
start
Time in milliseconds when the animation started.
|
private ConvexObject |
target
The target object of the merge (possibly unowned)
|
private boolean |
unclaimed
Whether or not the target object was unclaimed before.
|
Constructor and Description |
---|
MergeAnimation(ConvexObject owned,
ConvexObject target,
ConvexObject result,
java.util.List<ConvexObject> contained)
Constructs a new merge animation with the given event data.
|
Modifier and Type | Method and Description |
---|---|
private void |
clipAdd(java.awt.geom.Path2D path,
java.awt.geom.Point2D p,
java.awt.geom.Point2D slope,
java.awt.geom.Point2D a,
java.awt.geom.Point2D b,
java.awt.geom.Point2D firstBase,
java.awt.geom.Point2D firstSlope,
java.awt.geom.Point2D secondBase,
java.awt.geom.Point2D secondSlope)
Adds the given slope to the given point and then adds the
resulting point to the given path.
|
private java.awt.geom.Path2D |
computeFlowPath(java.util.List<java.awt.geom.Point2D> data,
java.awt.geom.Point2D firstStart,
java.awt.geom.Point2D firstEnd,
java.awt.geom.Point2D secondStart,
java.awt.geom.Point2D secondEnd,
float flowFactor)
Computes the flow path showing the merge progress, this
path slowly moves to fill the entire merge area (the
quadrilateral defined by the merge lines).
|
private java.awt.geom.Point2D |
computeSlope(java.awt.geom.Point2D source,
java.awt.geom.Point2D target,
float fraction)
Computes the 'slope' that needs to be added
to the given source point to get to the given
fraction in the direction of the given target.
|
private <T extends java.awt.geom.Point2D> |
createPath(java.util.List<T> points)
Creates a path from the given list of points.
|
private java.awt.geom.Point2D |
interpolate(java.awt.geom.Point2D source,
java.awt.geom.Point2D target,
float fraction)
Interpolates between the given two points starting
from the source and ending at the given fraction to
the target point.
|
protected boolean |
render(java.awt.Graphics2D g)
Renders the next frame of this animation.
|
private static final float LINE_DURATION
private static final float FLOW_DURATION
private boolean unclaimed
private ConvexObject owned
private ConvexObject target
private java.awt.geom.Point2D[] mergeLines
private java.util.List<ConvexObject> contained
private long start
private java.awt.geom.Path2D firstOuter
private java.awt.geom.Path2D firstInner
private java.awt.geom.Path2D secondOuter
private java.awt.geom.Path2D secondInner
private java.util.List<java.awt.geom.Point2D> firstInnerData
firstInner
private java.util.List<java.awt.geom.Point2D> secondInnerData
secondInner
public MergeAnimation(ConvexObject owned, ConvexObject target, ConvexObject result, java.util.List<ConvexObject> contained)
owned
- The owned object the merge was started from.target
- The target object of the merge.result
- The result of the merge.contained
- The objects contained within the merge area.protected boolean render(java.awt.Graphics2D g)
Animation
render
in class ClaimAnimation
g
- The graphics context to use.private java.awt.geom.Path2D computeFlowPath(java.util.List<java.awt.geom.Point2D> data, java.awt.geom.Point2D firstStart, java.awt.geom.Point2D firstEnd, java.awt.geom.Point2D secondStart, java.awt.geom.Point2D secondEnd, float flowFactor)
data
- The data for the inner hull segment moving
towards the other end of the merge area.firstStart
- The first point of the line segment
defining the first merge line starting from the
current side of the area.firstEnd
- The second point of the line segment
defining the first merge line starting from the
current side of the area.secondStart
- The first point of the line segment
defining the second merge line starting from the
current side of the area.secondEnd
- The second point of the line segment
defining the second merge line starting from the
current side of the area.flowFactor
- The progress made so far in filling the
merge area, this value is between 0 and 1.private void clipAdd(java.awt.geom.Path2D path, java.awt.geom.Point2D p, java.awt.geom.Point2D slope, java.awt.geom.Point2D a, java.awt.geom.Point2D b, java.awt.geom.Point2D firstBase, java.awt.geom.Point2D firstSlope, java.awt.geom.Point2D secondBase, java.awt.geom.Point2D secondSlope)
path
- The path to append to.p
- The point to add the slope to.slope
- The slope to add.a
- The first point of the line segment defining the
merge line on the other side of the merge area.b
- The second point of the line segment defining the
merge line on the other side of the merge area.firstBase
- The starting location of the first merge line.firstSlope
- The slope denoting the progress along the first merge line.secondBase
- The starting location of the second merge line.secondSlope
- The slope denoting the progress along the second merge line.private <T extends java.awt.geom.Point2D> java.awt.geom.Path2D createPath(java.util.List<T> points)
T
- The point data type.points
- The list of points.private java.awt.geom.Point2D interpolate(java.awt.geom.Point2D source, java.awt.geom.Point2D target, float fraction)
source
- The source point.target
- The target point.fraction
- The fraction to cover.private java.awt.geom.Point2D computeSlope(java.awt.geom.Point2D source, java.awt.geom.Point2D target, float fraction)
source
- The source point.target
- The target point.fraction
- The fraction to cover.