public class ComponentList<C extends ModelComponent> extends ModelComponentBase implements ComponentListView<C>, MutableCompositeComponent<C>, java.lang.Iterable<C>, java.util.Collection<C>, ParameterizedClass
CompositeComponent.NavpanelDisplay
ModelComponent.NavpanelVisibility
Modifier and Type | Field and Description |
---|---|
static CompositeComponent.NavpanelDisplay |
DEFAULT_NAVPANEL_DISPLAY |
static PropertyList |
myProps |
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
Constructor and Description |
---|
ComponentList(java.lang.Class<C> type) |
ComponentList(java.lang.Class<C> type,
java.lang.String name) |
ComponentList(java.lang.Class<C> type,
java.lang.String name,
java.lang.String shortName) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(C comp)
Adds a component to this MutableCompositeComponent.
|
void |
add(C comp,
int idx) |
boolean |
addAll(java.util.Collection<? extends C> c) |
void |
addComponents(ModelComponent[] comps,
int[] indices,
int ncomps)
Adds a set of components to this MutableCompositeComponent.
|
boolean |
addFixed(C comp) |
boolean |
addNumbered(C comp,
int number) |
void |
clear() |
java.lang.Object |
clone() |
void |
componentChanged(ComponentChangeEvent e)
Notifies this composite component that a change has occured within one or
more of its descendants.
|
boolean |
contains(C comp)
Faster implementation using component parent pointer.
|
boolean |
contains(java.lang.Object obj)
Returns true if a particular element is contained in this list.
|
boolean |
containsAll(java.util.Collection<?> c) |
ComponentList<C> |
copy(int flags,
java.util.Map<ModelComponent,ModelComponent> copyMap) |
void |
ensureCapacity(int cap) |
C |
findComponent(java.lang.String path)
Recursively searches for a subcomponent of this ModelComponent,
identified by a path of component names.
|
C |
get(int idx)
Get the component at a particular index, or null if there is no such
component.
|
C |
get(java.lang.String nameOrNumber)
Get the component with particular name, or null if there is no such
component.
|
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
C |
getByNumber(int num)
Get the component with the specified number, or null if there is no such
component.
|
java.util.Iterator<? extends HierarchyNode> |
getChildren() |
CompositeComponent.NavpanelDisplay |
getNavpanelDisplay()
Returns the DisplayMode for this component.
|
int |
getNumberLimit()
Returns the current upper limit for numbers among all subcomponents in
this composite.
|
boolean |
getOneBasedNumbering()
Queries if one-based numbering is enabled for this component list.
|
java.lang.Class<C> |
getParameterType()
Returns the base type for the class parameterization.
|
java.lang.String |
getShortName()
Gets the short name of this component list.
|
boolean |
hasChildren() |
boolean |
hasParameterizedType()
Queries whether this class explicitly utilizes a parameterized type.
|
boolean |
hierarchyContainsReferences()
Returns true if the component hierarchy formed by this component and its
descendents is closed with respect to references.
|
int |
indexOf(ModelComponent comp)
Get the index of a particular component in this list, or -1 if the
specified component is not present.
|
void |
invalidateNumbers()
Invalidates stored numbers in cases where component numbers have been
manually changed
|
boolean |
isEditable()
Queries whether or not this component is editable from the ArtiSynth
GUI.
|
boolean |
isEmpty() |
java.util.Iterator<C> |
iterator()
Return an iterator over all components in this list.
|
int |
nextComponentNumber()
Returns the number that will be assigned to the next component added to
this list.
|
int |
numComponents()
Returns the number of components in this CompositeComponent.
|
void |
postscan(java.util.Deque<ScanToken> tokens,
CompositeComponent ancestor)
Performs any required post-scanning for this component.
|
C |
remove(int idx) |
boolean |
remove(java.lang.Object obj)
Removes a component from this MutableCompositeComponent, returning true if the
componet was in fact found and removed.
|
void |
removeAll() |
boolean |
removeAll(java.util.Collection<?> c) |
void |
removeComponents(ModelComponent[] comps,
int[] indices,
int ncomps)
Removes a set of components from this MutableCompositeComponent.
|
void |
resetNumbersToIndices()
Reset the numbering so that numbers and indices match.
|
boolean |
retainAll(java.util.Collection<?> c) |
void |
scan(ReaderTokenizer rtok,
java.lang.Object ref)
Scans this element from a ReaderTokenizer.
|
C |
set(int idx,
C comp) |
void |
setEditable(boolean editable) |
void |
setNavpanelDisplay(CompositeComponent.NavpanelDisplay mode)
Sets the display mode for this component.
|
C |
setNumbered(int idx,
C comp,
int number) |
void |
setOneBasedNumbering(boolean enable)
Sets whether or not one-based numbering is enabled for this component
list.
|
void |
setShortName(java.lang.String name) |
int |
size()
Get the number of components in this list.
|
java.lang.Object[] |
toArray() |
<C> C[] |
toArray(C[] array) |
void |
updateNameMap(java.lang.String newName,
java.lang.String oldName,
ModelComponent comp) |
checkFlag, checkName, checkNameUniqueness, clearFlag, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, hasState, isFixed, isMarked, isScanning, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setScanning, setSelected, setWritable, updateReferences, write
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName
equals, hashCode, parallelStream, removeIf, spliterator, stream
connectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, setFixed, setMarked, setName, setNumber, setParent, setSelected, setWritable, updateReferences
getProperty
isWritable, write
public static CompositeComponent.NavpanelDisplay DEFAULT_NAVPANEL_DISPLAY
public static PropertyList myProps
public ComponentList(java.lang.Class<C> type)
public ComponentList(java.lang.Class<C> type, java.lang.String name)
public ComponentList(java.lang.Class<C> type, java.lang.String name, java.lang.String shortName)
public PropertyList getAllPropertyInfo()
HasProperties
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class ModelComponentBase
public C get(java.lang.String nameOrNumber)
get
in interface ComponentListView<C extends ModelComponent>
get
in interface CompositeComponent
nameOrNumber
- name of the componentpublic C getByNumber(int num)
getByNumber
in interface ComponentListView<C extends ModelComponent>
getByNumber
in interface CompositeComponent
num
- number of the componentpublic int numComponents()
numComponents
in interface CompositeComponent
numComponents
in interface IndexedComponentList
public int indexOf(ModelComponent comp)
indexOf
in interface ComponentListView<C extends ModelComponent>
indexOf
in interface CompositeComponent
comp
- component to search forpublic C findComponent(java.lang.String path)
findComponent
in interface CompositeComponent
path
- path leading to the subcomponentpublic int getNumberLimit()
getNumberLimit
in interface CompositeComponent
public CompositeComponent.NavpanelDisplay getNavpanelDisplay()
getNavpanelDisplay
in interface CompositeComponent
public void setNavpanelDisplay(CompositeComponent.NavpanelDisplay mode)
NORMAL
.mode
- new display modepublic void componentChanged(ComponentChangeEvent e)
This method should propagate the notification up the component hierarchy
by calling notifyParentOfChange
.
componentChanged
in interface ComponentChangeListener
componentChanged
in interface CompositeComponent
e
- optional argument giving specific information about the changepublic void updateNameMap(java.lang.String newName, java.lang.String oldName, ModelComponent comp)
updateNameMap
in interface CompositeComponent
public boolean hierarchyContainsReferences()
In particular, this means that one does not need to search outside the hierarchy when looking for dependencies.
hierarchyContainsReferences
in interface CompositeComponent
public int nextComponentNumber()
nextComponentNumber
in interface ComponentListView<C extends ModelComponent>
public int size()
ComponentListView
size
in interface ComponentListView<C extends ModelComponent>
size
in interface java.util.Collection<C extends ModelComponent>
size
in interface ListView<C extends ModelComponent>
public C get(int idx)
ComponentListView
get
in interface ComponentListView<C extends ModelComponent>
get
in interface CompositeComponent
get
in interface IndexedComponentList
get
in interface ListView<C extends ModelComponent>
idx
- index of the componentpublic java.util.Iterator<C> iterator()
ComponentListView
iterator
in interface ComponentListView<C extends ModelComponent>
iterator
in interface java.lang.Iterable<C extends ModelComponent>
iterator
in interface java.util.Collection<C extends ModelComponent>
iterator
in interface ListView<C extends ModelComponent>
public boolean contains(java.lang.Object obj)
ListView
contains
in interface java.util.Collection<C extends ModelComponent>
contains
in interface ListView<C extends ModelComponent>
obj
- element to search forpublic boolean isEmpty()
isEmpty
in interface java.util.Collection<C extends ModelComponent>
public java.lang.Class<C> getParameterType()
ParameterizedClass
getParameterType
in interface ParameterizedClass
public boolean hasParameterizedType()
ParameterizedClass
hasParameterizedType
in interface ParameterizedClass
true
if this class utilizes a parameterized type.public boolean addAll(java.util.Collection<? extends C> c)
addAll
in interface java.util.Collection<C extends ModelComponent>
public java.util.Iterator<? extends HierarchyNode> getChildren()
getChildren
in interface HierarchyNode
getChildren
in class ModelComponentBase
public boolean hasChildren()
hasChildren
in interface HierarchyNode
hasChildren
in class ModelComponentBase
public boolean add(C comp)
add
in interface MutableCompositeComponent<C extends ModelComponent>
add
in interface java.util.Collection<C extends ModelComponent>
comp
- component to be addetrue
if the component was actually addedpublic boolean addFixed(C comp)
public void add(C comp, int idx)
public boolean addNumbered(C comp, int number)
public void addComponents(ModelComponent[] comps, int[] indices, int ncomps)
indices
is not
null, it specified the index locations at which the components should be
added. It is up to the caller to insure that the specified index values
make sense; in particular, they must not exceed the final size of the
component and no two specified indices can be the same.addComponents
in interface MutableCompositeComponent<C extends ModelComponent>
comps
- list of components to be addedindices
- (optional) index locations of componentsncomps
- number of components to be addedpublic boolean remove(java.lang.Object obj)
remove
in interface MutableCompositeComponent<C extends ModelComponent>
remove
in interface java.util.Collection<C extends ModelComponent>
obj
- component to be addedpublic C remove(int idx)
public void removeComponents(ModelComponent[] comps, int[] indices, int ncomps)
indices
is not
null, it is used to return the indices where the components were located.removeComponents
in interface MutableCompositeComponent<C extends ModelComponent>
comps
- components to be removedindices
- (optional) stores the indices of the removed componentsncomps
- number of components to be removedpublic void removeAll()
public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<C extends ModelComponent>
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<C extends ModelComponent>
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<C extends ModelComponent>
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<C extends ModelComponent>
public <C> C[] toArray(C[] array)
toArray
in interface java.util.Collection<C extends ModelComponent>
public void clear()
clear
in interface java.util.Collection<C extends ModelComponent>
public void ensureCapacity(int cap)
public boolean isEditable()
MutableCompositeComponent
false
,
it should not be possible to use the GUU to delete child components.isEditable
in interface MutableCompositeComponent<C extends ModelComponent>
true
if this component can be edited from the GUI.public void setEditable(boolean editable)
public void setOneBasedNumbering(boolean enable)
enable
- if true
, enabled one-based numberingpublic boolean getOneBasedNumbering()
setOneBasedNumbering(boolean)
.true
if one-based numbering is enabledpublic void setShortName(java.lang.String name)
public java.lang.String getShortName()
ComponentListView
getShortName
in interface ComponentListView<C extends ModelComponent>
public boolean contains(C comp)
contains
in interface ComponentListView<C extends ModelComponent>
comp
- component to search forpublic void scan(ReaderTokenizer rtok, java.lang.Object ref) throws java.io.IOException
ModelComponentBase
write
.scan
in interface ModelComponent
scan
in interface Scannable
scan
in class ModelComponentBase
rtok
- Tokenizer from which to scan the elementref
- optional reference object which can be used for resolving references to
other objectsjava.io.IOException
- if an I/O or formatting error occuredpublic void postscan(java.util.Deque<ScanToken> tokens, CompositeComponent ancestor) throws java.io.IOException
PostScannable
scan()
method and stored in the token queue.
The most common use of this method is to resolve the paths
of component references, which may not have been created
at the time of the initial scan()
call.postscan
in interface PostScannable
postscan
in class ModelComponentBase
tokens
- token information that was stored during
scan()
.ancestor
- ancestor component with respect to which
reference component paths are defined.java.io.IOException
- if an error is encountered (such as a reference to a
non-existent component)public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class ModelComponentBase
java.lang.CloneNotSupportedException
public ComponentList<C> copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
copy
in class ModelComponentBase
public void invalidateNumbers()
public void resetNumbersToIndices()