/** * Notifies MapBoundsListeners about a change to the bounds or crs. * * @param event The event to be fired */ protected void fireMapBoundsListenerMapBoundsChanged( Type type, ReferencedEnvelope oldBounds, ReferencedEnvelope newBounds) { if (boundsListeners == null) { return; } if (newBounds == bounds) { // issue a copy to the boundsListeners for safety newBounds = new ReferencedEnvelope(bounds); } MapBoundsEvent event = new MapBoundsEvent(this, type, oldBounds, newBounds); for (MapBoundsListener boundsListener : boundsListeners) { try { boundsListener.mapBoundsChanged(event); } catch (Throwable t) { if (LOGGER.isLoggable(Level.FINER)) { LOGGER.logp( Level.FINE, boundsListener.getClass().getName(), "mapBoundsChanged", t.getLocalizedMessage(), t); } } } }
/** * Called by the map content's viewport when its bounds have changed. Used here to watch for a * changed CRS, in which case the map is re-displayed at full extent. */ @Override public void mapBoundsChanged(MapBoundsEvent event) { paramsLock.writeLock().lock(); try { int type = event.getType(); if ((type & MapBoundsEvent.COORDINATE_SYSTEM_MASK) != 0) { /* * The coordinate reference system has changed. Set the map * to display the full extent of layer bounds to avoid the * effect of a shrinking map */ setFullExtent(); reset(); } } finally { paramsLock.writeLock().unlock(); } }