org.robokind.api.motion.jointgroup
Class AbstractJointGroup<Id,G extends JointGroup,J extends Joint>

java.lang.Object
  extended by org.robokind.api.common.property.PropertyChangeNotifier
      extended by org.robokind.api.motion.jointgroup.AbstractJointGroup<Id,G,J>
Type Parameters:
Id - Type used to identify Joints
G - Type of child JointGroups
J - Type of Joints used by this JointGroup
All Implemented Interfaces:
org.robokind.api.common.property.PropertyChangeSource, JointGroup<Id,G,J>
Direct Known Subclasses:
RobotJointGroup

public abstract class AbstractJointGroup<Id,G extends JointGroup,J extends Joint>
extends org.robokind.api.common.property.PropertyChangeNotifier
implements JointGroup<Id,G,J>

Abstract class providing common functionality for JointGroups.

Author:
Matthew Stevenson

Field Summary
protected  List<G> myGroups
          Child JointGroups
protected  List<Id> myJointIds
          JointIds used by this JointGroup
protected  String myName
          Name of this JointGroup
 
Fields inherited from interface org.robokind.api.motion.jointgroup.JointGroup
PROP_ADD_JOINT_GROUP, PROP_ADD_JOINT_ID, PROP_ENABLED, PROP_JOINT_CHANGED, PROP_NAME, PROP_REMOVE_JOINT_GROUP, PROP_REMOVE_JOINT_ID, PROP_STRUCTURE_CHANGED
 
Constructor Summary
AbstractJointGroup()
          Creates an empty AbstractJointGroup
AbstractJointGroup(String name, List<Id> ids, List<G> groups)
           
 
Method Summary
 void addGroup(G group)
          Add a child JointGroup.
 void addJointId(Id jointId)
          Adds a JointId to this JointGroup.
 boolean getEnabled()
          Returns the enabled state
 int getGroupCount()
          Return the number of child JointGroups.
 J getJoint(int index)
          Returns the Joint at the given index, or null if out of bounds.
protected abstract  J getJointById(Id jointId)
          Retrieves a Joint with the given jointId.
 int getJointCount()
          Returns the number of JointIds for this JointGroup.
 G getJointGroup(int index)
          Returns the child JointGroup at the given index.
 List<G> getJointGroups()
          Returns a List of the children JointGroups.
 Id getJointId(int index)
          Returns the JointId at the given index.
 List<Id> getJointIds()
          Returns a List of JointIds for this JointGroup
 List<J> getJoints()
          Returns a List of Joints belonging to this JointGroup.
 String getName()
          Returns the name to use
 void insertGroup(G group, int index)
          Add a child JointGroup at the given index.
 void insertJointId(Id jointId, int index)
          Adds a JointId to this JointGroup at the given index.
 void removeGroup(G group)
          Removes a child JointGroup.
 void removeGroupAt(int index)
          Removes a child JointGroup at the given index.
 void removeJointId(Id jointId)
          Removes a JointId
 void removeJointIdAt(int index)
          Removes the JointId with the given index.
 void setEnabled(boolean enabled)
          Sets the enabled state of the JointGroup
 void setName(String name)
          Sets the name of the JointGroup
 String toString()
           
 
Methods inherited from class org.robokind.api.common.property.PropertyChangeNotifier
addPropertyChangeListener, addPropertyChangeListener, clearAllListeners, clearListeners, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, hasListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.robokind.api.common.property.PropertyChangeSource
addPropertyChangeListener, addPropertyChangeListener, removePropertyChangeListener, removePropertyChangeListener
 

Field Detail

myName

protected String myName
Name of this JointGroup


myJointIds

protected List<Id> myJointIds
JointIds used by this JointGroup


myGroups

protected List<G extends JointGroup> myGroups
Child JointGroups

Constructor Detail

AbstractJointGroup

public AbstractJointGroup()
Creates an empty AbstractJointGroup


AbstractJointGroup

public AbstractJointGroup(String name,
                          List<Id> ids,
                          List<G> groups)
Parameters:
name - name of this JointGroup
ids - initial JointIds
groups - initial child JointGroups
Method Detail

getJointById

