Package org.joshy.gfx.node

Examples of org.joshy.gfx.node.Bounds


        double x = Double.MAX_VALUE;
        double y = Double.MAX_VALUE;
        double x2 = Double.NEGATIVE_INFINITY;
        double y2 = Double.NEGATIVE_INFINITY;
        for(SNode n : items()) {
            Bounds b = n.getTransformedBounds();
            if(b == null) {
                u.p("warning: bounds null on" + n);
            }
            x  = Math.min(x,  b.getX());
            y  = Math.min(y,  b.getY());
            x2 = Math.max(x2, b.getX2());
            y2 = Math.max(y2, b.getY2());
        }
        return new Bounds(x,y,x2-x,y2-y);
    }
View Full Code Here


                x*scale+panX,
                y*scale+panY);
    }

    public Bounds transformToDrawing(Bounds bounds) {
        return new Bounds(
                bounds.getX()*scale+panX,
                bounds.getY()*scale+panY,
                bounds.getWidth()*scale,
                bounds.getHeight()*scale);
    }
View Full Code Here

            x = Math.min(x, ux);
            y = Math.min(y, uy);
            w = Math.max(w, ux + n.getTransformedBounds().getWidth());
            h = Math.max(h, uy + n.getTransformedBounds().getHeight());
        }
        return new Bounds(x,y,w-x,h-y);
    }
View Full Code Here

        dragRectStartPoint = null;
        dragRectEndPoint = null;
        pressed = false;
        if(selectedHandle instanceof ResizeHandle) {
            ResizeHandle rh = (ResizeHandle) selectedHandle;
            final Bounds startBounds = this.resizeStartBounds;
            final SResizeableNode sn = rh.getResizeableNode();
            final Bounds endBounds = new Bounds(sn.getX(), sn.getY(), sn.getWidth(), sn.getHeight());
            context.getUndoManager().pushAction(new UndoManager.UndoableAction(){
                public void executeUndo() {
                    sn.setX(startBounds.getX());
                    sn.setY(startBounds.getY());
                    sn.setWidth(startBounds.getWidth());
                    sn.setHeight(startBounds.getHeight());
                }
                public void executeRedo() {
                    sn.setX(endBounds.getX());
                    sn.setY(endBounds.getY());
                    sn.setWidth(endBounds.getWidth());
                    sn.setHeight(endBounds.getHeight());
                }
                public String getName() {
                    return "Resize node";
                }
            });
View Full Code Here

        context.redraw();
    }

    @Override
    public Bounds getBounds() {
        return new Bounds(getTranslateX()-radius,getTranslateY()-radius,radius*2,radius*2);
    }
View Full Code Here

        }

        //draw an indicator for all link nodes
        for(SNode node : context.getDocument().getCurrentPage().getNodes()) {
            if(!node.isLink()) continue;
            Bounds bds = node.getTransformedBounds();
            g.translate(bds.getX2(), bds.getY2());
            g.setPaint(FlatColor.WHITE);
            g.fillRoundRect(0,0,30,15,10,10);
            g.setPaint(FlatColor.BLACK);
            g.drawRoundRect(0,0,30,15,10,10);
            g.drawText("Go!",Font.DEFAULT,3,12);
            g.translate(-bds.getX2(), -bds.getY2());
        }

        //draw the move position indicator
        if(!showIndicator) return;
        Bounds sb = context.getSketchCanvas().selection.calculateBounds();
        String l1 = "";
        String l2 = "";
        if(selectedHandle != null) {
            String[] lines = selectedHandle.customStatusLines();
            if(lines == null || lines.length < 1) {
                l1 = "w: "+moveInfoFormatter.format(sb.getWidth());
                l2 = "h: "+moveInfoFormatter.format(sb.getHeight());
            } else {
                if(lines.length >= 1) l1 = lines[0];
                if(lines.length >= 2) l2 = lines[1];
            }
        } else {
            l1 = "x: "+moveInfoFormatter.format(sb.getX());
            l2 = "y: "+moveInfoFormatter.format(sb.getY());
        }
        sb = context.getSketchCanvas().transformToDrawing(sb);

        g.setPaint(FlatColor.hsb(0,0,0.6,ido));
        g.fillRoundRect(sb.getX()+sb.getWidth()+20,sb.getY()+sb.getHeight()/2-20,50,40,10,10);
        g.setPaint(new FlatColor(1.0,1.0,1.0,ido));
        g.drawText(l1,moveInfoFont,sb.getX()+sb.getWidth()+20+10,sb.getY()+sb.getHeight()/2-20+15);
        g.drawText(l2,moveInfoFont,sb.getX()+sb.getWidth()+20+10,sb.getY()+sb.getHeight()/2-20+15+15);
        g.setPaint(FlatColor.hsb(0,0,0.4,ido));
        g.drawRoundRect(sb.getX()+sb.getWidth()+20,sb.getY()+sb.getHeight()/2-20,50,40,10,10);
    }
View Full Code Here

            //g.translate(-100,-100);
        }

        @Override
        public Bounds getVisualBounds() {
            return new Bounds(0,0,100,100);
        }
View Full Code Here

        this.x = 0;
    }

    @Override
    public Bounds getBounds() {
        return new Bounds(x,y,w,h);
    }
View Full Code Here

            }
        }

        @Override
        public Bounds getVisualBounds() {
            return new Bounds(0,0,600,600);
        }
View Full Code Here

        listview.setRenderer(new ListView.ItemRenderer<SketchDocument.SketchPage>() {
            public void draw(GFX gfx, ListView listView, SketchDocument.SketchPage item,
                             int index, double x, double y, double width, double height) {
                gfx.setPaint(context.getDocument().getBackgroundFill());
                gfx.fillRect(x, y, width, height);
                Bounds oldClip = gfx.getClipRect();
                gfx.setClipRect(new Bounds(x, y, width, height));
                if (item != null) {
                    gfx.translate(x, y);
                    double w = context.getDocument().getWidth();
                    double h = context.getDocument().getHeight();
                    double s = 100.0 / w;
View Full Code Here

TOP

Related Classes of org.joshy.gfx.node.Bounds

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.