Package org.joshy.sketch.model

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


        return new VectorDocContext(main, this);
    }

    @Override
    public CanvasDocument createNewDoc() {
        return new SketchDocument();
    }
View Full Code Here


            this.context = context;
        }

        @Override
        public void execute() {
            SketchDocument doc = context.getDocument();
            SketchDocument.SketchPage page = doc.addPage();
            insertContents(page);
            context.pageList.listview.setSelectedIndex(doc.getCurrentPageIndex());
        }
View Full Code Here

        symbolAddButton = new Button(getString("sidebar.insertSymbol"));
        symbolAddButton.onClicked(new Callback<ActionEvent>() { public void call(ActionEvent event) {
            if(listView.getSelectedIndex() < 0) return;
            SNode node = listView.getModel().get(listView.getSelectedIndex());
            SketchDocument sd = context.getDocument();
            sd.getCurrentPage().add(node.duplicate(null));
            context.redraw();
        }});


        EventBus.getSystem().addListener(listView, MouseEvent.MouseAll, new Callback<MouseEvent>() {
            public double prevx;
            public boolean created;
            public SNode dupe;

            public void call(MouseEvent event) {
                if(event.getType() == MouseEvent.MousePressed) {
                    ContextMenu.hideAll();
                    if(event.getButton() == 3) { // check for right clicks to open the context menu
                        showContextMenu(event);
                        return;
                    }
                }
                if(event.getType() == MouseEvent.MouseDragged) {
                    if(created && dupe != null) {
                        Point2D pt = event.getPointInNodeCoords(context.getCanvas());
                        pt = context.getSketchCanvas().transformToCanvas(pt);
                        Bounds b = dupe.getBounds();
                        dupe.setTranslateX(pt.getX()-b.getWidth()/2);
                        dupe.setTranslateY(pt.getY()-b.getHeight()/2);
                        context.redraw();
                    }
                    if(event.getX() < 0 && prevx >= 0 && !created) {
                        created = true;
                        if(listView.getSelectedIndex() < 0) return;
                        SNode node = listView.getModel().get(listView.getSelectedIndex());
                        SketchDocument sd = context.getDocument();
                        dupe = node.duplicate(null);
                        Bounds b = dupe.getBounds();
                        sd.getCurrentPage().add(dupe);
                        Point2D pt = event.getPointInNodeCoords(context.getCanvas());
                        pt = context.getSketchCanvas().transformToCanvas(pt);
                        dupe.setTranslateX(pt.getX()-b.getWidth()/2);
                        dupe.setTranslateY(pt.getY()-b.getHeight()/2);
                        context.redraw();
View Full Code Here

            return getString("menus.raiseNodeTop");
        }

        @Override
        public void execute() {
            SketchDocument doc = context.getDocument();
            List<SNode> model = doc.getCurrentPage().getModel();
            List<SNode> nodes = new ArrayList<SNode>();
            for(SNode node : context.getSelection().items()) {
                nodes.add(node);
            }
            model.removeAll(nodes);
View Full Code Here

    @Override
    protected void mouseReleased(MouseEvent event, Point2D.Double cursor) {
    }

    private void load(File file, Point2D cursor) throws IOException {
        SketchDocument doc = (SketchDocument) context.getDocument();
        SImage image = new SImage(file);
        image.setTranslateX(cursor.getX());
        image.setTranslateY(cursor.getY());
        doc.getCurrentPage().add(image);
        context.redraw();
    }
View Full Code Here

        }

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

            List<SNode> nodes = new ArrayList<SNode>();
            for(SNode node : context.getSelection().items()) {
                nodes.add(node);
            }
            int max = -1;
            for(SNode node : nodes) {
                max = Math.max(max,doc.getCurrentPage().getModel().indexOf(node));
            }
            //if there is room to move up
            List<SNode> model = doc.getCurrentPage().getModel();
            if(max+1 < model.size()) {
                SNode nextNode = model.get(max+1);
                model.removeAll(nodes);
                int n = model.indexOf(nextNode);
                model.addAll(n+1,nodes);
View Full Code Here

        }

        @Override
        public void execute() {
            if(context.getSelection().isEmpty()) return;
            SketchDocument doc = context.getDocument();
            List<SNode> model = doc.getCurrentPage().getModel();
            List<SNode> nodes = new ArrayList<SNode>();
            for(SNode node : context.getSelection().items()) {
                nodes.add(node);
            }
            int min = Integer.MAX_VALUE;
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

        }

        @Override
        public void execute() {
            if(context.getSelection().isEmpty()) return;
            SketchDocument doc = context.getDocument();
            List<SNode> model = doc.getCurrentPage().getModel();
            List<SNode> nodes = new ArrayList<SNode>();
            for(SNode node : context.getSelection().items()) {
                nodes.add(node);
            }
            //just remove and move all to the bottom
View Full Code Here

    protected void mousePressed(MouseEvent event, Point2D.Double cursor) {
        cursor = snapToGrid(cursor);
        start = cursor;

        SketchDocument doc = context.getDocument();
        doc.getCurrentPage().add(node);
        context.getUndoManager().pushAction(new UndoableAddNodeAction(context, node,"node"));
        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.