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

📄 th_transformersymbol.java

📁 aresde 空间数据开发 例子
💻 JAVA
字号:
/**
 * @(#) TH_TransformerSymbol.java 2007-11-8
 *
 * TIANHUI 2007
 */
package com.th.workframe;

import java.io.IOException;

import com.esri.arcgis.display.CharacterMarkerSymbol;
import com.esri.arcgis.display.IColor;
import com.esri.arcgis.display.MultiLayerMarkerSymbol;
import com.esri.arcgis.display.RgbColor;
import com.esri.arcgis.interop.AutomationException;
import com.esri.arcgis.support.ms.stdole.Font;
import com.esri.arcgis.support.ms.stdole.StdFont;

/**
 * <code><strong> TH_CharacterMarkerSymbol  变压器修饰符号 </strong><code> 
 * 
 * @author <strong> GUJUN </strong>
 * @version 2007-11-8 上午10:30:14
 * @since 1.0
 */
public class TH_TransformerSymbol
extends MultiLayerMarkerSymbol {

	//变压器项数
	public static int TRANSFORMER_TWO = 0;
	public static int TRANSFORMER_THREE = 1;
	
	//符号序号
	private int bgIndex = 65;
	private int clIndex = 66;
	
	//变压器符号的组成元素与背景色
	private CharacterMarkerSymbol circle1, circle2, circle3, bg1, bg2, bg3;
	
	/**
	 * 串行版本标识
	 */
	private static final long serialVersionUID = 1L;

	
	/**
	 * 构造函数
	 * @param xNumber	int		变压器相数
	 * @param size		double	符号大小
	 * @param colors	int[]	符号的组成颜色
	 * @param bgColor	int		符号的背景色
	 */
	public TH_TransformerSymbol(int xNumber, double size, int[] colors, int bgColor) throws Exception {
		
		if(xNumber > TH_TransformerSymbol.TRANSFORMER_TWO) {
			//三相变压器
			ThreeTransformer(size, colors, bgColor);
		}else {
			//双相变压器
			doubleTransformer(size, colors, bgColor);
		}//Endif
		
	}
	
	/**
	 * doubleTransformer() 双相变压器
	 * @param size		double	符号大小
	 * @param colors	int[]	符号的组成颜色
	 * @param bgColor	int		符号的背景色
	 * @throws Exception
	 */
	private void doubleTransformer(double size, int[] colors, int bgColor) throws Exception {
		
		//字体
		Font symbolFont = new StdFont();
		symbolFont.setName(TH_GISFont.FONT_NAME);
		
		//构建符号背景
		bg1 = new CharacterMarkerSymbol();
		bg2 = new CharacterMarkerSymbol();
		bg1.setFont(symbolFont);
		bg2.setFont(symbolFont);
		bg1.setCharacterIndex(bgIndex);
		bg2.setCharacterIndex(bgIndex);
		this.setBackground(bgColor);
		
		//构建符号
		circle1 = new CharacterMarkerSymbol();
		circle2 = new CharacterMarkerSymbol();
		circle1.setFont(symbolFont);
		circle2.setFont(symbolFont);
		circle1.setCharacterIndex(clIndex);
		circle2.setCharacterIndex(clIndex);
		
		//设置颜色
		this.setColor(colors);
		
		//设置大小
		this.setSize(size);

		//组成变压器符号
		this.addLayer(bg1);
		this.addLayer(bg2);
		this.addLayer(circle1);
		this.addLayer(circle2);
		
	}
	
	/**
	 * ThreeTransformer() 三相变压器
	 * @param size		double	符号大小
	 * @param colors	int[]	符号的组成颜色
	 * @param bgColor	int		符号的背景色
	 * @throws Exception
	 */
	private void ThreeTransformer(double size, int[] colors, int bgColor) throws Exception {
		
		//字体
		Font symbolFont = new StdFont();
		symbolFont.setName(TH_GISFont.FONT_NAME);
		
		//构建符号背景
		bg1 = new CharacterMarkerSymbol();
		bg2 = new CharacterMarkerSymbol();
		bg3 = new CharacterMarkerSymbol();
		bg1.setFont(symbolFont);
		bg2.setFont(symbolFont);
		bg3.setFont(symbolFont);
		bg1.setCharacterIndex(bgIndex);
		bg2.setCharacterIndex(bgIndex);
		bg3.setCharacterIndex(bgIndex);
		this.setBackground(bgColor);
		
		//构建符号
		circle1 = new CharacterMarkerSymbol();
		circle2 = new CharacterMarkerSymbol();
		circle3 = new CharacterMarkerSymbol();
		circle1.setFont(symbolFont);
		circle2.setFont(symbolFont);
		circle3.setFont(symbolFont);
		circle1.setCharacterIndex(clIndex);
		circle2.setCharacterIndex(clIndex);
		circle3.setCharacterIndex(clIndex);
		
		//设置颜色
		this.setColor(colors);
		
		//设置大小
		this.setSize(size);

		//组成变压器符号
		this.addLayer(bg1);
		this.addLayer(bg2);
		this.addLayer(bg3);
		this.addLayer(circle1);
		this.addLayer(circle2);
		this.addLayer(circle3);
		
	}
	
	/**
	 * setBackground() 设置符号背景色
	 * @param bgColor	int 十六进制颜色
	 * @throws Exception
	 */
	public void setBackground(int bgColor) throws Exception {
		IColor icolor = new RgbColor();
		icolor.setRGB(bgColor);
		bg1.setColor(icolor);
		bg2.setColor(icolor);
		if(bg3 != null) {
			bg3.setColor(icolor);
		}//Endif
	}
	
	/**
	 * setColor() 设置符号前景色
	 * @param colors	int 十六进制颜色
	 * @throws Exception
	 */
	public void setColor(int[] colors) throws Exception {
		IColor icolor = new RgbColor();
		icolor.setRGB(colors[0]);
		circle1.setColor(icolor);
		icolor.setRGB(colors[1]);
		circle2.setColor(icolor);
		if(circle3 != null) {
			icolor.setRGB(colors[2]);
			circle3.setColor(icolor);
		}//Endif
	}
	
	/**
	 * setSize() 设置符号大小
	 * @param size	double 符号大小
	 * @throws AutomationException, IOException
	 */
	public void setSize(double size) throws AutomationException, IOException {
		
		//计算组件偏移量
		double tmp = size * 0.2;
		
		if(bg3 != null) {
			//三相
			bg1.setSize(size);
			bg1.setXOffset(-tmp);
			bg1.setYOffset(-tmp);
			bg2.setSize(size);
			bg2.setYOffset(size * 0.15);
			bg3.setSize(size);
			bg3.setXOffset(tmp);
			bg3.setYOffset(-tmp);
			
			circle1.setSize(size);
			circle1.setXOffset(-tmp);
			circle1.setYOffset(-tmp);
			circle2.setSize(size);
			circle2.setYOffset(size * 0.15);
			circle3.setSize(size);
			circle3.setXOffset(tmp);
			circle3.setYOffset(-tmp);
		}else {
			//双相
			bg1.setSize(size);
			bg1.setYOffset(-tmp);
			bg2.setSize(size);
			bg2.setYOffset(tmp);
			
			circle1.setSize(size);
			circle1.setYOffset(-tmp);
			circle2.setSize(size);
			circle2.setYOffset(tmp);
		}//Endif
	}
	
	/**
	 * setScale() 设置符号的显示比例
	 * @param scale double 比例值
	 * @throws Exception
	 */
	public void setScale(double scale) throws Exception {
		bg1.setXScale(scale);
		bg1.setYScale(scale);
		bg2.setXScale(scale);
		bg2.setYScale(scale);
		circle1.setXScale(scale);
		circle1.setYScale(scale);
		circle2.setXScale(scale);
		circle2.setYScale(scale);
		if(bg3 != null) {
			bg3.setXScale(scale);
			bg3.setYScale(scale);
			circle3.setXScale(scale);
			circle3.setYScale(scale);
		}//Endif	
	}

}

⌨️ 快捷键说明

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