Package org.apache.batik.gvt.renderer

Examples of org.apache.batik.gvt.renderer.ImageRenderer


    // paint the SVG document using the bridge package
    // create the appropriate renderer

    // TODO : optimization could reuse renderers
    ImageRenderer renderer = new StaticRenderer();
    renderer.updateOffScreen(w, h);
    // curTxf.translate(0.5, 0.5);
    renderer.setTransform(curTxf);
    renderer.setTree(this.root);
    this.root = null; // We're done with it...

    try {
      // now we are sure that the aoi is the image size
      Shape raoi = new Rectangle2D.Float(0, 0, width, height);
      // Warning: the renderer's AOI must be in user space
      renderer.repaint(curTxf.createInverse()
          .createTransformedShape(raoi));
      BufferedImage rend = renderer.getOffScreen();
      renderer = null; // We're done with it...

      BufferedImage dest = createImage(w, h);

      Graphics2D g2d = GraphicsUtil.createGraphics(dest);
View Full Code Here


        int h = (int)(height+0.5);

        // paint the SVG document using the bridge package
        // create the appropriate renderer
        ImageRendererFactory rendFactory = new ConcreteImageRendererFactory();
        ImageRenderer renderer = rendFactory.createStaticImageRenderer();
        renderer.updateOffScreen(w, h);
        renderer.setTransform(curTxf);
        renderer.setTree(this.root);
        this.root = null; // We're done with it...

        try {
            // now we are sure that the aoi is the image size
            Shape raoi = new Rectangle2D.Float(0, 0, width, height);
            // Warning: the renderer's AOI must be in user space
            renderer.repaint(curTxf.createInverse().
                             createTransformedShape(raoi));
            BufferedImage rend = renderer.getOffScreen();
            renderer = null; // We're done with it...

            BufferedImage dest = createImage(w, h);

            Graphics2D g2d = GraphicsUtil.createGraphics(dest);
View Full Code Here

        int w = (int)(width+0.5);
        int h = (int)(height+0.5);

        // paint the SVG document using the bridge package
        // create the appropriate renderer
        ImageRenderer renderer = rendFactory.createStaticImageRenderer();
        renderer.updateOffScreen(w, h);
        renderer.setTransform(Px);
        renderer.setTree(gvtRoot);
        gvtRoot = null; // We're done with it...

        try {
            // now we are sure that the aoi is the image size
            Shape raoi = new Rectangle2D.Float(0, 0, width, height);
            // Warning: the renderer's AOI must be in user space
            renderer.repaint(Px.createInverse().createTransformedShape(raoi));
            BufferedImage rend = renderer.getOffScreen();
            renderer = null; // We're done with it...

            BufferedImage dest = createImage(w, h);

            Graphics2D g2d = GraphicsUtil.createGraphics(dest);
View Full Code Here

        int w = (int)(width+0.5);
        int h = (int)(height+0.5);

        // paint the SVG document using the bridge package
        // create the appropriate renderer
        ImageRenderer renderer = rendFactory.createStaticImageRenderer();
        renderer.updateOffScreen(w, h);
        renderer.setTransform(Px);
        renderer.setTree(gvtRoot);
        gvtRoot = null; // We're done with it...

        try {
            // now we are sure that the aoi is the image size
            Shape raoi = new Rectangle2D.Float(0, 0, width, height);
            // Warning: the renderer's AOI must be in user space
            renderer.repaint(Px.createInverse().createTransformedShape(raoi));
            BufferedImage rend = renderer.getOffScreen();
            renderer = null; // We're done with it...

            BufferedImage dest = createImage(w, h);

            Graphics2D g2d = GraphicsUtil.createGraphics(dest);
View Full Code Here

 
  public BufferedImage renderToImage(SVGDocument document, int width, int height, boolean stretch){
   
    ImageRendererFactory rendererFactory;
    rendererFactory = new ConcreteImageRendererFactory();
    ImageRenderer renderer = rendererFactory.createStaticImageRenderer();

    GVTBuilder builder = new GVTBuilder();
    BridgeContext ctx = new BridgeContext(new UserAgentAdapter());
    ctx.setDynamicState(BridgeContext.STATIC);
    GraphicsNode rootNode = builder.build(ctx, document);

    renderer.setTree(rootNode);
   
    float docWidth  = (float) ctx.getDocumentSize().getWidth();
    float docHeight = (float) ctx.getDocumentSize().getHeight();
   
    float xscale = width/docWidth;
    float yscale = height/docHeight;
    if(!stretch){
      float scale = Math.min(xscale, yscale);
      xscale = scale;
      yscale = scale;
    }
   
    AffineTransform px  = AffineTransform.getScaleInstance(xscale, yscale);
   
    double tx = -0 + (width/xscale - docWidth)/2;
    double ty = -0 + (height/yscale - docHeight)/2;
    px.translate(tx, ty);
    //cgn.setViewingTransform(px);
   
    renderer.updateOffScreen(width, height);
    renderer.setTree(rootNode);
    renderer.setTransform(px);
    //renderer.clearOffScreen();
    renderer.repaint(new Rectangle(0, 0, width, height));

    return renderer.getOffScreen();

  }
View Full Code Here

        // paint the SVG document using the bridge package
        // create the appropriate renderer
        ImageRendererFactory rendFactory = new ConcreteImageRendererFactory();
        // ImageRenderer renderer = rendFactory.createDynamicImageRenderer();
        ImageRenderer renderer = rendFactory.createStaticImageRenderer();
        renderer.updateOffScreen(w, h);
        // curTxf.translate(0.5, 0.5);
        renderer.setTransform(curTxf);
        renderer.setTree(this.root);
        this.root = null; // We're done with it...

        try {
            // now we are sure that the aoi is the image size
            Shape raoi = new Rectangle2D.Float(0, 0, width, height);
            // Warning: the renderer's AOI must be in user space
            renderer.repaint(curTxf.createInverse().
                             createTransformedShape(raoi));
            BufferedImage rend = renderer.getOffScreen();
            renderer = null; // We're done with it...

            BufferedImage dest = createImage(w, h);

            Graphics2D g2d = GraphicsUtil.createGraphics(dest);
View Full Code Here

        int w = (int)width;
        int h = (int)height;

        // paint the SVG document using the bridge package
        // create the appropriate renderer
        ImageRenderer renderer = rendFactory.createImageRenderer();
        renderer.updateOffScreen(w, h);
        renderer.setTransform(Px);
        renderer.setTree(gvtRoot);
        gvtRoot = null; // We're done with it...

        try {
            // now we are sure that the aoi is the image size
            Shape raoi = new Rectangle2D.Float(0, 0, width, height);
            // Warning: the renderer's AOI must be in user space
            renderer.repaint(Px.createInverse().createTransformedShape(raoi));
            BufferedImage rend = renderer.getOffScreen();
            renderer = null; // We're done with it...

            BufferedImage dest = createImage(w, h);

            Graphics2D g2d = GraphicsUtil.createGraphics(dest);
View Full Code Here

        // paint the SVG document using the bridge package
        // create the appropriate renderer
        ImageRendererFactory rendFactory = new ConcreteImageRendererFactory();
        // ImageRenderer renderer = rendFactory.createDynamicImageRenderer();
        ImageRenderer renderer = rendFactory.createStaticImageRenderer();
        renderer.updateOffScreen(w, h);
        // curTxf.translate(0.5, 0.5);
        renderer.setTransform(curTxf);
        renderer.setTree(this.root);
        this.root = null; // We're done with it...

        try {
            // now we are sure that the aoi is the image size
            Shape raoi = new Rectangle2D.Float(0, 0, width, height);
            // Warning: the renderer's AOI must be in user space
            renderer.repaint(curTxf.createInverse().
                             createTransformedShape(raoi));
            BufferedImage rend = renderer.getOffScreen();
            renderer = null; // We're done with it...

            BufferedImage dest = createImage(w, h);

            Graphics2D g2d = GraphicsUtil.createGraphics(dest);
View Full Code Here

        int w = (int)width;
        int h = (int)height;

        // paint the SVG document using the bridge package
        // create the appropriate renderer
        ImageRenderer renderer = rendFactory.createImageRenderer();
        renderer.updateOffScreen(w, h);
        renderer.setTransform(Px);
        renderer.setTree(gvtRoot);
        gvtRoot = null; // We're done with it...

        try {
            // now we are sure that the aoi is the image size
            Shape raoi = new Rectangle2D.Float(0, 0, width, height);
            // Warning: the renderer's AOI must be in user space
            renderer.repaint(Px.createInverse().createTransformedShape(raoi));
            BufferedImage rend = renderer.getOffScreen();
            renderer = null; // We're done with it...

            BufferedImage dest = createImage(w, h);

            Graphics2D g2d = GraphicsUtil.createGraphics(dest);
View Full Code Here

    AffineTransform renderTransform = new AffineTransform();   
    renderTransform.scale(widthScale, heightScale);
    renderTransform.translate(-bounds.getMinX(), -bounds.getMinY())
   
    ImageRenderer renderer     = new ConcreteImageRendererFactory().createStaticImageRenderer();
    renderer.setTree(graphicsNode);   
    GVTTreeRenderer gvtRenderer = new GVTTreeRenderer(
        renderer,
        renderTransform,
        true,
        bounds,
View Full Code Here

TOP

Related Classes of org.apache.batik.gvt.renderer.ImageRenderer

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.