Package org.joshy.gfx.node

Examples of org.joshy.gfx.node.Bounds


        updateControlPositions();
    }

    private void snapX(AbstractResizeableNode node, double x) {
        LinearGradientFill f = getFill();
        Bounds b = node.getTransformedBounds();
        if(Math.abs(x-0)<5) {
            f.setStartX(0);
            f.setStartXSnapped(LinearGradientFill.Snap.Start);
            return;
        }
        if(Math.abs(x-b.getWidth()/2)<5) {
            f.setStartX(b.getWidth() / 2);
            f.setStartXSnapped(LinearGradientFill.Snap.Middle);
            return;
        }
        if(Math.abs(x-b.getWidth())<5) {
            f.setStartX(b.getWidth());
            f.setStartXSnapped(LinearGradientFill.Snap.End);
            return;
        }
        f.setStartX(x);
        f.setStartXSnapped(LinearGradientFill.Snap.None);
View Full Code Here


        refresh();
        updateControlPositions();
    }
    private void snapY(AbstractResizeableNode node, double y) {
        LinearGradientFill f = getFill();
        Bounds b = node.getTransformedBounds();
        if(Math.abs(y-0)<5) {
            f.setStartY(0);
            f.setStartYSnapped(LinearGradientFill.Snap.Start);
            return;
        }
        if(Math.abs(y-b.getHeight()/2)<5) {
            f.setStartY(b.getHeight() / 2);
            f.setStartYSnapped(LinearGradientFill.Snap.Middle);
            return;
        }
        if(Math.abs(y-b.getHeight())<5) {
            f.setStartY(b.getHeight());
            f.setStartYSnapped(LinearGradientFill.Snap.End);
            return;
        }
        f.setStartY(y);
        f.setStartYSnapped(LinearGradientFill.Snap.None);
View Full Code Here

    public SPoly() {
        points = new ArrayList<Point2D>();
        this.setFillPaint(FlatColor.BLUE);
        closed = false;
        bounds = new Bounds(0,0,0,0);
    }
View Full Code Here

        if(isClosed()) {
            p.closePath();
        }
        path = p;
        Rectangle2D bounds = path.getBounds2D();
        this.bounds = new Bounds(
                bounds.getX(),
                bounds.getY(),
                bounds.getWidth(),
                bounds.getHeight());
    }
View Full Code Here

        return closed;
    }

    @Override
    public Bounds getBounds() {
        return new Bounds(
                bounds.getX(),
                bounds.getY(),
                bounds.getWidth(),bounds.getHeight());

    }
View Full Code Here

        shape = (ResizableGrid9Shape)context.getSelection().items().iterator().next();
        sizedWidth = shape.getWidth();
        sizedHeight = shape.getHeight();
        shape.setWidth(shape.getOriginalWidth());
        shape.setHeight(shape.getOriginalHeight());
        Bounds bounds = shape.getBounds();
        handles.add(new VHandle(shape,shape.getLeft()+bounds.getX(),0, PositionHandle.Position.Left));
        handles.add(new VHandle(shape,shape.getRight()+bounds.getX(),0, PositionHandle.Position.Right));
        handles.add(new VHandle(shape,0,shape.getTop()+bounds.getY(), PositionHandle.Position.Top));
        handles.add(new VHandle(shape,0,shape.getBottom()+bounds.getY(), PositionHandle.Position.Bottom));

        hlocked = new Togglebutton("h locked");
        hlocked.setSelected(shape.isHLocked());
        hlocked.onClicked(new Callback<ActionEvent>(){
            public void call(ActionEvent event) {
View Full Code Here

    protected void mouseMoved(MouseEvent event, Point2D.Double cursor) {
    }

    @Override
    protected void mousePressed(MouseEvent event, Point2D.Double cursor) {
        Bounds bounds = shape.getBounds();
        //grow by 5 pixels on a side to account for the handles
        bounds = new Bounds(bounds.getX()-5,bounds.getY()-5,bounds.getWidth()+10,bounds.getHeight()+10);
        if(bounds.contains(cursor)) {
            for(VHandle handle : handles) {
                if((handle.getPosition() == PositionHandle.Position.Left) || (handle.getPosition() == PositionHandle.Position.Right)) {
                    if(Math.abs(cursor.getX()-handle.getX()) < 10) {
                        selectedHandle = handle;
                        return;
View Full Code Here

        master.updateControlPositions();
    }

    private void snapX(AbstractResizeableNode node, double x) {
        LinearGradientFill f = getFill();
        Bounds b = node.getTransformedBounds();
        if(Math.abs(x-0)<5) {
            f.setEndX(0);
            f.setEndXSnapped(LinearGradientFill.Snap.Start);
            return;
        }
        if(Math.abs(x-b.getWidth()/2)<5) {
            f.setEndX(b.getWidth() / 2);
            f.setEndXSnapped(LinearGradientFill.Snap.Middle);
            return;
        }
        if(Math.abs(x-b.getWidth())<5) {
            f.setEndX(b.getWidth());
            f.setEndXSnapped(LinearGradientFill.Snap.End);
            return;
        }
        f.setEndX(x);
        f.setEndXSnapped(LinearGradientFill.Snap.None);
View Full Code Here

    public void drawOverlay(GFX g) {
        g.push();
        g.translate(context.getSketchCanvas().getPanX(),context.getSketchCanvas().getPanY());
        g.scale(context.getSketchCanvas().getScale(),context.getSketchCanvas().getScale());
        g.setPaint(FlatColor.RED);
        Bounds bounds = shape.getBounds();
        g.drawRect(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight());
        FlatColor color = new FlatColor(0xff097d);
        for(VHandle handle : handles) {
            switch(handle.getPosition()) {
                case Top:
                case Bottom:
                    g.setPaint(color);
                    g.drawLine(bounds.getX(),handle.getY(),bounds.getX()+bounds.getWidth(),handle.getY());
                    DrawUtils.drawStandardHandle(g,bounds.getX(),handle.getY(),color);
                    DrawUtils.drawStandardHandle(g,bounds.getX()+bounds.getWidth(),handle.getY(),color);
                    break;
                case Right:
                case Left:
                    g.setPaint(color);
                    g.drawLine(handle.getX(),bounds.getY(),handle.getX(),bounds.getY()+bounds.getHeight());
                    DrawUtils.drawStandardHandle(g,handle.getX(),bounds.getY(),color);
                    DrawUtils.drawStandardHandle(g,handle.getX(),bounds.getY()+bounds.getHeight(),color);
                    break;
            }
        }
       
        g.setPaint(FlatColor.GREEN);
        g.translate(bounds.getX(),bounds.getY());
        for(SNode node: shape.getNodes()) {
            Bounds b = node.getTransformedBounds();
            g.drawRect(b.getX(),b.getY(),b.getWidth(),b.getHeight());
        }
        g.pop();
       
       
    }
View Full Code Here

        this(5);
    }

    @Override
    public Bounds getBounds() {
        return new Bounds(
                -getRadius(),
                -getRadius(),
                getRadius()*2,getRadius()*2);
    }
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.