Search in sources :

Example 1 with SliceSolver

use of org.twak.viewTrace.SliceSolver in project chordatlas by twak.

the class BlockGen method getUI.

@Override
public JComponent getUI() {
    JPanel panel = (JPanel) super.getUI();
    JButton profiles = new JButton("find profiles");
    profiles.addActionListener(e -> doProfile());
    JButton panos = new JButton("render panoramas");
    panos.addActionListener(e -> renderPanos());
    JButton features = new JButton("find image features");
    features.addActionListener(e -> segnetFacade());
    JButton viewFeatures = new JButton("features viewer");
    viewFeatures.addActionListener(e -> viewFeatures());
    JButton slice = new JButton("slice");
    slice.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new Thread() {

                public void run() {
                    File fs = getSlicedFile();
                    if (!fs.exists()) {
                        new SliceSolver(fs, new Slice(getCroppedFile(), getGISFile(), P, false), P);
                    }
                    tweed.frame.addGen(new ObjGen(tweed.makeWorkspaceRelative(fs).toString(), tweed), true);
                }
            }.start();
        }
    });
    JButton tooD = new JButton("slice UI");
    tooD.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new Slice(root, ProfileGen.SLICE_SCALE);
        }
    });
    JButton loadSln = new JButton("load last solution");
    loadSln.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            File f = getSolutionFile();
            if (f.exists()) {
                SolverState SS = (SolverState) new XStream().fromXML(f);
                SkelFootprint.postProcesss(SS);
                // PaintThing.debug.clear();
                // new Plot(SS.mesh).add( new ICanPaint() {
                // 
                // @Override
                // public void paint( Graphics2D g, PanMouseAdaptor ma ) {
                // 
                // g.setColor( Color.black );
                // g.setStroke( new BasicStroke( 2 ) );
                // 
                // if (SS.footprint != null)
                // for (Line l : SS.footprint) {
                // g.drawLine(
                // ma.toX( l.start.x ),
                // ma.toY( l.start.y ),
                // ma.toX( l.end.x ),
                // ma.toY( l.end.y ) );
                // }
                // 
                // }
                // });
                tweed.frame.addGen(new SkelGen(SS.mesh, tweed, BlockGen.this), true);
            } else {
                JOptionPane.showMessageDialog(tweed.frame(), "Unable to find pre-computed solution.\n" + f);
            }
        }
    });
    JTextArea name = new JTextArea(nameCoords());
    name.setEditable(false);
    panel.add(profiles, 0);
    panel.add(panos, 1);
    panel.add(features, 2);
    panel.add(new JLabel("other:"), 4);
    panel.add(slice);
    panel.add(viewFeatures);
    // panel.add( tooD );
    if (getSolutionFile().exists())
        panel.add(loadSln);
    panel.add(new JLabel("name:"));
    panel.add(name);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) XStream(com.thoughtworks.xstream.XStream) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) SliceSolver(org.twak.viewTrace.SliceSolver) SkelGen(org.twak.tweed.gen.skel.SkelGen) ActionListener(java.awt.event.ActionListener) Slice(org.twak.viewTrace.Slice) File(java.io.File)

Aggregations

XStream (com.thoughtworks.xstream.XStream)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 File (java.io.File)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JTextArea (javax.swing.JTextArea)1 SkelGen (org.twak.tweed.gen.skel.SkelGen)1 Slice (org.twak.viewTrace.Slice)1 SliceSolver (org.twak.viewTrace.SliceSolver)1