artisynth.core.probes
Class NumericInputProbe

java.lang.Object
  extended by artisynth.core.modelbase.ModelComponentBase
      extended by artisynth.core.modelbase.ModelAgentBase
          extended by artisynth.core.probes.Probe
              extended by artisynth.core.probes.NumericProbeBase
                  extended by artisynth.core.probes.NumericInputProbe
All Implemented Interfaces:
Displayable, CopyableComponent, HasState, ModelAgent, ModelComponent, java.lang.Cloneable, HasProperties, HierarchyNode, Scannable
Direct Known Subclasses:
AffineNumericInputProbe

public class NumericInputProbe
extends NumericProbeBase
implements CopyableComponent


Nested Class Summary
 
Nested classes/interfaces inherited from interface artisynth.core.modelbase.ModelComponent
ModelComponent.NavpanelVisibility
 
Field Summary
static double EXPLICIT_TIME
           
static PropertyList myProps
           
 
Fields inherited from class artisynth.core.probes.Probe
useOldSaveMethod, writeStartStopTimeInSeconds
 
Fields inherited from class artisynth.core.modelbase.ModelComponentBase
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
 
Fields inherited from interface artisynth.core.modelbase.CopyableComponent
COPY_REFERENCES
 
Constructor Summary
NumericInputProbe()
           
NumericInputProbe(ModelComponent e)
           
NumericInputProbe(ModelComponent e, java.lang.String[] propNames, double startTime, double stopTime)
           
NumericInputProbe(ModelComponent e, java.lang.String propName, double startTime, double stopTime)
           
NumericInputProbe(ModelComponent e, java.lang.String propName, java.lang.String fileName)
           
NumericInputProbe(Property[] props, ModelComponent e)
           
NumericInputProbe(Property[] props, ModelComponent e, double ymin, double ymax)
           
NumericInputProbe(Property prop, ModelComponent e)
           
NumericInputProbe(Property prop, ModelComponent e, double ymin, double ymax)
           
 
Method Summary
 void addData(double[] data, double timeStep)
          Adds one or more data samples to internal data list.

Samples can be evenly distributed with given time step or time of each sample can be explicitly set.
 void addData(double t, double[] v)
           
 void addData(double t, Vector v)
          Adds data to internal data list.
 void addData(double t, VectorNd v)
          Adds data to internal data list.
 void addData(java.io.File file, double timeStep)
           
 void addData(ReaderTokenizer rtok, double timeStep)
           
 void apply(double t)
          Interpolate data to specified time and set related properties values.
 java.lang.Object clone()
           
 ModelComponent copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
          Create a copy of this component.
 void createNumericList(int vsize)
           
 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).
 PropertyList getAllPropertyInfo()
          Returns a list giving static information about all properties exported by this object.
 boolean getCopyReferences(java.util.List<ModelComponent> refs, ModelComponent ancestor)
          Collects external references which must also be copied in order to duplicate this component.
 boolean getExtendData()
          Returns true if data is to be extended past the last knot point
 NumericList getInput()
           
 void getState(ComponentState state)
          Get the current state of this component.
 boolean hasState()
          Returns true if this component has state.
 boolean isDuplicatable()
          Returns true if this component can be duplicated.
 boolean isInput()
          Returns true if this probe is an input probe, and false otherwise.
 boolean isSettable()
           
 void load()
          When called (perhaps by the Artsynth timeline), causes information about this probe to be loaded from the attached file.
 void loadEmpty()
           
 void postscan(java.util.Deque<ScanToken> tokens, CompositeComponent ancestor)
          Performs any required post-scanning for this component.
 void read(java.io.File file)
          Reads the start and stop times, scale value, and data for this probe from an ascii file.
 void save()
          When called (perhaps by the Artsynth timeline), causes information about this probe to be written to the attached file.
 void scan(ReaderTokenizer rtok, java.lang.Object ref)
          Scans this element from a ReaderTokenizer.
 boolean scanItem(ReaderTokenizer rtok, java.util.Deque<ScanToken> tokens)
           
 void set(Property[] props, java.lang.String[] driverExpressions, java.lang.String[] variableNames, int[] variableDimensions)
           
 void set(Property[] props, java.lang.String[] driverExpressions, java.lang.String[] variableNames, int[] variableDimensions, PlotTraceInfo[] traceInfos)
           
 void setAttachedFileName(java.lang.String fileName)
           
 void setAttachedFileName(java.lang.String fileName, java.lang.String fmtStr)
           
 void setData(double sec)
           
 void setExtendData(boolean extend)
          Enables extension of data past the last knot point.
 void setInputProperties(Property[] props)
           
 void setState(ComponentState state)
          Set the state of this component.
 void write(java.io.PrintWriter pw, java.lang.String fmtStr)
          Writes the start and stop times, scale value, and data for this probe to a PrintWriter, using the format described for read(File).
 void writeItems(java.io.PrintWriter pw, NumberFormat fmt, CompositeComponent ancestor)
          write components to a file
 
