Search in sources :

Example 1 with LabeledComponentPanel

use of maspack.widgets.LabeledComponentPanel 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)

Example 2 with LabeledComponentPanel

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

the class PropertyWidgetDialog method initialize.

private void initialize() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    Container pane = getContentPane();
    pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
    LabeledComponentPanel propPanel = new LabeledComponentPanel();
    propPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    // myChooser = new PropertyChooser ("component/property", 30, myMain);
    // myChooser.setAlignmentX (Component.CENTER_ALIGNMENT);
    // myChooser.addValueChangeListener (this);
    // pane.add (Box.createRigidArea (new Dimension (0, 4)));
    // propPanel.addWidget (myChooser);
    myPropField = new PropertyField("component/property", 30, myMain);
    myPropField.setAlignmentX(Component.CENTER_ALIGNMENT);
    myPropField.addValueChangeListener(this);
    propPanel.addWidget(myPropField);
    propPanel.addWidget(new JSeparator());
    mySliderSelector = new BooleanSelector("slider");
    mySliderSelector.addValueChangeListener(this);
    propPanel.addWidget(mySliderSelector);
    myRangeField = new DoubleIntervalField("range", new DoubleInterval(0, 1), "%.6g");
    // new VectorMultiField (
    // "range", new String[] { "min:", "max:" }, new Vector2d (0, 1),
    // "%.6f");
    // myRangeField.setAlignmentX (Component.CENTER_ALIGNMENT);
    propPanel.addWidget(myRangeField);
    myLabelTextField = new StringField("labelText", 20);
    myLabelTextField.setEnabledAll(false);
    myLabelTextField.addValueCheckListener(new ValueCheckListener() {

        public Object validateValue(ValueChangeEvent e, StringHolder errMsg) {
            String newName = (String) e.getValue();
            String err = ModelComponentBase.checkName(newName, null);
            if (err != null) {
                err = "Invalid name '" + newName + "': " + err;
                newName = null;
            }
            if (errMsg != null) {
                errMsg.value = err;
            }
            return newName;
        }
    });
    propPanel.addWidget(myLabelTextField);
    myLabelFontColorSelector = new ColorSelector("labelFontColor");
    myLabelFontColorSelector.enableNullColors();
    myLabelFontColorSelector.setValue(null);
    propPanel.addWidget(myLabelFontColorSelector);
    myBackgroundColorSelector = new ColorSelector("backgroundColor");
    myBackgroundColorSelector.enableNullColors();
    myBackgroundColorSelector.setValue(null);
    propPanel.addWidget(myBackgroundColorSelector);
    // sliderPanel.add (myRangeField);
    // pane.add (Box.createRigidArea (new Dimension (0, 4)));
    // pane.add (sliderPanel);
    pane.add(propPanel);
    pane.add(new JSeparator());
    // set slider value here because valueChanged needs some
    // other widgets instantiated.
    mySliderSelector.setValue(false);
    mySliderSelector.setEnabledAll(false);
    OptionPanel options = new OptionPanel("OK Cancel", this);
    myOKButton = options.getButton("OK");
    myOKButton.setEnabled(false);
    options.setAlignmentX(Component.CENTER_ALIGNMENT);
    pane.add(options);
    pack();
}
Also used : BoxLayout(javax.swing.BoxLayout) JSeparator(javax.swing.JSeparator) Container(java.awt.Container) PropertyField(artisynth.core.gui.widgets.PropertyField) ValueCheckListener(maspack.widgets.ValueCheckListener) ValueChangeEvent(maspack.widgets.ValueChangeEvent) StringHolder(maspack.util.StringHolder) BooleanSelector(maspack.widgets.BooleanSelector) DoubleIntervalField(maspack.widgets.DoubleIntervalField) StringField(maspack.widgets.StringField) DoubleInterval(maspack.util.DoubleInterval) LabeledComponentPanel(maspack.widgets.LabeledComponentPanel) ColorSelector(maspack.widgets.ColorSelector) OptionPanel(maspack.widgets.OptionPanel)

