Package org.joshy.gfx.node

Examples of org.joshy.gfx.node.Bounds


                    +"abcdefghijklmnopqrstuvwxyz"
                    +"0123456789"
                    +" ,./;'[]\\!@#$%^&*()_+-="
                    ;
            node.setText(key);
            Bounds bounds = node.getTransformedBounds();
            BufferedImage img = new BufferedImage((int)bounds.getWidth()+1,(int)bounds.getHeight()+1,BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = img.createGraphics();
            g2.translate(-bounds.getX(), -bounds.getY());
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            SwingGFX gfx = new SwingGFX(g2);
            double[] metrics = node.getExportMetrics(gfx);
            g2.translate(node.getTranslateX(), node.getTranslateY());

View Full Code Here


        }
    }

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

        this(0,0,100,100);       
    }

    @Override
    public Bounds getBounds() {
        return new Bounds(getTranslateX()+getX(),getTranslateY()+getY(),getWidth(),getHeight());
    }
View Full Code Here

    }

    @Override
    public void doLayout() {
        if(selected) {
            Bounds bounds = selection.calculateBounds();
            bounds = context.getSketchCanvas().transformToDrawing(bounds);
            bounds = NodeUtils.convertToScene(context.getSketchCanvas(),bounds);
            Stage stage = this.getStage();

            double x = bounds.getX();
            double y = bounds.getY() + bounds.getHeight()+20;
            double h = stage.getContent().getVisualBounds().getHeight();
            double w = stage.getContent().getVisualBounds().getWidth();
            double bottom = y + this.getHeight();

            //if to low then put above the item
            if(bottom > h-140) {
                //the 130 above is to account for the height of the fill picker
                y = bounds.getY()-this.getHeight()-20;
            }
            //if off the top now, then move to the right
            if (y < 0) {
                y = 10;
                x = bounds.getX2() + 20;
            }

            //if off the right then move to the left
            if(x + this.getWidth() > w) {
                x = bounds.getX()-this.getWidth()-20;
            }

            //if too far off the left then just shove on the left edge and accept it will overlap
            if(x < 0) {
                x = 20;
View Full Code Here

            double top = Integer.MAX_VALUE;
            for(SNode node: context.getSelection().items()) {
                top = Math.min(top,node.getTransformedBounds().getY());
            }
            for(SNode node: context.getSelection().items()) {
                Bounds bounds = node.getTransformedBounds();
                double diff = top - (bounds.getY());
                node.setTranslateY(node.getTranslateY()+diff);
                diffs.put(node,new Point2D.Double(0,diff));
            }
            context.redraw();
            AlignUndoAction action = new AlignUndoAction(diffs, context, getString("menus.alignNodeTop"));
View Full Code Here

    private void setFillStuff(Paint paint) {
        if(paint instanceof RadialGradientFill) {
            RadialGradientFill grad = (RadialGradientFill) paint.duplicate();
            SShape shape = (SShape) context.getSelection().firstItem();
            Bounds bounds = shape.getTransformedBounds();
            grad.setCenterX(bounds.getWidth()/2);
            grad.setCenterY(bounds.getWidth()/2);
            grad.setRadius(Math.min(bounds.getWidth()/2,bounds.getHeight()/2));
            setPropertyWithUndo("fillPaint",grad);
            return;
        }
        if(paint instanceof LinearGradientFill) {
            LinearGradientFill grad = (LinearGradientFill) paint.duplicate();
            SShape shape = (SShape) context.getSelection().firstItem();
            Bounds bounds = shape.getTransformedBounds();
            switch(grad.getStartXSnapped()) {
                case Start:  grad.setStartX(0); break;
                case Middle: grad.setStartX(bounds.getWidth()/2); break;
                case End:    grad.setStartX(bounds.getWidth()); break;
            }
            switch(grad.getEndXSnapped()) {
                case Start:  grad.setEndX(0); break;
                case Middle: grad.setEndX(bounds.getWidth()/2); break;
                case End:    grad.setEndX(bounds.getWidth()); break;
            }
            switch(grad.getStartYSnapped()) {
                case Start:  grad.setStartY(0); break;
                case Middle: grad.setStartY(bounds.getHeight()/2); break;
                case End:    grad.setStartY(bounds.getHeight()); break;
            }
            switch(grad.getEndYSnapped()) {
                case Start:  grad.setEndY(0); break;
                case Middle: grad.setEndY(bounds.getHeight()/2); break;
                case End:    grad.setEndY(bounds.getHeight()); break;
            }
            setPropertyWithUndo("fillPaint",grad);
            return;
        }
        //if just a normal color
View Full Code Here

        @Override
        public void execute() {
            Map<SNode,Point2D.Double> diffs = new HashMap<SNode,Point2D.Double>();
            double bottom = Integer.MIN_VALUE;
            for(SNode node: context.getSelection().items()) {
                Bounds bounds = node.getTransformedBounds();
                bottom = Math.max(bottom, bounds.getY() + bounds.getHeight());
            }
            for(SNode node: context.getSelection().items()) {
                Bounds bounds = node.getTransformedBounds();
                double diff = bottom - (bounds.getY() + bounds.getHeight());
                node.setTranslateY(node.getTranslateY()+diff);
                diffs.put(node,new Point2D.Double(0,diff));
            }
            context.redraw();
            AlignUndoAction action = new AlignUndoAction(diffs, context, getDisplayName());
View Full Code Here

    }

    public void drawOverlay(GFX g) {
        if(context.getSelection().size() != 1) return;
        if(node == null) return;
        Bounds bounds = node.getBounds();
        g.setPaint(FlatColor.RED);
        g.drawRect(bounds.getX(),bounds.getY(),bounds.getWidth()*node.getScaleX(),bounds.getHeight()*node.getScaleY());

        for(ScaleHandle h : handles) {
            g.drawOval(h.getX()-5,h.getY()-5,10,10);
        }

View Full Code Here

            double left = Integer.MAX_VALUE;
            for(SNode node: context.getSelection().items()) {
                left = Math.min(left, node.getTransformedBounds().getX());
            }
            for(SNode node: context.getSelection().items()) {
                Bounds bounds = node.getTransformedBounds();
                double diff = left - (bounds.getX());
                node.setTranslateX(node.getTranslateX()+diff);
                diffs.put(node,new Point2D.Double(diff,0));
            }
            context.redraw();
            AlignUndoAction action = new AlignUndoAction(diffs, context, getDisplayName());
View Full Code Here

        @Override
        public void execute() {
            Map<SNode,Point2D.Double> diffs = new HashMap<SNode,Point2D.Double>();
            double right = Integer.MIN_VALUE;
            for(SNode node: context.getSelection().items()) {
                Bounds bounds = node.getTransformedBounds();
                right = Math.max(right,bounds.getX()+bounds.getWidth());
            }
            for(SNode node: context.getSelection().items()) {
                Bounds bounds = node.getTransformedBounds();
                double diff = right - (bounds.getX()+bounds.getWidth());
                node.setTranslateX(node.getTranslateX()+diff);
                diffs.put(node,new Point2D.Double(diff,0));
            }
            context.redraw();
            AlignUndoAction action = new AlignUndoAction(diffs, context, getDisplayName());
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.