Class Container

java.lang.Object
nl.colorize.multimedialib.stage.Container
All Implemented Interfaces:
Iterable<StageNode2D>, StageNode2D

public class Container extends Object implements StageNode2D, Iterable<StageNode2D>
Stage node that does not provide any graphics, but can instead be used to add additional graphics as children. Modifying the container's transform will propagate to its children.

Containers can optionally have a name. This name is only used for identification, it does not influence the container's appearance or behavior in any way.

Children are limited to 2D graphics, since the stage has a hard separation between 2D and 3D graphics. Use Group for 3D graphics.

  • Constructor Details

    • Container

      public Container(String name)
    • Container

      public Container()
  • Method Details

    • addChild

      public void addChild(StageNode2D child)
    • addChild

      public void addChild(StageNode2D child, Point2D relativePosition)
      Convenience method that adds the specified graphics to this container, then moved the graphics' position to the specified offset.
    • addChild

      public void addChild(StageNode2D child, float relativeX, float relativeY)
      Convenience method that adds the specified graphics to this container, then moved the graphics' position to the specified offset.
    • addChildContainer

      public Container addChildContainer()
      Convenience method that creates a new container, adds it as a child to this container, then returns the created child container.
    • removeChild

      public void removeChild(StageNode2D child)
    • clearChildren

      public void clearChildren()
    • forEach

      public <T extends StageNode2D> void forEach(Class<T> type, Consumer<T> callback)
      Invokes the specified callback function for all matching graphics within this container.
    • getStageBounds

      public Rect getStageBounds()
      Returns the smallest rectangle that can contain the bounds of all graphics within this container.
      Specified by:
      getStageBounds in interface StageNode2D
    • animate

      public void animate(Timer sceneTime)
      Description copied from interface: StageNode2D
      Called by the renderer at the end of frame updates, while rendering the stage. animationTimer contains the elapsed time since the currently active scene was started. This allows animations to display correctly, without the need to update every single node during each frame update.
      Specified by:
      animate in interface StageNode2D
    • iterator

      public Iterator<StageNode2D> iterator()
      Specified by:
      iterator in interface Iterable<StageNode2D>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getName

      public String getName()
    • getTransform

      public Transform getTransform()
      Description copied from interface: StageNode2D
      Returns this node's local transform, which is interpreted relative to its parent node. The local transform can be modified by application code to modify how and where the node is displayed.
      Specified by:
      getTransform in interface StageNode2D
    • getGlobalTransform

      public Transform getGlobalTransform()
      Description copied from interface: StageNode2D
      Returns this node's global transform, which is interpreted relative to the stage. The global transform is updated by the renderer when drawing the stage at the end of frame updates. Recalculating the global transform is relatively expensive, and is therefore only done once per frame. This means that any changes made to a node's local transform since the last frame update may not yet been reflected in the current state of its global transform.
      Specified by:
      getGlobalTransform in interface StageNode2D
    • getChildren

      protected nl.colorize.util.SubscribableCollection<StageNode2D> getChildren()