Example 3 with LabeledComponentPanel

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

the class EditorUtils method saveMeshAsAnsysFile.

public static void saveMeshAsAnsysFile(final FemModel3d model) {
    final Main main = Main.getMain();
    JFrame frame = main.getMainFrame();
    final JDialog saveOptions = new JDialog(frame, "Save As Ansys File");
    LabeledComponentPanel savePanel = new LabeledComponentPanel();
    savePanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 0, 8));
    final StringField dirField = new StringField("Output folder", main.getModelDirectory().getAbsolutePath(), 20);
    dirField.setStretchable(true);
    dirField.getTextField().setEditable(false);
    final JButton browseButton = new JButton("Change");
    browseButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent a_evt) {
            JFileChooser chooser = new JFileChooser();
            chooser.setCurrentDirectory(main.getModelDirectory());
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            if (chooser.showSaveDialog(browseButton) == JFileChooser.APPROVE_OPTION) {
                dirField.setValue(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });
    browseButton.setMargin(new Insets(3, 3, 3, 3));
    GuiUtils.setFixedSize(browseButton, new Dimension(80, 25));
    dirField.add(browseButton);
    savePanel.addWidget(dirField);
    final StringField nodeField = new StringField("Node file name", "mesh.node", 10);
    nodeField.setStretchable(true);
    savePanel.addWidget(nodeField);
    final StringField elemField = new StringField("Element file name", "mesh.elem", 10);
    elemField.setStretchable(true);
    savePanel.addWidget(elemField);
    final JCheckBox elemType = new JCheckBox("Use custom type values for different elements");
    savePanel.addWidget(elemType);
    LabeledComponentPanel elemTypePanel = new LabeledComponentPanel();
    elemTypePanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
    final IntegerField tetField = new IntegerField("Tets (4 node)", 1);
    tetField.getTextField().setEditable(false);
    elemTypePanel.addWidget(tetField);
    final IntegerField quadtetField = new IntegerField("Quadtets (10 node)", 1);
    quadtetField.getTextField().setEditable(false);
    elemTypePanel.addWidget(quadtetField);
    final IntegerField wedgeField = new IntegerField("Wedges", 1);
    wedgeField.getTextField().setEditable(false);
    elemTypePanel.addWidget(wedgeField);
    final IntegerField hexField = new IntegerField("Hexs (8 node)", 1);
    hexField.getTextField().setEditable(false);
    elemTypePanel.addWidget(hexField);
    final IntegerField quadhexField = new IntegerField("Quadhexs (20 node)", 1);
    quadhexField.getTextField().setEditable(false);
    elemTypePanel.addWidget(quadhexField);
    savePanel.addWidget(elemTypePanel);
    elemType.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent a_evt) {
            if (elemType.isSelected()) {
                tetField.getTextField().setEditable(true);
                quadtetField.getTextField().setEditable(true);
                wedgeField.getTextField().setEditable(true);
                hexField.getTextField().setEditable(true);
                quadhexField.getTextField().setEditable(true);
            } else {
                tetField.getTextField().setEditable(false);
                quadtetField.getTextField().setEditable(false);
                wedgeField.getTextField().setEditable(false);
                hexField.getTextField().setEditable(false);
                quadhexField.getTextField().setEditable(false);
            }
        }
    });
    OptionPanel dialogOptions = new OptionPanel("Save Cancel", new ActionListener() {

        public void actionPerformed(ActionEvent a_evt) {
            if (a_evt.getActionCommand().equals("Save")) {
                File directory = new File(dirField.getStringValue());
                File nodeFile = new File(directory, nodeField.getStringValue());
                File elemFile = new File(directory, elemField.getStringValue());
                AnsysWriter.writeNodeFile(model, nodeFile.getAbsolutePath());
                AnsysWriter.writeElemFile(model, elemFile.getAbsolutePath());
            }
            saveOptions.dispose();
        }
    });
    GuiUtils.setFixedSize(dialogOptions.getButton("Save"), new Dimension(80, 25));
    GuiUtils.setFixedSize(dialogOptions.getButton("Cancel"), new Dimension(80, 25));
    dialogOptions.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
    savePanel.addWidget(dialogOptions);
    saveOptions.getContentPane().add(savePanel);
    saveOptions.pack();
    saveOptions.setMinimumSize(saveOptions.getPreferredSize());
    saveOptions.setVisible(true);
}
Also used : Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) IntegerField(maspack.widgets.IntegerField) Dimension(java.awt.Dimension) ActionListener(java.awt.event.ActionListener) StringField(maspack.widgets.StringField) LabeledComponentPanel(maspack.widgets.LabeledComponentPanel) Main(artisynth.core.driver.Main) OptionPanel(maspack.widgets.OptionPanel)

