Example usage for java.awt.geom Dimension2D setSize

List of usage examples for java.awt.geom Dimension2D setSize

Introduction

In this page you can find the example usage for java.awt.geom Dimension2D setSize.

Prototype

public abstract void setSize(double width, double height);

Source Link

Document

Sets the size of this Dimension object to the specified width and height.

Usage

From source file:com.igormaznitsa.jhexed.renders.svg.SVGImage.java

private static GraphicsNode loadDiagramFromStream(final InputStream in, final Dimension2D docSize)
        throws IOException {
    final String parser = XMLResourceDescriptor.getXMLParserClassName();
    final SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);
    final SVGDocument doc = factory.createSVGDocument("http://www.igormaznitsa.com/jhexed/svg", in);

    String strDocWidth = doc.getRootElement().getAttribute("width");
    String strDocHeight = doc.getRootElement().getAttribute("height");

    final GVTBuilder bldr = new GVTBuilder();

    final UserAgent userAgent = new UserAgentAdapter();
    final DocumentLoader loader = new DocumentLoader(userAgent);
    final BridgeContext ctx = new BridgeContext(userAgent, loader);

    final GraphicsNode result = bldr.build(ctx, doc);

    strDocWidth = strDocWidth.isEmpty() ? Double.toString(result.getSensitiveBounds().getWidth()) : strDocWidth;
    strDocHeight = strDocHeight.isEmpty() ? Double.toString(result.getSensitiveBounds().getHeight())
            : strDocHeight;/*from   ww  w.  j av a 2 s.com*/

    docSize.setSize(Double.parseDouble(strDocWidth.trim()), Double.parseDouble(strDocHeight.trim()));

    return result;
}

From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java

public static Dimension2D calculateSizeOfMapInPixels(final MindMap model, final MindMapPanelConfig cfg,
        final boolean expandAll) {
    final MindMap workMap = new MindMap(model, null);
    workMap.resetPayload();//from   ww  w  . j a v a2  s. co m

    BufferedImage img = new BufferedImage(32, 32,
            cfg.isDrawBackground() ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB);
    Dimension2D blockSize = null;
    Graphics2D gfx = img.createGraphics();
    try {
        Utils.prepareGraphicsForQuality(gfx);
        if (calculateElementSizes(gfx, workMap, cfg)) {
            if (expandAll) {
                final AbstractElement root = (AbstractElement) workMap.getRoot().getPayload();
                root.collapseOrExpandAllChildren(false);
                calculateElementSizes(gfx, workMap, cfg);
            }
            blockSize = layoutModelElements(workMap, cfg);
            final double paperMargin = cfg.getPaperMargins() * cfg.getScale();
            blockSize.setSize(blockSize.getWidth() + paperMargin * 2, blockSize.getHeight() + paperMargin * 2);
        }
    } finally {
        gfx.dispose();
    }
    return blockSize;
}

From source file:org.uva.itast.blended.omr.pages.PageImage.java

public Dimension2D sizeInPixels(Size size) {
    Dimension2D dim = new Dimension();
    dim.setSize(getAllignmentInfo().getScaleX() * size.getWidth(),
            getAllignmentInfo().getScaleY() * size.getHeight());
    return dim;/* www  . ja  v  a2  s  .co  m*/
}

From source file:org.uva.itast.blended.omr.pages.PageImage.java

public Dimension2D sizeToMilimeters(Size size) {
    Dimension2D dim = new Dimension();
    dim.setSize(size.getWidth() / getAllignmentInfo().getScaleX(),
            size.getHeight() / getAllignmentInfo().getScaleY());
    return dim;/*  w  w  w  . ja va 2 s  .c o  m*/
}