Package org.joshy.gfx.node

Examples of org.joshy.gfx.node.Bounds


            if(this.doc != null) doc = this.doc;
            if(this.context != null) doc = context.getDocument();

            Paint fill = this.backgroundFill;
            if(this.backgroundFill instanceof LinearGradientFill) {
                fill = DocumentActions.resizeTo((LinearGradientFill) this.backgroundFill,new Bounds(0,0,doc.getWidth(),doc.getHeight()));
            }
            doc.setBackgroundFill(fill);
            doc.getProperties().put("theme",this);

            for(SketchDocument.SketchPage page : doc.getPages()) {
View Full Code Here


    }

    @Override
    public void execute() {
        if(context.getSelection().isEmpty()) return;
        Bounds sbounds = context.getSelection().calculateBounds();
        ResizableGrid9Shape shape = new ResizableGrid9Shape(0,0,sbounds.getWidth(),sbounds.getHeight());
        shape.setTranslateX(sbounds.getX());
        shape.setTranslateY(sbounds.getY());

        SketchDocument doc = context.getDocument();
        for(SNode node : context.getSelection().sortedItems(doc)) {
            shape.add(node);
            doc.getCurrentPage().remove(node);
View Full Code Here

            save.export(file, (PixelDocument) doc);
        }
    }

    public static void exportFragment(File file, Iterable<SNode> nodes) {
        Bounds bounds = calculateBounds(nodes);
        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());
        ExportProcessor.processFragment(new PNGExporter(), g2, nodes);
        g2.dispose();
        try {
            ImageIO.write(img,"png", file);
        } catch (IOException e) {
View Full Code Here

        }
    }

    @Override
    public void export(File file, SketchDocument doc) {
        Bounds bounds = null;
        if(includeDocumentBounds) {
            bounds = new Bounds(0,0,doc.getWidth(),doc.getHeight());
        } else {
            bounds = calculateBounds(doc.getCurrentPage().getModel());
        }
        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());
        PNGExporter exporter = new PNGExporter();
        exporter.setIncludeDocumentBackground(includeBackground);
        ExportProcessor.process(exporter, g2, doc);
        if(includeStamp) {
            g2.translate(bounds.getX(),bounds.getY());
            g2.setPaint(Color.BLACK);
            Font font = org.joshy.gfx.draw.Font.DEFAULT.getAWTFont();
            g2.setFont(font);
            String stamp = "handcrafted with LeonardoSketch.org";
            Rectangle2D sb = font.getStringBounds(stamp, g2.getFontRenderContext());
View Full Code Here

        double x = Double.MAX_VALUE;
        double y = Double.MAX_VALUE;
        double w = Double.MIN_VALUE;
        double h = Double.MIN_VALUE;
        for(SNode n : model) {
            Bounds b = n.getTransformedBounds();
            /*
            if(n instanceof SShape) {
                b = ((SShape) n).getEffectBounds();
            }
            */
            x = Math.min(x, b.getX());
            y = Math.min(y, b.getY());
            w = Math.max(w, b.getX() + b.getWidth());
            h = Math.max(h, b.getY() + b.getHeight());
        }
        return new Bounds(x,y,w-x,h-y);
    }
View Full Code Here

                    }
                    if(asset.getKind().equals(AssetDB.FONT)) {
                        img = RenderUtil.fontToImage(asset);
                    }
                    if(img != null) {
                        Bounds oldClip = gfx.getClipRect();
                        gfx.setClipRect(new Bounds(x,y,w,h));
                        gfx.drawImage(img,x,y);
                        gfx.setClipRect(oldClip);
                    }
                }
            }
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.