Search in sources :

Example 1 with Mode

use of org.twak.tweed.gen.VizSkelGen.Mode in project chordatlas by twak.

the class ProfileGen method getUI.

@Override
public JComponent getUI() {
    JSlider slider = new JSlider(JSlider.HORIZONTAL, -1, gNode.getChildren().size(), -1);
    slider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            tweed.enqueue(new Runnable() {

                @Override
                public void run() {
                    int value = slider.getValue();
                    for (Spatial s : gNode.getChildren()) {
                        if (s instanceof Node) {
                            Integer i = s.getUserData(ProfileGen.class.getSimpleName());
                            if (i != null && s instanceof Node)
                                if (value == -1 || i == value)
                                    s.setCullHint(CullHint.Inherit);
                                else
                                    s.setCullHint(CullHint.Always);
                        }
                    }
                    tweed.gainFocus();
                }
            });
        }
    });
    JButton skel = new JButton("optimize");
    skel.addActionListener(ae -> doSkel());
    JComboBox<Mode> vizMode = new JComboBox<>(Mode.values());
    vizMode.addActionListener(e -> doViz((Mode) vizMode.getSelectedItem()));
    // JButton writeProfiles = new JButton("dump profs");
    // writeProfiles.addActionListener( ae -> writeProfiles() );
    JButton stateBuilder = new JButton("segmenter ui");
    stateBuilder.addActionListener(ae -> new SSBuilder(this, tweed.features));
    JButton profs = new JButton("2d profiles");
    profs.addActionListener(ae -> new ProfileAssignmentViewer(faces));
    JPanel out = new JPanel(new ListDownLayout());
    out.add(skel);
    out.add(new JLabel("profiles rendered:"));
    out.add(slider);
    out.add(new JLabel("viz:"));
    out.add(vizMode);
    // out.add( writeProfiles );
    out.add(stateBuilder);
    out.add(profs);
    return out;
}
Also used : JPanel(javax.swing.JPanel) ListDownLayout(org.twak.utils.ui.ListDownLayout) JComboBox(javax.swing.JComboBox) Node(com.jme3.scene.Node) Mode(org.twak.tweed.gen.VizSkelGen.Mode) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) CullHint(com.jme3.scene.Spatial.CullHint) ChangeEvent(javax.swing.event.ChangeEvent) Spatial(com.jme3.scene.Spatial) JSlider(javax.swing.JSlider) ChangeListener(javax.swing.event.ChangeListener)

Aggregations

Node (com.jme3.scene.Node)1 Spatial (com.jme3.scene.Spatial)1 CullHint (com.jme3.scene.Spatial.CullHint)1 JButton (javax.swing.JButton)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JSlider (javax.swing.JSlider)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1 Mode (org.twak.tweed.gen.VizSkelGen.Mode)1 ListDownLayout (org.twak.utils.ui.ListDownLayout)1