Example usage for java.awt.geom Rectangle2D setRect

List of usage examples for java.awt.geom Rectangle2D setRect

Introduction

In this page you can find the example usage for java.awt.geom Rectangle2D setRect.

Prototype

public abstract void setRect(double x, double y, double w, double h);

Source Link

Document

Sets the location and size of this Rectangle2D to the specified double values.

Usage

From source file:de.iteratec.iteraplan.businesslogic.exchange.visio.informationflow.VisioInformationFlowExport.java

@Override
public Document createDiagram() {

    init();// ww w .j  a  v a2  s  . c o m

    if (informationFlowOptions.isUseNamesLegend()) {
        setVisioNamesLegend(new VisioNamesLegend(this.getTargetPage()));
    }

    setColorDimension(createColorDimension(informationFlowOptions.getColorOptionsBean(),
            TypeOfBuildingBlock.INFORMATIONSYSTEMRELEASE));

    lineDimension = createLineDimension(informationFlowOptions.getLineOptionsBean(),
            TypeOfBuildingBlock.INFORMATIONSYSTEMRELEASE);

    lineCaptionSelected = informationFlowOptions.getSelectionType();
    lineCaptionAttributeId = informationFlowOptions.getLineCaptionSelectedAttributeId();

    addMissingParentNodes();
    addResultNodes();
    groupNodes();

    for (GXLNode node : GXLUtil.getNodes(graph)) {
        setIsrNodeTexts(node);
    }

    addEdges();

    try {
        LOGGER.debug("trying to add graph to gxl2visio converter");

        List<LayoutOperation> layoutOperations = determineLayoutOperations();

        Rectangle2D graphAreaBounds = visioDocumentCreator.addGraph(graph, layoutOperations);
        // correct the position of the bounding box, since it's returned incorrectly by the "addGraph"-method
        graphAreaBounds.setRect(0, 0, graphAreaBounds.getWidth(), graphAreaBounds.getHeight());

        Shape title = createDiagramTitle(
                MessageAccess.getStringOrNull("graphicalExport.informationflow.title", getLocale()));
        List<Shape> queryInfo = createQueryInfo(graphAreaBounds);

        Rectangle2D legendsBox = createLegends(graphAreaBounds);

        setTitlePos(graphAreaBounds, title, queryInfo);
        setQueryInfoPos(queryInfo, title.getPinX(), title.getPinY() - getQueryInfoHeight(queryInfo));

        Point2D adjustment = adjustPage(graphAreaBounds, title, queryInfo, legendsBox);
        legendsBox = new Rectangle2D.Double(legendsBox.getX() + adjustment.getX(),
                legendsBox.getY() + adjustment.getY(), legendsBox.getWidth(), legendsBox.getHeight());

        createGeneratedInformation(this.getTargetPage().getWidth());
        createLogos(0, 0, this.getTargetPage().getWidth(), this.getTargetPage().getHeight());

        if (informationFlowOptions.isUseNamesLegend()) {
            createNamesLegend(legendsBox);
        }

    } catch (GraphStructureException gex) {
        throw new IteraplanTechnicalException(IteraplanErrorMessages.INTERNAL_ERROR, gex);
    } catch (MasterNotFoundException e) {
        throw new IteraplanTechnicalException(IteraplanErrorMessages.INTERNAL_ERROR, e);
    }
    return visioDocumentCreator.getDocument();
}

From source file:fr.inria.soctrace.framesoc.ui.histogram.view.HistogramView.java

/**
 * Display the chart in the UI thread, using the loaded interval.
 * /*from w  w w . ja  v a2  s.co  m*/
 * @param chart
 *            jfreechart chart
 * @param histogramInterval
 *            displayed interval
 * @param first
 *            flag indicating if it is the first refresh for a given load
 */