Methods inherited from class artisynth.core.probes.NumericProbeBase
applyDefaultDisplayRanges, decreaseDisplayRanges, dispose, getAttachedProperties, getData, getDefaultDisplayMax, getDefaultDisplayMin, getDefaultDisplayRange, getDisplay, getDrivers, getFormat, getInterpolation, getInterpolationOrder, getLegend, getMinMaxValues, getNumericList, getOrderedTraceIndex, getPlotTraceInfo, getRange, getRangeHints, getTraceColor, getTraceLabel, getValues, getVariables, getVsize, increaseDisplayRanges, isCloneable, isEmpty, isPrintable, isSmallDisplayVisible, isTraceVisible, isValidVariableName, print, removeDisplay, removeLegend, resetTraceColors, resetTraceOrder, scaleNumericList, setDefaultDisplayRange, setDefaultDisplayRange, setFormat, setInterpolation, setInterpolationOrder, setLegendLabels, setRangeHints, setScale, setSmallDisplayVisible, setTraceColor, setTraceLabel, setTraceOrder, setTraceVisible, setValues, swapPlotTraceOrder, updateDisplays, updateDisplays, updateDisplaysForPropertyChanges, updateDisplaysWithoutAutoRanging
 
Methods inherited from class artisynth.core.probes.Probe
getAttachedFile, getAttachedFileName, getChildren, getDefaultScale, getDefaultStartTime, getDefaultStopTime, getDefaultUpdateInterval, getInitialState, getProperty, getScale, getStartTime, getStopTime, getTimelineTime, getTrack, getUpdateInterval, getVirtualTime, hasAttachedFile, hasChildren, isActive, isAttachedFileRelative, isEventTime, isScalable, nextEventTime, setActive, setName, setScalable, setStartStopTimes, setStartTime, setStopTime, setTrack, setUpdateInterval
 
Methods inherited from class artisynth.core.modelbase.ModelAgentBase
finalize, getModel, initialize, setModel, setModelFromComponent, write
 
Methods inherited from class artisynth.core.modelbase.ModelComponentBase
checkFlag, checkName, checkNameUniqueness, clearFlag, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getSoftReferences, isFixed, isMarked, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setSelected, updateReferences
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface artisynth.core.modelbase.ModelComponent
connectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, isFixed, isMarked, isSelected, notifyParentOfChange, setFixed, setMarked, setName, setNumber, setParent, setSelected, updateReferences
 
Methods inherited from interface maspack.properties.HasProperties
getProperty
 
Methods inherited from interface maspack.properties.HierarchyNode
getChildren, hasChildren
 
Methods inherited from interface maspack.util.Scannable
isWritable, write
 

Field Detail

EXPLICIT_TIME

public static final double EXPLICIT_TIME
See Also:
Constant Field Values

myProps

public static PropertyList myProps
Constructor Detail

NumericInputProbe

public NumericInputProbe()

NumericInputProbe

public NumericInputProbe(ModelComponent e)

NumericInputProbe

public NumericInputProbe(ModelComponent e,
                         java.lang.String propName,
                         java.lang.String fileName)
                  throws java.io.IOException
Throws:
java.io.IOException

NumericInputProbe

public NumericInputProbe(ModelComponent e,
                         java.lang.String propName,
                         double startTime,
                         double stopTime)

NumericInputProbe

public NumericInputProbe(ModelComponent e,
                         java.lang.String[] propNames,
                         double startTime,
                         double stopTime)

NumericInputProbe

public NumericInputProbe(Property prop,
                         ModelComponent e)

NumericInputProbe

public NumericInputProbe(Property prop,
                         ModelComponent e,
                         double ymin,
                         double ymax)

NumericInputProbe

public NumericInputProbe(Property[] props,
                         ModelComponent e)

NumericInputProbe

public NumericInputProbe(Property[] props,
                         ModelComponent e,
                         double ymin,
                         double ymax)
Method Detail

getAllPropertyInfo

public PropertyList getAllPropertyInfo()
Description copied from interface: HasProperties
Returns a list giving static information about all properties exported by this object.

Specified by:
getAllPropertyInfo in interface HasProperties
Overrides:
getAllPropertyInfo in class NumericProbeBase
Returns:
static information for all exported properties

setInputProperties

public void setInputProperties(Property[] props)

setExtendData

