Package playn.scene

Class LayerUtil

java.lang.Object
playn.scene.LayerUtil

public class LayerUtil extends Object
Utility class for transforming coordinates between Layers.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    bind(Layer layer, Signal<Clock> paint, Slot<Clock> onPaint)
    Automatically connects onPaint to paint when layer is added to a scene graph, and disconnects it when layer is removed.
    static void
    bind(Layer layer, Signal<Clock> update, Slot<Clock> onUpdate, Signal<Clock> paint, Slot<Clock> onPaint)
    Automatically connects onUpdate to update, and onPaint to paint when layer is added to a scene graph, and disconnects them when layer is removed.
    static Layer
    Returns the layer hit by (screen) position p (or null) in the scene graph rooted at root, using Layer.hitTest(pythagoras.f.Point).
    static int
    Returns the depth of the given layer in its local scene graph.
    static boolean
    hitTest(Layer layer, float x, float y)
    Returns true if a coordinate on the screen touches a Layer.
    static boolean
    hitTest(Layer layer, XY pos)
    Returns true if an XY touches a Layer.
    static int
    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
    print(Log log, Layer layer)
    Prints the layer heirarchy starting at layer, using Log.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.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LayerUtil

      public LayerUtil()
  • Method Details

    • layerToScreen

      public static Point layerToScreen(Layer layer, XY point, Point into)
      Converts the supplied point from coordinates relative to the specified layer to screen coordinates. The results are stored into into, which is returned for convenience.
    • layerToScreen

      public static Point layerToScreen(Layer layer, float x, float y)
      Converts the supplied point from coordinates relative to the specified layer to screen coordinates.
    • layerToParent

      public 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. The results are stored into into, which is returned for convenience.
    • layerToParent

      public 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.
    • screenToLayer

      public static Point screenToLayer(Layer layer, XY point, Point into)
      Converts the supplied point from screen coordinates to coordinates relative to the specified layer. The results are stored into into , which is returned for convenience.
    • screenToLayer

      public static Point screenToLayer(Layer layer, float x, float y)
      Converts the supplied point from screen coordinates to coordinates relative to the specified layer.
    • parentToLayer

      public 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. The results are stored into into, which is returned for convenience.
    • parentToLayer

      public 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. The results are stored into into, which is returned for convenience.
    • getHitLayer

      public static Layer getHitLayer(Layer root, Point p)
      Returns the layer hit by (screen) position p (or null) in the scene graph rooted at root, using Layer.hitTest(pythagoras.f.Point). Note that p is mutated by this call.
    • hitTest

      public static boolean hitTest(Layer layer, XY pos)
      Returns true if an XY touches a Layer. Note: if the supplied layer has no size, this will always return false.
    • hitTest

      public static boolean hitTest(Layer layer, float x, float y)
      Returns true if a coordinate on the screen touches a Layer. Note: if the supplied layer has no size, this will always return false.
    • layerUnderPoint

      public static Layer layerUnderPoint(Layer root, float x, float y)
      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

      public static int indexInParent(Layer layer)
      Returns the index of the given layer within its parent, or -1 if the parent is null.
    • bind

      public static void bind(Layer layer, Signal<Clock> paint, Slot<Clock> onPaint)
      Automatically connects onPaint to paint when layer is added to a scene graph, and disconnects it when layer is removed.
    • bind

      public static void bind(Layer layer, Signal<Clock> update, Slot<Clock> onUpdate, Signal<Clock> paint, Slot<Clock> onPaint)
      Automatically connects onUpdate to update, and onPaint to paint when layer is added to a scene graph, and disconnects them when layer is removed.
    • graphDepth

      public static int graphDepth(Layer layer)
      Returns the depth of the given layer in its local scene graph. A root layer (one with null parent) will always return 0.
    • print

      public static void print(Log log, Layer layer)
      Prints the layer heirarchy starting at layer, using Log.debug(java.lang.String).