private void displayChart(final JFreeChart chart, final TimeInterval displayed, final boolean first) {
    // prepare the new histogram UI
    Display.getDefault().syncExec(new Runnable() {
        @Override
        public void run() {
            // Clean parent
            for (Control c : compositeChart.getChildren()) {
                c.dispose();
            }
            // histogram chart
            chartFrame = new ChartComposite(compositeChart, SWT.NONE, chart, USE_BUFFER) {

                @Override
                public void mouseMove(MouseEvent e) {
                    super.mouseMove(e);

                    // update cursor
                    if (!isInDataArea(e.x, e.y)) {
                        getShell().setCursor(ARROW_CURSOR);
                    } else {
                        if (dragInProgress || (activeSelection && (isNear(e.x, selectedTs0))
                                || isNear(e.x, selectedTs1))) {
                            getShell().setCursor(IBEAM_CURSOR);
                        } else {
                            getShell().setCursor(ARROW_CURSOR);
                        }
                    }

                    // update marker
                    long v = getTimestampAt(e.x);
                    if (dragInProgress) {
                        // when drag is in progress, the moving side is always Ts1
                        selectedTs1 = v;
                        long min = Math.min(selectedTs0, selectedTs1);
                        long max = Math.max(selectedTs0, selectedTs1);
                        marker.setStartValue(min);
                        marker.setEndValue(max);
                        timeChanged = true;
                        timeBar.setSelection(min, max);
                    }

                    // update status line
                    updateStatusLine(v);
                }

                @Override
                public void mouseUp(MouseEvent e) {
                    super.mouseUp(e);

                    dragInProgress = false;
                    selectedTs1 = getTimestampAt(e.x);
                    if (selectedTs0 > selectedTs1) {
                        // reorder Ts0 and Ts1
                        long tmp = selectedTs1;
                        selectedTs1 = selectedTs0;
                        selectedTs0 = tmp;
                    } else if (selectedTs0 == selectedTs1) {
                        marker.setStartValue(selectedTs0);
                        marker.setEndValue(selectedTs0);
                        activeSelection = false;
                        timeBar.setSelection(loadedInterval);
                        updateStatusLine(selectedTs0);
                    }
                }

                @Override
                public void mouseDown(MouseEvent e) {
                    super.mouseDown(e);

                    if (activeSelection) {
                        if (isNear(e.x, selectedTs0)) {
                            // swap in order to have Ts1 as moving side
                            long tmp = selectedTs0;
                            selectedTs0 = selectedTs1;
                            selectedTs1 = tmp;
                        } else if (isNear(e.x, selectedTs1)) {
                            // nothing to do if the moving side is already Ts1
                        } else {
                            // near to no one: remove marker and add a new one
                            removeMarker();
                            selectedTs0 = getTimestampAt(e.x);
                            addNewMarker(selectedTs0, selectedTs0);
                        }
                    } else {
                        removeMarker();
                        selectedTs0 = getTimestampAt(e.x);
                        addNewMarker(selectedTs0, selectedTs0);
                    }
                    activeSelection = true;
                    dragInProgress = true;
                }

                private boolean isNear(int pos, long value) {
                    final int RANGE = 3;
                    int vPos = getPosAt(value);
                    if (Math.abs(vPos - pos) <= RANGE) {
                        return true;
                    }
                    return false;
                }

                boolean isInDataArea(int x, int y) {
                    if (chartFrame != null) {
                        org.eclipse.swt.graphics.Rectangle swtRect = chartFrame.getScreenDataArea();
                        Rectangle2D screenDataArea = new Rectangle();
                        screenDataArea.setRect(swtRect.x, swtRect.y, swtRect.width, swtRect.height);
                        return swtRect.contains(x, y);
                    }
                    return false;
                }
            };

            chartFrame.addMouseWheelListener(new MouseWheelListener() {

                @Override
                public void mouseScrolled(MouseEvent e) {
                    if ((e.stateMask & SWT.CTRL) == SWT.CTRL) {
                        if (e.count > 0) {
                            // zoom in
                            zoomChartAxis(true, e.x, e.y);
                        } else {
                            // zoom out
                            zoomChartAxis(false, e.x, e.y);
                        }
                    }
                }

                private void zoomChartAxis(boolean increase, int x, int y) {
                    double min = plot.getDomainAxis().getRange().getLowerBound();
                    double max = plot.getDomainAxis().getRange().getUpperBound();
                    X_FORMAT.setContext((long) min, (long) max, true);
                    Point2D p = chartFrame.translateScreenToJava2D(new Point(x, y));
                    PlotRenderingInfo plotInfo = chartFrame.getChartRenderingInfo().getPlotInfo();

                    if (increase) {
                        double dmin = min;
                        double dmax = max;
                        if (dmin <= 0) {
                            double inc = -2 * dmin + 1;
                            dmin += inc;
                            dmax += inc;
                        }
                        double diff = (dmax - dmin) / dmin;
                        if (diff >= 0.01) {
                            // zoom only if the (max - min) is at least 1% of the min
                            plot.zoomDomainAxes(0.5, plotInfo, p, true);
                        }
                    } else {
                        // XXX On Fedora 17 this always dezoom all
                        plot.zoomDomainAxes(-0.5, plotInfo, p, true);
                    }

                    // adjust
                    min = plot.getDomainAxis().getRange().getLowerBound();
                    max = plot.getDomainAxis().getRange().getUpperBound();
                    Range maxRange = new Range(Math.max(loadedInterval.startTimestamp, min),
                            Math.min(loadedInterval.endTimestamp, max));
                    plot.getDomainAxis().setRange(maxRange);

                }
            });

            // - size
            chartFrame.setSize(compositeChart.getSize());
            // - prevent y zooming
            chartFrame.setRangeZoomable(false);
            // - prevent x zooming (we do it manually with wheel)
            chartFrame.setDomainZoomable(false);
            // - workaround for last xaxis tick not shown (jfreechart bug)
            RectangleInsets insets = plot.getInsets();
            plot.setInsets(new RectangleInsets(insets.getTop(), insets.getLeft(), insets.getBottom(), 25));
            // - time bounds
            plot.getDomainAxis().setLowerBound(displayed.startTimestamp);
            plot.getDomainAxis().setUpperBound(displayed.endTimestamp);
            // producers and types
            if (first) {
                for (ConfigurationData data : configurationMap.values()) {
                    data.tree.getViewer().setInput(data.roots);
                    data.tree.setCheckedElements(data.checked);
                    data.tree.getViewer().refresh();
                    data.tree.getViewer().expandAll();
                }
            }
            // timebar
            timeBar.setSelection(loadedInterval);
        }
    });

}

