|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrobocode.naval.ComponentManager
public class ComponentManager
Manages the different components that can be assigned to a ship.
Field Summary | |
---|---|
static int |
MAX_COMPONENTS
The maximum amount of components that can be added to a ship. |
Constructor Summary | |
---|---|
ComponentManager()
|
Method Summary | ||
---|---|---|
void |
addComponent(IComponent component)
Add a component. |
|
void |
addComponent(int index,
IComponent component)
Add a component on the specified index. |
|
static ComponentManager |
copy(ComponentManager manager)
Get a copy of the given ComponentManager . |
|
Color |
getColor(int index)
Get the color of the component at the specified index. |
|
|
getComponent(Class<T> componentClass)
Get the first component that matches the given class. |
|
IComponent |
getComponent(int index)
Get the component at the specified index. |
|
ArrayList<IComponent> |
getComponentArrayList()
|
|
|
getComponents(Class<T> componentClass)
Get an array of components that match the given class. |
|
|
indexOf(T value)
Get the index of the specified component. |
|
boolean |
isValidIndex(int index)
Determines whether the given index is a valid index for this ComponentManager . |
|
void |
removeComponent(int index)
Remove the component at the specified index. |
|
|
removeComponent(T component)
Remove the specified component. |
|
|
removeComponents(Class<T> componentClass)
Remove the components that match the specified class. |
|
void |
setColor(int index,
Color color)
Set the color of the component at the specified index. |
|
int |
size()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_COMPONENTS
Constructor Detail |
---|
public ComponentManager()
Method Detail |
---|
public ArrayList<IComponent> getComponentArrayList()
public static final ComponentManager copy(ComponentManager manager)
ComponentManager
.
manager
- The manager that has to be copied.
public int size()
public boolean isValidIndex(int index)
ComponentManager
.
index
- The index we want to validate.
true
when the given index is valid; false
otherwise.public <T extends IComponent> int indexOf(T value)
-1
when the component has not available.
indexOf
in interface IComponents
value
- The component from whom to get the index.
public void removeComponent(int index)
removeComponent
in interface IComponents
index
- The index of the component that has to be removed.public IComponent getComponent(int index)
getComponent
in interface IComponents
index
- The index of the component.
public void addComponent(IComponent component)
addComponent
in interface IComponents
component
- The component that has to be added.public void addComponent(int index, IComponent component)
addComponent
in interface IComponents
index
- The index at which the add the component.component
- The component whom has to be added.public <T extends IComponent> void removeComponent(T component)
removeComponent
in interface IComponents
component
- The component to remove.public <T extends IComponent> void removeComponents(Class<T> componentClass)
removeComponents
in interface IComponents
componentClass
- The class of the objects to remove.public <T extends IComponent> T getComponent(Class<T> componentClass)
null
when there is no component of the given class.
getComponent
in interface IComponents
componentClass
- The class of the component.
public <T extends IComponent> T[] getComponents(Class<T> componentClass)
null
when there are no components matching the given class.
getComponents
in interface IComponents
componentClass
- The common class of the objects.
public void setColor(int index, Color color)
index
- The index of the component.color
- The color that the component should have.public Color getColor(int index)
index
- The index of the component.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |