Search in sources :

Example 1 with ValueChangeListener

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

the class MeshCollisionViewer method createRenderPropsPanel.

private void createRenderPropsPanel(PolygonalMesh mesh) {
    PropertyDialog dialog = new PropertyDialog("Edit render props", new RenderPropsPanel(PropertyUtils.createProperties(mesh.getRenderProps())), "OK Cancel");
    dialog.locateRight(this);
    dialog.addGlobalValueChangeListener(new ValueChangeListener() {

        public void valueChange(ValueChangeEvent e) {
            viewer.rerender();
        }
    });
    dialog.setVisible(true);
}
Also used : ValueChangeEvent(maspack.widgets.ValueChangeEvent) ValueChangeListener(maspack.widgets.ValueChangeListener) PropertyDialog(maspack.widgets.PropertyDialog) RenderPropsPanel(maspack.widgets.RenderPropsPanel)

Example 2 with ValueChangeListener

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

the class MeshViewer method actionPerformed.

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd.equals("Edit render props")) {
        PropertyDialog dialog = new PropertyDialog("Edit render props", new RenderPropsPanel(PropertyUtils.createProperties(myRenderProps)), "OK Cancel");
        dialog.locateRight(this);
        dialog.addGlobalValueChangeListener(new ValueChangeListener() {

            public void valueChange(ValueChangeEvent e) {
                for (MeshBase mesh : myMeshes) {
                    mesh.setRenderProps(myRenderProps);
                }
                viewer.rerender();
            }
        });
        myPopupManager.registerDialog(dialog);
        dialog.setVisible(true);
    } else if (cmd.equals("Edit viewer props")) {
        PropertyDialog dialog = myPopupManager.createPropertyDialog("OK Cancel");
        dialog.setVisible(true);
    } else if (cmd.equals("Quit")) {
        exit(0);
    } else if (cmd.equals("Load mesh ...")) {
        int retVal = myMeshChooser.showOpenDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            File file = myMeshChooser.getSelectedFile();
            loadMesh(file);
        }
    } else if (cmd.equals("Save mesh ...")) {
        int retVal = myMeshChooser.showOpenDialog(this);
        if (retVal == JFileChooser.APPROVE_OPTION) {
            File file = myMeshChooser.getSelectedFile();
            saveMesh(file);
        }
    } else if (cmd.equals("Show mesh selector")) {
        if (myMeshSelector == null) {
            createMeshSelector();
            myMeshSelector.setSelected(myMeshCursor);
        }
        myMeshSelector.setLocationRelativeTo(this);
        myMeshSelector.setVisible(true);
    } else if (cmd.equals("Hide mesh selector")) {
        myMeshSelector.setVisible(false);
    } else if (cmd.equals("Show property dialog ...")) {
        setPropertyDialogVisible(true);
    } else if (cmd.equals("Hide property dialog")) {
        setPropertyDialogVisible(false);
    } else if (cmd.equals("Background color")) {
        setBackgroundColor();
    } else if (cmd.equals("Perspective view")) {
        viewer.setOrthographicView(false);
    } else if (cmd.equals("Orthographic view")) {
        viewer.setOrthographicView(true);
    }
}
Also used : ValueChangeEvent(maspack.widgets.ValueChangeEvent) ValueChangeListener(maspack.widgets.ValueChangeListener) PropertyDialog(maspack.widgets.PropertyDialog) RenderPropsPanel(maspack.widgets.RenderPropsPanel) MeshBase(maspack.geometry.MeshBase) File(java.io.File) Point(java.awt.Point)

Example 3 with ValueChangeListener

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

the class FemMuscleDemo method createMusclePanel.

public void createMusclePanel() {
    ControlPanel myControlPanel = new ControlPanel("options", "LiveUpdate");
    FemControlPanel.addMuscleControls(myControlPanel, tissue, myModel);
    myControlPanel.addWidget(tissue, "profile");
    ComponentList<MuscleBundle> muscles = ((FemMuscleModel) tissue).getMuscleBundles();
    for (int i = 0; i < muscles.size(); ++i) {
        DoubleFieldSlider slider = (DoubleFieldSlider) myControlPanel.addWidget("activation [N per Muscle]", this, "models/FemBeam/models/fem/bundles/" + i + ":excitation", 0, 1);
        slider.setRoundingTolerance(0.00001);
        slider.getLabel().setForeground(getMuscleColor(i));
        BooleanSelector checkBox = (BooleanSelector) PropertyWidget.create("", muscles.get(i), "renderProps.visible");
        checkBox.addValueChangeListener(new ValueChangeListener() {

            public void valueChange(ValueChangeEvent e) {
                rerender();
            }
        });
        slider.add(checkBox);
    }
    for (int i = 0; i < muscles.size(); ++i) {
        BooleanSelector selector = (BooleanSelector) myControlPanel.addWidget("fibres active", this, "models/FemBeam/models/fem/bundles/" + i + ":fibresActive");
        selector.getLabel().setForeground(getMuscleColor(i));
        BooleanSelector checkBox = (BooleanSelector) PropertyWidget.create("", muscles.get(i).getFibres(), "renderProps.visible");
        checkBox.addValueChangeListener(new ValueChangeListener() {

            public void valueChange(ValueChangeEvent e) {
                rerender();
            }
        });
        selector.add(checkBox);
    }
    addControlPanel(myControlPanel);
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) ValueChangeEvent(maspack.widgets.ValueChangeEvent) ValueChangeListener(maspack.widgets.ValueChangeListener) BooleanSelector(maspack.widgets.BooleanSelector) ControlPanel(artisynth.core.gui.ControlPanel) FemControlPanel(artisynth.core.gui.FemControlPanel) FemMuscleModel(artisynth.core.femmodels.FemMuscleModel) Point(artisynth.core.mechmodels.Point) DoubleFieldSlider(maspack.widgets.DoubleFieldSlider)

