public class ComponentUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static char |
componentPropertySeparator |
Constructor and Description |
---|
ComponentUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addComponents(java.util.List<? extends ModelComponent> list,
int[] indices,
java.util.List<MutableCompositeComponent<?>> parents) |
static void |
addComponents(java.util.List<? extends ModelComponent> list,
int[] indices,
java.util.List<MutableCompositeComponent<?>> parents,
boolean reverse) |
static void |
addComponents(java.util.List<? extends ModelComponent> list,
int[] indices,
MutableCompositeComponent<?> parent) |
static void |
addComponentsInReverse(java.util.List<? extends ModelComponent> list,
int[] indices,
java.util.List<MutableCompositeComponent<?>> parents) |
static boolean |
addCopyComponents(java.util.List<ModelComponent> list,
ModelComponent comp) |
static boolean |
addCopyReferences(java.util.List<ModelComponent> list,
ModelComponent comp,
ModelComponent ancestor) |
static java.util.HashMap<ModelComponent,artisynth.core.modelbase.ComponentUtils.Dependencies> |
buildDependencyMap(CompositeComponent comp) |
static CompositeComponent |
castRefToAncestor(java.lang.Object ref) |
static void |
checkReferenceContainment(ModelComponent comp) |
static CompositeComponent |
farthestEncapsulatingAncestor(ModelComponent c)
Returns the farthest ancestor of a component (or the component
itself) for which
hierarchyContainsDependencies() returns true . |
static ModelComponent |
findCommonAncestor(java.util.List<? extends ModelComponent> comps)
Returns the common ancestor, if any, for a list of model components.
|
static ModelComponent |
findCommonAncestor(ModelComponent comp1,
ModelComponent comp2)
Returns the common ancestor, if any, for two model components.
|
static ModelComponent |
findComponent(ModelComponent comp,
java.lang.String path) |
static java.lang.Object |
findComponentOrProperty(ModelComponent comp,
java.lang.String path) |
static java.util.LinkedList<ModelComponent> |
findCopyComponents(java.util.List<ModelComponent> comps) |
static java.util.LinkedList<ModelComponent> |
findDependentComponents(java.util.List<ModelComponent> update,
java.util.List<? extends ModelComponent> comps) |
static Property |
findProperty(ModelComponent comp,
java.lang.String path) |
static int |
getDepth(ModelComponent comp)
Returns the depth of a component within the component hierarchy.
|
static java.lang.String |
getDiagnosticName(ModelComponent comp)
Returns name information for a model comonent suitable for diagnistic
printing.
|
static CompositeComponent |
getGrandParent(ModelComponent comp) |
static java.lang.String |
getPathName(ModelComponent comp) |
static java.lang.String |
getPathName(ModelComponent ancestor,
ModelComponent comp) |
static java.lang.String |
getPathName(ModelComponent reference,
ModelComponent target,
boolean compact)
Returns a path name from a reference component to a target component.
|
static ModelComponent |
getPropertyComponent(Property prop)
Returns the ModelComponent, if any, associated with a given property.
|
static java.lang.String |
getPropertyPathName(Property prop) |
static java.lang.String |
getPropertyPathName(Property prop,
ModelComponent topAncestor,
boolean excludeLeaf) |
static java.lang.String |
getWritePathName(CompositeComponent ancestor,
ModelComponent comp) |
static java.lang.String |
getWritePropertyPathName(Property prop,
ModelComponent topAncestor) |
static boolean |
haveCommonAncestor(ModelComponent comp1,
ModelComponent comp2)
Returns
true if two components have a common ancestor. |
static boolean |
isAncestorOf(ModelComponent comp0,
ModelComponent comp1)
Returns true if comp0 is an ancestor of comp1.
|
static boolean |
isAncestorSelected(ModelComponent comp) |
static boolean |
isConnected(ModelComponent comp1,
ModelComponent comp2)
Returns true if
comp2 is connected to the same
component hierarchy as comp1 . |
static ModelComponent |
loadComponent(java.io.File file,
CompositeComponent ancestor,
java.lang.Class<?> expectedType) |
static ModelComponent |
maybeCopy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap,
CopyableComponent c) |
static ModelComponent |
maybeGetCopy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap,
CopyableComponent c) |
static CompositeComponent |
nearestEncapsulatingAncestor(ModelComponent c)
Returns the closest ancestor of a component (or the component
itself) for which
hierarchyContainsDependencies() returns true . |
static java.util.ArrayList<Property> |
parseProperties(java.util.Deque<ScanToken> tokens,
CompositeComponent ancestor) |
static Property |
parseProperty(java.lang.Object obj,
CompositeComponent ancestor) |
static void |
recursivelyBuildDependencyMap(java.util.HashMap<ModelComponent,artisynth.core.modelbase.ComponentUtils.Dependencies> map,
ModelComponent c) |
static <E extends ModelComponent> |
recursivelyFindComponents(java.lang.Class<E> clazz,
CompositeComponent comp,
java.util.List<E> out) |
static boolean |
referencesContained(CompositeComponent ancestor,
ModelComponent comp)
Returns true if all references associated with a component are recursively
contained beneath a specified ancestor.
|
static java.util.LinkedList<MutableCompositeComponent<?>> |
removeComponents(java.util.List<? extends ModelComponent> list,
int[] indices) |
static void |
saveComponent(java.io.File file,
ModelComponent comp,
NumberFormat fmt,
ModelComponent ancestor) |
static void |
testPaths(CompositeComponent comp)
Used for debugging.
|
static <C extends ModelComponent> |
updateReferences(ModelComponent c,
java.util.List<C> refs,
boolean undo,
java.util.Deque<java.lang.Object> undoInfo) |
static boolean |
withinHierarchy(ModelComponent comp,
ModelComponent ancestor)
Returns true if a component is equal to, or is a descendant of a
particular ancestor component.
|
static boolean |
withinHierarchy(ModelComponent comp,
TransformableGeometry topObject)
Returns true if a component is equal to, or is a descendant of a
particular object.
|
public static final char componentPropertySeparator
public static java.util.LinkedList<ModelComponent> findDependentComponents(java.util.List<ModelComponent> update, java.util.List<? extends ModelComponent> comps)
public static java.util.LinkedList<MutableCompositeComponent<?>> removeComponents(java.util.List<? extends ModelComponent> list, int[] indices)
public static boolean isAncestorSelected(ModelComponent comp)
public static void addComponents(java.util.List<? extends ModelComponent> list, int[] indices, java.util.List<MutableCompositeComponent<?>> parents)
public static void addComponentsInReverse(java.util.List<? extends ModelComponent> list, int[] indices, java.util.List<MutableCompositeComponent<?>> parents)
public static void addComponents(java.util.List<? extends ModelComponent> list, int[] indices, MutableCompositeComponent<?> parent)
public static void addComponents(java.util.List<? extends ModelComponent> list, int[] indices, java.util.List<MutableCompositeComponent<?>> parents, boolean reverse)
public static boolean withinHierarchy(ModelComponent comp, ModelComponent ancestor)
comp
- component to checkancestor
- ancestor componentpublic static boolean withinHierarchy(ModelComponent comp, TransformableGeometry topObject)
comp
- component to checktopObject
- candidate ancestor componentpublic static boolean addCopyComponents(java.util.List<ModelComponent> list, ModelComponent comp)
public static java.util.LinkedList<ModelComponent> findCopyComponents(java.util.List<ModelComponent> comps)
public static boolean addCopyReferences(java.util.List<ModelComponent> list, ModelComponent comp, ModelComponent ancestor)
public static int getDepth(ModelComponent comp)
public static boolean haveCommonAncestor(ModelComponent comp1, ModelComponent comp2)
true
if two components have a common ancestor.public static boolean isConnected(ModelComponent comp1, ModelComponent comp2)
comp2
is connected to the same
component hierarchy as comp1
.public static ModelComponent findCommonAncestor(ModelComponent comp1, ModelComponent comp2)
public static ModelComponent findCommonAncestor(java.util.List<? extends ModelComponent> comps)
public static boolean isAncestorOf(ModelComponent comp0, ModelComponent comp1)
public static boolean referencesContained(CompositeComponent ancestor, ModelComponent comp)
ancestor
- ancestor component beneath which reference should be containedcomp
- component whose references should be checkedpublic static java.lang.String getDiagnosticName(ModelComponent comp)
public static void checkReferenceContainment(ModelComponent comp)
public static CompositeComponent nearestEncapsulatingAncestor(ModelComponent c)
hierarchyContainsDependencies()
returns true
.
That means all inter-component references are contained
within the ancestor's hierarchy. If no such ancestor is found,
null
is returned.public static CompositeComponent farthestEncapsulatingAncestor(ModelComponent c)
hierarchyContainsDependencies()
returns true
.
That means all inter-component references are contained
within the ancestor's hierarchy. If no such ancestor is found,
null
is returned.public static void saveComponent(java.io.File file, ModelComponent comp, NumberFormat fmt, ModelComponent ancestor) throws java.io.IOException
java.io.IOException
public static ModelComponent loadComponent(java.io.File file, CompositeComponent ancestor, java.lang.Class<?> expectedType) throws java.io.IOException
java.io.IOException
public static ModelComponent getPropertyComponent(Property prop)
prop
- property to be queriedpublic static ModelComponent findComponent(ModelComponent comp, java.lang.String path)
public static Property findProperty(ModelComponent comp, java.lang.String path)
public static java.lang.Object findComponentOrProperty(ModelComponent comp, java.lang.String path)
public static Property parseProperty(java.lang.Object obj, CompositeComponent ancestor) throws java.io.IOException
java.io.IOException
public static java.util.ArrayList<Property> parseProperties(java.util.Deque<ScanToken> tokens, CompositeComponent ancestor) throws java.io.IOException
java.io.IOException
public static java.lang.String getPathName(ModelComponent comp)
public static java.lang.String getPathName(ModelComponent ancestor, ModelComponent comp)
public static java.lang.String getPathName(ModelComponent reference, ModelComponent target, boolean compact)
public static java.lang.String getWritePropertyPathName(Property prop, ModelComponent topAncestor)
public static java.lang.String getPropertyPathName(Property prop, ModelComponent topAncestor, boolean excludeLeaf)
public static java.lang.String getPropertyPathName(Property prop)
public static CompositeComponent getGrandParent(ModelComponent comp)
public static ModelComponent maybeGetCopy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap, CopyableComponent c)
public static ModelComponent maybeCopy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap, CopyableComponent c)
public static <E extends ModelComponent> void recursivelyFindComponents(java.lang.Class<E> clazz, CompositeComponent comp, java.util.List<E> out)
public static java.lang.String getWritePathName(CompositeComponent ancestor, ModelComponent comp)
public static void testPaths(CompositeComponent comp)
public static CompositeComponent castRefToAncestor(java.lang.Object ref) throws java.io.IOException
java.io.IOException
public static void recursivelyBuildDependencyMap(java.util.HashMap<ModelComponent,artisynth.core.modelbase.ComponentUtils.Dependencies> map, ModelComponent c)
public static java.util.HashMap<ModelComponent,artisynth.core.modelbase.ComponentUtils.Dependencies> buildDependencyMap(CompositeComponent comp)
public static <C extends ModelComponent> void updateReferences(ModelComponent c, java.util.List<C> refs, boolean undo, java.util.Deque<java.lang.Object> undoInfo)