From source file:com.att.aro.ui.view.diagnostictab.GraphPanel.java

private void zoomEventUIUpdate() {
    // allow for better scrolling efficiency for new size
    chartPanelScrollPane().getHorizontalScrollBar().setUnitIncrement(zoomCounter * 10);
    // update the screen panels for repaint
    getChartPanel().updateUI();//from  ww  w  .j  ava  2 s  .  c  o  m
    // updates the scroll bar after resize updates.
    // SwingUtilities.invokeLater(new Runnable() {
    // public void run() {
    // resetScrollPosition();
    Rectangle2D plotArea = getChartPanel().getScreenDataArea();
    XYPlot plot = (XYPlot) getAdvancedGraph().getPlot();

    int plotWidth = initialPlotAreaWidth;

    for (int i = 1; i <= zoomCounter; i++) {
        plotWidth = (plotWidth * 2) + 16;
    }
    plotArea.setRect(plotArea.getX(), plotArea.getY(), plotWidth, plotArea.getHeight());
    double scrollPoint = new Float(
            plot.getDomainAxis().valueToJava2D(getCrosshair(), plotArea, plot.getDomainAxisEdge())).intValue();

    int width = chartPanelScrollPane().getWidth();
    scrollPoint = Math.max(0, scrollPoint - (width / 2));

    this.pointX = (int) scrollPoint;
}

From source file:org.apache.fop.render.ps.PSDocumentHandler.java