Example 4 with ValueChangeListener

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

the class SelectComponentPanelHandler method createPanel.

public void createPanel() {
    myPanel = new JPanel();
    myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.X_AXIS));
    ImageIcon comboSelectIcon = GuiUtils.loadIcon(SelectableComponentPanel.class, "icon/downArrow.png");
    mySelectFilterButton = ButtonCreator.createIconicButton(comboSelectIcon, "Set Filter", "Set selection filter", true, false, null);
    componentFilter = new ClassField("", ClassField.All, 15);
    componentFilter.getTextField().setHorizontalAlignment(JTextField.RIGHT);
    componentFilter.setSpacing(0);
    componentFilter.getTextField().addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent e) {
            if (e.getModifiersEx() == ButtonMasks.getContextMenuMask()) {
                showFilterPopup();
            }
        }
    });
    componentFilter.addValueChangeListener(new ValueChangeListener() {

        public void valueChange(ValueChangeEvent e) {
            doSetComponentFilter((Class) e.getValue());
        }
    });
    GuiUtils.setFixedSize(mySelectFilterButton, 18, 18);
    mySelectFilterButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                showFilterPopup();
            }
        }
    });
    myComponentField = new ComponentField("", 30, myMain);
    // GuiUtils.setFixedSize (parentBtn, 24, 24);
    myPanel.add(Box.createRigidArea(new Dimension(36, 20)));
    myPanel.add(mySelectFilterButton);
    myPanel.add(componentFilter);
    myPanel.add(myComponentField);
    // myPanel.add(componentName);
    // //myPanel.add(selectParent);
    // myPanel.add(parentBtn);
    myFrame.add(myPanel, BorderLayout.SOUTH);
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) ValueChangeEvent(maspack.widgets.ValueChangeEvent) MouseEvent(java.awt.event.MouseEvent) ValueChangeListener(maspack.widgets.ValueChangeListener) ComponentField(artisynth.core.gui.widgets.ComponentField) BoxLayout(javax.swing.BoxLayout) MouseAdapter(java.awt.event.MouseAdapter) Dimension(java.awt.Dimension) ClassField(artisynth.core.gui.widgets.ClassField)

Example 5 with ValueChangeListener

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

the class ComponentPropertyField method addPropertySelector.

protected void addPropertySelector() {
    myPropertySelector = new StringSelector("", new String[] { nullString });
    myPropertySelector.setValue(nullString);
    myPropertySelector.addValueChangeListener(new ValueChangeListener() {

        public void valueChange(ValueChangeEvent e) {
            setValueFromPropertySelector();
        }
    });
    myPropertiesAllowed = true;
    addMajorComponent(myPropertySelector);
}
Also used : ValueChangeEvent(maspack.widgets.ValueChangeEvent) ValueChangeListener(maspack.widgets.ValueChangeListener) StringSelector(maspack.widgets.StringSelector)

Aggregations

ValueChangeEvent (maspack.widgets.ValueChangeEvent)5 ValueChangeListener (maspack.widgets.ValueChangeListener)5 PropertyDialog (maspack.widgets.PropertyDialog)2 RenderPropsPanel (maspack.widgets.RenderPropsPanel)2 FemMuscleModel (artisynth.core.femmodels.FemMuscleModel)1 MuscleBundle (artisynth.core.femmodels.MuscleBundle)1 ControlPanel (artisynth.core.gui.ControlPanel)1 FemControlPanel (artisynth.core.gui.FemControlPanel)1 ClassField (artisynth.core.gui.widgets.ClassField)1 ComponentField (artisynth.core.gui.widgets.ComponentField)1 Point (artisynth.core.mechmodels.Point)1 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 File (java.io.File)1 BoxLayout (javax.swing.BoxLayout)1 ImageIcon (javax.swing.ImageIcon)1 JPanel (javax.swing.JPanel)1 MeshBase (maspack.geometry.MeshBase)1