Package playn.scene
Class LayerUtil
java.lang.Object
playn.scene.LayerUtil
Utility class for transforming coordinates between
Layer
s.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Automatically connectsonPaint
topaint
whenlayer
is added to a scene graph, and disconnects it whenlayer
is removed.static void
bind
(Layer layer, Signal<Clock> update, Slot<Clock> onUpdate, Signal<Clock> paint, Slot<Clock> onPaint) Automatically connectsonUpdate
toupdate
, andonPaint
topaint
whenlayer
is added to a scene graph, and disconnects them whenlayer
is removed.static Layer
getHitLayer
(Layer root, Point p) Returns the layer hit by (screen) positionp
(or null) in the scene graph rooted atroot
, usingLayer.hitTest(pythagoras.f.Point)
.static int
graphDepth
(Layer layer) Returns the depth of the given layer in its local scene graph.static boolean
Returns true if a coordinate on the screen touches aLayer
.static boolean
static int
indexInParent
(Layer layer) Returns the index of the given layer within its parent, or -1 if the parent is null.static Point
layerToParent
(Layer layer, Layer parent, float x, float y) Converts the supplied point from coordinates relative to the specified child layer to coordinates relative to the specified parent layer.static Point
layerToParent
(Layer layer, Layer parent, XY point, Point into) Converts the supplied point from coordinates relative to the specified child layer to coordinates relative to the specified parent layer.static Point
layerToScreen
(Layer layer, float x, float y) Converts the supplied point from coordinates relative to the specified layer to screen coordinates.static Point
layerToScreen
(Layer layer, XY point, Point into) Converts the supplied point from coordinates relative to the specified layer to screen coordinates.static Layer
layerUnderPoint
(Layer root, float x, float y) Gets the layer underneath the given screen coordinates, ignoring hit testers.static Point
parentToLayer
(Layer parent, Layer layer, XY point, Point into) Converts the supplied point from coordinates relative to the specified parent to coordinates relative to the specified child layer.static Point
parentToLayer
(Layer layer, XY point, Point into) Converts the supplied point from coordinates relative to its parent to coordinates relative to the specified layer.static void
Prints the layer heirarchy starting atlayer
, usingLog.debug(java.lang.String)
.static Point
screenToLayer
(Layer layer, float x, float y) Converts the supplied point from screen coordinates to coordinates relative to the specified layer.static Point
screenToLayer
(Layer layer, XY point, Point into) Converts the supplied point from screen coordinates to coordinates relative to the specified layer.
-
Constructor Details
-
LayerUtil
public LayerUtil()
-
-
Method Details
-
layerToScreen
Converts the supplied point from coordinates relative to the specified layer to screen coordinates. The results are stored intointo
, which is returned for convenience. -
layerToScreen
Converts the supplied point from coordinates relative to the specified layer to screen coordinates. -
layerToParent
Converts the supplied point from coordinates relative to the specified child layer to coordinates relative to the specified parent layer. The results are stored intointo
, which is returned for convenience. -
layerToParent
Converts the supplied point from coordinates relative to the specified child layer to coordinates relative to the specified parent layer. -
screenToLayer
Converts the supplied point from screen coordinates to coordinates relative to the specified layer. The results are stored intointo
, which is returned for convenience. -
screenToLayer
Converts the supplied point from screen coordinates to coordinates relative to the specified layer. -
parentToLayer
Converts the supplied point from coordinates relative to its parent to coordinates relative to the specified layer. The results are stored intointo
, which is returned for convenience. -
parentToLayer
Converts the supplied point from coordinates relative to the specified parent to coordinates relative to the specified child layer. The results are stored intointo
, which is returned for convenience. -
getHitLayer
Returns the layer hit by (screen) positionp
(or null) in the scene graph rooted atroot
, usingLayer.hitTest(pythagoras.f.Point)
. Note thatp
is mutated by this call. -
hitTest
-
hitTest
Returns true if a coordinate on the screen touches aLayer
. Note: if the supplied layer has no size, this will always return false. -
layerUnderPoint
Gets the layer underneath the given screen coordinates, ignoring hit testers. This is useful for inspecting the scene graph for debugging purposes, and is not intended for use is shipped code. The layer returned is the one that has a size and is the deepest within the graph and contains the coordinate. -
indexInParent
Returns the index of the given layer within its parent, or -1 if the parent is null. -
bind
Automatically connectsonPaint
topaint
whenlayer
is added to a scene graph, and disconnects it whenlayer
is removed. -
bind
public static void bind(Layer layer, Signal<Clock> update, Slot<Clock> onUpdate, Signal<Clock> paint, Slot<Clock> onPaint) Automatically connectsonUpdate
toupdate
, andonPaint
topaint
whenlayer
is added to a scene graph, and disconnects them whenlayer
is removed. -
graphDepth
Returns the depth of the given layer in its local scene graph. A root layer (one with null parent) will always return 0. -
print
Prints the layer heirarchy starting atlayer
, usingLog.debug(java.lang.String)
.
-