Package org.joshy.gfx.node

Examples of org.joshy.gfx.node.Bounds


        master.updateControlPositions();
    }

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


        public double getX() {
            return x;
        }

        public void setX(double x) {
            Bounds bounds = shape.getBounds();
            x = Math.max(bounds.getX(),x);
            x = Math.min(bounds.getX()+bounds.getWidth(),x);
            this.x = x;
            x -= bounds.getX();
            if(position == PositionHandle.Position.Left) {
                shape.setLeft(x);
            }
            if(position == PositionHandle.Position.Right) {
                shape.setRight(x);
View Full Code Here

        public void execute() {
            if(context.getSelection().size() != 1) return;
            SNode node = context.getSelection().firstItem();
            if(!(node instanceof SPath)) return;
            SPath path = (SPath) node;
            Bounds bounds = path.getTransformedBounds();
            for(SPath.SubPath sub : path.getSubPaths()) {
                for(SPath.PathPoint pt : sub.getPoints()) {

                    pt.x = pt.x -bounds.getX()+path.getTranslateX();
                    pt.y = pt.y -bounds.getY()+path.getTranslateY();
                    pt.cx1 = pt.cx1 -bounds.getX()+path.getTranslateX();
                    pt.cy1 = pt.cy1 -bounds.getY()+path.getTranslateY();
                    pt.cx2 = pt.cx2 -bounds.getX()+path.getTranslateX();
                    pt.cy2 = pt.cy2 -bounds.getY()+path.getTranslateY();

                    modifyPoint(bounds,path,pt);

                    pt.x = pt.x + bounds.getX()-path.getTranslateX();
                    pt.y = pt.y + bounds.getY()-path.getTranslateY();
                    pt.cx1 = pt.cx1 + bounds.getX()-path.getTranslateX();
                    pt.cy1 = pt.cy1 + bounds.getY()-path.getTranslateY();
                    pt.cx2 = pt.cx2 + bounds.getX()-path.getTranslateX();
                    pt.cy2 = pt.cy2 + bounds.getY()-path.getTranslateY();
                }
            }
            path.recalcPath();
            context.redraw();
        }
View Full Code Here

        public double getY() {
            return y;
        }

        public void setY(double y) {
            Bounds bounds = shape.getBounds();
            y = Math.max(bounds.getY(),y);
            y = Math.min(bounds.getY()+bounds.getHeight(),y);
            this.y = y;
            y -= bounds.getY();
            if(position == PositionHandle.Position.Top) {
                shape.setTop(y);
            }
            if(position == PositionHandle.Position.Bottom) {
                shape.setBottom(y);
View Full Code Here

    }

    @Override
    public Bounds getBounds() {
        Rectangle2D r = calcBounds(getTranslateX(),getTranslateY()).getBounds2D();
        return new Bounds(r.getX(),r.getY(),r.getWidth(),r.getHeight());
    }
View Full Code Here


    @Override
    public void draw(GFX g) {
        Font fnt = Font.name("OpenSans").size(8).resolve();
        Bounds oldBounds = g.getClipRect();
        g.setClipRect(new Bounds(0,0,getWidth(),getHeight()));

        //draw the background
        if(vertical) {
            g.setPaint(new LinearGradientFill().setStartX(0).setEndX(getWidth()).setStartY(0).setEndY(0)
                    .addStop(0,FlatColor.hsb(0,0,0.9))
View Full Code Here

    }

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

        this.setHeight(this.icon.getHeight());
    }

    @Override
    public Bounds getLayoutBounds() {
        return new Bounds(getTranslateX(), getTranslateY(), this.icon.getWidth(), this.icon.getHeight());
    }
View Full Code Here

        if(shadow != null) {
            int blurRadius = shadow.getBlurRadius();
            if(blurRadius <= 0) blurRadius = 0;
            double xoff = shadow.getXOffset();
            double yoff = shadow.getYOffset();
            Bounds b = getBounds();

            if(buf == null
                    || shadow != oldShadow
                    || b.getWidth() != oldWidth
                    || b.getHeight() != oldHeight
                    || shadow.isInner() != oldInner
                    || contentChanged) {
                if(shadow.isInner()) {
                    regenInnerShadow(g);
                } else {
                    regenShadow(g);
                }
                oldInner = shadow.isInner();
                contentChanged = false;
            }
            double oldOpacity = g.getOpacity();
            g.setOpacity(shadow.getOpacity());
            g.draw(buf,b.getX()-blurRadius*2+xoff,b.getY()-blurRadius*2+yoff);
            g.setOpacity(oldOpacity);
        }
    }
View Full Code Here

    }

    protected void regenInnerShadow(GFX g) {
        //setup
        int blurRadius = 5;
        Bounds b = getBounds();
        ImageBuffer bufx = g.createBuffer(
                (int)b.getWidth()+blurRadius*2,
                (int)b.getHeight()+blurRadius*2);

        //render shadow to buffer
        bufx.clear();
        GFX g2 = bufx.getGFX();
        g2.setPaint(FlatColor.BLACK);
        g2.translate(10, 10);
        fillShape(g2);
        g2.translate(-10, -10);
        bufx.apply(new BlurEffect(blurRadius));
        g2.dispose();

        //invert alpha channel
        for(int i=0; i<bufx.buf.getWidth(); i++) {
            for(int j=0; j<bufx.buf.getHeight(); j++) {
                int rgb = bufx.buf.getRGB(i,j);
                int a = (0xFF000000 & rgb)>>24;
                a = 255-a;
                rgb = (rgb & 0x00FFFFFF) | (a<<24);
                bufx.buf.setRGB(i,j,rgb);
            }
        }


        //composite using a boolean op to mask out the bg
        buf = g.createBuffer(
                (int)b.getWidth()+blurRadius*2,
                (int)b.getHeight()+blurRadius*2);
        SwingGFX gx =(SwingGFX)buf.getGFX();
        Graphics2D graphics2D = (Graphics2D) gx.getNative();
        graphics2D.setComposite(AlphaComposite.SrcOver);

        initPaint(gx);
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.