[转] Symbol对象

GIS中的离散实体有三种:点、线、面,在ArcEngine中用三种符号对应表示,分别是:MarkSymbol、LineSymbol和FillSymbol。此外还有TextSymbol用于文字标注,3DChart用来显示饼图等三维对象。

所有符号都实现ISymbol和IMapLevel接口,ISymbol定义一个符号对象的基本属性和方法,IMapLevel定义属性可以确定符号显示的图层,和图层类似,用于确定符号的叠加顺序。

一、MarkerSymbol对象

  MarkerSymbol对象用于修饰点对象符号,拥有12个子类:

Classes Description
ArrowMarkerSymbol 箭头形式符号,箭头的样式只有一个:esriAMSPlain
BarChartSymbol Defines a bar chart symbol.
CharacterMarker3DSymbol (3DAnalyst) 3D Character Marker Symbol component.
CharacterMarkerSymbol 字符形式符号,用于将一个点要素显示为字符状。Characterindex属性用来确定显示的字符
Marker3DSymbol (3DAnalyst) 3D Marker Symbol component.
MultiLayerMarkerSymbol 使用多个符号进行叠加生成新符号。
PictureMarkerSymbol 以图片为背景的符号,把一个点对象的外形表示为一个位图,可以指定Picture或者使用CreateMarkSymbolFromFile获取一张位图
PieChartSymbol Defines a pie chart symbol.
SimpleMarker3DSymbol (3DAnalyst) Simple 3D Marker Symbol component.
SimpleMarkerSymbol 简单类型点符号,有五种类型(esriSMSCircle、esriSMSSquare、esriSMSCross、esriSMSX和esriSMSDiamond)
StackedChartSymbol Defines a stacked chart symbol.
TextMarkerSymbol (TrackingAnalyst)
Class used to create a text marker symbol used to symbolize point geometries.

  都实现IMarkerSymbol接口,定义了Angle、Color、Size、Xoffset、Yoffset。

        private void simpleLineSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;
            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            simpleLineSymbol.Width = 10;
            IRgbColor rgbColor = getRGB(255, 0, 0);
            simpleLineSymbol.Color = rgbColor;
            ISymbol symbol = simpleLineSymbol as ISymbol;
            symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
            IActiveView activeView = this.axMapControl1.ActiveView;
            //用activeView.ScreenDisplay进行画图
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(symbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();//释放资源
        }

        private void cartographicLineSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass();//制图线符号
            cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt;
            cartographicLineSymbol.Join = esriLineJoinStyle.esriLJSBevel;//连接方式
            cartographicLineSymbol.Width = 10;
            cartographicLineSymbol.MiterLimit = 4;//Size threshold(阈值) for showing mitered line joins.
            ILineProperties lineProperties;
            lineProperties = cartographicLineSymbol as ILineProperties;
            lineProperties.Offset = 0;
            double[] dob = new double[6];
            dob[0] = 0;
            dob[1] = 1;
            dob[2] = 2;
            dob[3] = 3;
            dob[4] = 4;
            dob[5] = 5;
            ITemplate template = new TemplateClass();//定义模版
            template.Interval = 1;
            for (int i = 0; i < dob.Length; i += 2)
            {
                template.AddPatternElement(dob[i], dob[i + 1]);
            }
            lineProperties.Template = template;

            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            IRgbColor rgbColor = getRGB(0, 255, 0);
            cartographicLineSymbol.Color = rgbColor;
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(cartographicLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }

        private void multiLayerLineSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass();
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;
            simpleLineSymbol.Width = 10;
            IRgbColor rgbColor = getRGB(255, 0, 0);
            simpleLineSymbol.Color = rgbColor;
            ISymbol symbol = simpleLineSymbol as ISymbol;
            symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;

            ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass();
            cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt;
            cartographicLineSymbol.Join = esriLineJoinStyle.esriLJSBevel;
            cartographicLineSymbol.Width = 10;
            cartographicLineSymbol.MiterLimit = 4;
            ILineProperties lineProperties;
            lineProperties = cartographicLineSymbol as ILineProperties;
            lineProperties.Offset = 0;
            double[] dob = new double[6];
            dob[0] = 0;
            dob[1] = 1;
            dob[2] = 2;
            dob[3] = 3;
            dob[4] = 4;
            dob[5] = 5;
            ITemplate template = new TemplateClass();
            template.Interval = 1;
            for (int i = 0; i < dob.Length; i += 2)
            {
                template.AddPatternElement(dob[i], dob[i + 1]);
            }
            lineProperties.Template = template;

            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            rgbColor = getRGB(0, 255, 0);
            cartographicLineSymbol.Color = rgbColor;
            multiLayerLineSymbol.AddLayer(simpleLineSymbol);
            multiLayerLineSymbol.AddLayer(cartographicLineSymbol);

            IActiveView activeView = this.axMapControl1.ActiveView;

            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(multiLayerLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }

        private void hashLineSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IHashLineSymbol hashLineSymbol = new HashLineSymbolClass();
            ILineProperties lineProperties = hashLineSymbol as ILineProperties;
            lineProperties.Offset = 0;
            double[] dob = new double[6];
            dob[0] = 0;
            dob[1] = 1;
            dob[2] = 2;
            dob[3] = 3;
            dob[4] = 4;
            dob[5] = 5;
            ITemplate template = new TemplateClass();
            template.Interval = 1;
            for (int i = 0; i < dob.Length; i += 2)
            {
                template.AddPatternElement(dob[i], dob[i + 1]);
            }
            lineProperties.Template = template;

            hashLineSymbol.Width = 2;
            hashLineSymbol.Angle = 45;
            IRgbColor hashColor = new RgbColor();
            hashColor = getRGB(0, 0, 255);
            hashLineSymbol.Color = hashColor;

            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            IActiveView activeView = this.axMapControl1.ActiveView;

            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(hashLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }

        //下面的没有看
        private void markerLineSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();
            IRgbColor rgbColor = getRGB(255, 0, 0);
            arrowMarkerSymbol.Color = rgbColor as IColor;
            arrowMarkerSymbol.Length = 10;
            arrowMarkerSymbol.Width = 10;
            arrowMarkerSymbol.Style = esriArrowMarkerStyle.esriAMSPlain;

            IMarkerLineSymbol markerLineSymbol = new MarkerLineSymbolClass();
            markerLineSymbol.MarkerSymbol = arrowMarkerSymbol;
            rgbColor = getRGB(0, 255, 0);
            markerLineSymbol.Color = rgbColor;
            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(markerLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }

        private void pictureLineSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IPictureLineSymbol pictureLineSymbol = new PictureLineSymbolClass();
            //创建图片符号
            //string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";
            string path = Directory.GetCurrentDirectory();
            string fileName = path + @"\qq.bmp";
            pictureLineSymbol.CreateLineSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);
            IRgbColor rgbColor = getRGB(0, 255, 0);
            pictureLineSymbol.Color = rgbColor;
            pictureLineSymbol.Offset = 0;
            pictureLineSymbol.Width = 10;
            pictureLineSymbol.Rotate = false;

            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(pictureLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }

