Search in sources :

Example 1 with AlignTool

use of org.twak.tweed.tools.AlignTool in project chordatlas by twak.

the class MiniGen method getUI.

@Override
public JComponent getUI() {
    JPanel out = new JPanel(new ListDownLayout());
    JButton clear = new JButton("hide all");
    clear.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            bounds.clear();
            tweed.enqueue(new Runnable() {

                public void run() {
                    calculate();
                }
            });
        }
    });
    JButton all = new JButton("load all");
    all.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            bounds.clear();
            bounds.add(new double[] { -Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE, Double.MAX_VALUE });
            tweed.enqueue(new Runnable() {

                public void run() {
                    calculate();
                }
            });
        }
    });
    final JCheckBox renderLines = new JCheckBox("wireframe");
    renderLines.setSelected(this.renderLines);
    renderLines.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            tweed.enqueue(new Callable<Spatial>() {

                public Spatial call() throws Exception {
                    MiniGen.this.renderLines = renderLines.isSelected();
                    calculate();
                    return null;
                }
            });
        }
    });
    final JSlider renderTransparent = new JSlider(0, MAX, (int) (MAX * transparency));
    renderTransparent.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            tweed.enqueue(new Callable<Spatial>() {

                public Spatial call() throws Exception {
                    MiniGen.this.transparency = (renderTransparent.getValue() / (float) MAX);
                    calculate();
                    return null;
                }
            });
        }
    });
    JButton align = new JButton("align tool");
    align.addActionListener(e -> tweed.setTool(new AlignTool(tweed)));
    out.add(all);
    out.add(clear);
    out.add(renderLines);
    out.add(renderTransparent);
    out.add(align);
    return out;
}
Also used : JPanel(javax.swing.JPanel) ListDownLayout(org.twak.utils.ui.ListDownLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Callable(java.util.concurrent.Callable) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) JSlider(javax.swing.JSlider) ChangeListener(javax.swing.event.ChangeListener) AlignTool(org.twak.tweed.tools.AlignTool)

Aggregations

ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Callable (java.util.concurrent.Callable)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JPanel (javax.swing.JPanel)1 JSlider (javax.swing.JSlider)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1 AlignTool (org.twak.tweed.tools.AlignTool)1 ListDownLayout (org.twak.utils.ui.ListDownLayout)1