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

📄 polygondrawingtask.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
字号:
package com.esri.solutions.jitk.web.tasks.redlining.shape;

import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.log4j.Logger;

import com.esri.adf.web.data.geometry.WebExtent;
import com.esri.adf.web.data.symbol.WebSimplePolygonSymbol;
import com.esri.adf.web.data.symbol.WebSymbol;
import com.esri.adf.web.faces.event.MapEvent;
import com.esri.solutions.jitk.common.geometry.GeometryConverter;
import com.esri.solutions.jitk.web.tasks.redlining.map.BoundaryTypeMap;
import com.esri.solutions.jitk.web.tasks.redlining.map.FillTypeMap;
import com.esri.solutions.jitk.web.tasks.redlining.map.TransparencyPercentMap;

public class PolygonDrawingTask extends LineDrawingTask {
	
	private static final long serialVersionUID = 3549460433053928358L;
	private static final Logger _logger = Logger.getLogger(PolygonDrawingTask.class);
	
	protected String _polygonFillColor = null;
	protected String _fillColorParam = null;
	protected long _polygonFillInterval = 10;
	protected int _polygonFillTypeId = -1;
	protected int _polygonBoundaryWidth = -1;
	protected String _polygonBoundaryColor = null;
	protected String _polygonFillTransparency = "0.5";
	protected String _simplePolygonBoundaryType = WebSimplePolygonSymbol.SOLID;
	protected String _fillTypeParam = null;
	protected String _boundaryColorParam = null;
	protected String _boundaryWidthParam = null;
	
	protected Map<String, String> _simplePolygonBoundarySymbolList = null;
	private LinkedHashMap<String, String> _polygonBoundaryTypeList = null;
	private LinkedHashMap<Integer, String> _polygonFillTypeList = null;
	private Map<String, String> _polygonFillTransparencyList = null;	
	
	public void initPolygonProperties() {
		this._polygonFillTypeList = new FillTypeMap();
		this._polygonBoundaryTypeList = new BoundaryTypeMap();
		this._polygonFillTransparencyList = new TransparencyPercentMap();
		this._simplePolygonBoundarySymbolList = new BoundaryTypeMap();
	}
	
	public void placePolygon(MapEvent event){
		
		try {
			_logger.info("Placing polygon redline on map.");
			requestTaskRender();
			
			mgResource.addGraphicFeature(event.getWebGeometry().toMapGeometry(event.getWebContext().getWebMap()), getPolygonSymbol());
			
			event.getWebContext().refresh();
		
		} catch (Exception ex) {
			renderExceptionMessage(ex);
			_logger.error("Could not place polygon redline on map.", ex);
		}
	}
	
	public void placeRectangle(MapEvent event) {
		
		try {
			_logger.info("Placing rectangle redline on map.");
			requestTaskRender();
			
			mgResource.addGraphicFeature(GeometryConverter.toWebPolygon((WebExtent)event.getWebGeometry().toMapGeometry(event.getWebContext().getWebMap())), getPolygonSymbol());
			
			event.getWebContext().refresh();			
		
		} catch (Exception ex) {
			renderExceptionMessage(ex);
			_logger.error("Could not place rectangle redline on map.");
		}
	}

	protected WebSymbol getPolygonSymbol() {
		
		WebSimplePolygonSymbol symbol = new WebSimplePolygonSymbol();
		symbol.setLineType(getSimplePolygonBoundaryType());
		symbol.setCapType(WebSimplePolygonSymbol.ROUND);
		symbol.setWidth(getPolygonBoundaryWidth());
		symbol.setColor(getPolygonBoundaryColor());
		
		symbol.setFillType(FillTypeMap.POLYGON_FILL_TYPE[getPolygonFillTypeId()]);
		symbol.setFillColor(getPolygonFillColor());
		symbol.setFillTransparency(Double.parseDouble(getPolygonFillTransparency())/100);
		symbol.setFillInterval((int)getPolygonFillInterval());
		
		symbol.setAntialiasing(true);
        
        return symbol;
	}

	public String getPolygonFillColor() {
		if (_polygonFillColor == null) this._polygonFillColor = this._fillColorParam;
		return _polygonFillColor;
	}

	public void setPolygonFillColor(String polygonFillColor) {
		this._polygonFillColor = polygonFillColor;
	}	
	
	public String getFillColorParam() {
		return this._fillColorParam;
	}

	public void setFillColorParam(String fillColorParam) {
		this._fillColorParam = fillColorParam;
	}	
	
	public long getPolygonFillInterval() {
		return _polygonFillInterval;
	}

	public void setPolygonFillInterval(long polygonFillInterval) {
		this._polygonFillInterval = polygonFillInterval;
	}	
	
	public int getPolygonFillTypeId() {
		if (_polygonFillTypeId < 0) _polygonFillTypeId = Integer.parseInt(this._fillTypeParam);
		return _polygonFillTypeId;
	}

	public void setPolygonFillTypeId(int polygonFillTypeId) {
		this._polygonFillTypeId = polygonFillTypeId;
	}	
	
	public String getPolygonBoundaryColor() {
		if (_polygonBoundaryColor == null) _polygonBoundaryColor = this._boundaryColorParam;
		return _polygonBoundaryColor;
	}

	public void setPolygonBoundaryColor(String polygonBoundaryColor) {
		this._polygonBoundaryColor = polygonBoundaryColor;
	}

	public int getPolygonBoundaryWidth() {
		if (_polygonBoundaryWidth < 0) _polygonBoundaryWidth = Integer.parseInt(this._boundaryWidthParam);
		return _polygonBoundaryWidth;
	}

	public void setPolygonBoundaryWidth(int polygonBoundaryWidth) {
		this._polygonBoundaryWidth = polygonBoundaryWidth;
	}	
	
	public String getPolygonFillTransparency() {
		return this._polygonFillTransparency;
	}

	public void setPolygonFillTransparency(String polygonFillTransparency) {
		this._polygonFillTransparency = polygonFillTransparency;
	}

	public String getSimplePolygonBoundaryType() {
		return this._simplePolygonBoundaryType;
	}

	public void setSimplePolygonBoundaryType(String simplePolygonBoundaryType) {
		this._simplePolygonBoundaryType = simplePolygonBoundaryType;
	}	
	
	public String getFillTypeParam() {
		return this._fillTypeParam;
	}

	public void setFillTypeParam(String fillTypeParam) {
		this._fillTypeParam = fillTypeParam;
	}

	public String getBoundaryColorParam() {
		return this._boundaryColorParam;
	}

	public void setBoundaryColorParam(String boundaryColorParam) {
		this._boundaryColorParam = boundaryColorParam;
	}

	public String getBoundaryWidthParam() {
		return this._boundaryWidthParam;
	}

	public void setBoundaryWidthParam(String boundaryWidthParam) {
		this._boundaryWidthParam = boundaryWidthParam;
	}
	
	public Map<String, String> getSimplePolygonBoundarySymbolList() {
		return this._simplePolygonBoundarySymbolList;
	}
	
	public LinkedHashMap<String, String> getPolygonBoundaryTypeList() {
		return _polygonBoundaryTypeList;
	}

	public LinkedHashMap<Integer, String> getPolygonFillTypeList() {
		return _polygonFillTypeList;
	}
	
	public Map<String, String> getPolygonFillTransparencyList() {
		return _polygonFillTransparencyList;
	}
}

⌨️ 快捷键说明

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