/** {@inheritDoc} */
public void startPage(int index, String name, String pageMasterName, Dimension size) throws IFException {
    try {//w  ww .  ja  v  a2  s.c  o  m
        if (this.currentPageNumber == 0) {
            //writeHeader();
        }

        this.currentPageNumber++;

        gen.getResourceTracker().notifyStartNewPage();
        gen.getResourceTracker().notifyResourceUsageOnPage(PSProcSets.STD_PROCSET);
        gen.writeDSCComment(DSCConstants.PAGE, new Object[] { name, new Integer(this.currentPageNumber) });

        double pageWidth = size.width / 1000.0;
        double pageHeight = size.height / 1000.0;
        boolean rotate = false;
        List pageSizes = new java.util.ArrayList();
        if (this.psUtil.isAutoRotateLandscape() && (pageHeight < pageWidth)) {
            rotate = true;
            pageSizes.add(new Long(Math.round(pageHeight)));
            pageSizes.add(new Long(Math.round(pageWidth)));
        } else {
            pageSizes.add(new Long(Math.round(pageWidth)));
            pageSizes.add(new Long(Math.round(pageHeight)));
        }
        pageDeviceDictionary.put("/PageSize", pageSizes);
        this.currentPageDefinition = new PageDefinition(new Dimension2DDouble(pageWidth, pageHeight), rotate);

        //TODO Handle extension attachments for the page!!!!!!!
        /*
        if (page.hasExtensionAttachments()) {
        for (Iterator iter = page.getExtensionAttachments().iterator();
            iter.hasNext();) {
            ExtensionAttachment attachment = (ExtensionAttachment) iter.next();
            if (attachment instanceof PSSetPageDevice) {*/
        /**
         * Extract all PSSetPageDevice instances from the
         * attachment list on the s-p-m and add all
         * dictionary entries to our internal representation
         * of the the page device dictionary.
         *//*
            PSSetPageDevice setPageDevice = (PSSetPageDevice)attachment;
            String content = setPageDevice.getContent();
            if (content != null) {
             try {
                 pageDeviceDictionary.putAll(PSDictionary.valueOf(content));
             } catch (PSDictionaryFormatException e) {
                 PSEventProducer eventProducer = PSEventProducer.Provider.get(
                         getUserAgent().getEventBroadcaster());
                 eventProducer.postscriptDictionaryParseError(this, content, e);
             }
            }
            }
            }
            }*/

        final Integer zero = new Integer(0);
        Rectangle2D pageBoundingBox = new Rectangle2D.Double();
        if (rotate) {
            pageBoundingBox.setRect(0, 0, pageHeight, pageWidth);
            gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[] { zero, zero,
                    new Long(Math.round(pageHeight)), new Long(Math.round(pageWidth)) });
            gen.writeDSCComment(DSCConstants.PAGE_HIRES_BBOX,
                    new Object[] { zero, zero, new Double(pageHeight), new Double(pageWidth) });
            gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION, "Landscape");
        } else {
            pageBoundingBox.setRect(0, 0, pageWidth, pageHeight);
            gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[] { zero, zero,
                    new Long(Math.round(pageWidth)), new Long(Math.round(pageHeight)) });
            gen.writeDSCComment(DSCConstants.PAGE_HIRES_BBOX,
                    new Object[] { zero, zero, new Double(pageWidth), new Double(pageHeight) });
            if (psUtil.isAutoRotateLandscape()) {
                gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION, "Portrait");
            }
        }
        this.documentBoundingBox.add(pageBoundingBox);
        gen.writeDSCComment(DSCConstants.PAGE_RESOURCES, new Object[] { DSCConstants.ATEND });

        gen.commentln("%FOPSimplePageMaster: " + pageMasterName);
    } catch (IOException ioe) {
        throw new IFException("I/O error in startPage()", ioe);
    }
}

From source file:org.apache.fop.render.ps.PSRenderer.java

