⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 weboverview.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	 * has not been invoked, then this method will return {@link #DEFAULT_MAXIMUM_EXTENT_RATIO}.
	 * See the class documentation for more information on the MaxExtentRatio property.
	 * 
	 * @return Value of MaxExtentRatio property.
	 */
	public double getMaxExtentRatio() {
		return maxExtentRatio;
	}

	/**
	 * Sets the value of the MaxExtentRatio property.  See the class documentation for more information
	 * on the MaxExtentRatio property.
	 * 
	 * @param maxExtentRatio		Value of the MaxExtentRatio property, must be greater than 0.0.
	 * 
	 * @throws IllegalArgumentException		Thrown if the <code>maxExtentRatio</code> argument is less than
	 * 										or equal to 0.0.
	 */
	public void setMaxExtentRatio(final double maxExtentRatio) {
		LOG.debug("Attempting to set MaxExtentRatio to " + maxExtentRatio);
		
		if (maxExtentRatio <= 0.0) {
			throw new IllegalArgumentException("MaxExtentRatio cannot be less than 0.0");
		}
		this.maxExtentRatio = maxExtentRatio;
		
		LOG.debug("Successfully set MaxExtentRatio to " + maxExtentRatio);
	}

	
	@Override
	public String getImageUrl() {
		String url = super.getImageUrl();
		
		if (url == null || url.equalsIgnoreCase("NODATA")) {
			byte[] image = ImageUtil.createBlankImage(this.getWidth(), this.getHeight(), 1.0D, this.getImageFormat());
			url = WebUtil.getMimeURL("jitkWebOverview", image, this.getWebContext().getWebSession());
		}
		
		return url;
	}

	/**
	 * Determines if the Overview Map should be redrawn based on the following conditions:
	 * 
	 * <ul>
	 * 	<li>If the Overview Map is visible and
	 *  <li>If the state of Overview Funcationalities has changed.
	 *  <li>If the Overview Map extent does not fully contain the Map extent or
	 *  <li>If the Extent Ratio between the Overview Map and Map does not fall between MinExtentRatio and
	 *  	MaxExtentRatio
	 * </ul>
	 * 
	 * @return Flag indicating of the Overview Map should be redrawn.
	 */
	protected boolean shouldRedrawOvMap () {
		if (!this.isVisible()) {
			LOG.debug("Overview Map is not visible, it should not be redrawn");
			return false;
		}
		
		if (ovFuncStateChanged()) {
			return true;
		}
		
		WebExtent mapExtent = null;
		WebExtent ovExtent = null;
		
		mapExtent = this.map.getCurrentExtent();
		ovExtent = this.getDrawExtent();
		
		if (!contains(ovExtent, mapExtent)) {
			
			if (LOG.isDebugEnabled()) {
				LOG.debug("Map extent is not fully contained within the Overview Map extent, Overview Map needs to be redrawn");
				LOG.debug("Overview Map Extent: " + ovExtent.toString());
				LOG.debug("Map Extent: " + mapExtent.toString());
			}
			
			return true;
		}
		
		double ovExtentWidth = 0.0D;
		double mapExtentWidth = 0.0D;
		double widthRatio = 0.0D;
		
		ovExtentWidth = ovExtent.getWidth();
		mapExtentWidth = mapExtent.getWidth();
		
		widthRatio = ovExtentWidth / mapExtentWidth;
		
		if (LOG.isDebugEnabled()) {
			LOG.debug("Overview Map Extent Width: " + ovExtentWidth);
			LOG.debug("Map Extent Width: " + mapExtentWidth);
			LOG.debug("Width Ratio: " + widthRatio);
		}
		if (widthRatio < getMinExtentRatio() || widthRatio > getMaxExtentRatio()) {
			LOG.debug("Width Ratio is less than " + getMinExtentRatio() + 
						" or greater than " + getMaxExtentRatio() + 
						" so Overview Map needs to be redrawn.");
			
			return true;
		}
		
		LOG.debug("Overview Map does not need redrawn.");
		return false;
	}
	
	/**
	 * Helper method to determine if the <code>outer</code> extent completely
	 * contains the <code>inner</code> extent.  Completely contains means that all
	 * 4 corners of the inner extent must lie within the outer extent.
	 * 
	 * @param outer  Outer Extent, should represent the larger extent.
	 * @param inner  Inner Extent, should represent the smaller extent.
	 * @return Flag indicating if the Outer extent completely contains the Inner extent.
	 */
	private boolean contains (WebExtent outer, WebExtent inner) {
		
		assert (outer != null);
		assert (inner != null);
		
		double outerX = outer.getMinX();
		double outerY = outer.getMinY();
		double outerWidth = outer.getWidth();
		double outerHeight = outer.getHeight();
		
		double innerX = inner.getMinX();
		double innerY = inner.getMinY();
		double innerWidth = inner.getWidth();
		double innerHeight = inner.getHeight();
		
		return innerX >= outerX && 
				innerY >= outerY && 
				(innerX + innerWidth) <= (outerX + outerWidth) && 
				(innerY + innerHeight) <= (outerY + outerHeight);
	}
	
	/**
	 * Calculates a new Draw Extent for the Overview Map.  The Draw Extent represents
	 * the extent at which the Overview Map will be drawn.  The new Draw Extent is calculated
	 * by performing the following steps:
	 * 
	 * <ul>
	 * 	<li>Retrieving Current Map Extent
	 *  <li>Expanding Current Map Extent by MinExtentRatio to become new Draw Extent
	 *  <li>Clipping the 4 corners of the Draw Extent to make sure they don't exceed
	 *      the Map's Full Extent
	 * </ul>
	 * 
	 * Once the new Draw Extent is calculated it is set within this object by invoking
	 * {@link #setDrawExtent(WebExtent)}.
	 * 
	 */
	private void calculateNewDrawExtent () {
		WebExtent drawExtent = null;
		WebExtent mapExtent = null;
		
		mapExtent = this.map.getCurrentExtent();
		drawExtent = new WebExtent(mapExtent);
		
		drawExtent.expand(getMinExtentRatio());
	
		// Clip draw extent so that it does not exceed the full extent of the map
		WebExtent fullExtent = map.getFullExtent();
		if (drawExtent.getMinX() < fullExtent.getMinX()) {
			drawExtent.setMinX(fullExtent.getMinX());
		}
		if (drawExtent.getMinY() < fullExtent.getMinY()) {
			drawExtent.setMinY(fullExtent.getMinY());
		}
		if (drawExtent.getMaxX() > fullExtent.getMaxX()) {
			drawExtent.setMaxX(fullExtent.getMaxX());
		}
		if (drawExtent.getMaxY() > fullExtent.getMaxY()) {
			drawExtent.setMaxY(fullExtent.getMaxY());
		}
		
		this.setDrawExtent(drawExtent);
	}
	
	/**
	 * Determines if any OverviewFunctionalities have been enabled or disabled or if
	 * any have been added or removed.
	 * 
	 * @return Flag indicating a change in Overview Functionality state.
	 */
	private boolean ovFuncStateChanged () {
		List<OverviewFunctionality> ovFuncs = this.getOverviewFunctionalities();
		
		for (java.util.Map.Entry<OverviewFunctionality, Boolean> entry : m_ovFuncState.entrySet()) {
			boolean currentState = entry.getValue();
			boolean newState = entry.getKey().isDisabled();
			
			if (currentState != newState) {
				return true;
			}
			
			// Check for removed Overview Functionalities
			if (!ovFuncs.contains(entry.getKey())) {
				return true;
			}
		}
		
		// Check for added Overview Functionalities
		for (OverviewFunctionality ovFunc : ovFuncs) {
			if (!m_ovFuncState.containsKey(ovFunc)) {
				return true;
			}
		}
		
		return false;
	}
	
	/**
	 * Updates the current state of Overview Functionalities so that a change can
	 * be detected later.  The enabled/disabled state is maintained.
	 */
	private void updateOvFuncState() {
		m_ovFuncState.clear();
		List<OverviewFunctionality> ovFuncs = this.getOverviewFunctionalities();
		for (OverviewFunctionality ovFunc : ovFuncs) {
			m_ovFuncState.put(ovFunc, ovFunc.isDisabled());
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -