Search in sources :

Example 1 with DoubleField

use of maspack.widgets.DoubleField in project artisynth_core by artisynth.

the class MenuBarHandler method createStepDisplay.

private DoubleField createStepDisplay() {
    DoubleField display = new DoubleField("step:", 0, "%7.5f");
    display.setToolTipText("maximum step size");
    display.getTextField().setToolTipText("maximum step size");
    // display.setEnabledAll (false);
    display.setColumns(5);
    display.addValueChangeListener(this);
    display.addValueCheckListener(new ValueCheckListener() {

        public Object validateValue(ValueChangeEvent e, StringHolder errMsg) {
            double dval = ((Double) e.getValue()).doubleValue();
            if (dval <= 0) {
                return PropertyUtils.illegalValue("value must be positive", errMsg);
            } else {
                return PropertyUtils.validValue(e.getValue(), errMsg);
            }
        }
    });
    return display;
}
Also used : ValueCheckListener(maspack.widgets.ValueCheckListener) ValueChangeEvent(maspack.widgets.ValueChangeEvent) StringHolder(maspack.util.StringHolder) DoubleField(maspack.widgets.DoubleField)

Example 2 with DoubleField

use of maspack.widgets.DoubleField in project artisynth_core by artisynth.

the class NumericProbeEditor method fillPanes.

private void fillPanes() {
    vectorPane.removeAll();
    propPane.removeAll();
    addVectorButton = new JButton(GuiStorage.getAddIcon());
    GuiUtils.setFixedSize(addVectorButton, 25, 25);
    addVectorButton.addActionListener(this);
    addVectorButton.setActionCommand("Add");
    addVectorButton.setAlignmentX(LEFT_ALIGNMENT);
    addVectorButton.setOpaque(true);
    addPropertyButton = new JButton(GuiStorage.getAddIcon());
    GuiUtils.setFixedSize(addPropertyButton, 25, 25);
    addPropertyButton.setActionCommand("Add Property");
    addPropertyButton.addActionListener(this);
    addPropertyButton.setAlignmentX(LEFT_ALIGNMENT);
    addPropertyButton.setOpaque(true);
    infoPaneA = new JPanel();
    infoPaneA.setLayout(new BoxLayout(infoPaneA, BoxLayout.X_AXIS));
    infoPaneA.setOpaque(false);
    infoPaneB = new JPanel();
    infoPaneB.setLayout(new BoxLayout(infoPaneB, BoxLayout.X_AXIS));
    infoPaneB.setOpaque(false);
    nameLabel = new JLabel("Name");
    infoPaneA.setAlignmentX(LEFT_ALIGNMENT);
    infoPaneA.add(nameLabel);
    infoPaneA.add(Box.createRigidArea(new Dimension(15, 0)));
    infoPaneA.add(Box.createHorizontalGlue());
    infoPaneA.add(new JLabel("Dim"));
    infoPaneC = new JPanel();
    infoPaneC.setLayout(new BoxLayout(infoPaneC, BoxLayout.X_AXIS));
    infoPaneC.add(Box.createHorizontalGlue());
    infoPaneC.add(new JLabel("Formula"));
    infoPaneC.add(Box.createHorizontalGlue());
    infoPaneC.setOpaque(false);
    infoPaneC.setAlignmentX(LEFT_ALIGNMENT);
    infoPaneB.add(Box.createRigidArea(new Dimension(50, 0)));
    infoPaneB.add(Box.createHorizontalGlue());
    infoPaneB.add(new JLabel("Component"));
    infoPaneB.add(Box.createHorizontalGlue());
    infoPaneB.add(new JLabel("Property"));
    infoPaneB.setAlignmentX(LEFT_ALIGNMENT);
    infoPaneB.add(Box.createRigidArea(new Dimension(100, 0)));
    vectorPane.add(infoPaneA);
    propPane.add(infoPaneB);
    equationPane.add(infoPaneC);
    // filePane.add(new JLabel("File:"));
    // filePane.add(horizontalSpacer(10));
    attachedFileField = new StringField("attached file", 24);
    // filePane.add(attachedFileField);
    // filePane.add(horizontalSpacer(10));
    browseButton = new JButton("Browse");
    browseButton.addActionListener(this);
    attachedFileField.addMajorComponent(browseButton);
    // filePane.add(browseButton);
    // todo: retreive default values from Probe class
    startTimeField = new DoubleField("start time", Probe.getDefaultStartTime());
    startTimeField.setColumns(8);
    startTimeField.setFormat("%8.4f");
    endTimeField = new DoubleField("end time", Probe.getDefaultStopTime());
    endTimeField.setColumns(8);
    endTimeField.setFormat("%8.4f");
    scaleField = new DoubleField("scale", Probe.getDefaultScale());
    scaleField.setColumns(8);
    intervalField = new DoubleField("update interval", 0.01, "%8.4f");
    intervalField.setColumns(8);
    // intervalField.setFormat ("%8.4f");
    probeNameField = new StringField("name", 8);
    probeNameField.setValue("");
    probeNameField.setStretchable(true);
    dispUpperField = new DoubleField("upper", 50);
    dispUpperField.setColumns(4);
    dispLowerField = new DoubleField("lower", -50);
    dispLowerField.setColumns(4);
    rangeField = new DoubleIntervalField("display range");
    rangeField.setGUIVoidEnabled(true);
    rangeField.setVoidValueEnabled(true);
    // optionsPane.add(probeNameField);
    // optionsPane.add(horizontalSpacer(5));
    // optionsPane.add(startTimeField);
    // optionsPane.add(horizontalSpacer(5));
    // optionsPane.add(endTimeField);
    // optionsPane.add(horizontalSpacer(5));
    leftPropertyPanel.addWidget(probeNameField);
    leftPropertyPanel.addWidget(startTimeField);
    leftPropertyPanel.addWidget(endTimeField);
    // optionsPane.add(scaleField);
    // optionsPane.add(Box.createRigidArea(new Dimension(5, 0)));
    addProbeButton = new JButton("Done");
    addProbeButton.addActionListener(this);
    closeButton = new JButton("Cancel");
    closeButton.addActionListener(this);
    bottomPane.add(addProbeButton);
    bottomPane.add(Box.createRigidArea(new Dimension(10, 0)));
    bottomPane.add(closeButton);
}
Also used : JPanel(javax.swing.JPanel) DoubleIntervalField(maspack.widgets.DoubleIntervalField) BoxLayout(javax.swing.BoxLayout) StringField(maspack.widgets.StringField) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) DoubleField(maspack.widgets.DoubleField)

