private static Rectangle2D union(Rectangle2D src1, Rectangle2D src2) { double x1 = Math.min(src1.getMinX(), src2.getMinX()); double y1 = Math.min(src1.getMinY(), src2.getMinY()); double x2 = Math.max(src1.getMaxX(), src2.getMaxX()); double y2 = Math.max(src1.getMaxY(), src2.getMaxY()); Rectangle2D result = new Rectangle2D.Double(); result.setFrameFromDiagonal(x1, y1, x2, y2); return result; }
public static double[] createIntersection(double[] a1, double[] a2) { Rectangle2D r1 = new Rectangle2D.Double(), r2 = new Rectangle2D.Double(); r1.setFrameFromDiagonal(a1[0], 0, a1[1], 1); r2.setFrameFromDiagonal(a2[0], 0, a2[1], 1); Rectangle2D r3 = r1.createIntersection(r2); return new double[] { r3.getMinX(), r3.getMaxX() }; }
private static Rectangle2D adaptToValidateCropArea(ViewCanvas<ImageElement> view, Rectangle2D area) { AffineTransform transform = view.getAffineTransform(); Point2D pMin = new Point2D.Double(area.getMinX(), area.getMinY()); Point2D pMax = new Point2D.Double(area.getMaxX(), area.getMaxY()); transform.transform(pMin, pMin); transform.transform(pMax, pMax); Rectangle2D rect = new Rectangle2D.Double(); rect.setFrameFromDiagonal(pMin, pMax); return rect; }
static Rectangle adaptToinitCropArea(Rectangle2D area) { if (area == null) { return null; } ViewCanvas<ImageElement> view = getView(); AffineTransform transform = view.getInverseTransform(); Point2D pMin = new Point2D.Double(area.getMinX(), area.getMinY()); Point2D pMax = new Point2D.Double(area.getMaxX(), area.getMaxY()); transform.transform(pMin, pMin); transform.transform(pMax, pMax); Rectangle2D rect = new Rectangle2D.Double(); rect.setFrameFromDiagonal(pMin, pMax); return rect.getBounds(); }
/** * STEP 3 methods */ private ReferencedEnvelope computeMosaicBounds() { final Rectangle2D initialBounds = new Rectangle2D.Double(); initialBounds.setFrameFromDiagonal(this.westBound, this.southBound, this.eastBound, this.northBound); final ReferencedEnvelope boundsEnvelope = new ReferencedEnvelope(initialBounds, DefaultGeographicCRS.WGS84); try { return boundsEnvelope.transform(this.targetCRS, true); } catch (TransformException | FactoryException e) { throw new OperatorException(e); } }
public Rectangle2D screen2Realworld(int pScreenWidth, int pScreenHeight, Point2D pLowerLeft, Point2D pUpperRight) { Point2D lRealworldLowerLeft = screen2Realworld(pScreenWidth, pScreenHeight, pLowerLeft); Point2D lRealworldUpperRight = screen2Realworld(pScreenWidth, pScreenHeight, pUpperRight); Rectangle2D lResultRect = new Rectangle2D.Double(); lResultRect.setFrameFromDiagonal(lRealworldLowerLeft, lRealworldUpperRight); return lResultRect; }
@Override public void drawLine(int x1, int y1, int x2, int y2) { Rectangle2D bounds = new Rectangle(); bounds.setFrameFromDiagonal(x1, y1, x2, y2); doDraw(OpType.DRAW_LINE, correctForStroke(bounds), x1, y1, x2, y2); }
@Override public void drawLine(int x1, int y1, int x2, int y2) { Rectangle2D bounds = new Rectangle(); bounds.setFrameFromDiagonal(x1, y1, x2, y2); doDraw(OpType.DRAW_LINE, correctForStroke(bounds), x1, y1, x2, y2); }
@Override public void mouseDragged(MouseEvent e) { //Move the coordinate system with respect to the dragging direction if (SwingUtilities.isMiddleMouseButton(e)) { originX -= (previousX - e.getX()); originY -= (previousY - e.getY()); previousX = e.getX(); previousY = e.getY(); //Set the selection box for segment selection } else if (SwingUtilities.isLeftMouseButton(e)) { selectionBox = new Rectangle2D.Float(); selectionBox.setFrameFromDiagonal(e.getX()-originX, e.getY()-originY, previousX-originX, previousY-originY); } repaint(); }
@Override public void buildShape(MouseEventDouble mouseevent) { Rectangle2D rectangle = new Rectangle2D.Double(); rectangle.setFrameFromDiagonal(getHandlePoint(eHandlePoint.NW.index), getHandlePoint(eHandlePoint.SE.index)); setShape(new Ellipse2D.Double(rectangle.getX(), rectangle.getY(), rectangle.getWidth(), rectangle.getHeight()), mouseevent); updateLabel(mouseevent, getDefaultView2d(mouseevent)); }
@Override public void setSize(Dimension size) { if(initialized == false) setInitializer(new RandomLocationTransformer<V>(size)); super.setSize(size); double t = size.width/50.0; innerBounds.setFrameFromDiagonal(t,t,size.width-t,size.height-t); max_dimension = Math.max(size.height, size.width); }
@Override public void setSize(Dimension size) { if(initialized == false) setInitializer(new RandomLocationTransformer<V>(size)); super.setSize(size); double t = size.width/50.0; innerBounds.setFrameFromDiagonal(t,t,size.width-t,size.height-t); max_dimension = Math.max(size.height, size.width); }
ReferencedEnvelope getTargetEnvelope() { final double west = (Double) getPropertyValue(BoundsInputPanel.PROPERTY_WEST_BOUND); final double north = (Double) getPropertyValue(BoundsInputPanel.PROPERTY_NORTH_BOUND); final double east = (Double) getPropertyValue(BoundsInputPanel.PROPERTY_EAST_BOUND); final double south = (Double) getPropertyValue(BoundsInputPanel.PROPERTY_SOUTH_BOUND); final Rectangle2D bounds = new Rectangle2D.Double(); bounds.setFrameFromDiagonal(west, north, east, south); return new ReferencedEnvelope(bounds, DefaultGeographicCRS.WGS84); }
ReferencedEnvelope getTargetEnvelope() { final double west = (Double) getPropertyValue(BoundsInputPanel.PROPERTY_WEST_BOUND); final double north = (Double) getPropertyValue(BoundsInputPanel.PROPERTY_NORTH_BOUND); final double east = (Double) getPropertyValue(BoundsInputPanel.PROPERTY_EAST_BOUND); final double south = (Double) getPropertyValue(BoundsInputPanel.PROPERTY_SOUTH_BOUND); final Rectangle2D bounds = new Rectangle2D.Double(); bounds.setFrameFromDiagonal(west, north, east, south); return new ReferencedEnvelope(bounds, DefaultGeographicCRS.WGS84); }
ReferencedEnvelope getTargetEnvelope() { final double west = (Double) getPropertyValue(BoundsInputPanel.PROPERTY_WEST_BOUND); final double north = (Double) getPropertyValue(BoundsInputPanel.PROPERTY_NORTH_BOUND); final double east = (Double) getPropertyValue(BoundsInputPanel.PROPERTY_EAST_BOUND); final double south = (Double) getPropertyValue(BoundsInputPanel.PROPERTY_SOUTH_BOUND); final Rectangle2D bounds = new Rectangle2D.Double(); bounds.setFrameFromDiagonal(west, north, east, south); return new ReferencedEnvelope(bounds, DefaultGeographicCRS.WGS84); }
@Override public void actionPerformed(ActionEvent e) { final ProductSceneView sceneView = appContext.getSelectedProductSceneView(); final Layer selectedLayer = sceneView.getSelectedLayer(); Rectangle2D modelBounds = selectedLayer.getModelBounds(); if (modelBounds != null) { final Viewport viewport = sceneView.getLayerCanvas().getViewport(); final AffineTransform m2vTransform = viewport.getModelToViewTransform(); final AffineTransform v2mTransform = viewport.getViewToModelTransform(); final Rectangle2D viewBounds = m2vTransform.createTransformedShape(modelBounds).getBounds2D(); viewBounds.setFrameFromDiagonal(viewBounds.getMinX() - 10, viewBounds.getMinY() - 10, viewBounds.getMaxX() + 10, viewBounds.getMaxY() + 10); final Shape transformedModelBounds = v2mTransform.createTransformedShape(viewBounds); sceneView.zoom(transformedModelBounds.getBounds2D()); } }
private ReferencedEnvelope computeReprojectedBounds() { final Rectangle2D bounds = new Rectangle2D.Double(); bounds.setFrameFromDiagonal(westBound, northBound, eastBound, southBound); final ReferencedEnvelope boundsEnvelope = new ReferencedEnvelope(bounds, DefaultGeographicCRS.WGS84); ReferencedEnvelope targetEnvelope = null; try { targetEnvelope = boundsEnvelope.transform(targetCRS, true); } catch (TransformException e) { e.printStackTrace(); } catch (FactoryException e) { e.printStackTrace(); } if (targetEnvelope == null) { throw new OperatorException("Cannot compute reprojected bounds"); } return targetEnvelope; //new Rectangle2D.Double(envelope.getMinX(), envelope.getMinY(), envelope.getWidth(), envelope.getHeight()); }
@Override public Rectangle2D getBounds() { Line2D conn = getConnectionPoints(); Rectangle2D r = new Rectangle2D.Double(); r.setFrameFromDiagonal(conn.getX1(), conn.getY1(), conn.getX2(), conn.getY2()); return r; }
/** * Returns the bounds, in absolute (item-space) coordinates, of the total * bounds occupied by all currently visible VisualItems. * @param b the Rectangle2D to use to store the return value * @return the bounding box of all visible VisualItems */ public synchronized Rectangle2D getItemBounds(Rectangle2D b) { b.setFrameFromDiagonal(m_bounds.getMinX(), m_bounds.getMinY(), m_bounds.getMaxX(), m_bounds.getMaxY()); return b; }
@Override public void buildShape(MouseEventDouble mouseevent) { Rectangle2D rectangle = null; if (pts.size() > 1) { if (!getHandlePoint(eHandlePoint.NW.index).equals(getHandlePoint(eHandlePoint.SE.index))) { rectangle = new Rectangle2D.Double(); rectangle.setFrameFromDiagonal(getHandlePoint(eHandlePoint.NW.index), getHandlePoint(eHandlePoint.SE.index)); } } setShape(rectangle, mouseevent); updateLabel(mouseevent, getDefaultView2d(mouseevent)); }