use of artisynth.core.gui.Displayable in project artisynth_core by artisynth.
the class InputNumericProbeEditor method setInputProbe.
// //
// // Called when a user adds an input property
// //
// public void addInputProbeProperty (int index, Property prop)
// {
// myProperties.set (index, prop);
//
// NumericConverter conv = new NumericConverter(prop.get());
// String varname = getUniqueVariableName(INPUT_PREFIX);
// NumericProbeVariable var = new NumericProbeVariable(conv.getDimension());
// myVariables.put (varname, var);
// NumericProbeDriver driver = new NumericProbeDriver();
// driver.setExpression (varname, myVariables);
// myDrivers.set (index, driver);
//
// AddVectorPane newVec = new AddVectorPane(this, varname);
// newVec.setDim(var.getDimension());
// addVectorGUI(newVec);
// super.updateGUI();
// }
private void setInputProbe() {
ArrayList<String> variableNames = new ArrayList<String>();
ArrayList<Integer> variableDims = new ArrayList<Integer>();
for (Map.Entry<String, NumericProbeVariable> entry : myVariables.entrySet()) {
variableNames.add(entry.getKey());
variableDims.add(entry.getValue().getDimension());
System.out.println(entry.getKey() + " -- " + entry.getValue());
}
int[] varDimsInt = new int[variableDims.size()];
for (int i = 0; i < variableDims.size(); i++) {
varDimsInt[i] = variableDims.get(i);
// System.out.println("size of V="+variableDims.get(i));
}
NumericInputProbe probeToSet;
if (oldProbe == null) {
ModelComponent refComp = ComponentUtils.getPropertyComponent(myProperties.get(0));
probeToSet = new NumericInputProbe(refComp);
} else {
probeToSet = oldProbe;
}
probeToSet.set(myProperties.toArray(new Property[0]), getDriverExpressions(), variableNames.toArray(new String[0]), varDimsInt);
probeToSet.setStartTime(startTimeField.getDoubleValue());
probeToSet.setStopTime(endTimeField.getDoubleValue());
probeToSet.setScale(scaleField.getDoubleValue());
probeToSet.setName(probeNameField.getStringValue());
String attachedFilePath = attachedFileField.getStringValue();
if (attachedFilePath != null) {
if (attachedFilePath.equals("") || !attachedInputFileValid(attachedFilePath, null)) {
attachedFilePath = null;
}
}
if (attachedFilePath != null) {
probeToSet.setAttachedFileName(attachedFilePath);
try {
probeToSet.load();
((Displayable) probeToSet).updateDisplays();
} catch (IOException e) {
System.err.println("Couldn't load probe ");
e.printStackTrace();
probeToSet.setAttachedFileName(null);
}
} else {
probeToSet.setAttachedFileName(null);
if (probeToSet.getNumericList().isEmpty()) {
// add knots at beginning and end
if (probeToSet.isSettable()) {
probeToSet.setData(probeToSet.getStartTime());
probeToSet.setData(probeToSet.getStopTime());
} else {
probeToSet.loadEmpty();
}
}
}
if (oldProbe == null) {
AddComponentsCommand cmd = new AddComponentsCommand("add input probe", probeToSet, myMain.getRootModel().getInputProbes());
myMain.getUndoManager().saveStateAndExecute(cmd);
}
}
use of artisynth.core.gui.Displayable in project artisynth_core by artisynth.
the class ProbeInfo method expandProbe.
public void expandProbe() {
int width = myDisplayArea.getWidth();
int height = GuiStorage.PROBE_DETAIL_HEIGHT;
if (getProbe() instanceof Displayable) {
Displayable dispProbe = (Displayable) getProbe();
JPanel display = dispProbe.getDisplay(width, height, false);
if (display instanceof NumericProbePanel && getProbe() instanceof NumericProbeBase) {
smallDisplay = (NumericProbePanel) display;
}
myDisplayArea.add(display);
}
myLabel.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, Color.BLACK));
myController.updateComponentSizes();
updateProbeDisplays();
}
Aggregations