/** * Displays coordinates of the given position. * * @param p world position */ private void displayCoords(DirectPosition2D p) { label.setText(String.format(numFormat, p.getX(), p.getY())); ensureMinLabelWidth(); }
/** * Zoom in by the currently set increment, with the map centred at the location (in world * coords) of the mouse click * * @param e map mapPane mouse event */ @Override public void onMouseClicked(MapMouseEvent e) { Rectangle paneArea = ((JComponent) getMapPane()).getVisibleRect(); DirectPosition2D mapPos = e.getWorldPos(); double scale = getMapPane().getWorldToScreenTransform().getScaleX(); double newScale = scale * zoom; DirectPosition2D corner = new DirectPosition2D( mapPos.getX() - 0.5d * paneArea.getWidth() / newScale, mapPos.getY() + 0.5d * paneArea.getHeight() / newScale); Envelope2D newMapArea = new Envelope2D(); newMapArea.setFrameFromCenter(mapPos, corner); getMapPane().setDisplayArea(newMapArea); }
/** * Zoom out by the currently set increment, with the map centred at the location (in world * coords) of the mouse click * * @param ev the mouse event */ @Override public void onMouseClicked(MapMouseEvent ev) { Rectangle paneArea = ((JComponent) getMapPane()).getVisibleRect(); DirectPosition2D mapPos = ev.getWorldPos(); double scale = getMapPane().getWorldToScreenTransform().getScaleX(); double newScale = scale / zoom; DirectPosition2D corner = new DirectPosition2D( mapPos.getX() - 0.5d * paneArea.getWidth() / newScale, mapPos.getY() + 0.5d * paneArea.getHeight() / newScale); Envelope2D newMapArea = new Envelope2D(); newMapArea.setFrameFromCenter(mapPos, corner); getMapPane().setDisplayArea(newMapArea); }
mapPos.getX() - 0.5d * paneArea.getWidth() / newScale, mapPos.getY() + 0.5d * paneArea.getHeight() / newScale);
/** Circumscribed rectangle (smallest) for full disk earth image */ public static Envelope2D circumscribeFullDisk(CoordinateReferenceSystem geosCRS) throws TransformException, FactoryException { if (!isGeostationaryCRS(geosCRS)) { return null; } MathTransform mt = CRS.findMathTransform(geosCRS, CRS.getProjectedCRS(geosCRS).getBaseCRS(), true); MathTransform imt = mt.inverse(); ParameterValueGroup parameters = CRS.getMapProjection(geosCRS).getParameterValues(); double semiMajorAxis = parameters.parameter("semi_major").doubleValue(); double satelliteHeight = parameters.parameter("satellite_height").doubleValue(); double centralMeridian = parameters.parameter("central_meridian").doubleValue(); DirectPosition2D dp2d = new DirectPosition2D(); double halfFoVRadians = Math.acos(semiMajorAxis / (satelliteHeight + semiMajorAxis)); double halfFoVDegrees = Math.toDegrees(halfFoVRadians); dp2d.setLocation(centralMeridian - halfFoVDegrees, 0.); imt.transform(dp2d, dp2d); double xMin = dp2d.getX(); dp2d.setLocation(centralMeridian + halfFoVDegrees, 0.); imt.transform(dp2d, dp2d); double xMax = dp2d.getX(); dp2d.setLocation(centralMeridian, -halfFoVDegrees); imt.transform(dp2d, dp2d); double yMin = dp2d.getY(); dp2d.setLocation(centralMeridian, halfFoVDegrees); imt.transform(dp2d, dp2d); double yMax = dp2d.getY(); return new Envelope2D(geosCRS, xMin, yMin, xMax - xMin, yMax - yMin); }
/** * Displays coordinates of the given position. * * @param p world position */ private void displayCoords(DirectPosition2D p) { label.setText(String.format(numFormat, p.getX(), p.getY())); ensureMinLabelWidth(); }
private static Coordinate[] getWorldCoordinates( final double minX, final double minY, final double maxX, final double maxY, final int numPointsPerSegment, final MathTransform gridToCRS) throws MismatchedDimensionException, TransformException { final Point2D[] gridCoordinates = getGridCoordinates(minX, minY, maxX, maxY, numPointsPerSegment); final Coordinate[] worldCoordinates = new Coordinate[gridCoordinates.length]; for (int i = 0; i < gridCoordinates.length; i++) { final DirectPosition2D worldPt = new DirectPosition2D(); final DirectPosition2D dp = new DirectPosition2D(gridCoordinates[i]); gridToCRS.transform(dp, worldPt); worldCoordinates[i] = new Coordinate(worldPt.getX(), worldPt.getY()); } return worldCoordinates; }
/** * Zoom out by the currently set increment, with the map * centred at the location (in world coords) of the mouse * click * * @param ev the mouse event */ @Override public void onMouseClicked(MapMouseEvent ev) { Rectangle paneArea = ((JComponent) getMapPane()).getVisibleRect(); DirectPosition2D mapPos = ev.getWorldPos(); double scale = getMapPane().getWorldToScreenTransform().getScaleX(); double newScale = scale / zoom; DirectPosition2D corner = new DirectPosition2D( mapPos.getX() - 0.5d * paneArea.getWidth() / newScale, mapPos.getY() + 0.5d * paneArea.getHeight() / newScale); Envelope2D newMapArea = new Envelope2D(); newMapArea.setFrameFromCenter(mapPos, corner); getMapPane().setDisplayArea(newMapArea); }
/** * Zoom in by the currently set increment, with the map * centred at the location (in world coords) of the mouse * click * * @param e map mapPane mouse event */ @Override public void onMouseClicked(MapMouseEvent e) { Rectangle paneArea = ((JComponent) getMapPane()).getVisibleRect(); DirectPosition2D mapPos = e.getWorldPos(); double scale = getMapPane().getWorldToScreenTransform().getScaleX(); double newScale = scale * zoom; DirectPosition2D corner = new DirectPosition2D( mapPos.getX() - 0.5d * paneArea.getWidth() / newScale, mapPos.getY() + 0.5d * paneArea.getHeight() / newScale); Envelope2D newMapArea = new Envelope2D(); newMapArea.setFrameFromCenter(mapPos, corner); getMapPane().setDisplayArea(newMapArea); }