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

📄 scalecontrol.java

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

import java.io.IOException;
import java.text.DecimalFormat;

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

import org.apache.log4j.Logger;

import com.esri.adf.web.data.WebMap;
import com.esri.solutions.jitk.web.event.IScaleSliderConfig;

/**
 * The {@link TableControl} provides the functionality to display results in a
 * in form of a table.
 * 
 */
public class ScaleControl extends UIOutput {
	private static Logger _logger = Logger.getLogger(ScaleControl.class.getName());
	
    /**
     * The standard component family for this component.
     */
    public static final String COMPONENT_FAMILY = 
        "com.esri.jitk.web.Information.Scale";
    /**
     * The standard component type for this component.
     */
    public static final String COMPONENT_TYPE = 
        "com.esri.jitk.web.Information.Scale";
            
    private String convertScale(double scale){
    	DecimalFormat df = new DecimalFormat("###,###,###,###");
    	
    	String str = df.format(scale);
   
	  	String scaleStr = "1:" + str;
	  	
	  	if ((scale < 1) && (scale != 0.0)) {
	  		scale = 1 / scale;
	  		str = df.format(scale);
	  		scaleStr = df.format(str) + ":1";
	  	} else if (scale == 0.0) {
	  		_logger.error("Map scale reported as zero");
	  	}
	  	
	  	return scaleStr;
    }
    
    /**
     * 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("jitkTaskScaleInfoArray[jitkTaskScaleInfoArray.length]='" + getClientId(context) + "';");
      writer.endElement("script");
      
      IScaleSliderConfig ssb = (IScaleSliderConfig) context.getApplication().createValueBinding("#{scaleSliderBB}").getValue(context);                  
      WebMap webMap = (WebMap)this.getAttributes().get("value");
      double currentMapScale = webMap.getMapScale();
      
      writer.startElement("script", this);
      writer.writeAttribute("language", "javascript", null);      
      writer.write("initSlider('" + Long.toString(Math.round(ssb.getMinScale())) + "','"+ Long.toString(Math.round(ssb.getMaxScale())) + "','"+ Long.toString(Math.round(currentMapScale)) + "');");
      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);

     
      String scaleRatioStr = convertScale(webMap.getMapScale());      
      writer.write(scaleRatioStr);
      
      writer.endElement("span");
      writer.flush();
    }

    /**
     * Encode end
     * 
     * @param FacesContext
     */
    public void encodeEnd(FacesContext context) throws IOException {
    	return;
    }
    
}

⌨️ 快捷键说明

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