Package org.apache.xmlgraphics.java2d

Examples of org.apache.xmlgraphics.java2d.Graphics2DImagePainter


    /** {@inheritDoc} */
    public Image convert(Image src, Map hints) {
        checkSourceFlavor(src);
        final ImageRendered rendImage = (ImageRendered)src;

        Graphics2DImagePainter painter = new Graphics2DImagePainter() {

            public Dimension getImageSize() {
                return rendImage.getSize().getDimensionMpt();
            }

View Full Code Here


        } catch (Exception e) {
            throw new ImageException("GVT tree could not be built for SVG graphic", e);
        }

        //Create the painter
        Graphics2DImagePainter painter = new Graphics2DImagePainter() {

            public void paint(Graphics2D g2d, Rectangle2D area) {
                // If no viewbox is defined in the svg file, a viewbox of 100x100 is
                // assumed, as defined in SVGUserAgent.getViewportSize()
                float iw = (float) ctx.getDocumentSize().getWidth();
View Full Code Here

                Map atts = new java.util.HashMap();
                atts.put(CONV_MODE, "bitmap");
                atts.put(SRC_TRANSPARENCY, "true");
                rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts);
               
                Graphics2DImagePainter painter = new Graphics2DImagePainter() {

                    public void paint(Graphics2D g2d, Rectangle2D area) {
                        g2d.setFont(mapper.getFont(font.getFontSize()));
                        g2d.translate(0, baseline + additionalBPD);
                        g2d.scale(1000, 1000);
View Full Code Here

        Map atts = new java.util.HashMap();
        atts.put(CONV_MODE, "bitmap");
        atts.put(SRC_TRANSPARENCY, "true");
        rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts);
       
        Graphics2DImagePainter painter = new Graphics2DImagePainter() {

            public void paint(Graphics2D g2d, Rectangle2D area) {
                g2d.translate(xoffset, yoffset);
                g2d.scale(1000, 1000);
                float startx = effBorderRect.x;
View Full Code Here

    /** {@inheritDoc} */
    public Image convert(Image src, Map hints) {
        checkSourceFlavor(src);
        final ImageRendered rendImage = (ImageRendered)src;

        Graphics2DImagePainter painter = new Graphics2DImagePainter() {

            public Dimension getImageSize() {
                return rendImage.getSize().getDimensionMpt();
            }

View Full Code Here

        ViewerFrame frame = new ViewerFrame(g2dImage);
        frame.setVisible(true);
    }

    private ImageGraphics2D createErrorImage() {
        Graphics2DImagePainter painter = new Graphics2DImagePainter() {

            public Dimension getImageSize() {
                return new Dimension(10, 10);
            }

            public void paint(Graphics2D g2d, Rectangle2D area) {
                g2d.translate(area.getX(), area.getY());
                double w = area.getWidth();
                double h = area.getHeight();

                //Fit in paint area
                Dimension imageSize = getImageSize();
                double sx = w / imageSize.getWidth();
                double sy = h / imageSize.getHeight();
                if (sx != 1.0 || sy != 1.0) {
                    g2d.scale(sx, sy);
                }

                g2d.setColor(Color.RED);
                g2d.setStroke(new BasicStroke(0));
                g2d.drawRect(0, 0, imageSize.width, imageSize.height);
                g2d.drawLine(0, 0, imageSize.width, imageSize.height);
                g2d.drawLine(0, imageSize.height, imageSize.width, 0);
            }
           
        };
        Dimension dim = painter.getImageSize();
       
        ImageSize size = new ImageSize();
        size.setSizeInMillipoints(dim.width, dim.height);
        size.setResolution(imageManager.getImageContext().getSourceResolution());
        size.calcPixelsFromSize();
View Full Code Here

                    Rectangle paintRect = new Rectangle(
                            30, 30,
                            getWidth() - 60, getHeight() - 60);
                    //g2d.translate(paintRect.getX(), paintRect.getY());

                    Graphics2DImagePainter painter = g2dImage.getGraphics2DImagePainter();
                    Dimension dim = painter.getImageSize();
                    double sx = paintRect.getWidth() / dim.getWidth();
                    double sy = paintRect.getHeight() / dim.getHeight();
                    //g2d.scale(sx, sy);
                   
                    /*
                    Rectangle2D targetRect = new Rectangle2D.Double(
                            paintRect.x * sx, paintRect.y * sy,
                            dim.width, dim.height);
                            */
                    Rectangle2D targetRect = new Rectangle2D.Double(
                            paintRect.x, paintRect.y,
                            paintRect.width, paintRect.height);
                   
                   
                    g2d.draw(targetRect);
                    painter.paint(g2d, targetRect);
                } finally {
                    g2d.dispose();
                }
            }
        };
View Full Code Here

        assertEquals(ImageFlavor.RAW_PNG, img.getFlavor());
        assertTrue(img instanceof ImageRawStream);
    }
   
    private Image createG2DImage() {
        Graphics2DImagePainter painter = new DemoPainter();
        Dimension dim = painter.getImageSize();
       
        ImageSize size = new ImageSize();
        size.setSizeInMillipoints(dim.width, dim.height);
        size.setResolution(72);
        size.calcPixelsFromSize();
View Full Code Here

                //Set the resolution to that of the FOUserAgent
                size.setResolution(context.getSourceResolution());
                size.calcPixelsFromSize();
                info.setSize(size);

                Graphics2DImagePainter painter = new Graphics2DImagePainter() {

                    public Dimension getImageSize() {
                        return size.getDimensionMpt();
                    }
View Full Code Here

        } catch (Exception e) {
            throw new ImageException("GVT tree could not be built for SVG graphic", e);
        }

        //Create the painter
        Graphics2DImagePainter painter = new Graphics2DImagePainter() {

            public void paint(Graphics2D g2d, Rectangle2D area) {
                // If no viewbox is defined in the svg file, a viewbox of 100x100 is
                // assumed, as defined in SVGUserAgent.getViewportSize()
                float iw = (float) ctx.getDocumentSize().getWidth();
View Full Code Here

TOP

Related Classes of org.apache.xmlgraphics.java2d.Graphics2DImagePainter

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.