Package org.joshy.gfx.draw

Examples of org.joshy.gfx.draw.LinearGradientFill


    @Test public void testArrow() {

    }

    @Test public void testGradientRect() throws Exception {
        MultiGradientFill grad = new LinearGradientFill()
                .setStartX(3).setStartY(0).setEndX(97).setEndY(0)
                .addStop(0, FlatColor.BLUE)
                .addStop(1, FlatColor.RED);
        SRect rect = new SRect(0,0,100,100);
        rect.setFillPaint(grad);
View Full Code Here


        Doc xdoc = saveAndReadback(doc);
        Elem e = xdoc.xpath("/svg/linearGradient/stop").iterator().next();
        assertTrue("0.0".equals(e.attr("offset")));
    }
    @Test public void testLinearGradientRect() throws Exception {
        MultiGradientFill grad = new LinearGradientFill()
                .setStartX(0).setEndX(100)
                .setStartY(0).setEndY(0)
                .addStop(0,FlatColor.GREEN)
                .addStop(0.5,FlatColor.WHITE)
                .addStop(1.0,FlatColor.BLACK);
View Full Code Here

        refresh();
        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 void changed() {
        if(shape instanceof AbstractResizeableNode) {
            AbstractResizeableNode res = (AbstractResizeableNode) shape;
            Paint paint = shape.getFillPaint();
            if(paint instanceof LinearGradientFill) {
                LinearGradientFill lg = (LinearGradientFill) paint;
                switch(lg.getStartXSnapped()) {
                    case Start: lg.setStartX(0); break;
                    case Middle: lg.setStartX(res.getBounds().getWidth() / 2); break;
                    case End: lg.setStartX(res.getBounds().getWidth()); break;
                }
                switch(lg.getStartYSnapped()) {
                    case Start: lg.setStartY(0); break;
                    case Middle: lg.setStartY(res.getBounds().getHeight() / 2); break;
                    case End: lg.setStartY(res.getBounds().getHeight()); break;
                }
                switch(lg.getEndXSnapped()) {
                    case Start: lg.setEndX(0); break;
                    case Middle: lg.setEndX(res.getBounds().getWidth()/2); break;
                    case End: lg.setEndX(res.getBounds().getWidth()); break;
                }
                switch(lg.getEndYSnapped()) {
                    case Start: lg.setEndY(0); break;
                    case Middle: lg.setEndY(res.getBounds().getHeight() / 2); break;
                    case End: lg.setEndY(res.getBounds().getHeight()); break;
                }
            }
        }
        super.changed();
    }
View Full Code Here

        master.refresh();
        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

        master.refresh();
        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

            if(name != null) doc.getCurrentPage().setName(name);
        }
    }

    public static LinearGradientFill resizeTo(LinearGradientFill grad, Bounds bounds) {
        LinearGradientFill g2 = (LinearGradientFill) grad.duplicate();
        switch(grad.getStartXSnapped()) {
            case Start: g2.setStartX(bounds.getX()); break;
            case Middle: g2.setStartX(bounds.getCenterX()); break;
            case End: g2.setStartX(bounds.getX2()); break;
        }
        switch(grad.getEndXSnapped()) {
            case Start: g2.setEndX(bounds.getX()); break;
            case Middle: g2.setEndX(bounds.getCenterX()); break;
            case End: g2.setEndX(bounds.getX2()); break;
        }
        switch(grad.getStartYSnapped()) {
            case Start: g2.setStartY(bounds.getY()); break;
            case Middle: g2.setStartY(bounds.getCenterY()); break;
            case End: g2.setStartY(bounds.getY2()); break;
        }
        switch(grad.getEndYSnapped()) {
            case Start: g2.setEndY(bounds.getY()); break;
            case Middle: g2.setEndY(bounds.getCenterY()); break;
            case End: g2.setEndY(bounds.getY2()); break;
        }
        return g2;
    }
View Full Code Here

        //center
        s = 5;
        //g.setPaint(new FlatColor(0xa00000));
        double hue = color.getHue();
        MultiGradientFill fill = new LinearGradientFill()
                .setStartX(0).setEndX(0).setStartY(0).setEndY(s * 2)
                .addStop(0, FlatColor.hsb(hue, 0.4, 1.0))
                .addStop(1, FlatColor.hsb(hue, 1.0, 1.0));
        g.setPaint(fill);
        g.translate(x-s,y-s);
View Full Code Here

            g.fillPolygon(new double[]{0.0-s/2,0.0+yoff, s/2,0.0 +yoff,0,s+yoff});
            //center
            s = 10;
            yoff = 1;
            double hue = color.getHue();
            MultiGradientFill fill = new LinearGradientFill()
                    .setStartX(0).setEndX(0).setStartY(0).setEndY(s)
                    .addStop(0,FlatColor.hsb(hue,0.4,1.0))
                    .addStop(1,FlatColor.hsb(hue,1.0,1.0))
                    ;
            g.setPaint(fill);
            g.translate(0,0);
            g.fillPolygon(new double[]{0.0-s/2,0.0+yoff, s/2,0.0 +yoff,0,s+yoff});
            g.translate(0,0);
        } else {
            //shadow
            g.setPaint(new FlatColor(0x404040).deriveWithAlpha(0.5));
            s = 14;
            yoff = 1;
            g.fillPolygon(new double[]{0.0+yoff, 0.0-s/2, 0.0+yoff, s/2,0.0+s +yoff,0});


            //border
            g.setPaint(FlatColor.WHITE);
            s = 14;
            yoff = 0;
            g.fillPolygon(new double[]{0.0+yoff, 0.0-s/2, 0.0+yoff, s/2,0.0+s +yoff,0});
            //center
            s = 10;
            yoff = 1;
            double hue = color.getHue();
            MultiGradientFill fill = new LinearGradientFill()
                    .setStartX(0).setEndX(s).setStartY(0).setEndY(0)
                    .addStop(0,FlatColor.hsb(hue,0.4,1.0))
                    .addStop(1,FlatColor.hsb(hue,1.0,1.0))
                    ;
            g.setPaint(fill);
View Full Code Here

TOP

Related Classes of org.joshy.gfx.draw.LinearGradientFill

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.