com.tensegrity.composite.util
Class CompositeHierarchyPath

java.lang.Object
  extended bycom.tensegrity.composite.util.CompositeHierarchyPath

public final class CompositeHierarchyPath
extends java.lang.Object

This class provides functionalities useful when working with arrangements of composites, especially when it comes to transforming coordinates from the view to a Composite respectively a CompositeContainer or vice versa.

Version:
$Id: CompositeHierarchyPath.java,v 1.14 2005/04/13 15:19:28 MichaelKegel Exp $
Author:
MichaelKegel
See Also:
CompositeHierarchyUtilities

Method Summary
 Transform2D buildTransform(int type)
          Returns a transformation that is defined through the constant given by type and can be used to constant transformation type CompositeHierarchyUtilities.TRANSFORM_FROM_VIEW_TO_COMPOSITE transform a coordinate from the coordinate system of the view into the coordinate system of the composite CompositeHierarchyUtilities.TRANSFORM_FROM_COMPOSITE_TO_VIEW transform a coordinate from the coordinate system of the composite into the coordinate system of the view CompositeHierarchyUtilities.TRANSFORM_FROM_VIEW_TO_CONTAINER transform a coordinate from the coordinate system of the view into the coordinate system of the composites container CompositeHierarchyUtilities.TRANSFORM_FROM_CONTAINER_TO_VIEW transform a coordinate from the coordinate system of the composites container into the coordinate system of the view
 void clear()
          Removes all elements from this CompositeHierarchyPath.
 BaseCompositeContainer getBaseCompositeContainer(int level)
          Returns the BaseCompositeContainer at the level given by level.
 BaseCompositeContainer[] getBaseCompositeContainerArray()
          Returns an array with all BaseCompositeContainers that belong to the CompositeHierarchyPath.
 java.util.List getCompositeList()
          Returns a List holding the Composites within this CompositeHierarchyPath.
 CompositeView getCompositeView()
          Deprecated. since leveled hierarchies can be build starting from a CompositeGroup it is not ensured that the BaseCompositeContainer at index 0 is a CompositeView. Use #getBaseCompositeContainer(int) or #getBaseCompositeContainerArray() instead.
 BaseCompositeContainer getDeepestBaseCompositeContainer()
          Returns the deepest BaseCompositeContainer that can be found in the CompositeHierarchyPath.
 BaseComposite getLastPathComposite()
          Returns the last element from the CompositeHierarchyPath.
 boolean isEmpty()
          Returns a boolean that indicates whether the CompositeHierarchyPath is empty or not.
 boolean isSubPath(CompositeHierarchyPath other)
          Returns a boolean that indicates whether the CompositeHierarchyPath given by other is a subpath to this CompositeHierarchyPath.
 int length()
          Returns the length of this path.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

length

public int length()
Returns the length of this path.

Returns:
the length of this path.

getCompositeList

public java.util.List getCompositeList()
Returns a List holding the Composites within this CompositeHierarchyPath.

Returns:
a List holding the Composites.

getCompositeView

public CompositeView getCompositeView()
Deprecated. since leveled hierarchies can be build starting from a CompositeGroup it is not ensured that the BaseCompositeContainer at index 0 is a CompositeView. Use #getBaseCompositeContainer(int) or #getBaseCompositeContainerArray() instead.

Returns the CompositeView of the CompositeHierarchyPath. The CompositeView is the BaseCompositeContainer at index 0.

Returns:
CompositeView the CompositeView of the path

getBaseCompositeContainer

public BaseCompositeContainer getBaseCompositeContainer(int level)
Returns the BaseCompositeContainer at the level given by level. If the level is to high for this path null is returned.
POSTCONDITION null is returned if the given level is to high for the CompositeHierarchyPath.

Parameters:
level - the level to return the BaseCompositeContainer for
Returns:
BaseCompositeContainer the BaseCompositeContainer at the given level or null

getDeepestBaseCompositeContainer

public BaseCompositeContainer getDeepestBaseCompositeContainer()
Returns the deepest BaseCompositeContainer that can be found in the CompositeHierarchyPath. Usually this is the BaseCompositeContainer that contains the BaseComposite returned by #getLastPathComposite().

Returns:
BaseCompositeContainer the deepest BaseCompositeContainer from the CompositeHierarchyPath

getBaseCompositeContainerArray

public BaseCompositeContainer[] getBaseCompositeContainerArray()
Returns an array with all BaseCompositeContainers that belong to the CompositeHierarchyPath.

Returns:
an array holding all BaseCompositeContainers of this CompositeHierarchyPath.

getLastPathComposite

public BaseComposite getLastPathComposite()
Returns the last element from the CompositeHierarchyPath. Last element means in this case the element with the highest level. It always an instance of BaseComposite or a super class and is in fact the one the CompositeHierarchyPath represents the path to.

Returns:
BaseComposite the BaseComposite the CompositeHierarchyPath represents the path to

clear

public void clear()
Removes all elements from this CompositeHierarchyPath.


isEmpty

public boolean isEmpty()
Returns a boolean that indicates whether the CompositeHierarchyPath is empty or not.

Returns:
boolean flag that indicates that the CompositeHierarchyPath is empty

isSubPath

public boolean isSubPath(CompositeHierarchyPath other)
Returns a boolean that indicates whether the CompositeHierarchyPath given by other is a subpath to this CompositeHierarchyPath. A CompositeHierarchyPath is a subpath to another exactly when all elements of the path are part of the other one.

Parameters:
other - the CompositeHierarchyPath to check against
Returns:
boolean flag that indicates that the given CompositeHierarchyPath is a subpath of this one

toString

public java.lang.String toString()

buildTransform

public Transform2D buildTransform(int type)
Returns a transformation that is defined through the constant given by type and can be used to
constant transformation type
CompositeHierarchyUtilities.TRANSFORM_FROM_VIEW_TO_COMPOSITE transform a coordinate from the coordinate system of the view into the coordinate system of the composite
CompositeHierarchyUtilities.TRANSFORM_FROM_COMPOSITE_TO_VIEW transform a coordinate from the coordinate system of the composite into the coordinate system of the view
CompositeHierarchyUtilities.TRANSFORM_FROM_VIEW_TO_CONTAINER transform a coordinate from the coordinate system of the view into the coordinate system of the composites container
CompositeHierarchyUtilities.TRANSFORM_FROM_CONTAINER_TO_VIEW transform a coordinate from the coordinate system of the composites container into the coordinate system of the view

Parameters:
type - the type of the Transform2D to be returned.
Returns:
a Transform2D of the given type.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.