public void setExtendData(boolean extend)
Enables extension of data past the last knot point.

Parameters:
extend - true if data is to be extended past the last knot point

getExtendData

public boolean getExtendData()
Returns true if data is to be extended past the last knot point

Returns:
true if data is extended

read

public void read(java.io.File file)
          throws java.io.IOException
Reads the start and stop times, scale value, and data for this probe from an ascii file. The following information should be provided in order, separated by white space: The start and stop times can be indicated in either seconds or nanoseconds. The former is assumed if the value is a double with a decimal point. For example, the following input
 2.0 10.0 1.2
 linear 2 explicit
 0.0 2.0 2.0
 1.1 4.0 3.0
 3.0 0.0 1.0
 
specifies a probe with a start and stop time of 2 and 10 seconds, respectively, a scale value of 1.2, linear interpolation, 2 values at each knot point, and three knot points at times 0.0, 1.1, and 3.0. If knot time is given implicitly by a time setp, then time is assumed to start at 0. The following input
 2000000000 3000000000 2.5
 step 2 2.0
 2.0 2.0
 4.0 3.0
 0.0 1.0
 
specifies a probe with a start and stop time of 2 and 3 seconds, respectively, a scale value of 2.5, step interpolation, 2 values at each knot point, and three knot points with times of 0, 2.0, and 4.0 (given implicity by a step size of 2.0).

The character '#' is a comment character, causing all subsequent input up to the next new line to be ignored.

Parameters:
file - File from which to read the probe information
Throws:
java.io.IOException - if an I/O or format error occurred.

write

public void write(java.io.PrintWriter pw,
                  java.lang.String fmtStr)
           throws java.io.IOException
Writes the start and stop times, scale value, and data for this probe to a PrintWriter, using the format described for read(File). The format used for producing floating point numbers can be controlled using a printf-style format string, details of which are described in NumberFormat.

Parameters:
pw - writer which accepts the output
fmtStr - printf-style format string (if set to null then "%g" will be assumed, which will produce full precision output).
Throws:
java.io.IOException - if an I/O error occurs.

setAttachedFileName

public void setAttachedFileName(java.lang.String fileName)
Overrides:
setAttachedFileName in class Probe

setAttachedFileName

public void setAttachedFileName(java.lang.String fileName,
                                java.lang.String fmtStr)

save

public void save()
          throws java.io.IOException
When called (perhaps by the Artsynth timeline), causes information about this probe to be written to the attached file.

Overrides:
save in class Probe
Throws:
java.io.IOException
See Also:
write(java.io.PrintWriter, java.lang.String)

loadEmpty

public void loadEmpty()

load

public void load()
          throws java.io.IOException
When called (perhaps by the Artsynth timeline), causes information about this probe to be loaded from the attached file.

Overrides:
load in class Probe
Throws:
java.io.IOException

addData

public void addData(java.io.File file,
                    double timeStep)
             throws java.io.IOException
Throws:
java.io.IOException

addData

public void addData(double[] data,
                    double timeStep)
Adds one or more data samples to internal data list.

Samples can be evenly distributed with given time step or time of each sample can be explicitly set. In this case, timeStep must have value of EXPLICIT_TIME and before every data sample must be its temporal information.
Internal data sample size of this input probe can be determined by NumericProbeBase.getVsize() method.

Parameters:
data - data array, which can contain multiple data samples
timeStep - time step in seconds or EXPLICIT_TIME if data contains explicitly set timestamps

addData

public void addData(double t,
                    VectorNd v)
Adds data to internal data list.

Parameters:
t - time in seconds
v - vector of values
Throws:
java.lang.IllegalArgumentException - if size of vector is not equal to NumericProbeBase.getVsize()

addData

public void addData(double t,
                    double[] v)

addData

public void addData(double t,
                    Vector v)
Adds data to internal data list.

Parameters:
t - time in seconds
v - vector of values
Throws:
java.lang.IllegalArgumentException - if size of vector is not equal to NumericProbeBase.getVsize()

addData

public void addData(ReaderTokenizer rtok,
                    double timeStep)
             throws java.io.IOException
Throws:
java.io.IOException

apply

public void apply(double t)
Interpolate data to specified time and set related properties values.

Specified by:
apply in class NumericProbeBase
Parameters:
t - current time

hasState

public boolean hasState()
Description copied from interface: ModelComponent
Returns true if this component has state. Structure change events involving components that have state will cause the current state history of of the system to be cleared.

Specified by:
hasState in interface ModelComponent
Overrides:
hasState in class Probe

createState

public ComponentState createState(ComponentState prevState)
Description copied from interface: HasState
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). 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.

