📄 aimsrenderertask.java
字号:
package com.esri.adf.web.aims.tasks;
import java.util.LinkedHashMap;
import com.esri.adf.web.aims.data.AIMSMapFunctionality;
import com.esri.adf.web.aims.data.AIMSMapResource;
import com.esri.adf.web.data.WebContext;
import com.esri.adf.web.data.WebContextInitialize;
import com.esri.adf.web.data.tasks.TaskInfo;
import com.esri.adf.web.data.tasks.TaskInfoBean;
import com.esri.adf.web.faces.event.TaskEvent;
import com.esri.aims.mtier.model.map.Layers;
import com.esri.aims.mtier.model.map.Map;
import com.esri.aims.mtier.model.map.layer.FeatureLayer;
import com.esri.aims.mtier.model.map.layer.renderer.SimpleRenderer;
import com.esri.aims.mtier.model.map.layer.renderer.symbol.SimpleLineSymbol;
import com.esri.aims.mtier.model.map.layer.renderer.symbol.SimpleMarkerSymbol;
import com.esri.aims.mtier.model.map.layer.renderer.symbol.SimplePolygonSymbol;
import com.esri.adf.web.aims.tasks.AIMSRendererTaskUtil;
public class AIMSRendererTask implements WebContextInitialize, TaskInfoBean
{
private TaskInfo taskInfo = null;
private String taskName = null;
private WebContext context = null;
private AIMSMapResource aimsResource = null;
private LinkedHashMap aimsResourceList = null;
private LinkedHashMap aimsLayerList = null;
private LinkedHashMap pointMarkerTypeList = null;
private LinkedHashMap lineTypeList = null;
private LinkedHashMap lineJoinTypeList = null;
private LinkedHashMap lineCapTypeList = null;
private LinkedHashMap polygonBoundaryJoinTypeList = null;
private LinkedHashMap polygonBoundaryCapTypeList = null;
private LinkedHashMap polygonBoundaryTypeList = null;
private LinkedHashMap polygonFillTypeList = null;
private int aimsResourceId = 0;
private int aimsLayerId = 0;
private int pointMarkerTypeId = 0;
private int lineTypeId = 0;
private int lineJoinTypeId = 0;
private int lineCapTypeId = 0;
private int polygonBoundaryJoinTypeId = 0;
private int polygonBoundaryCapTypeId = 0;
private int polygonBoundaryTypeId = 0;
private int polygonFillTypeId = 0;
//render parameters for point layer
private int pointWidth = 8;
private String pointColor = "0,0,0";
private boolean pointAntialiasing = true;
private String pointOutlineColor = "255,255,255";
private boolean pointOverlap = true;
private String pointShadow = "255,0,0";
private boolean pointUserCentrid = true;
private double pointTransparency = 1.0;
//render parameter for line layer
private boolean lineAntialiasing = true;
private String lineColor = "0,0,0";
private boolean lineOverlap = true;
private int lineWidth = 1;
private double lineTransparency = 1.0;
//render parameter for polygon layer
private boolean polygonAntialiasing = true;
private boolean polygonBoundary = true;
private String polygonBoundaryColor = "0,0,0";
private double polygonBoundaryTransparency = 1.0;
private int polygonBoundaryWidth = 1;
private String polygonFillColor = "0,0,0";
private double polygonFillTransparency = 1.0;
private boolean polygonOverlap = true;
private long polygonFillInterval = 5;
public AIMSRendererTask()
{
this.taskInfo = new AIMSRendererTaskInfo();
this.taskName = "ArcIMS Renderer Task";
}
public void destroy()
{
this.context = null;
}
public void init(WebContext context)
{
setContext(context);
}
public void doSelectAimsResource(TaskEvent event)
{
this.setAimsResource(AIMSTaskUtil.getAimsResourceById(this.context, this.aimsResourceId));
this.aimsLayerList = AIMSTaskUtil.getLayerList(this.aimsResource);
}
public void doSelectAimsLayer(TaskEvent event)
{
try
{
AIMSMapFunctionality aimsMapFunctionality = null;
Map aimsMap = null;
Layers aimsLayers = null;
FeatureLayer featureLayer = null;
String featureLayerType = null;
if(this.aimsResource != null)
{
aimsMapFunctionality = (AIMSMapFunctionality)this.aimsResource.getFunctionality("map");
aimsMap = aimsMapFunctionality.getMap();
aimsLayers = aimsMap.getLayers();
featureLayer = (FeatureLayer)aimsLayers.item(this.aimsLayerId);
featureLayerType = featureLayer.getFeatureClass();
//System.out.println(featureLayerType);
if(featureLayerType.equalsIgnoreCase("point") == true)
{
((AIMSRendererTaskInfo)this.taskInfo).applyPointLayerRendererLayout();
}
else if(featureLayerType.equalsIgnoreCase("line") == true)
{
((AIMSRendererTaskInfo)this.taskInfo).applyLineLayerRendererLayout();
}
else if(featureLayerType.equalsIgnoreCase("polygon") == true)
{
((AIMSRendererTaskInfo)this.taskInfo).applyPolygonLayerRendererLayout();
}
else {}
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
public void doRendering(TaskEvent event)
{
try
{
AIMSMapFunctionality aimsMapFunctionality = null;
Map aimsMap = null;
Layers aimsLayers = null;
FeatureLayer featureLayer = null;
String featureLayerType = null;
if(this.aimsResource != null)
{
aimsMapFunctionality = (AIMSMapFunctionality)this.aimsResource.getFunctionality("map");
aimsMap = aimsMapFunctionality.getMap();
aimsLayers = aimsMap.getLayers();
featureLayer = (FeatureLayer)aimsLayers.item(this.aimsLayerId);
featureLayerType = featureLayer.getFeatureClass();
//System.out.println(featureLayerType);
if(featureLayerType.equalsIgnoreCase("point") == true)
{
featureLayer.setRenderer(doPointRendering());
}
else if(featureLayerType.equalsIgnoreCase("line") == true)
{
featureLayer.setRenderer(doLineRendering());
}
else if(featureLayerType.equalsIgnoreCase("polygon") == true)
{
featureLayer.setRenderer(doPolygonRendering());
}
else {}
aimsMap.refresh();
this.context.refresh();
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
public SimpleRenderer doPointRendering()
{
SimpleRenderer simpleRenderer = new SimpleRenderer();
SimpleMarkerSymbol simplemarker = new SimpleMarkerSymbol();
simplemarker.setColor(this.pointColor);
simplemarker.setMarkerType((String)this.pointMarkerTypeList.get(this.pointMarkerTypeId));
simplemarker.setTransparency(this.pointTransparency);
simplemarker.setOutline(this.pointOutlineColor);
simplemarker.setWidth(this.pointWidth);
simplemarker.setAntialiasing(this.pointAntialiasing);
simplemarker.setOverlap(this.pointOverlap);
simplemarker.setShadow(this.pointShadow);
simplemarker.setUseCentroid(this.pointUserCentrid);
simpleRenderer.setSymbol(simplemarker);
return simpleRenderer;
}
public SimpleRenderer doLineRendering()
{
SimpleRenderer simpleRenderer = new SimpleRenderer();
SimpleLineSymbol simpleline = new SimpleLineSymbol();
simpleline.setColor(this.lineColor);
simpleline.setLineType((String)this.lineTypeList.get(this.lineTypeId));
simpleline.setTransparency(this.lineTransparency);
simpleline.setAntialiasing(this.lineAntialiasing);
simpleline.setCapType((String)this.lineCapTypeList.get(this.lineCapTypeId));
simpleline.setOverlap(this.lineOverlap);
simpleline.setWidth(this.lineWidth);
simpleline.setJoinType((String)this.lineJoinTypeList.get(this.lineJoinTypeId));
simpleRenderer.setSymbol(simpleline);
return simpleRenderer;
}
public SimpleRenderer doPolygonRendering()
{
SimpleRenderer simpleRenderer = new SimpleRenderer();
SimplePolygonSymbol simplepolygon = new SimplePolygonSymbol();
simplepolygon.setBoundary(this.polygonBoundary);
simplepolygon.setBoundaryType((String)this.polygonBoundaryTypeList.get(this.polygonBoundaryTypeId));
simplepolygon.setBoundaryColor(this.polygonBoundaryColor);
simplepolygon.setBoundaryWidth(this.polygonBoundaryWidth);
simplepolygon.setBoundaryCapType((String)this.polygonBoundaryCapTypeList.get(this.polygonBoundaryCapTypeId));
simplepolygon.setBoundaryJoinType((String)this.polygonBoundaryJoinTypeList.get(this.polygonBoundaryJoinTypeId));
simplepolygon.setBoundaryTransparency(this.polygonBoundaryTransparency);
simplepolygon.setAntialiasing(this.polygonAntialiasing);
simplepolygon.setOverlap(this.polygonOverlap);
simplepolygon.setFillType((String)this.polygonFillTypeList.get(this.polygonFillTypeId));
simplepolygon.setFillColor(this.polygonFillColor);
simplepolygon.setFillTransparency(this.polygonFillTransparency);
simpleRenderer.setSymbol(simplepolygon);
return simpleRenderer;
}
public TaskInfo getTaskInfo()
{
if(this.context == null)
{
taskInfo.getTaskDescriptor().setDisabled(true);
}
doSelectAimsLayer(null);
return this.taskInfo;
}
public void setTaskInfo(TaskInfo taskInfo)
{
this.taskInfo = taskInfo;
}
public WebContext getContext()
{
return context;
}
public void setContext(WebContext context)
{
if(context != null)
{
this.context = context;
this.aimsResourceList = AIMSTaskUtil.getAimsResourceList(this.context);
if(this.aimsResource == null)
{
this.setAimsResource(AIMSTaskUtil.getAimsResourceById(this.context, 0));
}
this.aimsLayerList = AIMSTaskUtil.getLayerList(this.aimsResource);
this.pointMarkerTypeList = AIMSRendererTaskUtil.getPointMarkerType();
this.lineTypeList = AIMSRendererTaskUtil.getLineType();
this.lineCapTypeList = AIMSRendererTaskUtil.getCapType();
this.lineJoinTypeList = AIMSRendererTaskUtil.getJoinType();
this.polygonBoundaryCapTypeList = AIMSRendererTaskUtil.getCapType();
this.polygonBoundaryJoinTypeList = AIMSRendererTaskUtil.getJoinType();
this.polygonFillTypeList = AIMSRendererTaskUtil.getPolygonFillType();
this.polygonBoundaryTypeList = AIMSRendererTaskUtil.getPolygonBoundaryType();
}
else
{
taskInfo.getTaskDescriptor().setDisabled(true);
}
}
public String getTaskName()
{
return taskName;
}
public void setTaskName(String taskName)
{
this.taskName = taskName;
}
public int getAimsLayerId() {
return aimsLayerId;
}
public void setAimsLayerId(int aimsLayerId) {
this.aimsLayerId = aimsLayerId;
}
public LinkedHashMap getAimsLayerList()
{
this.doSelectAimsResource(null);
this.aimsLayerList = AIMSTaskUtil.getLayerList(this.aimsResource);
return aimsLayerList;
}
public void setAimsLayerList(LinkedHashMap aimsLayerList)
{
this.aimsLayerList = aimsLayerList;
}
public AIMSMapResource getAimsResource()
{
return aimsResource;
}
public void setAimsResource(AIMSMapResource aimsResource)
{
this.aimsResource = aimsResource;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -