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

📄 bctagsmapfunctionality.java

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

import java.io.IOException;
import java.io.InputStream;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import com.esri.adf.web.ags.data.AGSMapFunctionality;
import com.esri.adf.web.data.export.ExportProperties;
import com.esri.solutions.jitk.web.data.IBCTMapFunctionality;
import com.esri.solutions.jitk.web.data.image.JAIBCTProcessor;
import com.esri.solutions.jitk.web.data.image.TintParameters;

public class BCTAGSMapFunctionality extends AGSMapFunctionality implements IBCTMapFunctionality {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7230414378070952936L;

	private static final Logger LOG = LogManager.getLogger(BCTAGSMapFunctionality.class);
	
	private byte m_brightness = 0;
	private byte m_contrast = 1;
	private TintParameters m_tint;
	
	/* (non-Javadoc)
	 * @see com.esri.solutions.jitk.web.tasks.serviceprops.IBCTMapFunctionality#getBrightness()
	 */
	public byte getBrightness() {
		return m_brightness;
	}
	/* (non-Javadoc)
	 * @see com.esri.solutions.jitk.web.tasks.serviceprops.IBCTMapFunctionality#setBrightness(byte)
	 */
	public void setBrightness(byte brightness) {
		m_brightness = brightness;
	}
	/* (non-Javadoc)
	 * @see com.esri.solutions.jitk.web.tasks.serviceprops.IBCTMapFunctionality#getContrast()
	 */
	public byte getContrast() {
		return m_contrast;
	}
	/* (non-Javadoc)
	 * @see com.esri.solutions.jitk.web.tasks.serviceprops.IBCTMapFunctionality#setContrast(byte)
	 */
	public void setContrast(byte contrast) {
		m_contrast = contrast;
	}
	/* (non-Javadoc)
	 * @see com.esri.solutions.jitk.web.tasks.serviceprops.IBCTMapFunctionality#getTint()
	 */
	public TintParameters getTint() {
		return m_tint;
	}
	/* (non-Javadoc)
	 * @see com.esri.solutions.jitk.web.tasks.serviceprops.IBCTMapFunctionality#setTint(com.esri.solutions.jitk.web.tasks.serviceprops.TintParameters)
	 */
	public void setTint(TintParameters tint) {
		m_tint = tint;
	}
	
	
	@Override
	public InputStream exportImage()  {
		JAIBCTProcessor p = new JAIBCTProcessor();
		
		InputStream src = super.exportImage();
		
		p.setImageFormat(this.getResource().getWebContext().getWebMap().getImageFormat());
		p.setImageInputStream(src);
		p.setBrightness(m_brightness);
		p.setContrast(m_contrast);
		p.setTint(m_tint);
		
		try {
			return p.process();
		} catch (IOException e) {
			LOG.warn("", e);
			return null;
		}
	}
	
	public InputStream export(ExportProperties props) {
		InputStream source = super.export(props);
		
		
		if (source == null || !shouldApplyBCT()) {
			return source;
		}
		
		JAIBCTProcessor p = new JAIBCTProcessor();
		
		p.setImageFormat(props.getImageFormat());
		p.setImageInputStream(source);
		p.setBrightness(m_brightness);
		p.setContrast(m_contrast);
		p.setTint(m_tint);
		
		
		try {
			return p.process();
		} catch (IOException e) {
			LOG.warn("", e);
			return null;
		}
	}
	
	protected boolean shouldApplyBCT () {
		if (m_brightness != 0) {
			return true;
		}
		if (m_contrast != 1) {
			return true;
		}
		if (m_tint != null) {
			if (m_tint.getRedOffset() != 0) {
				return true;
			}
			if (m_tint.getGreenOffset() != 0) {
				return true;
			}
			if (m_tint.getBlueOffset() != 0) {
				return true;
			}
		}
		
		return false;
	}
}

⌨️ 快捷键说明

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