Ejemplo n.º 1
0
        public void GetFillColor()
        {
            var theme = new CategorialTheme();
            var themeItem = new CategorialThemeItem {Style = new VectorStyle {Fill = new SolidBrush(Color.Red)}, Value = 1.0};
            theme.ThemeItems = new EventedList<IThemeItem>(new[] { themeItem });

            const int valueAsInt = 1;
            const float valueAsFloat = 1.0f;

            Assert.AreEqual(Color.Transparent, theme.GetFillColor(0.5));
            Assert.AreEqual(Color.Red, theme.GetFillColor(1.0));
            Assert.AreEqual(Color.Red, theme.GetFillColor(valueAsInt));
            Assert.AreEqual(Color.Red, theme.GetFillColor(valueAsFloat));
            Assert.AreEqual(Color.Red, theme.GetFillColor(new ConvertableObject()));
            Assert.AreEqual(Color.Transparent, theme.GetFillColor(1.5));
            Assert.AreEqual(Color.Transparent, theme.GetFillColor(new ComparableObject()));

            theme.ThemeItems = new EventedList<IThemeItem>();
            Assert.AreEqual(Color.Transparent, theme.GetFillColor(0.5));
            Assert.AreEqual(Color.Transparent, theme.GetFillColor(1.0));
            Assert.AreEqual(Color.Transparent, theme.GetFillColor(valueAsInt));
            Assert.AreEqual(Color.Transparent, theme.GetFillColor(valueAsFloat));
            Assert.AreEqual(Color.Transparent, theme.GetFillColor(new ConvertableObject()));
            Assert.AreEqual(Color.Transparent, theme.GetFillColor(1.5));
            Assert.AreEqual(Color.Transparent, theme.GetFillColor(new ComparableObject()));
        }
Ejemplo n.º 2
0
        public static CategorialTheme CreateCategorialTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend,
                                                            int numberOfClasses, IList <IComparable> values, List <string> categories, int sizeMin, int sizeMax)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle
                {
                    GeometryType = typeof(IPolygon)
                };
            }

            var categorialTheme = new CategorialTheme(attribute, defaultStyle);

            for (int i = 0; i < numberOfClasses; i++)
            {
                string label = (categories != null)
                                   ? categories[i]
                                   : values[i].ToString();

                Color color = (numberOfClasses > 1)
                                  ? blend.GetColor((float)i / (numberOfClasses - 1))
                                  : ((SolidBrush)defaultStyle.Fill).Color;

                var vectorStyle = (VectorStyle)defaultStyle.Clone();

                var size = sizeMin + (sizeMax - sizeMin) * i / (float)numberOfClasses;

                if (defaultStyle.GeometryType == typeof(IPoint))
                {
                    vectorStyle.Fill       = new SolidBrush(color);
                    vectorStyle.Line.Width = 16;
                    vectorStyle.Shape      = defaultStyle.Shape;
                }
                else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }
                else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
                {
                    vectorStyle.Line = CreatePen(color, size, defaultStyle.Line);
                }
                else
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }

                CategorialThemeItem categorialThemeItem = (values[i] != null)
                                                              ? new CategorialThemeItem(label, vectorStyle, vectorStyle.LegendSymbol, values[i])
                                                              : new CategorialThemeItem(label, vectorStyle, vectorStyle.LegendSymbol);


                categorialTheme.AddThemeItem(categorialThemeItem);
            }

            return(categorialTheme);
        }
Ejemplo n.º 3
0
 private CategorialThemeItem(CategorialThemeItem another)
 {
     label = another.Category;
     style = (IStyle)another.Style.Clone();
     if (another.Symbol != null)
     {
     }
     else
     {
         log.WarnFormat("Symbol property of themeitem should not be null");
     }
     value = another.Value;
 }
Ejemplo n.º 4
0
 private CategorialThemeItem(CategorialThemeItem another)
 {
     label = another.Category;
     style = (IStyle) another.Style.Clone();
     if (another.Symbol != null)
     {
     }
     else
     {
         log.WarnFormat("Symbol property of themeitem should not be null");
     }
     value = another.Value;
 }
Ejemplo n.º 5
0
        private static CategorialTheme GetCategorialTheme(theme theme)
        {
            var themeCategory = (themeCategory)theme.Item;
            var defaultStyle = GetDefaultStyle(theme);
            
            var categorialTheme = new CategorialTheme(themeCategory.columnName, defaultStyle);

            foreach (themeItem catThemeItem in themeCategory.categoryThemeItems)
            {
                var categorialThemeItem = new CategorialThemeItem(catThemeItem.label, GetStyle(catThemeItem), null);
                categorialTheme.AddThemeItem(categorialThemeItem);
            }

            return categorialTheme;
        }
Ejemplo n.º 6
0
 public void AddThemeItem(CategorialThemeItem categorialThemeItem)
 {
     ThemeItems.Add(categorialThemeItem);
 }