Package nl.colorize.multimedialib.stage
Class Container
java.lang.Object
nl.colorize.multimedialib.stage.Container
Display object that acts as a container for holding 2D graphics. Children
are visited in the order they were added, which means children further down
the list will be drawn "on top of" children earlier in the list.
Containers have their own Transform
, and this is inherited by their
children. In other words, the child display object's position is relative
to its parent container's position, not relative to the stage.
Containers keep track of added and removed children. This information can be retrieved in two ways: by registering observers that are notified whenever a child is added or removed, or via a queue that can be polled on a frame-by-frame basis.
Containers can optionally be given a name. This name should be used purely for information purposes. Trying to look up containers by name during each frame will be too slow for most applications.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Convenience method that adds the specified graphics to this container, then moved the graphics' position to the specified offset.void
Convenience method that adds the specified graphics to this container, then moved the graphics' position to the specified offset.Convenience method that creates a child container, adds it as a child to this container, then returns the created child container.void
<T extends Graphic2D>
voidDeprecated.This method requires the container to iterate over all of its children, which has a performance impact if the container is large and this is done every frame.Returns theDisplayListLocation
attached to this graphic, which is used by the renderer to determine how this graphic should be drawn.Returns the smallest rectangle that can contain the bounds of all graphics within this container.void
removeChild
(Graphic2D child) toString()
void
update
(float deltaTime) Updates this object for the current frame.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface nl.colorize.multimedialib.stage.Graphic2D
getGlobalTransform, getTransform, hitTest, setPosition
-
Constructor Details
-
Container
-
Container
public Container()
-
-
Method Details
-
addChild
-
addChild
Convenience method that adds the specified graphics to this container, then moved the graphics' position to the specified offset. -
addChild
Convenience method that adds the specified graphics to this container, then moved the graphics' position to the specified offset. -
addChildContainer
Convenience method that creates a child container, adds it as a child to this container, then returns the created child container. -
removeChild
-
clearChildren
public void clearChildren() -
getChildren
-
forEach
Deprecated.This method requires the container to iterate over all of its children, which has a performance impact if the container is large and this is done every frame. Prefer direct references to the relevant graphics over using this method.Invokes the specified callback function for all matching graphics within this container. -
update
public void update(float deltaTime) Description copied from interface:Updatable
Updates this object for the current frame.deltaTime
indicates the elapsed time since the last frame update, in seconds. -
getStageBounds
Returns the smallest rectangle that can contain the bounds of all graphics within this container.- Specified by:
getStageBounds
in interfaceGraphic2D
-
toString
-
getLocation
Description copied from interface:Graphic2D
Returns theDisplayListLocation
attached to this graphic, which is used by the renderer to determine how this graphic should be drawn.- Specified by:
getLocation
in interfaceGraphic2D
-