Example 4 with LabeledComponentPanel

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

the class FemModel3dAgent method createGeometryPanel.

private void createGeometryPanel() {
    geometryPanel = new LabeledComponentPanel();
    geometryPanel.setLayout(new BoxLayout(geometryPanel, BoxLayout.Y_AXIS));
    meshSelector = new EnumSelector("mesh type", FemMeshType.Grid, FemMeshType.values());
    meshSelector.addValueChangeListener(this);
    geometryPanel.addWidget(meshSelector);
    createMeshPropPanel();
    geometryPanel.addWidget(meshPropPanel);
    elemSelector = new EnumSelector("element type", FemElementType.Tet, FemElementType.values());
    elemSelector.addValueChangeListener(this);
    geometryPanel.addWidget(elemSelector);
    updateElemSelector();
    if (mySettings != null && elemSelector.isEnabledAll() && mySettings.elemType != null) {
        elemSelector.maskValueChangeListeners(true);
        elemSelector.setValue(mySettings.elemType);
        elemSelector.maskValueChangeListeners(false);
    }
    addWidget(geometryPanel);
    geometryPanel.setBorder(GuiUtils.createTitledPanelBorder("Geometry"));
}
Also used : BoxLayout(javax.swing.BoxLayout) EnumSelector(maspack.widgets.EnumSelector) LabeledComponentPanel(maspack.widgets.LabeledComponentPanel)

Example 5 with LabeledComponentPanel

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

the class FemModel3dAgent method createLocationPanel.

private void createLocationPanel() {
    positionField = new VectorField("position", 3);
    positionField.setStretchable(true);
    positionField.addValueChangeListener(this);
    orientationField = new AxisAngleField("orientiation", new AxisAngle());
    orientationField.setStretchable(true);
    orientationField.addValueChangeListener(this);
    LabeledComponentPanel locationPanel = new LabeledComponentPanel();
    locationPanel.addWidget(positionField);
    locationPanel.addWidget(orientationField);
    addWidget(locationPanel);
    locationPanel.setBorder(GuiUtils.createTitledPanelBorder("Location"));
}
Also used : AxisAngle(maspack.matrix.AxisAngle) VectorField(maspack.widgets.VectorField) AxisAngleField(maspack.widgets.AxisAngleField) LabeledComponentPanel(maspack.widgets.LabeledComponentPanel)

Aggregations

LabeledComponentPanel (maspack.widgets.LabeledComponentPanel)8 BoxLayout (javax.swing.BoxLayout)4 OptionPanel (maspack.widgets.OptionPanel)3 VectorField (maspack.widgets.VectorField)3 Dimension (java.awt.Dimension)2 JSeparator (javax.swing.JSeparator)2 AxisAngle (maspack.matrix.AxisAngle)2 AxisAngleField (maspack.widgets.AxisAngleField)2 IntegerField (maspack.widgets.IntegerField)2 StringField (maspack.widgets.StringField)2 Main (artisynth.core.driver.Main)1 PropertyField (artisynth.core.gui.widgets.PropertyField)1 Container (java.awt.Container)1 Insets (java.awt.Insets)1 Point (java.awt.Point)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 File (java.io.File)1 JButton (javax.swing.JButton)1 JPanel (javax.swing.JPanel)1