Search in sources :

Example 6 with NumericConverter

use of maspack.properties.NumericConverter in project artisynth_core by artisynth.

the class NumericProbeBase method clone.

public Object clone() throws CloneNotSupportedException {
    NumericProbeBase probe = (NumericProbeBase) super.clone();
    probe.myNumericList = (NumericList) myNumericList.clone();
    probe.myInterpolation = new Interpolation(myInterpolation);
    if (myVariables != null) {
        // make a deep copy of the variable list
        probe.myVariables = new LinkedHashMap<String, NumericProbeVariable>();
        for (Map.Entry<String, NumericProbeVariable> entry : myVariables.entrySet()) {
            probe.myVariables.put(entry.getKey(), new NumericProbeVariable(entry.getValue()));
        }
    }
    if (myDrivers != null) {
        probe.myDrivers = new ArrayList<NumericProbeDriver>();
        for (NumericProbeDriver oldDriver : myDrivers) {
            NumericProbeDriver driver = new NumericProbeDriver();
            try {
                driver.setExpression(oldDriver.getExpression(), probe.myVariables);
            } catch (Exception e) {
                throw new InternalErrorException("Illegal driver expression '" + oldDriver.getExpression() + "': " + e.getMessage());
            }
            probe.myDrivers.add(driver);
        }
    }
    if (myPropList != null) {
        probe.myPropList = (ArrayList<Property>) myPropList.clone();
    }
    if (myConverters != null) {
        probe.myConverters = new NumericConverter[myConverters.length];
        for (int i = 0; i < myConverters.length; i++) {
            probe.myConverters[i] = new NumericConverter(myConverters[i]);
        }
    }
    // clear the displays because these are lazily allocated and
    // we don't want them reused
    probe.mySmallDisplay = null;
    probe.myDisplays = new ArrayList<NumericProbePanel>();
    // attached file should also not be brought into clone
    probe.myAttachedFileName = null;
    return probe;
}
Also used : NumericProbePanel(artisynth.core.gui.NumericProbePanel) PyString(org.python.core.PyString) IOException(java.io.IOException) Interpolation(maspack.interpolation.Interpolation) NumericConverter(maspack.properties.NumericConverter) PyStringMap(org.python.core.PyStringMap) Property(maspack.properties.Property)

Aggregations

NumericConverter (maspack.properties.NumericConverter)6 NumericProbeDriver (artisynth.core.probes.NumericProbeDriver)2 NumericProbeVariable (artisynth.core.probes.NumericProbeVariable)2 NumericList (maspack.interpolation.NumericList)2 NumericProbePanel (artisynth.core.gui.NumericProbePanel)1 IOException (java.io.IOException)1 Interpolation (maspack.interpolation.Interpolation)1 VectorNd (maspack.matrix.VectorNd)1 Property (maspack.properties.Property)1 PyString (org.python.core.PyString)1 PyStringMap (org.python.core.PyStringMap)1