Example 3 with DoubleField

use of maspack.widgets.DoubleField in project artisynth_core by artisynth.

the class ExcitationTargetAgent method createTargetWidget.

DoubleField createTargetWidget(ExcitationComponent target, double gain) {
    String name = ComponentUtils.getPathName(myAncestor, target);
    DoubleField field = new DoubleField(name, gain);
    field.addValueChangeListener(new GainHandler(target));
    field.setLabelStretchable(true);
    field.setStretchable(true);
    return field;
}
Also used : DoubleField(maspack.widgets.DoubleField)

Example 4 with DoubleField

use of maspack.widgets.DoubleField in project artisynth_core by artisynth.

the class ExcitationTargetAgent method selectionChanged.

public void selectionChanged(SelectionEvent e) {
    ModelComponent c = e.getLastAddedComponent();
    if (isValidTarget(c)) {
        ExcitationComponent ex = (ExcitationComponent) c;
        if (myState == State.SelectingExciters && ex != myExciter && myExciter.findTarget(ex) == -1) {
            myExciter.addTarget(ex, 1.0);
            DoubleField widget = createTargetWidget(ex, 1.0);
            myTargetPanel.addWidget(widget);
            myTargetPanel.mapWidgetToComponent(widget, ex);
            myTargetPanel.revalidate();
            myTargetPanel.repaint();
        }
    // else if (myExciter.findTarget(ex) != -1)
    // { mySelectedTargets.add (ex);
    // }
    }
}
Also used : ModelComponent(artisynth.core.modelbase.ModelComponent) ExcitationComponent(artisynth.core.mechmodels.ExcitationComponent) DoubleField(maspack.widgets.DoubleField)

Example 5 with DoubleField

use of maspack.widgets.DoubleField in project artisynth_core by artisynth.

the class FemModel3dAgent method createMeshPropPanel.

