Search in sources :

Example 1 with Dimension2dDouble

use of org.apache.poi.xdgf.geom.Dimension2dDouble in project poi by apache.

the class XDGFPage method getBoundingBox.

/**
     * @return bounding box of page
     */
public Rectangle2D getBoundingBox() {
    Dimension2dDouble sz = getPageSize();
    Point2D.Double offset = getPageOffset();
    return new Rectangle2D.Double(-offset.getX(), -offset.getY(), sz.getWidth(), sz.getHeight());
}
Also used : Dimension2dDouble(org.apache.poi.xdgf.geom.Dimension2dDouble) Point2D(java.awt.geom.Point2D) Dimension2dDouble(org.apache.poi.xdgf.geom.Dimension2dDouble)

Example 2 with Dimension2dDouble

use of org.apache.poi.xdgf.geom.Dimension2dDouble in project poi by apache.

the class XDGFPage method getPageSize.

/**
     * @return width/height of page
     */
public Dimension2dDouble getPageSize() {
    XDGFCell w = _pageSheet.getCell("PageWidth");
    XDGFCell h = _pageSheet.getCell("PageHeight");
    if (w == null || h == null)
        throw new POIXMLException("Cannot determine page size");
    return new Dimension2dDouble(Double.parseDouble(w.getValue()), Double.parseDouble(h.getValue()));
}
Also used : Dimension2dDouble(org.apache.poi.xdgf.geom.Dimension2dDouble) POIXMLException(org.apache.poi.POIXMLException)

Example 3 with Dimension2dDouble

use of org.apache.poi.xdgf.geom.Dimension2dDouble in project poi by apache.

the class VsdxToPng method renderToPng.

public static void renderToPng(XDGFPage page, File outFile, double scale, ShapeRenderer renderer) throws IOException {
    Dimension2dDouble sz = page.getPageSize();
    int width = (int) (scale * sz.getWidth());
    int height = (int) (scale * sz.getHeight());
    BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    final Graphics2D graphics = img.createGraphics();
    // default rendering options
    graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    graphics.setColor(Color.black);
    graphics.setBackground(Color.white);
    graphics.clearRect(0, 0, width, height);
    // Visio's coordinate system is flipped, so flip the image vertically
    graphics.translate(0, img.getHeight());
    graphics.scale(scale, -scale);
    // toplevel shapes only
    renderer.setGraphics(graphics);
    page.getContent().visitShapes(renderer);
    graphics.dispose();
    OutputStream out = new FileOutputStream(outFile);
    try {
        ImageIO.write(img, "png", out);
    } finally {
        out.close();
    }
}
Also used : Dimension2dDouble(org.apache.poi.xdgf.geom.Dimension2dDouble) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Aggregations

Dimension2dDouble (org.apache.poi.xdgf.geom.Dimension2dDouble)3 Graphics2D (java.awt.Graphics2D)1 Point2D (java.awt.geom.Point2D)1 BufferedImage (java.awt.image.BufferedImage)1 POIXMLException (org.apache.poi.POIXMLException)1