Specified by:
createState in interface HasState
Overrides:
createState in class Probe
Parameters:
prevState - If non-null, supplies a previous state that was created by this component and which can be used to provide pre-sizing hints.
Returns:
new object for storing this component's state

getState

public void getState(ComponentState state)
Description copied from interface: HasState
Get the current state of this component.

Specified by:
getState in interface HasState
Overrides:
getState in class Probe
Parameters:
state - receives the state information

setState

public void setState(ComponentState state)
Description copied from interface: HasState
Set the state of this component.

Specified by:
setState in interface HasState
Overrides:
setState in class Probe
Parameters:
state - state to be copied

isSettable

public boolean isSettable()
Overrides:
isSettable in class Probe

setData

public void setData(double sec)
Overrides:
setData in class Probe

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class NumericProbeBase
Throws:
java.lang.CloneNotSupportedException

getInput

public NumericList getInput()

scanItem

public boolean scanItem(ReaderTokenizer rtok,
                        java.util.Deque<ScanToken> tokens)
                 throws java.io.IOException
Throws:
java.io.IOException

scan

public void scan(ReaderTokenizer rtok,
                 java.lang.Object ref)
          throws java.io.IOException
Description copied from class: ModelComponentBase
Scans this element from a ReaderTokenizer. The expected text format is assumed to be compatible with that produced by write.

Specified by:
scan in interface ModelComponent
Specified by:
scan in interface Scannable
Overrides:
scan in class Probe
Parameters:
rtok - Tokenizer from which to scan the element
ref - optional reference object which can be used for resolving references to other objects
Throws:
java.io.IOException - if an I/O or formatting error occured

postscan

public void postscan(java.util.Deque<ScanToken> tokens,
                     CompositeComponent ancestor)
              throws java.io.IOException
Description copied from interface: ModelComponent
Performs any required post-scanning for this component. This involves handling any information whose processing was deferred during the 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.

Specified by:
postscan in interface ModelComponent
Overrides:
postscan in class ModelComponentBase
Parameters:
tokens - token information that was stored during scan().
ancestor - ancestor component with respect to which reference component paths are defined.
Throws:
java.io.IOException

writeItems

public void writeItems(java.io.PrintWriter pw,
                       NumberFormat fmt,
                       CompositeComponent ancestor)
                throws java.io.IOException
Description copied from class: Probe
write components to a file

Throws:
java.io.IOException

isInput

public boolean isInput()
Description copied from class: Probe
Returns true if this probe is an input probe, and false otherwise.

Overrides:
isInput in class Probe
Returns:
true if this is an input probe

set

public void set(Property[] props,
                java.lang.String[] driverExpressions,
                java.lang.String[] variableNames,
                int[] variableDimensions)

set

public void set(Property[] props,
                java.lang.String[] driverExpressions,
                java.lang.String[] variableNames,
                int[] variableDimensions,
                PlotTraceInfo[] traceInfos)

createNumericList

public void createNumericList(int vsize)
Overrides:
createNumericList in class NumericProbeBase

isDuplicatable

public boolean isDuplicatable()
Returns true if this component can be duplicated. Duplication means that we can expect to be able to make a complete copy of the component along with all it's external references. This method should return true if and only if CopyableComponent.getCopyReferences(java.util.List, artisynth.core.modelbase.ModelComponent) returns true.

This method is not currently used. It is intended to provide a faster way of determining if a component can be duplicated, without having to use CopyableComponent.getCopyReferences(java.util.List, artisynth.core.modelbase.ModelComponent) to build the list of copy references.

Specified by:
isDuplicatable in interface CopyableComponent
Returns:
true if this component can be duplicated.

getCopyReferences

public boolean getCopyReferences(java.util.List<ModelComponent> refs,
                                 ModelComponent ancestor)
Collects external references which must also be copied in order to duplicate this component. These references should exclude those which are contained within a specified component hierarchy. This method should return true if and only if CopyableComponent.isDuplicatable() returns true.

Specified by:
getCopyReferences in interface CopyableComponent
Parameters:
refs - list to which references are appended
ancestor - root node of the hierarchy from which references are to be excluded
Returns:
false if it is discovered that the component cannot be duplicated

copy

public ModelComponent copy(int flags,
                           java.util.Map<ModelComponent,ModelComponent> copyMap)
Description copied from interface: CopyableComponent
Create a copy of this component. If COPY_REFERENCES is set in flags, then any component referenced by this component should itself be set to a copy. This should be done first checking copyMap for an existing copy of the referenced component. If there is no existing copy, then a copy should be created by calling copy recursively and adding the new copy to copyMap.

Specified by:
copy in interface CopyableComponent
Overrides:
copy in class ModelComponentBase