二、LineSymbol对象

  用于修饰线性几何对象符号。Color和Width属性为两个唯一公共属性。

  子类有:

Classes Description
CartographicLineSymbol 制图线符号,实现ICatographicLineSymbol(主要设置线符号的节点属性,Join:设置线要素转折处的样式)和ILineProperties接口
HashLineSymbol 离散线符号
MarkerLineSymbol A line symbol composed of repeating markers.点线符号
MultiLayerLineSymbol A line symbol that contains one or more layers.使用重叠符号方法产生新符号
PictureLineSymbol A line symbol composed of either a BMP or an EMF picture.比如火车线路符号
SimpleLine3DSymbol (3DAnalyst) Simple 3D Line Symbol component.
SimpleLineSymbol 简单线符号
TextureLineSymbol (3DAnalyst) Texture Line Symbol component.(纹理贴图线符号)
        private void simpleLineSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;
            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            simpleLineSymbol.Width = 10;
            IRgbColor rgbColor = getRGB(255, 0, 0);
            simpleLineSymbol.Color = rgbColor;
            ISymbol symbol = simpleLineSymbol as ISymbol;
            symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
            IActiveView activeView = this.axMapControl1.ActiveView;
            //用activeView.ScreenDisplay进行画图
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(symbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();//释放资源
        }

        private void cartographicLineSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass();//制图线符号
            cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt;
            cartographicLineSymbol.Join = esriLineJoinStyle.esriLJSBevel;//连接方式
            cartographicLineSymbol.Width = 10;
            cartographicLineSymbol.MiterLimit = 4;//Size threshold(阈值) for showing mitered line joins.
            ILineProperties lineProperties;
            lineProperties = cartographicLineSymbol as ILineProperties;
            lineProperties.Offset = 0;
            double[] dob = new double[6];
            dob[0] = 0;
            dob[1] = 1;
            dob[2] = 2;
            dob[3] = 3;
            dob[4] = 4;
            dob[5] = 5;
            ITemplate template = new TemplateClass();//定义模版
            template.Interval = 1;
            for (int i = 0; i < dob.Length; i += 2)
            {
                template.AddPatternElement(dob[i], dob[i + 1]);
            }
            lineProperties.Template = template;

            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            IRgbColor rgbColor = getRGB(0, 255, 0);
            cartographicLineSymbol.Color = rgbColor;
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(cartographicLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }

        private void multiLayerLineSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass();
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;
            simpleLineSymbol.Width = 10;
            IRgbColor rgbColor = getRGB(255, 0, 0);
            simpleLineSymbol.Color = rgbColor;
            ISymbol symbol = simpleLineSymbol as ISymbol;
            symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;

            ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass();
            cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt;
            cartographicLineSymbol.Join = esriLineJoinStyle.esriLJSBevel;
            cartographicLineSymbol.Width = 10;
            cartographicLineSymbol.MiterLimit = 4;
            ILineProperties lineProperties;
            lineProperties = cartographicLineSymbol as ILineProperties;
            lineProperties.Offset = 0;
            double[] dob = new double[6];
            dob[0] = 0;
            dob[1] = 1;
            dob[2] = 2;
            dob[3] = 3;
            dob[4] = 4;
            dob[5] = 5;
            ITemplate template = new TemplateClass();
            template.Interval = 1;
            for (int i = 0; i < dob.Length; i += 2)
            {
                template.AddPatternElement(dob[i], dob[i + 1]);
            }
            lineProperties.Template = template;

            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            rgbColor = getRGB(0, 255, 0);
            cartographicLineSymbol.Color = rgbColor;
            multiLayerLineSymbol.AddLayer(simpleLineSymbol);
            multiLayerLineSymbol.AddLayer(cartographicLineSymbol);

            IActiveView activeView = this.axMapControl1.ActiveView;

            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(multiLayerLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }

        private void hashLineSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IHashLineSymbol hashLineSymbol = new HashLineSymbolClass();
            ILineProperties lineProperties = hashLineSymbol as ILineProperties;
            lineProperties.Offset = 0;
            double[] dob = new double[6];
            dob[0] = 0;
            dob[1] = 1;
            dob[2] = 2;
            dob[3] = 3;
            dob[4] = 4;
            dob[5] = 5;
            ITemplate template = new TemplateClass();
            template.Interval = 1;
            for (int i = 0; i < dob.Length; i += 2)
            {
                template.AddPatternElement(dob[i], dob[i + 1]);
            }
            lineProperties.Template = template;

            hashLineSymbol.Width = 2;
            hashLineSymbol.Angle = 45;
            IRgbColor hashColor = new RgbColor();
            hashColor = getRGB(0, 0, 255);
            hashLineSymbol.Color = hashColor;

            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            IActiveView activeView = this.axMapControl1.ActiveView;

            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(hashLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }

        //下面的没有看
        private void markerLineSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();
            IRgbColor rgbColor = getRGB(255, 0, 0);
            arrowMarkerSymbol.Color = rgbColor as IColor;
            arrowMarkerSymbol.Length = 10;
            arrowMarkerSymbol.Width = 10;
            arrowMarkerSymbol.Style = esriArrowMarkerStyle.esriAMSPlain;

            IMarkerLineSymbol markerLineSymbol = new MarkerLineSymbolClass();
            markerLineSymbol.MarkerSymbol = arrowMarkerSymbol;
            rgbColor = getRGB(0, 255, 0);
            markerLineSymbol.Color = rgbColor;
            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(markerLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }

        private void pictureLineSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IPictureLineSymbol pictureLineSymbol = new PictureLineSymbolClass();
            //创建图片符号
            //string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";
            string path = Directory.GetCurrentDirectory();
            string fileName = path + @"\qq.bmp";
            pictureLineSymbol.CreateLineSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);
            IRgbColor rgbColor = getRGB(0, 255, 0);
            pictureLineSymbol.Color = rgbColor;
            pictureLineSymbol.Offset = 0;
            pictureLineSymbol.Width = 10;
            pictureLineSymbol.Rotate = false;

            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(pictureLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
            activeView.ScreenDisplay.FinishDrawing();
        }

