Search in sources :

Example 1 with SimplePopup2

use of org.twak.utils.ui.SimplePopup2 in project chordatlas by twak.

the class TweedFrame method addLayer.

private void addLayer(MouseEvent evt) {
    SimplePopup2 sp = new SimplePopup2(evt);
    if (hasGIS()) {
        sp.add("+ mesh (obj)", new Runnable() {

            @Override
            public void run() {
                new SimpleFileChooser(frame, false, "Select .obj mesh file", new File(Tweed.JME), "obj") {

                    public void heresTheFile(File obj) throws Throwable {
                        // removeMeshSources();
                        String f = tweed.makeWorkspaceRelative(obj).toString();
                        addGen(new MeshGen(f, tweed), true);
                    }
                };
            }
        });
        sp.add("+ mesh (minimesh)", new Runnable() {

            @Override
            public void run() {
                new SimpleFileChooser(frame, false, "Select minimesh index file (index.xml), or obj to convert", new File(Tweed.JME), null) {

                    @Override
                    public void heresTheFile(File f) throws Throwable {
                        if (!f.getName().equals(MiniTransform.INDEX)) {
                            MiniTransform.convertToMini(f, new File(Tweed.DATA + "/minimesh"), () -> addGen(new MiniGen(new File("minimesh"), tweed), true));
                            return;
                        }
                        // removeMeshSources();
                        addGen(new MiniGen(tweed.makeWorkspaceRelative(f.getParentFile()), tweed), true);
                    }
                };
            }
        });
        sp.add("+ panos (jpg)", new Runnable() {

            @Override
            public void run() {
                new SimpleFileChooser(frame, false, "Select one of many panoramas images in a directory, or todo.list", new File(Tweed.JME), null) {

                    public void heresTheFile(File oneOfMany) throws Throwable {
                        // removeGens( PanoGen.class );
                        addGen(new PanoGen(tweed.makeWorkspaceRelative(oneOfMany.getParentFile()), tweed, Tweed.LAT_LONG), true);
                    }
                };
            }
        });
    } else {
        sp.add("+ gis (2d obj)", new Runnable() {

            @Override
            public void run() {
                new SimpleFileChooser(frame, false, "Select .obj gis footprints", new File(Tweed.JME), "obj") {

                    public void heresTheFile(File obj) throws Throwable {
                        removeGISSources();
                        addGen(new GISGen(tweed.makeWorkspaceRelative(obj), tweed), true);
                    }
                };
            }
        });
        // sp.add( "+ gis (3d obj)", new Runnable() {
        // @Override
        // public void run() {
        // new SimpleFileChooser( frame, false, "Select .obj gis footprints", new File( Tweed.JME ), "obj" ) {
        // public void heresTheFile( File obj ) throws Throwable {
        // 
        // };
        // };
        // }
        // } );
        sp.add("+ gis (gml)", new Runnable() {

            @Override
            public void run() {
                new SimpleFileChooser(frame, false, "Select .gml gis footprints", new File(Tweed.JME), "gml") {

                    public void heresTheFile(File gml) throws Throwable {
                        removeGISSources();
                        tweed.addGML(gml, null);
                    }
                };
            }
        });
    }
    sp.show();
}
Also used : MiniGen(org.twak.tweed.gen.MiniGen) PanoGen(org.twak.tweed.gen.PanoGen) SimplePopup2(org.twak.utils.ui.SimplePopup2) GISGen(org.twak.tweed.gen.GISGen) SimpleFileChooser(org.twak.utils.ui.SimpleFileChooser) File(java.io.File) MeshGen(org.twak.tweed.gen.MeshGen)

Example 2 with SimplePopup2

use of org.twak.utils.ui.SimplePopup2 in project chordatlas by twak.

the class MiniFacade method getMenu.

@Override
public void getMenu(MouseEvent e, PanMouseAdaptor ma, ChangeListener cl) {
    mouseDown(e, ma);
    SimplePopup2 pop = new SimplePopup2(e);
    if (dragging != null)
        pop.add("delete", new Runnable() {

            @Override
            public void run() {
                if (dragging != null)
                    rects.remove(dragging.f, dragging);
                cl.stateChanged(null);
            }
        });
    if (dragging != null)
        pop.add("duplicate", new Runnable() {

            @Override
            public void run() {
                mouseDown(e, ma);
                if (dragging != null) {
                    FRect rec = new FRect(dragging);
                    // rec.x += 0.5;
                    rec.x += rec.width + 0.3;
                    rects.put(rec.f, rec);
                    cl.stateChanged(null);
                }
            }
        });
    for (Feature f : Feature.values()) {
        pop.add("add " + f.name().toLowerCase(), new Runnable() {

            @Override
            public void run() {
                Point2d pt = flip(ma.from(e));
                FRect rec = new FRect(pt.x, pt.y, pt.x + 0.5, pt.y + 0.5);
                rec.f = f;
                rects.put(f, rec);
                cl.stateChanged(null);
            }
        });
    }
    pop.add("color", new Runnable() {

        @Override
        public void run() {
            new ColourPicker(null, new Color((float) color[0], (float) color[1], (float) color[2])) {

                @Override
                public void picked(Color color) {
                    MiniFacade.this.color = new double[] { color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 1 };
                    cl.stateChanged(null);
                }
            };
        }
    });
    pop.show();
}
Also used : ColourPicker(org.twak.utils.ui.ColourPicker) Point2d(javax.vecmath.Point2d) Color(java.awt.Color) SimplePopup2(org.twak.utils.ui.SimplePopup2)

Aggregations

SimplePopup2 (org.twak.utils.ui.SimplePopup2)2 Color (java.awt.Color)1 File (java.io.File)1 Point2d (javax.vecmath.Point2d)1 GISGen (org.twak.tweed.gen.GISGen)1 MeshGen (org.twak.tweed.gen.MeshGen)1 MiniGen (org.twak.tweed.gen.MiniGen)1 PanoGen (org.twak.tweed.gen.PanoGen)1 ColourPicker (org.twak.utils.ui.ColourPicker)1 SimpleFileChooser (org.twak.utils.ui.SimpleFileChooser)1