/** * Creates a new viewport with the specified world bounds. The input envelope is copied so * subsequent changes to it will not affect the viewport. * * <p>The initial screen area will be empty. * * @param bounds display area in world coordinates (may be {@code null}) * @param matchAspectRatio whether to enable aspect ratio matching */ public MapViewport(ReferencedEnvelope bounds, boolean matchAspectRatio) { this.editable = new AtomicBoolean(true); this.screenArea = new Rectangle(); this.hasCenteringTransforms = false; this.matchingAspectRatio = matchAspectRatio; copyBounds(bounds); setTransforms(true); }
/** * Creates a new viewport based on an existing instance. The world bounds, screen area and * aspect ratio matching setting of {@code sourceViewport} are copied. * * <p><strong>Note:</strong> The new viewport will be editable even if {@code sourceViewport} is * not editable. * * @param sourceViewport the viewport to copy * @throws IllegalArgumentException if {@code viewport} is {@code null} */ public MapViewport(MapViewport sourceViewport) { this.editable = new AtomicBoolean(true); this.matchingAspectRatio = sourceViewport.matchingAspectRatio; copyBounds(sourceViewport.bounds); doSetScreenArea(sourceViewport.screenArea); setTransforms(true); }
/** * Sets the display area in world coordinates. * * <p>If {@code bounds} is {@code null} or empty, default identity coordinate transforms will be * set. * * <p>If {@code bounds} is not empty, and aspect ratio matching is enabled, the coordinate * transforms will be calculated to centre the requested bounds in the current screen area (if * defined), after which the world bounds will be adjusted (enlarged) as required to match the * screen area's aspect ratio. * * <p>A {@code MapBoundsEvent} will be fired to inform listeners of the change from old to new * bounds. Note that when aspect ratio matching is enabled, the new bounds carried by the event * will be the viewport's adjusted bounds, not the originally requested bounds. * * @param requestedBounds the requested bounds (may be {@code null}) */ public void setBounds(ReferencedEnvelope requestedBounds) { lock.writeLock().lock(); try { if (checkEditable("setBounds")) { ReferencedEnvelope old = bounds; copyBounds(requestedBounds); setTransforms(true); fireMapBoundsListenerMapBoundsChanged(Type.BOUNDS, old, bounds); } } finally { lock.writeLock().unlock(); } }
/** * Creates a new viewport with the specified world bounds. * The input envelope is copied so subsequent changes to it will not affect the * viewport. * <p> * The initial screen area will be empty. * * @param bounds display area in world coordinates (may be {@code null}) * @param matchAspectRatio whether to enable aspect ratio matching */ public MapViewport(ReferencedEnvelope bounds, boolean matchAspectRatio) { this.editable = new AtomicBoolean(true); this.screenArea = new Rectangle(); this.hasCenteringTransforms = false; this.matchingAspectRatio = matchAspectRatio; copyBounds(bounds); setTransforms(true); }
/** * Creates a new viewport based on an existing instance. The world bounds, * screen area and aspect ratio matching setting of {@code sourceViewport} are * copied. * <p> * <strong>Note:</strong> The new viewport will be editable even if * {@code sourceViewport} is not editable. * * @param sourceViewport the viewport to copy * * @throws IllegalArgumentException if {@code viewport} is {@code null} */ public MapViewport(MapViewport sourceViewport) { this.editable = new AtomicBoolean(true); this.matchingAspectRatio = sourceViewport.matchingAspectRatio; copyBounds(sourceViewport.bounds); doSetScreenArea(sourceViewport.screenArea); setTransforms(true); }
if (checkEditable("setBounds")) { ReferencedEnvelope old = bounds; copyBounds(requestedBounds); setTransforms(true); fireMapBoundsListenerMapBoundsChanged(Type.BOUNDS, old, bounds);