Package org.joshy.sketch.model

Examples of org.joshy.sketch.model.SketchDocument$Guideline


        }

        @Override
        public void execute() {
            if(context.getSelection().size() < 2) return;
            SketchDocument doc = context.getDocument();

            final List<SNode> model = doc.getCurrentPage().getModel();

            final List<SNode> nodes = new ArrayList<SNode>();
            for(SNode node : model) {
                if(context.getSelection().contains(node)) {
                    nodes.add(node);
View Full Code Here


    protected void mousePressed(MouseEvent event, Point2D.Double cursor) {
        if(poly == null) {
            poly = new SPoly();
            poly.addPoint(snapPoint(cursor));
            hotspot = cursor;
            SketchDocument doc = (SketchDocument) context.getDocument();
            doc.getCurrentPage().add(poly);
            context.getUndoManager().pushAction(new UndoableAddNodeAction(context,poly,"polygon"));
            point = new Point2D.Double();
            point.setLocation(cursor);
            poly.addPoint(point);
            context.redraw();
View Full Code Here

    }

    private Point2D.Double snapPoint(Point2D cursor) {
        double nx = cursor.getX();
        double ny = cursor.getY();
        SketchDocument doc = context.getDocument();
        if(doc.isSnapGrid()) {
            nx = ((int)(nx/doc.getGridWidth()))*doc.getGridWidth();
            ny = ((int)(ny/doc.getGridHeight()))*doc.getGridHeight();
        }
        return new Point2D.Double(nx,ny);
    }
View Full Code Here

            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());
View Full Code Here

        @Override
        public void execute() {
            //duplicate the selection
            final List<SNode> dupes = new ArrayList<SNode>();
            SketchDocument doc = (SketchDocument) context.getDocument();
            for(SNode node : context.getSelection().sortedItems(doc)) {
                SNode dupe = node.duplicate(null);
                if(offset) {
                    dupe.setTranslateX(dupe.getTranslateX()+100);
                    dupe.setTranslateY(dupe.getTranslateY()+100);
                }
                dupes.add(dupe);
            }

            //make it undoable
            context.getUndoManager().pushAction(new UndoManager.UndoableAction(){
                public void executeUndo() {
                    SketchDocument doc = (SketchDocument) context.getDocument();
                    for(SNode dupe : dupes) {
                        doc.getCurrentPage().remove(dupe);
                    }
                    context.getSelection().clear();
                }
                public void executeRedo() {
                    SketchDocument doc = (SketchDocument) context.getDocument();
                    for(SNode dupe : dupes) {
                        doc.getCurrentPage().add(dupe);
                        doc.setDirty(true);
                    }
                }
                public String getName() {
                    return "duplicate";
                }
            });

            //clear selection
            context.getSelection().clear();
            //add to the doc
            for(SNode dupe : dupes) {
                doc.getCurrentPage().add(dupe);
                doc.setDirty(true);
                context.getSelection().addSelectedNode(dupe);
            }

        }
View Full Code Here

                    if(event.getX() < 0 && prevx >= 0 && !created) {
                        created = true;
                        if(photoList.getSelectedIndex() < 0) return;
                        Photo photo  = (Photo) photoList.getModel().get(photoList.getSelectedIndex());
                        try {
                            SketchDocument sd = context.getDocument();
                            String file = photo.getFullURL().getFile();
                            file = file.substring(file.lastIndexOf("/")+1);
                            dupe = new SImage(photo.getFullURL().toURI(), file, true, photo.getImage(), context);
                            sd.getCurrentPage().add(dupe);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        context.redraw();
                    }
View Full Code Here

                final File file = File.createTempFile("foo", ".png");
                file.deleteOnExit();

                CanvasDocument doc = context.getDocument();
                if(doc instanceof SketchDocument) {
                    SketchDocument sdoc = (SketchDocument) doc;
                    SavePNGAction save = new SavePNGAction(null);
                    VectorDocContext vdc = (VectorDocContext) context;
                    save.includeBackground = true;
                    if(includeStamp.isSelected()) {
                        save.includeStamp = true;
View Full Code Here

    @Override
    protected void newDocDialog() {
        //don't do the dialog. instead just create a new doc
       
        SketchDocument doc = new SketchDocument();
        doc.setPagesVisible(true);
        doc.setBackgroundFill(FlatColor.hsb(25,0.05,1.0));
        doc.setPresentation(true);
        doc.setDocBoundsActive(true);
        doc.setUnits(CanvasDocument.LengthUnits.Pixels);
        doc.setGridActive(false);
        doc.setSnapDocBounds(true);
        doc.setSnapGrid(false);
        doc.setSnapNodeBounds(true);

        doc.setWidth(800);
        doc.setHeight(500);

        SwitchTheme.PresoThemeAction theme = new SwitchTheme.Standard(doc, null);
        doc.getProperties().put("theme", theme);
        try {
            theme.execute();
        } catch (Exception e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        }

        //insert title page content on the first page
        SketchDocument.SketchPage page = doc.getCurrentPage();
        new PresoModeHelper.AddTitlePage(null).insertContents(page);

        try {
            newDocCreated(doc);
        } catch (Exception e) {
View Full Code Here

        }
        @Override
        public void execute() throws Exception {


            SketchDocument doc = null;
            if(this.doc != null) doc = this.doc;
            if(this.context != null) doc = context.getDocument();

            Paint fill = this.backgroundFill;
            if(this.backgroundFill instanceof LinearGradientFill) {
                fill = DocumentActions.resizeTo((LinearGradientFill) this.backgroundFill,new Bounds(0,0,doc.getWidth(),doc.getHeight()));
            }
            doc.setBackgroundFill(fill);
            doc.getProperties().put("theme",this);

            for(SketchDocument.SketchPage page : doc.getPages()) {
                for(SNode node : page.getNodes()) {
                    if(node instanceof SText) {
                        SText text = (SText) node;
                        styleText(text);
                    }
View Full Code Here

        Bounds sbounds = context.getSelection().calculateBounds();
        ResizableGrid9Shape shape = new ResizableGrid9Shape(0,0,sbounds.getWidth(),sbounds.getHeight());
        shape.setTranslateX(sbounds.getX());
        shape.setTranslateY(sbounds.getY());

        SketchDocument doc = context.getDocument();
        for(SNode node : context.getSelection().sortedItems(doc)) {
            shape.add(node);
            doc.getCurrentPage().remove(node);
        }
        doc.getCurrentPage().add(shape);
        context.getSelection().setSelectedNode(shape);
        context.selectButtonForTool(context.getEditResizableShapeTool());
        context.redraw();
    }
View Full Code Here

TOP

Related Classes of org.joshy.sketch.model.SketchDocument$Guideline

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.