projectioncontrol.java

来自「esri的ArcGIS Server超级学习模板程序(for java)」· Java 代码 · 共 91 行

JAVA
91
字号
package com.esri.solutions.jitk.web.faces.component;

import java.io.IOException;

import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;

import com.esri.adf.web.data.WebMap;
import com.esri.adf.web.data.geometry.WebSpatialReference;


/**
 * The {@link TableControl} provides the functionality to display results in a
 * in form of a table.
 * 
 */
public class ProjectionControl extends UIOutput {	
    /**
     * The standard component family for this component.
     */
    public static final String COMPONENT_FAMILY = "com.esri.jitk.web.Information.Projection";
    /**
     * The standard component type for this component.
     */
    public static final String COMPONENT_TYPE = "com.esri.jitk.web.Information.Projection";
          
    /**
     * Encode begin.
     * .
     * @param FacesContext
     */
    public void encodeBegin(FacesContext context) throws IOException {
      
      ResponseWriter writer = context.getResponseWriter();
      
      writer.startElement("script", this);
      writer.writeAttribute("language", "javascript", null);
      writer.write("jitkTaskInformation_addTagHandler();");
      writer.write("jitkTaskProjInfoArray[jitkTaskProjInfoArray.length]='" + getClientId(context) + "';");
      writer.endElement("script");
      
      writer.startElement("span", this);
      writer.writeAttribute("id", getClientId(context), null);
      String style = (String)this.getAttributes().get("style");
      if (style != null) writer.writeAttribute("style", style, null);
      String styleClass = (String)this.getAttributes().get("styleClass");
      if (styleClass != null) writer.writeAttribute("class", styleClass, null);
      writer.write(this.getFormattedSpatialReferenceString());
      writer.endElement("span");
      
      writer.flush();
    }

    protected String getFormattedSpatialReferenceString () {
    	String wsrString = getSpatialReferenceString();
        
    	if (wsrString.trim().length() == 0) {
    		return "";
    	}
    	
        wsrString = wsrString.replaceAll("_", " ");
		String[] comps = wsrString.split("\"");
    	return comps[1];
    }

	protected String getSpatialReferenceString() {
		WebMap webMap = (WebMap) this.getValue();
        
        WebSpatialReference wsr = webMap.getWebContext().getSpatialReference();
        if (wsr == null) {
        	return "";
        }
        
        String wsrString = wsr.getDefinitionString();
        if (wsrString == null) {
        	return "";
        }
        
		return wsrString;
	}
	
    /**
     * Encode end
     * 
     * @param FacesContext
     */
    public void encodeEnd(FacesContext context) throws IOException {
    	return;
    }   
}

⌨️ 快捷键说明

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