Package tripleplay.ui

Class Interface

java.lang.Object
tripleplay.ui.Interface
All Implemented Interfaces:
AutoCloseable, react.Closeable

public class Interface extends Object implements react.Closeable
The main class that integrates the Triple Play UI with a PlayN game. This class is mainly necessary to automatically validate hierarchies of Elements during each paint. Create an interface instance, create Root groups via the interface and add the Element.layers into your scene graph wherever you desire.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface react.Closeable

    react.Closeable.Set, react.Closeable.Util
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Animator
    An animator that can be used to animate things in this interface.
    final react.Signal<Clock>
    A signal emitted just before we render a frame.
    final Platform
    The platform in which this interface is operating.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Interface(Platform plat, react.Signal<Clock> frame)
    Creates an interface for plat.
  • Method Summary

    Modifier and Type
    Method
    Description
    <R extends Root>
    R
    addRoot(R root)
    Adds a root to this interface.
    void
     
    createRoot(Layout layout, Stylesheet sheet)
    Creates a root element with the specified layout and stylesheet.
    createRoot(Layout layout, Stylesheet sheet, GroupLayer parent)
    Creates a root element with the specified layout and stylesheet and adds its layer to the specified parent.
    boolean
    Removes the supplied root element from this interface and disposes its layer, iff it's currently added.
    void
    Removes and disposes all roots in this interface.
    boolean
    Removes the supplied root element from this interface, iff it's currently added.
    Returns an iterable over the current roots.

    Methods inherited from class java.lang.Object

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

    • plat

      public final Platform plat
      The platform in which this interface is operating.
    • frame

      public final react.Signal<Clock> frame
      A signal emitted just before we render a frame.
    • anim

      public final Animator anim
      An animator that can be used to animate things in this interface.
  • Constructor Details

    • Interface

      public Interface(Platform plat, react.Signal<Clock> frame)
      Creates an interface for plat. The interface will be connected to frame to drive any per-frame animations and activity. Either provide a frame signal whose lifetime is the same as the interface (for example Screen.paint), or call close() when this interface should be disconnected from the frame signal.
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface react.Closeable
    • roots

      public Iterable<Root> roots()
      Returns an iterable over the current roots. Don't delete from this iterable!
    • createRoot

      public Root createRoot(Layout layout, Stylesheet sheet)
      Creates a root element with the specified layout and stylesheet.
    • createRoot

      public Root createRoot(Layout layout, Stylesheet sheet, GroupLayer parent)
      Creates a root element with the specified layout and stylesheet and adds its layer to the specified parent.
    • addRoot

      public <R extends Root> R addRoot(R root)
      Adds a root to this interface. The root must have been created with this interface and not be added to any other interfaces. Generally you should use createRoot(tripleplay.ui.Layout, tripleplay.ui.Stylesheet), but this method is exposed for callers with special needs.
    • removeRoot

      public boolean removeRoot(Root root)
      Removes the supplied root element from this interface, iff it's currently added. If the root's layer has a parent, the layer will be removed from the parent as well. This leaves the Root's layer in existence, so it may be used again. If you're done with the Root and all of the elements inside of it, call disposeRoot(tripleplay.ui.Root) to free its resources.
      Returns:
      true if the root was removed, false if it was not currently added.
    • disposeRoot

      public boolean disposeRoot(Root root)
      Removes the supplied root element from this interface and disposes its layer, iff it's currently added. Disposing the layer disposes the layers of all elements contained in the root as well. Use this method if you're done with the Root. If you'd like to reuse it, call removeRoot(tripleplay.ui.Root) instead.
      Returns:
      true if the root was removed and disposed, false if it was not currently added.
    • disposeRoots

      public void disposeRoots()
      Removes and disposes all roots in this interface.