Package org.joshy.sketch.model

Examples of org.joshy.sketch.model.SGroup


                    nodes.add(node);
                }
            }

            model.removeAll(nodes);
            final SGroup group = new SGroup();
            group.addAll(nodes);
            model.add(group);
            context.getSelection().clear();
            context.getSelection().setSelectedNode(group);
            context.redraw();


            UndoManager.UndoableAction action = new UndoManager.UndoableAction() {
                public void executeUndo() {
                    model.remove(group);
                    for (SNode node : nodes) {
                        model.add(node);
                        node.setTranslateX(node.getTranslateX()+group.getTranslateX());
                        node.setTranslateY(node.getTranslateY()+group.getTranslateY());
                    }
                    context.getSelection().setSelectedNodes(nodes);
                    context.redraw();
                }

                public void executeRedo() {
                    model.removeAll(nodes);
                    group.addAll(nodes);
                    model.add(group);
                    context.getSelection().setSelectedNode(group);
                    context.redraw();
                }
View Full Code Here


        @Override
        public void execute() {
            if(context.getSelection().size() != 1) return;
            SNode n = context.getSelection().items().iterator().next();
            if(!(n instanceof SGroup)) return;
            final SGroup group = (SGroup) n;

            SketchDocument doc = context.getDocument();
            final List<SNode> model = doc.getCurrentPage().getModel();
            model.remove(group);
            model.addAll(group.getNodes());
            context.getSelection().clear();
            for(SNode node : group.getNodes()) {
                node.setTranslateX(node.getTranslateX()+group.getTranslateX());
                node.setTranslateY(node.getTranslateY()+group.getTranslateY());
                context.getSelection().addSelectedNode(node);
            }
            context.redraw();
            UndoManager.UndoableAction action = new UndoManager.UndoableAction() {
                public void executeUndo() {
                    model.removeAll(group.getNodes());
                    for (SNode node : group.getNodes()) {
                        node.setTranslateX(node.getTranslateX()-group.getTranslateX());
                        node.setTranslateY(node.getTranslateY()-group.getTranslateY());
                    }
                    model.add(group);
                    context.getSelection().setSelectedNode(group);
                    context.redraw();
                }

                public void executeRedo() {
                    model.remove(group);
                    for (SNode node : group.getNodes()) {
                        model.add(node);
                        node.setTranslateX(node.getTranslateX()+group.getTranslateX());
                        node.setTranslateY(node.getTranslateY()+group.getTranslateY());
                    }
                    context.getSelection().setSelectedNodes(group.getNodes());
                    context.redraw();
                }

                public CharSequence getName() {
                    return "ungroup shapes";
View Full Code Here

        URL url = ImportTests.class.getResource("test1.svg");
        SketchDocument doc = ImportAction.importSVG(url);
        //check that the first node is a group
        assertTrue(doc.getPages().get(0).getModel().get(0) instanceof SGroup);
        //go down the tree to the polygon
        SGroup g1 = (SGroup) doc.getPages().get(0).getModel().get(0);
        SGroup g2 = (SGroup) g1.getNodes().get(1);
        SPoly p1 = (SPoly) g2.getNodes().get(0);
        //test the color of the polygon
        assertTrue(p1.getFillPaint() instanceof FlatColor);
        FlatColor c1 = (FlatColor) p1.getFillPaint();
        assertTrue(c1.getRGBA() == 0xFF231F20);
    }
View Full Code Here

TOP

Related Classes of org.joshy.sketch.model.SGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.