protected abstract J getJointById(Id jointId)
Retrieves a Joint with the given jointId.

Parameters:
jointId - id of the joint to retrieve
Returns:
Joint with the given jointId, null if no Joint is found

setName

public void setName(String name)
Description copied from interface: JointGroup
Sets the name of the JointGroup

Specified by:
setName in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
name - new name to use

getName

public String getName()
Description copied from interface: JointGroup
Returns the name to use

Specified by:
getName in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Returns:
the name to use

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: JointGroup
Sets the enabled state of the JointGroup

Specified by:
setEnabled in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
enabled - enabled state to use

getJoint

public J getJoint(int index)
Returns the Joint at the given index, or null if out of bounds.

Specified by:
getJoint in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
index - index of the Joint to return
Returns:
Joint at the given index, or null if out of bounds

getJoints

public List<J> getJoints()
Returns a List of Joints belonging to this JointGroup.

Specified by:
getJoints in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Returns:
List of Joints belonging to this JointGroup

getEnabled

public boolean getEnabled()
Description copied from interface: JointGroup
Returns the enabled state

Specified by:
getEnabled in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Returns:
the enabled state

addJointId

public void addJointId(Id jointId)
Description copied from interface: JointGroup
Adds a JointId to this JointGroup. If the given id already exists in this JointGroup, it is ignored.

Specified by:
addJointId in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
jointId - the id to add

insertJointId

public void insertJointId(Id jointId,
                          int index)
Description copied from interface: JointGroup
Adds a JointId to this JointGroup at the given index. If the given id already exists in this JointGroup, it is ignored.

Specified by:
insertJointId in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
jointId - the id to add
index - index at which to insert the Joint Id

removeJointId

public void removeJointId(Id jointId)
Description copied from interface: JointGroup
Removes a JointId

Specified by:
removeJointId in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
jointId - id to remove

removeJointIdAt

public void removeJointIdAt(int index)
Description copied from interface: JointGroup
Removes the JointId with the given index.

Specified by:
removeJointIdAt in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
index - position of the JointId in this JointGroup's JointIds

getJointIds

public List<Id> getJointIds()
Description copied from interface: JointGroup
Returns a List of JointIds for this JointGroup

Specified by:
getJointIds in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Returns:
a List of JointIds for this JointGroup

getJointId

public Id getJointId(int index)
Description copied from interface: JointGroup
Returns the JointId at the given index.

Specified by:
getJointId in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
index - position of the JointId in the JointGroup's JointIds
Returns:
the JointId at the given index

getJointCount

public int getJointCount()
Description copied from interface: JointGroup
Returns the number of JointIds for this JointGroup.

Specified by:
getJointCount in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Returns:
the number of JointIds for this JointGroup

addGroup

public void addGroup(G group)
Description copied from interface: JointGroup
Add a child JointGroup.

Specified by:
addGroup in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
group - child JointGroup to add

insertGroup

public void insertGroup(G group,
                        int index)
Description copied from interface: JointGroup
Add a child JointGroup at the given index.

Specified by:
insertGroup in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
group - child JointGroup to add
index - position to add the child

removeGroup

public void removeGroup(G group)
Description copied from interface: JointGroup
Removes a child JointGroup.

Specified by:
removeGroup in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
group - the child to remove

removeGroupAt

public void removeGroupAt(int index)
Description copied from interface: JointGroup
Removes a child JointGroup at the given index.

Specified by:
removeGroupAt in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
index - position of the child to remove

getJointGroups

public List<G> getJointGroups()
Description copied from interface: JointGroup
Returns a List of the children JointGroups.

Specified by:
getJointGroups in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Returns:
a List of the children JointGroups

getJointGroup

public G getJointGroup(int index)
Description copied from interface: JointGroup
Returns the child JointGroup at the given index.

Specified by:
getJointGroup in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Parameters:
index - position to the child to remove
Returns:
the child JointGroup removed

getGroupCount

public int getGroupCount()
Description copied from interface: JointGroup
Return the number of child JointGroups.

Specified by:
getGroupCount in interface JointGroup<Id,G extends JointGroup,J extends Joint>
Returns:
the number of child JointGroups

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011-2013. All Rights Reserved.