Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PointScheme"/> class.
        /// </summary>
        public PointScheme()
        {
            Configure();
            PointCategory def = new PointCategory();

            Categories.Add(def);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PointScheme"/> class.
        /// </summary>
        /// <param name="extent">The geographic point size for the default will be 1/100th the specified extent.</param>
        public PointScheme(IRectangle extent)
        {
            Configure();
            PointCategory def = new PointCategory(extent);

            Categories.Add(def);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Uses the settings on this scheme to create a random category.
        /// </summary>
        /// <param name="filterExpression">Used as filterExpression and LegendText in the resulting category.</param>
        /// <returns>A new IFeatureCategory.</returns>
        public override IFeatureCategory CreateRandomCategory(string filterExpression)
        {
            PointCategory result    = new PointCategory();
            Color         fillColor = CreateRandomColor();

            result.Symbolizer       = new PointSymbolizer(fillColor, PointShape.Ellipse, 10);
            result.FilterExpression = filterExpression;
            result.LegendText       = filterExpression;
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Calculates the unique colors as a scheme
        /// </summary>
        /// <param name="fs">The featureset with the data Table definition</param>
        /// <param name="uniqueField">The unique field</param>
        public Hashtable GenerateUniqueColors(IFeatureSet fs, string uniqueField)
        {
            Hashtable result = new Hashtable(); // a hashtable of colors
            DataTable dt     = fs.DataTable;
            ArrayList vals   = new ArrayList();
            int       i      = 0;

            foreach (DataRow row in dt.Rows)
            {
                if (uniqueField != "FID")
                {
                    if (vals.Contains(row[uniqueField]) == false)
                    {
                        vals.Add(row[uniqueField]);
                    }
                }
                else
                {
                    vals.Add(i);
                    i++;
                }
            }
            Random rnd = new Random();

            foreach (object item in vals)
            {
                Color c = rnd.NextColor();
                while (result.ContainsKey(c))
                {
                    c = rnd.NextColor();
                }
                PointCategory cat = new PointCategory(c, PointShape.Rectangle, 10);
                string        flt = "[" + uniqueField + "] = ";
                if (uniqueField == "FID")
                {
                    flt += item;
                }
                else
                {
                    if (dt.Columns[uniqueField].DataType == typeof(string))
                    {
                        flt += "'" + item + "'";
                    }
                    else
                    {
                        flt += item.ToString();
                    }
                }
                cat.FilterExpression = flt;
                Categories.Add(cat);
                result.Add(c, item);
            }
            return(result);
        }
Ejemplo n.º 5
0
        private PointScheme ColorBox(IEnumerable <Color> colors)
        {
            PointScheme ps = new PointScheme();

            ps.Categories.Clear();
            foreach (Color color in colors)
            {
                IColorable c = _template as IColorable;
                if (c != null)
                {
                    c.Color = color;
                }
                PointCategory pc = new PointCategory(_template);
                ps.Categories.Add(pc);
            }
            ps.Categories[0].FilterExpression = "[" + _classificationField + "] < ";
            return(ps);
        }
Ejemplo n.º 6
0
        private Bitmap CreateDefaultSymbol(Color color, int symbolSize)
        {           
            double scaleSize = 1;
            Size2D size = new Size2D(symbolSize, symbolSize);
            Bitmap normalSymbol = new Bitmap((int)(size.Width * scaleSize) + 1, (int)(size.Height * scaleSize) + 1);
            Graphics bg = Graphics.FromImage(normalSymbol);

            Random rnd = new Random();
            Color randomColor = Color.FromArgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255));
            PointSymbolizer sym = new PointSymbolizer(randomColor, DotSpatial.Symbology.PointShape.Rectangle, 4);
            PointCategory category = new PointCategory(sym);
            bg.SmoothingMode = category.Symbolizer.Smoothing ? SmoothingMode.AntiAlias : SmoothingMode.None;
            Matrix trans = bg.Transform;

            trans.Translate(((float)(size.Width * scaleSize) / 2 - 1), (float)(size.Height * scaleSize) / 2 - 1);
            bg.Transform = trans;
            category.Symbolizer.Draw(bg, 1);
            return normalSymbol;
        }
Ejemplo n.º 7
0
 private PointScheme ColorBox(IEnumerable<Color> colors)
 {
     PointScheme ps = new PointScheme();
     ps.Categories.Clear();
     foreach (Color color in colors)
     {
         IColorable c = _template as IColorable;
         if (c != null)
         {
             c.Color = color;
         }
         PointCategory pc = new PointCategory(_template);
         ps.Categories.Add(pc);
     }
     ps.Categories[0].FilterExpression = "[" + _classificationField + "] < ";
     return ps;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// creates a new instance of the PointScheme, but assigns the specified symbolizer
 /// as the symbolizer to use on a single default category.
 /// </summary>
 /// <param name="extent">The geographic point size for the default will be 1/100th the specified extent</param>
 public PointScheme(IRectangle extent)
 {
     Configure();
     PointCategory def = new PointCategory(extent);
     Categories.Add(def);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates a new instance of PointScheme with no categories added to the list yet.
 /// </summary>
 public PointScheme()
 {
     Configure();
     PointCategory def = new PointCategory();
     Categories.Add(def);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Calculates the unique colors as a scheme
 /// </summary>
 /// <param name="fs">The featureset with the data Table definition</param>
 /// <param name="uniqueField">The unique field</param>
 public Hashtable GenerateUniqueColors(IFeatureSet fs, string uniqueField)
 {
     Hashtable result = new Hashtable(); // a hashtable of colors
     DataTable dt = fs.DataTable;
     ArrayList vals = new ArrayList();
     int i = 0;
     foreach (DataRow row in dt.Rows)
     {
         if (uniqueField != "FID")
         {
             if (vals.Contains(row[uniqueField]) == false)
             {
                 vals.Add(row[uniqueField]);
             }
         }
         else
         {
             vals.Add(i);
             i++;
         }
     }
     Random rnd = new Random();
     foreach (object item in vals)
     {
         Color c = rnd.NextColor();
         while (result.ContainsKey(c))
         {
             c = rnd.NextColor();
         }
         PointCategory cat = new PointCategory(c, PointShape.Rectangle, 10);
         string flt = "[" + uniqueField + "] = ";
         if (uniqueField == "FID")
         {
             flt += item;
         }
         else
         {
             if (dt.Columns[uniqueField].DataType == typeof(string))
             {
                 flt += "'" + item + "'";
             }
             else
             {
                 flt += item.ToString();
             }
         }
         cat.FilterExpression = flt;
         Categories.Add(cat);
         result.Add(c, item);
     }
     return result;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Uses the settings on this scheme to create a random category.
 /// </summary>
 /// <returns>A new IFeatureCategory</returns>
 public override IFeatureCategory CreateRandomCategory(string filterExpression)
 {
     PointCategory result = new PointCategory();
     Color fillColor = CreateRandomColor();
     result.Symbolizer = new PointSymbolizer(fillColor, PointShape.Ellipse, 10);
     result.FilterExpression = filterExpression;
     result.LegendText = filterExpression;
     return result;
 }