Package com.nevergarden.myna.display
Class DisplayObjectContainer
- java.lang.Object
 - 
- com.nevergarden.myna.events.EventDispatcher
 - 
- com.nevergarden.myna.display.DisplayObject
 - 
- com.nevergarden.myna.display.DisplayObjectContainer
 
 
 
 
- 
- All Implemented Interfaces:
 Drawable
- Direct Known Subclasses:
 Stage
public class DisplayObjectContainer extends DisplayObject
Base class for collection of DisplayObjects. DisplayObjectContainer does not have anything drawable for itself but it can contain many drawables inside, it's bounds are calulated by it's children. Using DisplayObjectContainer is not recommended as long as it has a lot of overhead for creating new arrays, use it when you want to group DisplayObjects together.- See Also:
 DisplayObject
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<DisplayObject>childrenArray of children in this container.- 
Fields inherited from class com.nevergarden.myna.display.DisplayObject
parent, pivot, position, rotation, scale, transform 
- 
Fields inherited from class com.nevergarden.myna.events.EventDispatcher
eventListeners 
 - 
 
- 
Constructor Summary
Constructors Constructor Description DisplayObjectContainer() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DisplayObjectaddChild(DisplayObject child)Adds a new child to itself.DisplayObjectaddChildAt(int index, DisplayObject child)Same as addChild method but with given index.java.lang.Booleancontains(DisplayObject child)Checks if given DisplayObject already exists in this container.DisplayObjectgetChildAt(int index)Get child at given index.intgetChildIndex(DisplayObject child)Gets index of a given DisplayObject.java.util.ArrayList<DisplayObject>getChildren()Get a list of all children in this container.intgetChildrenCount()Current children count.DisplayObjectContainergetParent()Get current container parentDisplayObjectremoveChild(DisplayObject child)Removes a child from it's tree.DisplayObjectremoveChildAt(int index)Removes a child from given index.voidremoveChildren()Clears the container.voidsetParent(DisplayObjectContainer container)Sets current container parent.voidswapChildren(DisplayObject child1, DisplayObject child2)Swap children in container.voidswapChildrenAt(int index1, int index2)Swap children with their given indices.- 
Methods inherited from class com.nevergarden.myna.display.DisplayObject
draw, getPosition, recalculateMatrix, removeFromParent, rotate, setLocalX, setLocalY, setPivot, setPivotX, setPivotY, setPosition, setRotation, setScale, setScaleX, setScaleY 
- 
Methods inherited from class com.nevergarden.myna.events.EventDispatcher
addEventListener, dispatchEvent, dispatchEventWith, dispatchEventWith, dispose, hasEventListener, invokeEvent, removeEventListener, removeEventListeners 
 - 
 
 - 
 
- 
- 
Field Detail
- 
children
protected final java.util.ArrayList<DisplayObject> children
Array of children in this container. 
 - 
 
- 
Method Detail
- 
getParent
public DisplayObjectContainer getParent()
Get current container parent 
- 
setParent
public void setParent(DisplayObjectContainer container)
Sets current container parent.- Overrides:
 setParentin classDisplayObject- Parameters:
 container- New Parent
 
- 
getChildrenCount
public int getChildrenCount()
Current children count.- Returns:
 - integer
 
 
- 
addChild
public DisplayObject addChild(DisplayObject child)
Adds a new child to itself.- Parameters:
 child-- Returns:
 
 
- 
addChildAt
public DisplayObject addChildAt(int index, DisplayObject child)
Same as addChild method but with given index. 
- 
contains
public java.lang.Boolean contains(DisplayObject child)
Checks if given DisplayObject already exists in this container. 
- 
getChildAt
public DisplayObject getChildAt(int index)
Get child at given index. 
- 
getChildIndex
public int getChildIndex(DisplayObject child)
Gets index of a given DisplayObject. 
- 
removeChild
public DisplayObject removeChild(DisplayObject child)
Removes a child from it's tree. 
- 
removeChildAt
public DisplayObject removeChildAt(int index)
Removes a child from given index. 
- 
removeChildren
public void removeChildren()
Clears the container. 
- 
swapChildren
public void swapChildren(DisplayObject child1, DisplayObject child2)
Swap children in container. 
- 
swapChildrenAt
public void swapChildrenAt(int index1, int index2)Swap children with their given indices. 
- 
getChildren
public java.util.ArrayList<DisplayObject> getChildren()
Get a list of all children in this container. 
 - 
 
 -