MapMouseEvent extends MouseEvent { public ReferencedEnvelope getEnvelopeByPixels(double widthPixels) { if (widthPixels < 0) { throw new IllegalArgumentException("invalid value for widthPixels: " + widthPixels); } Rectangle2D screenRect = new Rectangle2D.Double( getX() - (widthPixels / 2), getY() - (widthPixels / 2), widthPixels, widthPixels); MapPane pane = getSource(); Rectangle2D worldRect = pane.getScreenToWorldTransform().createTransformedShape( screenRect).getBounds2D(); return new ReferencedEnvelope(worldRect, pane.getMapContent().getCoordinateReferenceSystem()); } MapMouseEvent(MapPane pane, MouseEvent event);  MapMouseEvent(MapPane pane, MouseWheelEvent event); @Override MapPane getSource(); boolean isWheelEvent(); int getWheelAmount(); DirectPosition2D getMapPosition(); DirectPosition2D getWorldPos(); ReferencedEnvelope getEnvelopeByWorld(double widthWorld); ReferencedEnvelope getEnvelopeByPixels(double widthPixels);  }
@Test public void getEnvelopeByPixels() throws Exception { AffineTransform tr = pane.getMapContent().getViewport().getScreenToWorld(); Rectangle2D screenRect = new Rectangle2D.Double(x - 0.5, y - 0.5, 1, 1); Rectangle2D expected = tr.createTransformedShape(screenRect).getBounds2D(); createEvent(x, y); ReferencedEnvelope actual = mapEv.getEnvelopeByPixels(1); assertRect(expected, actual); }