Ejemplo n.º 1
0
        /// <summary>
        /// 复制
        /// </summary>
        /// <returns></returns>
        public override moRenderer Clone()
        {
            moUniqueValueRenderer sRenderer = new moUniqueValueRenderer();

            sRenderer._Field     = _Field;
            sRenderer._HeadTitle = _HeadTitle;
            sRenderer._ShowHead  = _ShowHead;
            Int32 sValueCount = _Values.Count;

            for (Int32 i = 0; i <= sValueCount - 1; i++)
            {
                string   sValue  = _Values[i];
                moSymbol sSymbol = null;
                if (_Symbols[i] != null)
                {
                    sSymbol = _Symbols[i].Clone();
                }
                sRenderer.AddUniqueValue(sValue, sSymbol);
            }
            if (_DefaultSymbol != null)
            {
                sRenderer.DefaultSymbol = _DefaultSymbol.Clone();
            }
            sRenderer._ShowDefaultSymbol = _ShowDefaultSymbol;
            return(sRenderer);
        }
Ejemplo n.º 2
0
        private void SetFeatureSymbols()
        {
            Int32 sFeatureCount = _Features.Count;

            if (_Renderer.RendererType == moRendererTypeConstant.Simple)
            {
                moSimpleRenderer sRenderer = (moSimpleRenderer)_Renderer;
                for (Int32 i = 0; i <= sFeatureCount - 1; i++)
                {
                    _Features.GetItem(i).Symbol = sRenderer.Symbol;
                }
            }
            else if (_Renderer.RendererType == moRendererTypeConstant.UniqueValue)
            {
                moUniqueValueRenderer sRenderer = (moUniqueValueRenderer)_Renderer;
                string sFieldName  = sRenderer.Field;
                Int32  sFieldIndex = _AttributeFields.FindField(sFieldName);
                if (sFieldIndex >= 0)
                {
                    for (Int32 i = 0; i <= sFeatureCount - 1; i++)
                    {
                        string sValueString = GetValueString(_Features.GetItem(i).Attributes.GetItem(sFieldIndex));
                        _Features.GetItem(i).Symbol = sRenderer.FindSymbol(sValueString);
                    }
                }
                else
                {
                    for (Int32 i = 0; i <= sFeatureCount - 1; i++)
                    {
                        _Features.GetItem(i).Symbol = null;
                    }
                }
            }
            else if (_Renderer.RendererType == moRendererTypeConstant.ClassBreaks)
            {
                moClassBreaksRenderer sRenderer = (moClassBreaksRenderer)_Renderer;
                string sFieldName              = sRenderer.Field;
                Int32  sFieldIndex             = _AttributeFields.FindField(sFieldName);
                moValueTypeConstant sValueType = _AttributeFields.GetItem(sFieldIndex).ValueType;
                if (sFieldIndex >= 0)
                {
                    for (Int32 i = 0; i <= sFeatureCount - 1; i++)
                    {
                        double sValue = 0;
                        if (sValueType == moValueTypeConstant.dInt16)
                        {
                            sValue = (Int16)_Features.GetItem(i).Attributes.GetItem(sFieldIndex);
                        }
                        else if (sValueType == moValueTypeConstant.dInt32)
                        {
                            sValue = (Int32)_Features.GetItem(i).Attributes.GetItem(sFieldIndex);
                        }
                        else if (sValueType == moValueTypeConstant.dInt64)
                        {
                            sValue = (Int64)_Features.GetItem(i).Attributes.GetItem(sFieldIndex);
                        }
                        else if (sValueType == moValueTypeConstant.dSingle)
                        {
                            sValue = (float)_Features.GetItem(i).Attributes.GetItem(sFieldIndex);
                        }
                        else if (sValueType == moValueTypeConstant.dDouble)
                        {
                            sValue = (double)_Features.GetItem(i).Attributes.GetItem(sFieldIndex);
                        }
                        else
                        {
                            throw new Exception("Invalid value type of field " + sFieldName);
                        }

                        _Features.GetItem(i).Symbol = sRenderer.FindSymbol(sValue);
                    }
                }
                else
                {
                    for (Int32 i = 0; i <= sFeatureCount - 1; i++)
                    {
                        _Features.GetItem(i).Symbol = null;
                    }
                }
            }
            else
            {
                throw new Exception("Invalid renderer type!");
            }
        }