Package com.treasure.hunt.view.utils
Class TreeConstructor
- java.lang.Object
-
- com.treasure.hunt.view.utils.TreeConstructor
-
public class TreeConstructor extends java.lang.Object
Constructs an object tree primarily used for the list of turns in the game. The tree is formed in a recursive way by invokinggetTree(Turn)
. New items and leafs can be implemented by writing newcreateItem()
methods according to the scheme:public static TreeItem<String> createItem(Object object) { //choose a good root representation for the object TreeItem<String> root = [create_root_for_object]; //if there are members foreach(Object member: object) { root.getChildren().add(createItem(member)); } return root; }
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javafx.scene.control.TreeItem<java.lang.String>
createItem(Turn turn)
Create the tree item for a turn.static javafx.scene.control.TreeItem<java.lang.String>
createItem(GeometryAngle angle)
Creates a tree item for a geometry angle.static <T> javafx.scene.control.TreeItem<java.lang.String>
createItem(GeometryItem<T> geometryItem)
Creates a tree item for a geometry item.static javafx.scene.control.TreeItem<java.lang.String>
createItem(GeometryStyle geometryStyle)
Creates a tree item for a geometry style.static javafx.scene.control.TreeItem<java.lang.String>
createItem(GeometryType geometryType)
Creates a tree item for a geometry type.static javafx.scene.control.TreeItem<java.lang.String>
createItem(Hint hint)
Get the tree item for a hint.static javafx.scene.control.TreeItem<java.lang.String>
createItem(SearchPath path)
Creates a tree item for a search path.static javafx.scene.control.TreeItem<java.lang.String>
createItem(java.lang.String format, java.lang.Object... args)
Creates a leaf tree item for a format string.static javafx.scene.control.TreeItem<java.lang.String>
createItem(org.locationtech.jts.geom.Coordinate coordinate)
Creates a leaf tree item for a coordinate.static javafx.scene.control.TreeItem<java.lang.String>
createItem(org.locationtech.jts.geom.Geometry geometry)
Creates a tree item for a geometry.static javafx.scene.control.TreeItem<java.lang.String>
createItem(org.locationtech.jts.geom.LineSegment lineSegment)
Creates a tree item for a line segment.static javafx.scene.control.TreeView<java.lang.String>
getTree(Turn turn)
Create the tree root for a turn.
-
-
-
Method Detail
-
getTree
public static javafx.scene.control.TreeView<java.lang.String> getTree(Turn turn)
Create the tree root for a turn. Its root is invisible and this roots only purpose is to hold the turns fields. It utilisescreateItem(Turn)
.- Parameters:
turn
- the object trees root turn- Returns:
- root tree view with the object tree of the turn
-
createItem
public static javafx.scene.control.TreeItem<java.lang.String> createItem(Turn turn)
Create the tree item for a turn. Its children are the items for the turn's fields:- treasure location (
createItem(Coordinate)
) - hint (
createItem(Hint)
) - search path (
createItem(SearchPath)
)
- Parameters:
turn
- turn to display- Returns:
- root tree item for the turn object tree
- treasure location (
-
createItem
public static javafx.scene.control.TreeItem<java.lang.String> createItem(Hint hint)
Get the tree item for a hint. Here, we differentiate betweenAngleHint
,CircleHint
, etc. and use the corresponding methods.- Parameters:
hint
- hint, which is printed in the tree item- Returns:
- root tree item for a hint and its members
- See Also:
createItem(GeometryAngle)
,createItem(Coordinate)
-
createItem
public static javafx.scene.control.TreeItem<java.lang.String> createItem(SearchPath path)
Creates a tree item for a search path. The children are tree items for the paths fields:- list of way points (
createItem(Coordinate)
) - list of additional geometry items (
createItem(GeometryItem)
)
- Parameters:
path
- search path to create the tree item for- Returns:
- root tree item for a search path
- See Also:
createItem(Coordinate)
,createItem(GeometryItem)
- list of way points (
-
createItem
public static javafx.scene.control.TreeItem<java.lang.String> createItem(GeometryAngle angle)
Creates a tree item for a geometry angle. The children are tree items for the angles defining points: left, center & right usingcreateItem(Coordinate)
.- Parameters:
angle
- angle to print as a tree item- Returns:
- root tree item for a geometry angle
- See Also:
createItem(Coordinate)
-
createItem
public static <T> javafx.scene.control.TreeItem<java.lang.String> createItem(GeometryItem<T> geometryItem)
Creates a tree item for a geometry item. The children are tree items for the items fields:- object (
createItem(String, Object...)
,createItem(Geometry)
,createItem(LineSegment)
)}) - geometry type (
createItem(GeometryType)
- geometry style (
createItem(GeometryStyle)
- Type Parameters:
T
- type of the object wrapped in the geometry item- Parameters:
geometryItem
- geometry item to print as a tree item- Returns:
- root tree item representing a geometry item
- See Also:
GeometryItem
,GeometryType
,GeometryStyle
- object (
-
createItem
public static javafx.scene.control.TreeItem<java.lang.String> createItem(org.locationtech.jts.geom.LineSegment lineSegment)
Creates a tree item for a line segment. The name is derived by theClass.getSimpleName()
method. The children are tree items for the two line segment pointsLineSegment.p0
andLineSegment.p1
.- Parameters:
lineSegment
- line segment to print as a tree item- Returns:
- root tree item representing a line segment
- See Also:
createItem(String, Object...)
-
createItem
public static javafx.scene.control.TreeItem<java.lang.String> createItem(org.locationtech.jts.geom.Geometry geometry)
Creates a tree item for a geometry. The children are tree items for the geometry's coordinates.- Parameters:
geometry
- geometry to print as a tree item- Returns:
- root tree item representing a geometry
- See Also:
createItem(Coordinate)
-
createItem
public static javafx.scene.control.TreeItem<java.lang.String> createItem(GeometryStyle geometryStyle)
Creates a tree item for a geometry style. The children are all the separate fields of the style.- Parameters:
geometryStyle
- style to print as a tree item- Returns:
- root tree item representing a geometry style
- See Also:
createItem(String, Object...)
-
createItem
public static javafx.scene.control.TreeItem<java.lang.String> createItem(GeometryType geometryType)
Creates a tree item for a geometry type. The children are all the separate fields of the type.- Parameters:
geometryType
- type to print as a tree item- Returns:
- root tree item representing a geometry type
- See Also:
createItem(String, Object...)
-
createItem
public static javafx.scene.control.TreeItem<java.lang.String> createItem(org.locationtech.jts.geom.Coordinate coordinate)
Creates a leaf tree item for a coordinate.- Parameters:
coordinate
- coordinate to print as a tree item- Returns:
- leaf tree item representing a coordinate
- See Also:
print(Coordinate)
-
createItem
public static javafx.scene.control.TreeItem<java.lang.String> createItem(java.lang.String format, java.lang.Object... args)
Creates a leaf tree item for a format string.- Parameters:
format
- a format stringargs
- arguments for the format string- Returns:
- leaf tree item representing the formatted string
- See Also:
String.format(String, Object...)
-
-