?? th_transformersymbol.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 + -