private void createMeshPropPanel() {
    meshPropPanel = new LabeledComponentPanel();
    gridDimField = new VectorField("widths", DEFAULT_GRID_DIM, "%8.3f");
    gridDivField = new IntegerMultiField("divisions", DEFAULT_GRID_DIV, "%d");
    gridDimField.setStretchable(true);
    gridDivField.setStretchable(true);
    tubeDimField = new VectorField("widths (L, rin, rout)", DEFAULT_TUBE_DIM, "%8.3f");
    tubeDivField = new IntegerMultiField("divisions (nt, nl, nr)", DEFAULT_TUBE_DIV, "%d");
    tubeDimField.setStretchable(true);
    tubeDivField.setStretchable(true);
    torusDimField = new VectorField("widths (R, rin, rout)", DEFAULT_TORUS_DIM, "%8.3f");
    torusDivField = new IntegerMultiField("divisions (nt, nl, nr)", DEFAULT_TORUS_DIV, "%d");
    torusDimField.setStretchable(true);
    torusDivField.setStretchable(true);
    sphereNodesField = new IntegerSelector("node count", SPHERE_NODE_OPTIONS);
    extrusDepthField = new DoubleField("depth", DEFAULT_EXTRUSION_DEPTH, "%8.3f");
    extrusLayersField = new IntegerField("layers", DEFAULT_EXTRUSION_LAYERS, "%d");
    extrusFileField = createFileChooser("obj file", null, "obj");
    extrusFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
    extrusDepthField.setStretchable(true);
    extrusLayersField.setStretchable(true);
    ansysNodeFileField = createFileChooser("node file", null, "node");
    ansysNodeFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
    ansysElemFileField = createFileChooser("elem file", null, "elem");
    ansysElemFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
    tetgenNodeFileField = createFileChooser("node file", null, "node");
    tetgenNodeFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
    tetgenEleFileField = createFileChooser("ele file", null, "ele");
    tetgenEleFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
    ucdMeshFileField = createFileChooser("INP file", null, "inp");
    ucdMeshFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
    surfaceMeshFileField = createFileChooser("OBJ file", null, "obj");
    surfaceMeshFileField.setAlignmentX(Component.LEFT_ALIGNMENT);
    scaleField = new ScaleField("scale", 1);
    scaleField.setStretchable(true);
    autoScaleBtn = new JButton("auto scale");
    autoScaleBtn.addActionListener(this);
    scaleField.addMajorComponent(autoScaleBtn);
    restoreDefaultValues();
    if (mySettings != null) {
        meshSelector.maskValueChangeListeners(true);
        meshSelector.setValue(mySettings.meshType);
        meshSelector.maskValueChangeListeners(false);
        gridDimField.setValue(mySettings.gridWidths);
        gridDivField.setValue(mySettings.gridDivisions);
        tubeDimField.setValue(mySettings.tubeWidths);
        tubeDivField.setValue(mySettings.tubeDivisions);
        torusDimField.setValue(mySettings.torusWidths);
        torusDivField.setValue(mySettings.torusDivisions);
        sphereNodesField.setValue(mySettings.sphereNodes);
        extrusDepthField.setValue(mySettings.extrusionDepth);
        extrusLayersField.setValue(mySettings.extrusionLayers);
        if (new File(mySettings.extrusionFile).isFile()) {
            extrusFileField.setValue(mySettings.extrusionFile);
        }
        if (new File(mySettings.ansysNodeFile).isFile()) {
            ansysNodeFileField.setValue(mySettings.ansysNodeFile);
        }
        if (new File(mySettings.ansysElemFile).isFile()) {
            ansysElemFileField.setValue(mySettings.ansysElemFile);
        }
        if (new File(mySettings.tetgenNodeFile).isFile()) {
            tetgenNodeFileField.setValue(mySettings.tetgenNodeFile);
        }
        if (new File(mySettings.tetgenEleFile).isFile()) {
            tetgenEleFileField.setValue(mySettings.tetgenEleFile);
        }
        if (new File(mySettings.ucdFile).isFile()) {
            ucdMeshFileField.setValue(mySettings.ucdFile);
        }
        if (new File(mySettings.surfaceMeshFile).isFile()) {
            surfaceMeshFileField.setValue(mySettings.surfaceMeshFile);
        }
    }
    updateMeshPanel();
}
Also used : VectorField(maspack.widgets.VectorField) IntegerSelector(maspack.widgets.IntegerSelector) IntegerMultiField(maspack.widgets.IntegerMultiField) JButton(javax.swing.JButton) IntegerField(maspack.widgets.IntegerField) LabeledComponentPanel(maspack.widgets.LabeledComponentPanel) File(java.io.File) DoubleField(maspack.widgets.DoubleField) ScaleField(maspack.widgets.ScaleField)

Aggregations

DoubleField (maspack.widgets.DoubleField)19 BooleanSelector (maspack.widgets.BooleanSelector)4 Dimension (java.awt.Dimension)3 JLabel (javax.swing.JLabel)3 IntegerField (maspack.widgets.IntegerField)3 VectorField (maspack.widgets.VectorField)3 SelectableComponentPanel (artisynth.core.gui.SelectableComponentPanel)2 ModelComponent (artisynth.core.modelbase.ModelComponent)2 JButton (javax.swing.JButton)2 JScrollPane (javax.swing.JScrollPane)2 StringHolder (maspack.util.StringHolder)2 OptionPanel (maspack.widgets.OptionPanel)2 ValueChangeEvent (maspack.widgets.ValueChangeEvent)2 ValueCheckListener (maspack.widgets.ValueCheckListener)2 MuscleElementDesc (artisynth.core.femmodels.MuscleElementDesc)1 ExcitationComponent (artisynth.core.mechmodels.ExcitationComponent)1 MotionTargetComponent (artisynth.core.mechmodels.MotionTargetComponent)1 WayPoint (artisynth.core.probes.WayPoint)1 File (java.io.File)1 BoxLayout (javax.swing.BoxLayout)1