List of usage examples for java.awt.geom Rectangle2D add
public void add(Rectangle2D r)
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); }