三、FillSymbol对象

  用来修饰多边形等具有面积的几何形体的符号对象。只定义Color和OutLine两个属性。

Classes Description
ColorRampSymbol (Carto) ESRI ColorRampSymbol for raster rendering.
ColorSymbol (Carto) ESRI ColorSymbol for raster rendering.
DotDensityFillSymbol Defines a dot density fill symbol, a data driven symbol commonly used with the DotDensityRenderer对象.
GradientFillSymbol 渐变颜色填充符号,IntervalCount属性来设置用户所需要的颜色梯度。
LineFillSymbol 线填充符号,表现为重复的线条,可以设置线的角度,偏移量和线之间的间隔距离。
MarkerFillSymbol 点填充符号,使用一个Marker符号作为背景填充符号,实现了IMarkerFillSymbol和IFillProperties两个接口
MultiLayerFillSymbol 多层填充符号,使用多个填充符号进行叠加
PictureFillSymbol A fill symbol based on either a BMP or an EMF picture.
RasterRGBSymbol (Carto) ESRI RasterRGBSymbol for raster rendering.
SimpleFillSymbol A fill symbol comprised from a predefined set of styles.
TextureFillSymbol (3DAnalyst) Texture Fill Symbol component.
        private void simpleFillSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //简单填充符号
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
            simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
            simpleFillSymbol.Color = getRGB(255, 0, 0);
            //创建边线符号
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;
            simpleLineSymbol.Color = getRGB(0, 255, 0);
            simpleLineSymbol.Width = 10;
            ISymbol symbol = simpleLineSymbol as ISymbol;
            symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;

            simpleFillSymbol.Outline = simpleLineSymbol;
            //创建面对象
            object Missing = Type.Missing;
            IPolygon polygon = new PolygonClass();
            IPointCollection pointCollection = polygon as IPointCollection;
            IPoint point = new PointClass();
            point.PutCoords(5, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(5, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            polygon.SimplifyPreserveFromTo();
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(simpleFillSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
        }

        private void lineFillSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ICartographicLineSymbol cartoLine = new CartographicLineSymbol();
            cartoLine.Cap = esriLineCapStyle.esriLCSButt;
            cartoLine.Join = esriLineJoinStyle.esriLJSMitre;
            cartoLine.Color = getRGB(255, 0, 0);
            cartoLine.Width = 2;
            //Create the LineFillSymbo
            ILineFillSymbol lineFill = new LineFillSymbol();
            lineFill.Angle = 45;
            lineFill.Separation = 10;
            lineFill.Offset = 5;
            lineFill.LineSymbol = cartoLine;
            object Missing = Type.Missing;
            IPolygon polygon = new PolygonClass();
            IPointCollection pointCollection = polygon as IPointCollection;
            IPoint point = new PointClass();
            point.PutCoords(5, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(5, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            polygon.SimplifyPreserveFromTo();
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(lineFill as ISymbol);
            activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
        }

        private void markerFillSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();
            IRgbColor rgbColor = getRGB(255, 0, 0);
            arrowMarkerSymbol.Color = rgbColor as IColor;
            arrowMarkerSymbol.Length = 10;
            arrowMarkerSymbol.Width = 10;
            arrowMarkerSymbol.Style = esriArrowMarkerStyle.esriAMSPlain;

            IMarkerFillSymbol markerFillSymbol = new MarkerFillSymbolClass();
            markerFillSymbol.MarkerSymbol = arrowMarkerSymbol;
            rgbColor = getRGB(0, 255, 0);
            markerFillSymbol.Color = rgbColor;
            markerFillSymbol.Style = esriMarkerFillStyle.esriMFSGrid;

            IFillProperties fillProperties = markerFillSymbol as IFillProperties;
            fillProperties.XOffset = 2;
            fillProperties.YOffset = 2;
            fillProperties.XSeparation = 15;
            fillProperties.YSeparation = 20;

            object Missing = Type.Missing;
            IPolygon polygon = new PolygonClass();
            IPointCollection pointCollection = polygon as IPointCollection;
            IPoint point = new PointClass();
            point.PutCoords(5, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(5, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            polygon.SimplifyPreserveFromTo();
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(markerFillSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
        }

        private void gradientFillSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IGradientFillSymbol gradientFillSymbol = new GradientFillSymbolClass();
            IAlgorithmicColorRamp algorithcColorRamp = new AlgorithmicColorRampClass();
            algorithcColorRamp.FromColor = getRGB(255, 0, 0);
            algorithcColorRamp.ToColor = getRGB(0, 255, 0);
            algorithcColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
            gradientFillSymbol.ColorRamp = algorithcColorRamp;
            gradientFillSymbol.GradientAngle = 45;
            gradientFillSymbol.GradientPercentage = 0.9;
            gradientFillSymbol.Style = esriGradientFillStyle.esriGFSLinear;

            object Missing = Type.Missing;
            IPolygon polygon = new PolygonClass();
            IPointCollection pointCollection = polygon as IPointCollection;
            IPoint point = new PointClass();
            point.PutCoords(5, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(5, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            polygon.SimplifyPreserveFromTo();
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(gradientFillSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
        }

        private void pictureFillSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IPictureFillSymbol pictureFillSymbol = new PictureFillSymbolClass();
            //创建图片符号
            //string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";
            string path = Directory.GetCurrentDirectory();
            string fileName = path + @"\qq.bmp";
            pictureFillSymbol.CreateFillSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);
            pictureFillSymbol.Color = getRGB(0, 255, 0);

            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;
            simpleLineSymbol.Color = getRGB(255, 0, 0);
            ISymbol symbol = pictureFillSymbol as ISymbol;
            symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;

            pictureFillSymbol.Outline = simpleLineSymbol;
            pictureFillSymbol.Angle = 45;

            object Missing = Type.Missing;
            IPolygon polygon = new PolygonClass();
            IPointCollection pointCollection = polygon as IPointCollection;
            IPoint point = new PointClass();
            point.PutCoords(5, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(5, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            polygon.SimplifyPreserveFromTo();
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(pictureFillSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
        }

        private void multilayerFillSymbolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IMultiLayerFillSymbol multiLayerFillSymbol = new MultiLayerFillSymbolClass();

            IGradientFillSymbol gradientFillSymbol = new GradientFillSymbolClass();
            IAlgorithmicColorRamp algorithcColorRamp = new AlgorithmicColorRampClass();
            algorithcColorRamp.FromColor = getRGB(255, 0, 0);
            algorithcColorRamp.ToColor = getRGB(0, 255, 0);
            algorithcColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
            gradientFillSymbol.ColorRamp = algorithcColorRamp;
            gradientFillSymbol.GradientAngle = 45;
            gradientFillSymbol.GradientPercentage = 0.9;
            gradientFillSymbol.Style = esriGradientFillStyle.esriGFSLinear;

            ICartographicLineSymbol cartoLine = new CartographicLineSymbol();
            cartoLine.Cap = esriLineCapStyle.esriLCSButt;
            cartoLine.Join = esriLineJoinStyle.esriLJSMitre;
            cartoLine.Color = getRGB(255, 0, 0);
            cartoLine.Width = 2;
            //Create the LineFillSymbo
            ILineFillSymbol lineFill = new LineFillSymbol();
            lineFill.Angle = 45;
            lineFill.Separation = 10;
            lineFill.Offset = 5;
            lineFill.LineSymbol = cartoLine;

            multiLayerFillSymbol.AddLayer(gradientFillSymbol);
            multiLayerFillSymbol.AddLayer(lineFill);

            object Missing = Type.Missing;
            IPolygon polygon = new PolygonClass();
            IPointCollection pointCollection = polygon as IPointCollection;
            IPoint point = new PointClass();
            point.PutCoords(5, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(5, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 10);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            point.PutCoords(10, 5);
            pointCollection.AddPoint(point, ref Missing, ref Missing);
            polygon.SimplifyPreserveFromTo();
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(multiLayerFillSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);
            activeView.ScreenDisplay.FinishDrawing();
        }

四、TextSymbol对象

  用于修饰文字元素,实现ITextSymbol,ISimpleTextSymbol,IFormattedTextSymbol接口。

  ITextSymbol是定义文本字符对象的主要接口,通过IFontDisp接口来设置字体的大小、粗体、斜体等。

  ISimpleTextSymbol

  BezierTextPath对象可以让文字的路径按照贝塞尔曲线设置。

  ITextPath接口提供用来计算每个字符文字路径的位置。

  IFormattedTextSymbol接口用来设置背景对象、阴影等属性

        private void textSybmolToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ITextSymbol textSymbol = new TextSymbolClass();
            System.Drawing.Font drawFont = new System.Drawing.Font("宋体", 16, FontStyle.Bold);
            stdole.IFontDisp fontDisp = (stdole.IFontDisp)(new stdole.StdFontClass());
            textSymbol.Font = fontDisp;
            textSymbol.Color = getRGB(0, 255, 0);
            textSymbol.Size = 20;
            IPolyline polyline = new PolylineClass();
            IPoint point = new PointClass();
            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            ITextPath textPath = new BezierTextPathClass();
            //创建简单标注
            ILineSymbol lineSymbol = new SimpleLineSymbolClass();
            lineSymbol.Color = getRGB(255, 0, 0);
            lineSymbol.Width = 5;
            ISimpleTextSymbol simpleTextSymbol = textSymbol as ISimpleTextSymbol;
            simpleTextSymbol.TextPath = textPath;
            object oLineSymbol = lineSymbol;
            object oTextSymbol = textSymbol;
            IActiveView activeView = this.axMapControl1.ActiveView;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(oLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.SetSymbol(oTextSymbol as ISymbol);
            activeView.ScreenDisplay.DrawText(polyline as IGeometry, "简单标注"); ;
            activeView.ScreenDisplay.FinishDrawing();

            //创建气泡标注(两中风格,一种是有锚点,一种是marker方式)
            //锚点方式
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
            simpleFillSymbol.Color = getRGB(0, 255, 0);
            simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
            IBalloonCallout balloonCallout = new BalloonCalloutClass();
            balloonCallout.Style = esriBalloonCalloutStyle.esriBCSRectangle;
            balloonCallout.Symbol = simpleFillSymbol;
            balloonCallout.LeaderTolerance = 10;

            point.PutCoords(5, 5);
            balloonCallout.AnchorPoint = point;

            IGraphicsContainer graphicsContainer = activeView as IGraphicsContainer;
            IFormattedTextSymbol formattedTextSymbol = new TextSymbolClass();
            formattedTextSymbol.Color = getRGB(0, 0, 255);
            point.PutCoords(10, 5);
            ITextBackground textBackground = balloonCallout as ITextBackground;
            formattedTextSymbol.Background = textBackground;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(formattedTextSymbol as ISymbol);
            activeView.ScreenDisplay.DrawText(point as IGeometry, "气泡1");
            activeView.ScreenDisplay.FinishDrawing();

            //marker方式
            textSymbol = new TextSymbolClass();
            textSymbol.Color = getRGB(255, 0, 0);
            textSymbol.Angle = 0;
            textSymbol.RightToLeft = false;
            textSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABaseline;
            textSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull;

            IMarkerTextBackground markerTextBackground = new MarkerTextBackgroundClass();
            markerTextBackground.ScaleToFit = true;
            markerTextBackground.TextSymbol = textSymbol;

            IRgbColor rgbColor = new RgbColorClass();
            IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();
            //string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";
            string path = Directory.GetCurrentDirectory();
            string fileName = path + @"\qq.bmp";
            pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);
            pictureMarkerSymbol.Angle = 0;
            pictureMarkerSymbol.BitmapTransparencyColor = rgbColor;
            pictureMarkerSymbol.Size = 20;
            pictureMarkerSymbol.XOffset = 0;
            pictureMarkerSymbol.YOffset = 0;

            markerTextBackground.Symbol = pictureMarkerSymbol as IMarkerSymbol;

            formattedTextSymbol = new TextSymbolClass();
            formattedTextSymbol.Color = getRGB(255, 0, 0);
            fontDisp.Size = 10;
            fontDisp.Bold = true;
            formattedTextSymbol.Font = fontDisp;

            point.PutCoords(15, 5);

            formattedTextSymbol.Background = markerTextBackground;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(formattedTextSymbol as ISymbol);
            activeView.ScreenDisplay.DrawText(point as IGeometry, "气泡2");
            activeView.ScreenDisplay.FinishDrawing();

        }

五、3DChartSymbol对象

  是一个抽象类,有三个子类:BarChart(用来着色)、PieChart、StaekedChart。

  它实现多个接口:IChartSymbol、IBarChartSymbol、IPieChartSymbol和IStackedSymbol等。

  IChartSymbol接口主要用于计算一个ChartSymbol对象中的柱状和饼状部分的尺寸,其中Maximum值是创建3DChartSymbol对象后必须设置的一个属性,着色一般在一个要素图层上进行,因而可以从它的要素类中获得一系列的数值统计值。如果有三个数值参与着色,系统则必须对三个数值进行大小比较,找出最大的那个赋值给Maximum。Value属性用数组来设置柱状高度或饼状宽度。可以用ISymbolArray来管理多个参与着色的符号对象。

  BarChartSymbol对象实现IBarChartSymbol接口,用不同类型的柱子代表一个要素中的不同属性,高度取决于属性值得大小。

  PieChartSymbol对象实现IPieChartSymbol接口,用一个饼图来显示一个要素中的不同属性,不同属性按照他们的数值大小,占有不同比例的扇形区域。

  StackedSymbol对象实现IStackedSymbol接口,堆积的柱子表示一个要素中的不同属性,Fixed属性为true时,每个柱子的高度都一样,false时,柱子尺寸根据要素类的属性来计算得出。

时间: 2024-10-08 07:35:21

[转] Symbol对象的相关文章

ES6系列_10之Symbol在对象中的作用

在ES5中 对象属性名都是字符串,这容易造成属性名的冲突,比如,你使用了一个他人提供的对象,但又想为这个对象添加新的方法(mixin 模式),新方法的名字就有可能与现有方法产生冲突,于是 ES6 引入了Symbol.Symbol是一种新的原始数据类型,表示独一无二的值.它是继undefined.null.布尔值(Boolean).字符串(String).数值(Number).对象(Object)六种数据类型之后的第七种数据类型.凡是属性名属于 Symbol 类型,就都是独一无二的,可以保证不会与

ES6(六) --- Symbol

概述: ES5 中属性名都是字符串,这容易就造成命名的冲突,特别是在混入模式(mixin模式)下.为解决这个问题ES6 引入了Symbol, Symbol是一种新的基本数据类型,表示独一无二的值!  和ES5 中的六种基本数据类型(Undefined,Null,Boolean,String,Number,Object)同级. 简单的来说Symbol 的作用就是为了防止属性方法命名冲突 var s1 = Symbol('rain') var s2 = Symbol('rain') s1==s2 /

转载:理解scala中的Symbol

相信很多人和我一样,在刚接触Scala时,会觉得Symbol类型很奇怪,既然Scala中字符串都是不可变的,那么Symbol类型到底有什么作用呢? 简单来说,相比较于String类型,Symbol类型有两个比较明显的特点:节省内存和快速比较.在进入正题之前,让我们先来了解一下Java中String的intern()方法. 一.String的intern方法介绍 Oracle的开发文档上讲解的很详细:String类内部维护一个字符串池(strings pool),当调用String的intern(

Symbol(ruby里的冒号)

Symbol:表示“名字”,比如字符串的名字,标识符的名字. 创建一个 Symbol 对象的方法:在名字或者字符串前面加上冒号 :test :"hello ruby" 在 Ruby 中每一个对象都有唯一的对象标识符(Object Identifier),可以通过 object_id方法来得到一个对象的标识符. 来看看 Symbol 对象和 String 对象的差别: puts :str.object_id #710748 puts :str.object_id #710748 puts

symbol lookup error *** , undefined symbol 错误

在重装samba过程后遇到一些问题,使用 gdb 时产生报错: gdb: symbol lookup error: gdb: undefined symbol: PyUnicodeUCS2_FromEncodedObject 原因是 gdb 依赖了python的一些包,而那些包版本太旧,使用时就会发生一些未定义的错误. 使用 nm 命令和 ldd 命令可辅助解决这问题. nm 命令用于找到文件中的symbol对象,ldd用于打印 命令 的依赖库. 步骤如下: 1.运行 which gdb 找到g

symbol(唯一标识符)

symbol 是一种基本数据类型能作为对象属性的唯一标识符:这是该数据类型仅有的目的. 尝试将一个 symbol 值转换为一个 number 值时,会抛出一个 TypeError 错误 (e.g. +sym or sym | 0). 使用宽松相等时, Object(sym) == sym returns true. 这会阻止你从一个 symbol 值隐式地创建一个新的 string 类型的属性名.例如,Symbol("foo") + "bar" 将抛出一个 Type

JS的数据类型判断函数、数组对象结构处理、日期转换函数,浏览器类型判断函数合集

工具地址:https://github.com/BothEyes1993/bes-jstools bes-jstools 100多个基础常用JS函数和各种数据转换处理集合大全,此工具包是在 outils 的基础上,加上个人平时收集的代码片段进行的二次整合 Browser Support 7+ ? Latest ? Latest ? Latest ? Latest ? 6.1+ ? Installing npm install bes-jstools --save Using nodejs con

Scala编程--基本类型和操作

如果你熟悉Java,你会很开心地发现Java基本类型和操作符在Scala里有同样的意思.然而即使你是一位资深Java开发者,这里也仍然有一些有趣的差别使得本章值得一读.因为本章提到的一些Scala的方面实质上与Java相同,我们插入了一些注释,Java开发者可以安全跳过,以加快你的进程.本章里,你会获得Scala基本类型的概观,包括String和值类型Int,Long,Short,Byte,Float,Double,Char还有Boolean.你会学到可以在这些类型上执行的操作,包括Scala表

Scala语法学习手册

1       快速入门... 2 1.1             分号... 2 1.2             常变量声明... 2 1.2.1         val常量... 2 1.2.2         var变量... 2 1.2.3         类型推导... 3 1.2.4         函数编程风格... 3 1.3             Range. 3 1.4             定义函数... 4 1.5             while.if 4 1.6