/** {@inheritDoc} */
public void renderPage(PageViewport page) throws IOException, FOPException {
    log.debug("renderPage(): " + page);

    if (this.currentPageNumber == 0) {
        writeHeader();//  w  w  w . j av  a  2 s .c o m
    }

    this.currentPageNumber++;

    gen.getResourceTracker().notifyStartNewPage();
    gen.getResourceTracker().notifyResourceUsageOnPage(PSProcSets.STD_PROCSET);
    gen.writeDSCComment(DSCConstants.PAGE,
            new Object[] { page.getPageNumberString(), new Integer(this.currentPageNumber) });

    double pageWidth = page.getViewArea().width / 1000f;
    double pageHeight = page.getViewArea().height / 1000f;
    boolean rotate = false;
    List pageSizes = new java.util.ArrayList();
    if (getPSUtil().isAutoRotateLandscape() && (pageHeight < pageWidth)) {
        rotate = true;
        pageSizes.add(new Long(Math.round(pageHeight)));
        pageSizes.add(new Long(Math.round(pageWidth)));
    } else {
        pageSizes.add(new Long(Math.round(pageWidth)));
        pageSizes.add(new Long(Math.round(pageHeight)));
    }
    pageDeviceDictionary.put("/PageSize", pageSizes);

    if (page.hasExtensionAttachments()) {
        for (Iterator iter = page.getExtensionAttachments().iterator(); iter.hasNext();) {
            ExtensionAttachment attachment = (ExtensionAttachment) iter.next();
            if (attachment instanceof PSSetPageDevice) {
                /**
                 * Extract all PSSetPageDevice instances from the
                 * attachment list on the s-p-m and add all
                 * dictionary entries to our internal representation
                 * of the the page device dictionary.
                 */
                PSSetPageDevice setPageDevice = (PSSetPageDevice) attachment;
                String content = setPageDevice.getContent();
                if (content != null) {
                    try {
                        pageDeviceDictionary.putAll(PSDictionary.valueOf(content));
                    } catch (PSDictionaryFormatException e) {
                        PSEventProducer eventProducer = PSEventProducer.Provider
                                .get(getUserAgent().getEventBroadcaster());
                        eventProducer.postscriptDictionaryParseError(this, content, e);
                    }
                }
            }
        }
    }

    try {
        if (setupCodeList != null) {
            PSRenderingUtil.writeEnclosedExtensionAttachments(gen, setupCodeList);
            setupCodeList.clear();
        }
    } catch (IOException e) {
        log.error(e.getMessage());
    }
    final Integer zero = new Integer(0);
    Rectangle2D pageBoundingBox = new Rectangle2D.Double();
    if (rotate) {
        pageBoundingBox.setRect(0, 0, pageHeight, pageWidth);
        gen.writeDSCComment(DSCConstants.PAGE_BBOX,
                new Object[] { zero, zero, new Long(Math.round(pageHeight)), new Long(Math.round(pageWidth)) });
        gen.writeDSCComment(DSCConstants.PAGE_HIRES_BBOX,
                new Object[] { zero, zero, new Double(pageHeight), new Double(pageWidth) });
        gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION, "Landscape");
    } else {
        pageBoundingBox.setRect(0, 0, pageWidth, pageHeight);
        gen.writeDSCComment(DSCConstants.PAGE_BBOX,
                new Object[] { zero, zero, new Long(Math.round(pageWidth)), new Long(Math.round(pageHeight)) });
        gen.writeDSCComment(DSCConstants.PAGE_HIRES_BBOX,
                new Object[] { zero, zero, new Double(pageWidth), new Double(pageHeight) });
        if (getPSUtil().isAutoRotateLandscape()) {
            gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION, "Portrait");
        }
    }
    this.documentBoundingBox.add(pageBoundingBox);
    gen.writeDSCComment(DSCConstants.PAGE_RESOURCES, new Object[] { DSCConstants.ATEND });

    gen.commentln("%FOPSimplePageMaster: " + page.getSimplePageMasterName());

    gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP);

    if (page.hasExtensionAttachments()) {
        List extensionAttachments = page.getExtensionAttachments();
        for (int i = 0; i < extensionAttachments.size(); i++) {
            Object attObj = extensionAttachments.get(i);
            if (attObj instanceof PSExtensionAttachment) {
                PSExtensionAttachment attachment = (PSExtensionAttachment) attObj;
                if (attachment instanceof PSCommentBefore) {
                    gen.commentln("%" + attachment.getContent());
                } else if (attachment instanceof PSSetupCode) {
                    gen.writeln(attachment.getContent());
                }
            }
        }
    }

    // Write any unwritten changes to page device dictionary
    if (!pageDeviceDictionary.isEmpty()) {
        String content = pageDeviceDictionary.getContent();
        if (getPSUtil().isSafeSetPageDevice()) {
            content += " SSPD";
        } else {
            content += " setpagedevice";
        }
        PSRenderingUtil.writeEnclosedExtensionAttachment(gen, new PSSetPageDevice(content));
    }

    if (rotate) {
        gen.writeln(Math.round(pageHeight) + " 0 translate");
        gen.writeln("90 rotate");
    }
    concatMatrix(1, 0, 0, -1, 0, pageHeight);

    gen.writeDSCComment(DSCConstants.END_PAGE_SETUP);

    //Process page
    super.renderPage(page);

    //Show page
    gen.showPage();
    gen.writeDSCComment(DSCConstants.PAGE_TRAILER);
    if (page.hasExtensionAttachments()) {
        List extensionAttachments = page.getExtensionAttachments();
        for (int i = 0; i < extensionAttachments.size(); i++) {
            Object attObj = extensionAttachments.get(i);
            if (attObj instanceof PSExtensionAttachment) {
                PSExtensionAttachment attachment = (PSExtensionAttachment) attObj;
                if (attachment instanceof PSCommentAfter) {
                    gen.commentln("%" + attachment.getContent());
                }
            }
        }
    }
    gen.getResourceTracker().writeResources(true, gen);
}

From source file:tufts.vue.LWComponent.java

/**
 * @param mapRect -- incoming rectangle to transform to be relative to 0,0 of this component
 * @param zeroRect -- result is placed here -- will be created if is null
 * @return zeroRect/*from w  w  w  . j  a  va2  s  .com*/
 *
 * E.g., if the incoming mapRect was from map coords 100,100->120,120, and this component was at 100,100,
 * the resulting zeroRect in this case would be 0,0->20,20 (assuming no scale or rotation).
 *
 */
