Example usage for java.awt.geom Rectangle2D add

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

Introduction

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

Prototype

public void add(Rectangle2D r) 

Source Link

Document

Adds a Rectangle2D object to this Rectangle2D .

Usage

From source file:org.esa.snap.graphbuilder.gpf.ui.worldmap.NestWorldMapPane.java

public void zoomToProduct(Product product) {
    final GeoPos[][] selGeoBoundaries = dataModel.getSelectedGeoBoundaries();
    if ((product == null || product.getSceneGeoCoding() == null) && selGeoBoundaries.length == 0) {
        return;//  w  w w . j  av  a 2  s.c  o  m
    }

    //NESTMOD
    final GeneralPath[] generalPaths;
    if (product != null && product.getSceneGeoCoding() != null) {
        generalPaths = getGeoBoundaryPaths(product);
    } else {
        final ArrayList<GeneralPath> pathList = assemblePathList(selGeoBoundaries[0]);
        generalPaths = pathList.toArray(new GeneralPath[pathList.size()]);
    }

    Rectangle2D modelArea = new Rectangle2D.Double();
    final Viewport viewport = layerCanvas.getViewport();
    for (GeneralPath generalPath : generalPaths) {
        final Rectangle2D rectangle2D = generalPath.getBounds2D();
        if (modelArea.isEmpty()) {
            if (!viewport.isModelYAxisDown()) {
                modelArea.setFrame(rectangle2D.getX(), rectangle2D.getMaxY(), rectangle2D.getWidth(),
                        rectangle2D.getHeight());
            }
            modelArea = rectangle2D;
        } else {
            modelArea.add(rectangle2D);
        }
    }
    Rectangle2D modelBounds = modelArea.getBounds2D();
    modelBounds.setFrame(modelBounds.getX() - 2, modelBounds.getY() - 2, modelBounds.getWidth() + 4,
            modelBounds.getHeight() + 4);

    modelBounds = cropToMaxModelBounds(modelBounds);

    viewport.zoom(modelBounds);
}