public interface Hierarchical
描述以一个在以getRoot()为原点的二维坐标系中存在的对象,
该对象以getVerticalIndex()返回值为x轴坐标,
以getHorizontalIndex()为y轴坐标,
通过这两个参数描述该对象与getRoot()之间的相对位置。
该接口主要用于描述实现类与getRoot()的“距离”,
当在同时处理一批具有相同getRoot()的Hierarchical实例时,
可以根据“距离”确定它们被处理的先后顺序。
规定,任何Hierarchical的实现类,索引的递增递减都应该遵循下述原则:
getRoot()上方的对象,即该对象的父层级:
水平索引从VERTICAL_INDEX_START_POINT开始递增,
垂直索引从HORIZONTAL_INDEX_START_POINT开始递增
getRoot()下方的对象,即该对象的子层级:
水平索引从-VERTICAL_INDEX_START_POINT开始递减,
垂直索引从HORIZONTAL_INDEX_START_POINT开始递减
getRoot()为本身,即自身即为自己的根节点:
水平索引、垂直索引皆为0;
HierarchySelector| 限定符和类型 | 字段和说明 |
|---|---|
static int |
HORIZONTAL_INDEX_START_POINT
水平索引起始点
|
static int |
VERTICAL_INDEX_START_POINT
垂直索引起始点
|
| 限定符和类型 | 方法和说明 |
|---|---|
int |
getHorizontalIndex()
获取该对象与参照物的水平距离。
|
Object |
getRoot()
参照物,即坐标为
(0, 0)的对象。 |
int |
getVerticalIndex()
获取该对象与参照物的垂直距离。
|
static final int VERTICAL_INDEX_START_POINT
static final int HORIZONTAL_INDEX_START_POINT
Object getRoot()
(0, 0)的对象。
当对象本身即为参照物时,该方法应当返回其本身int getVerticalIndex()
int getHorizontalIndex()
getVerticalIndex()相同的情况下条,
该对象被扫描到的顺序。Copyright © 2022. All rights reserved.