Todo
investigate alternative tiebreaker algorithms (filed as JDK-8090927). If there are no on-axis nodes, compute the distance OUT (in the traversal direction) and the distance to the SIDE (perpendicular to the traversal direction) and compute a distance metric OUT + WEIGHT * SIDE. Choose the node with the smallest distance metric.
Todo
presumably WEIGHT is greater than one, so that nodes farther OUT but close (and not on) axis are chosen in preference to nodes that are physically closer but are farther off to the side. Determine WEIGHT somehow, possibly empirically (filed as JDK-8091219).
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private double | centerSideDistance(Direction dir, Bounds cur, Bounds tgt)
Computes the side distance from current center to target center. |
| private int | |
| private int | |
| private double | cornerSideDistance(Direction dir, Bounds cur, Bounds tgt)
Computes the side distance between the closest corners of the current and target. |
| private boolean | |
| private double | outDistance(Direction dir, Bounds cur, Bounds tgt)
Compute the out-distance to the near edge of the target in the traversal direction. |
| public Node | select(Node node, Direction dir, TraversalContext context)
Implements com. Traverse from owner, in direction dir. |
| public Node | selectFirst(TraversalContext
the context that contains the root context)Implements com. Return the first traversable node for the specified context (root). |
| public Node | selectLast(TraversalContext
the context that contains the root context)Implements com. Return the last traversable node for the specified context (root). |
| private int | |
| private int | |
| public int |
| WeightedClosestCorner | back to summary |
|---|---|
| pack-priv WeightedClosestCorner() | |
| centerSideDistance | back to summary |
|---|---|
| private double centerSideDistance(Direction dir, Bounds cur, Bounds tgt) Computes the side distance from current center to target center. Always positive. This is only used for on-axis nodes. | |
| compare1D | back to summary |
|---|---|
| private int compare1D(Bounds a, Bounds b) | |
| compare1D | back to summary |
|---|---|
| private int compare1D(Bounds a, Bounds b, Direction dir) | |
| cornerSideDistance | back to summary |
|---|---|
| private double cornerSideDistance(Direction dir, Bounds cur, Bounds tgt) Computes the side distance between the closest corners of the current and target. Always positive. This is only used for off-axis nodes. | |
| isOnAxis | back to summary |
|---|---|
| private boolean isOnAxis(Direction dir, Bounds cur, Bounds tgt) | |
| outDistance | back to summary |
|---|---|
| private double outDistance(Direction dir, Bounds cur, Bounds tgt) Compute the out-distance to the near edge of the target in the traversal direction. Negative means the near edge is "behind". | |
| select | back to summary |
|---|---|
| public Node select(Node node, Direction dir, TraversalContext context) Implements com. Doc from com. Traverse from owner, in direction dir. Return a the new target Node or null if no suitable target is found. Typically, the implementation of override algorithm handles only parent's direct children and looks like this: 1) Find the nearest parent of the "owner" that is handled by this algorithm (i.e. it's a direct child of the root). 2) select the next node within this direct child using the context.selectInSubtree() and return it 2a) if no such node exists, move to the next direct child in the direction (this is where the different order of direct children is defined) or if direct children are not traversable, the select the first node in the next direct child
| |
| selectFirst | back to summary |
|---|---|
| public Node selectFirst(TraversalContext context) Implements com. Doc from com. Return the first traversable node for the specified context (root).
| |
| selectLast | back to summary |
|---|---|
| public Node selectLast(TraversalContext context) Implements com. Doc from com. Return the last traversable node for the specified context (root).
| |
| trav1D | back to summary |
|---|---|
| private int trav1D(Bounds origin, Direction dir, List<Node> targets, TraversalContext context) | |
| trav2D | back to summary |
|---|---|
| private int trav2D(Bounds origin, Direction dir, List<Node> targets, TraversalContext context) | |
| traverse | back to summary |
|---|---|
| public int traverse(Bounds origin, Direction dir, List<Node> targets, TraversalContext context) | |