T
- The metadata storage type.public class ConjugationTree<T> extends PartitionTree<T,ConjugationTree<T>>
Modifier and Type | Class and Description |
---|---|
private static class |
ConjugationTree.ConjugateData
Class holding data about a single conjugate line.
|
Modifier and Type | Field and Description |
---|---|
private java.awt.geom.Line2D |
bisector
The bisector of this tree node (a conjugate of the parent bisector).
|
private java.util.List<java.awt.geom.Point2D> |
hull
The convex hull defining the bounds of this tree cell.
|
private ConjugationTree<T> |
left
The left child node of this node (containing CCW -1 points).
|
private java.util.List<java.awt.geom.Point2D> |
on
The points in this cell on the bisector line.
|
private ConjugationTree<T> |
parent
The parent node of this tree node.
|
private ConjugationTree<T> |
right
The right child node of this node (containing CCW 1 points).
|
private java.awt.geom.Path2D |
shape
The shape defining the bounds of this cell as constructed
from the convex hull points in
hull . |
Modifier | Constructor and Description |
---|---|
private |
ConjugationTree(ConjugationTree<T> parent,
java.util.List<java.awt.geom.Point2D> points,
java.awt.geom.Point2D on,
java.awt.geom.Line2D bisector,
java.util.List<java.awt.geom.Point2D> hull)
Constructs a new child conjugation tree node with the given parent node,
point set, conjugate bisector line and convex hull.
|
|
ConjugationTree(java.util.List<java.awt.geom.Point2D> points)
Constructs a new conjugation tree storing the given point set.
|
Modifier and Type | Method and Description |
---|---|
private static java.util.Comparator<java.awt.geom.Point2D> |
angularComparator(java.awt.geom.Line2D vector)
A comparator that compares points based on their angle to a
fixed point, relative to the angle of a fixed "base" vector.
|
private static java.awt.geom.Line2D |
clipLine(ConjugationTree<?> node,
java.awt.geom.Line2D line,
java.awt.geom.Point2D on)
Clips the given line segment to be fully contained within the bounds
of the given conjugation tree node.
|
private static ConjugationTree.ConjugateData |
computeConjugate(java.util.List<java.awt.geom.Point2D> left,
java.util.List<java.awt.geom.Point2D> right,
ConjugationTree<?> parent)
Computes a conjugate line for the given point sets and with
the given parent conjugation tree node.
|
private void |
constructShape()
Constructs the shape object for the bounds of this object.
|
private static java.awt.geom.Line2D |
extendLine(java.awt.geom.Line2D line)
Extends the given closed line segment to the geometric bounds of this
partition tree as defined by
Constants.PLAYFIELD_HEIGHT and
Constants.PLAYFIELD_WIDTH . |
private static Segment |
findUnusedSegment(java.util.List<java.awt.geom.Point2D> left,
java.util.List<java.awt.geom.Point2D> right,
java.util.Set<Segment> used,
Segment fallback)
Searches for lines that are not marked as used and similar to the segment
between the median points of two sorted point lists.
|
java.awt.geom.Line2D |
getBisector()
Gets the bisector line for this tree node.
|
java.awt.geom.Point2D |
getCentroid()
Gets the centroid of this conjugation tree node.
|
java.util.List<ConjugationTree<T>> |
getChildren()
Gets the child nodes of this tree node.
|
ConjugationTree<T> |
getLeftChild()
Gets the left child node of this tree node (CCW -1).
|
ConjugationTree<T> |
getParent()
Gets the parent tree node of this node.
|
java.util.List<java.awt.geom.Point2D> |
getPoints()
Gets all the points located on the bisector for this tree cell.
|
ConjugationTree<T> |
getRightChild()
Gets the right child node of this tree node (CCW 1).
|
ConjugationTree<T> |
getSelf()
Gets 'this' partition tree.
|
java.awt.Shape |
getShape()
Gets the shape defining the boundary of this tree cell.
|
boolean |
isLeafCell()
Checks if this tree node is a leaf cell.
|
private static Segment |
orientedLine(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2)
Create an oriented line segment given two points.
|
void |
render(java.awt.Graphics2D g)
Renders this object.
|
private static java.util.Comparator<java.awt.geom.Point2D> |
segmentProjectionComparator(java.awt.geom.Line2D segment)
Sorts the points on the order of their projections onto a segment,
from the direction of its first point to the direction of its second point.
|
addData, getData, getDepth, getHeight, setMarked, streamCells, streamLeafCells
getAnimation, hasAnimation, renderOrAnimate, runAnimation, setAnimation
private ConjugationTree<T> parent
private java.awt.geom.Line2D bisector
private java.util.List<java.awt.geom.Point2D> on
private ConjugationTree<T> left
private ConjugationTree<T> right
private java.util.List<java.awt.geom.Point2D> hull
private java.awt.geom.Path2D shape
hull
.public ConjugationTree(java.util.List<java.awt.geom.Point2D> points)
points
- The point set to store.private ConjugationTree(ConjugationTree<T> parent, java.util.List<java.awt.geom.Point2D> points, java.awt.geom.Point2D on, java.awt.geom.Line2D bisector, java.util.List<java.awt.geom.Point2D> hull)
parent
- The parent node for this conjugation tree node.points
- The points stored at or below this tree node.on
- The points on the bisector for this tree node.bisector
- The bisector for this tree node (conjugate of the parent bisector).hull
- The convex hull for this tree cell.private void constructShape()
public java.util.List<java.awt.geom.Point2D> getPoints()
public java.awt.geom.Line2D getBisector()
public ConjugationTree<T> getLeftChild()
null
if this node is a leaf.public ConjugationTree<T> getRightChild()
null
if this node is a leaf.public java.awt.geom.Point2D getCentroid()
public void render(java.awt.Graphics2D g)
RenderableObject
render
in class PartitionTree<T,ConjugationTree<T>>
g
- The graphics context to use.public java.awt.Shape getShape()
PartitionTree
getShape
in class PartitionTree<T,ConjugationTree<T>>
public ConjugationTree<T> getParent()
PartitionTree
getParent
in class PartitionTree<T,ConjugationTree<T>>
null
if this is node
is the root node of the tree.public boolean isLeafCell()
PartitionTree
isLeafCell
in class PartitionTree<T,ConjugationTree<T>>
public java.util.List<ConjugationTree<T>> getChildren()
PartitionTree
getChildren
in class PartitionTree<T,ConjugationTree<T>>
public ConjugationTree<T> getSelf()
PartitionTree
getSelf
in class PartitionTree<T,ConjugationTree<T>>
private static final java.awt.geom.Line2D clipLine(ConjugationTree<?> node, java.awt.geom.Line2D line, java.awt.geom.Point2D on)
node
- The tree node to contain the line within.line
- The line to clip.on
- A point on the given line and within the tree node.private static final java.awt.geom.Line2D extendLine(java.awt.geom.Line2D line)
Constants.PLAYFIELD_HEIGHT
and
Constants.PLAYFIELD_WIDTH
. The result being a new closed line
segment ending on the bounds of the partition tree.line
- The line to extend.private static final ConjugationTree.ConjugateData computeConjugate(java.util.List<java.awt.geom.Point2D> left, java.util.List<java.awt.geom.Point2D> right, ConjugationTree<?> parent)
left
- The left point set to split.right
- The right point set to split.parent
- The parent conjugation tree node.private static final java.util.Comparator<java.awt.geom.Point2D> segmentProjectionComparator(java.awt.geom.Line2D segment)
segment
- The segment on which to projectprivate static final Segment findUnusedSegment(java.util.List<java.awt.geom.Point2D> left, java.util.List<java.awt.geom.Point2D> right, java.util.Set<Segment> used, Segment fallback)
left
- The first sorted point list.right
- The second sorted point list.used
- The set of used lines.fallback
- The original segment to return in case no segment is found.left
list, then on the right
list.
If no unused line is found after reaching maxDistance, the segment between
the median points of the two sorted point lists is returned.private static final java.util.Comparator<java.awt.geom.Point2D> angularComparator(java.awt.geom.Line2D vector)
> PI rad
are considered as negative.vector
- The fixed "base" vector, represented as a line.private static final Segment orientedLine(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)
p1
- The first point.p2
- The second point.