//protected Rectangle2D transformMapToZeroRect(Rectangle2D mapRect, Rectangle2D zeroRect)
protected Rectangle2D transformMapToZeroRect(Rectangle2D mapRect) {
    //         if (zeroRect == null)
    //             zeroRect = (Rectangle2D) mapRect.clone(); // simpler than newInstace, tho we won't need the data-copy in the end
    Rectangle2D zeroRect = new Rectangle2D.Float();

    // If want to handle rotation, we'll need to transform each corner of the
    // rectangle separately, generating Polygon2D (which sun never implemented!)  or
    // a GeneralPath, in either case changing this method to return a Shape.  Better
    // would be to keep a cached rotated map Shape in each object, tho that means
    // solving the general problem of making sure we're updated any time our
    // ultimate map location/size/scale/rotation, etc, changes, which of course
    // changes if any of those values change on any ancestor.  If we did that, we'd
    // also be able to fully cache the _zeroTransform w/out having to recompute it
    // for each call just in case.  (Which would mean getting rid of this method
    // entirely and using the map shape in intersects, etc) Of course, crap, we
    // couldn't do all this for links, could we?  Tho maybe via special handing in an
    // override... tho that would only work for the transform, not the shape, as the
    // parent shape is useless to the link. FYI, currently, we only use this
    // for doing intersections of links and non-rectangular nodes

    //         final double[] points = new double[8];
    //         final double width = zeroRect.getWidth();
    //         final double height = zeroRect.getHeight();
    //         // UL
    //         points[0] = zeroRect.getX();
    //         points[1] = zeroRect.getY();
    //         // UR
    //         points[2] = points[0] + width;
    //         points[3] = points[1];
    //         // LL
    //         points[4] = points[0];
    //         points[5] = points[1] + height;
    //         // LR
    //         points[6] = points[0] + width;
    //         points[7] = points[1] + height;

    // Now that we know the below code can never handle rotation, we also might as
    // well toss out using the transform entirely and just use getMapScale /
    // getMapX/Y to mod a Rectangle2D.Float directly... Tho then our zoomed rollover
    // mod, which is in the transformDown code would stop working for rectangle
    // picking & clipping, tho we shouldn't need rect picking for zoomed rollovers,
    // (only point picking) and the zoomed rollover always draws no matter what (in
    // the MapViewer), so that may be moot, tho would need to fully test to be sure.
    // All of the this also applies to transformZeroToMapRect below.

    final AffineTransform tx = getZeroTransform();
    final double[] points = new double[4];
    points[0] = mapRect.getX();
    points[1] = mapRect.getY();
    points[2] = points[0] + mapRect.getWidth();
    points[3] = points[1] + mapRect.getHeight();
    try {
        tx.inverseTransform(points, 0, points, 0, 2);
    } catch (java.awt.geom.NoninvertibleTransformException e) {
        Util.printStackTrace(e);
    }

    zeroRect.setRect(points[0], points[1], points[2] - points[0], points[3] - points[1]);

    return zeroRect;

}

From source file:tufts.vue.LWComponent.java

/**
 * This will take the given zeroRect rectangle in local coordinates, and transform it
 * into map coordinates, setting mapRect and returning it.  If mapRect is null,
 * a new rectangle will be created and returned.
 *///  w w w  .ja va 2  s  .  co  m
public Rectangle2D transformZeroToMapRect(Rectangle2D zeroRect, Rectangle2D mapRect) {
    final AffineTransform tx = getZeroTransform();
    final double[] points = new double[4];

    points[0] = zeroRect.getX();
    points[1] = zeroRect.getY();
    points[2] = points[0] + zeroRect.getWidth();
    points[3] = points[1] + zeroRect.getHeight();
    tx.transform(points, 0, points, 0, 2);

    if (mapRect == null)
        mapRect = new Rectangle2D.Float();

    mapRect.setRect(points[0], points[1], points[2] - points[0], points[3] - points[1]);

    return mapRect;

    // Non-rotating & non-transform using version:
    //         final double scale = getMapScale();
    //         // would this be right? scale the x/y first?
    //         if (scale != 1) {
    //             rect.x *= scale;
    //             rect.y *= scale;
    //             rect.width *= scale;
    //             rect.height *= scale;
    //         }
    //         if (this instanceof LWLink) {
    //             // todo: eventually rewrite this routine entirely to use the transformations
    //             // (will need that if ever want to handle rotation, as well as to skip this
    //             // special case for links).
    //             rect.x += getParent().getMapX();
    //             rect.y += getParent().getMapY();
    //         } else {
    //             rect.x += getMapX();
    //             rect.y += getMapY();
    //         }

}