public abstract class ModelBase extends ComponentList<ModelComponent> implements Model, HasMenuItems, java.awt.event.ActionListener
ModelComponent.NavpanelVisibility
CompositeComponent.NavpanelDisplay
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_MAX_STEP_SIZE |
static PropertyList |
myProps |
DEFAULT_NAVPANEL_DISPLAY
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
STATE_IS_VOLATILE
Constructor and Description |
---|
ModelBase() |
ModelBase(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent event)
By default, this method does nothing.
|
abstract StepAdjustment |
advance(double t0,
double t1,
int flags)
Advances this model from time t0 to time t1.
|
ModelBase |
copy(java.util.Map<ModelComponent,ModelComponent> copyMap,
int flags) |
ComponentState |
createState(ComponentState prevState)
Factory routine to create a state object for this component, which can
then be used as an argument for
HasState.setState(artisynth.core.modelbase.ComponentState) and HasState.getState(artisynth.core.modelbase.ComponentState) . |
void |
dispose()
Called when the model is discarded.
|
PropertyList |
getAllPropertyInfo()
Returns a list giving static information about all properties exported by
this object.
|
static double |
getDefaultMaxStepSize()
Queries the default value used to initialize the maximum step
size for a model when it is created.
|
void |
getInitialState(ComponentState newstate,
ComponentState oldstate)
Gets an initial state for this component and returns the value in
state . |
double |
getMaxStepSize()
Returns the maximum step size by which this model should be advanced
within a simulation loop.
|
boolean |
getMenuItems(java.util.List<java.lang.Object> items)
Returns objects to be displayed under a "Model" menu in the main
ArtiSynth frame.
|
void |
getState(ComponentState state)
Get the current state of this component.
|
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.
|
void |
initialize(double t)
Causes this model to initialize itself at time t.
|
StepAdjustment |
preadvance(double t0,
double t1,
int flags)
Prepares this model for advance from time t0 to time t1.
|
static void |
setDefaultMaxStepSize(double step)
Sets default value used to initialize the maximum step
size for a model when it is created.
|
void |
setMaxStepSize(double sec)
Sets the maximum step size by which this model should be advanced within a
simulation loop.
|
void |
setState(ComponentState state)
Set the state of this component.
|
add, add, addAll, addComponents, addFixed, addNumbered, clear, clone, componentChanged, contains, contains, containsAll, copy, ensureCapacity, findComponent, get, get, getByNumber, getChildren, getNavpanelDisplay, getNumberLimit, getOneBasedNumbering, getParameterType, getShortName, hasChildren, indexOf, invalidateNumbers, isEditable, isEmpty, iterator, nextComponentNumber, numComponents, postscan, remove, remove, removeAll, removeAll, removeComponents, resetNumbersToIndices, retainAll, scan, set, setEditable, setNavpanelDisplay, setNumbered, setOneBasedNumbering, setShortName, size, toArray, toArray, updateNameMap
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
connectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected, setWritable, updateReferences
getProperty
getChildren, hasChildren
postscan
isWritable, write
getName
public static final double DEFAULT_MAX_STEP_SIZE
public static PropertyList myProps
public static double getDefaultMaxStepSize()
public static void setDefaultMaxStepSize(double step)
step
- new step sizepublic PropertyList getAllPropertyInfo()
HasProperties
getAllPropertyInfo
in interface HasProperties
getAllPropertyInfo
in class ComponentList<ModelComponent>
public void setState(ComponentState state)
public void getState(ComponentState state)
public void getInitialState(ComponentState newstate, ComponentState oldstate)
state
. If prevstate
is non-null, then it is
assumed to contain a previous initial state value returned by this
method, and state
should be set to be as consistent with
this previous state as possible. For example, suppose that this component
currently contains subcomponents A, B, and C, while the
prevstate
contains the state from a previous time when it
had components B, C, and D. Then state
should contain
substate values for B and C that are taken from
prevstate
. To facilitate this, the information returned in
state
should contain additional information such as the
identities of all the (current) subcomponents.getInitialState
in interface HasState
newstate
- receives the state informationoldstate
- previous state information; may be null
.public void initialize(double t)
HasState.setState(artisynth.core.modelbase.ComponentState)
, in which case t
may have an arbitrary value.initialize
in interface Model
t
- initialization time (seconds)public StepAdjustment preadvance(double t0, double t1, int flags)
If the method determines that the step size should be
reduced, it can return a StepAdjustment
object indicating
the recommended reduction. Otherwise, the method may return
null
The flags argument gives additional information that may
be relevant when advancing the model. Currently implemented
flags include Model.STATE_IS_VOLATILE
.
preadvance
in interface Model
t0
- current time (seconds)t1
- new time to advance to (seconds)flags
- additional information relevant to the advancepublic abstract StepAdjustment advance(double t0, double t1, int flags)
If the method determines that the step size should be
reduced, it can return a StepAdjustment
object indicating
the recommended reduction. Otherwise, the method may return
null
The flags argument gives additional information that may
be relevant when advancing the model. Currently implemented
flags include Model.STATE_IS_VOLATILE
.
public double getMaxStepSize()
getMaxStepSize
in interface Model
public void setMaxStepSize(double sec)
sec
- maximum step size (seconds)public ComponentState createState(ComponentState prevState)
HasState.setState(artisynth.core.modelbase.ComponentState)
and HasState.getState(artisynth.core.modelbase.ComponentState)
. The state object does not have to be set to the component's
current state. If the component does not have any state information,
this method should return an instance of
EmptyState
.createState
in interface HasState
prevState
- If non-null, supplies a previous state that
was created by this component and which can be used to provide
pre-sizing hints.public void dispose()
dispose
in interface Model
dispose
in interface Disposable
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
hierarchyContainsReferences
in class ComponentList<ModelComponent>
public ModelBase copy(java.util.Map<ModelComponent,ModelComponent> copyMap, int flags)
public boolean getMenuItems(java.util.List<java.lang.Object> items)
list
argument. The objects should be be items capable of being added to a
JMenu, including Component, JMenuItem, and String.
If the method returns false
(the default behavior), that is
taken to indicate that this component has no menu items.getMenuItems
in interface HasMenuItems
items
- collects the objects that should be addedfalse
if there are no items to add to the
model menu.GuiUtils.createMenuItem(java.awt.event.ActionListener, java.lang.String, java.lang.String)
public void actionPerformed(java.awt.event.ActionEvent event)
getMenuItems(java.util.List<java.lang.Object>)
.actionPerformed
in interface java.awt.event.ActionListener
public boolean hasParameterizedType()
ParameterizedClass
hasParameterizedType
in interface ParameterizedClass
hasParameterizedType
in class ComponentList<ModelComponent>
true
if this class utilizes a parameterized type.