Ejemplo n.º 1
0
        private void SetupMapLayers()
        {
            string dir      = Directory.GetCurrentDirectory();
            string dataPath = "\\..\\..\\..\\data\\geodata\\maps\\";
            string fileName = "europe_nation";


            ShapeFileReader shapeReader = new ShapeFileReader();

            iMapData = shapeReader.Read(dir + dataPath + fileName + ".shp"
                                        , dir + dataPath + fileName + ".dbf"
                                        , dir + dataPath + fileName + ".shx");

            // Border Layer
            borderLayer         = new MapPolygonBorderLayer();
            borderLayer.MapData = iMapData;

            // Polygon Layer
            polygonLayer          = new MapPolygonLayer();
            polygonLayer.MapData  = iMapData;
            polygonLayer.ColorMap = iColorMap;
            polygonLayer.IndexVisibilityHandler = iPcPlot.IndexVisibilityHandler;
            iPcPlot.FilterChanged += new EventHandler(iPcPlot_FilterChanged);

            polygonSelectionLayer              = new MapPolygonLayer();
            polygonSelectionLayer.MapData      = iMapData;
            polygonSelectionLayer.PolygonColor = Color.FromArgb(220, 220, 220);
            polygonSelectionLayer.Alpha        = 120;

            borderSelectionLayer             = new MapPolygonBorderLayer();
            borderSelectionLayer.MapData     = iMapData;
            borderSelectionLayer.BorderColor = Color.Black;
            borderSelectionLayer.Translation = new Vector3(0.6f, 0.6f, 0); // borderSelectionLayer.Translation.X;

            iSelectedInVisibility = new IndexVisibilityHandler(iMapData.RegionList.Count);
            iSelectedVisibility   = new IndexVisibilityHandler(iMapData.RegionList.Count);
            iSelectedInVisibility.Clear();

            iInVisibilityList = iSelectedInVisibility.CreateVisibilityList();
            iVisibilityList   = iSelectedVisibility.CreateVisibilityList();

            for (int i = 0, endI = iMapData.RegionList.Count; i < endI; i++)
            {
                iVisibilityList.SetVisibility(i, 0, false);
            }


            polygonSelectionLayer.IndexVisibilityHandler = iSelectedInVisibility;
            borderSelectionLayer.IndexVisibilityHandler  = iSelectedVisibility;

//            polygonSelectionLayer.SelectedPolygonColor = Color.Transparent;

            // Glyph Layer
            glyphLayer = new CountryGlyphLayer(iPanel);
            glyphLayer.ActiveGlyphPositioner         = new CenterGlyphPositioner();
            glyphLayer.ActiveGlyphPositioner.MapData = iMapData;
            glyphLayer.Input = iDataCube;
            glyphLayer.IndexVisibilityHandler = iPcPlot.IndexVisibilityHandler;

            // Choropleth Map
            choroMap = new ChoroplethMap();
            choroMap.VizComponentMouseDown += new EventHandler <VizComponentMouseEventArgs>(MouseDown);
            choroMap.VizComponentMouseUp   += new EventHandler <VizComponentMouseEventArgs>(MouseUp);

            // Add layers on the proper order
            choroMap.AddLayer(polygonLayer);
            choroMap.AddLayer(borderLayer);
            choroMap.AddLayer(polygonSelectionLayer);
            choroMap.AddLayer(borderSelectionLayer);
            choroMap.AddLayer(glyphLayer);
            Invalidate();

            //iSelectedColorLegend = new InteractiveColorLegend();
            //iSelectedColorLegend.ColorMap = iLegendColorMap;
            //iSelectedColorLegend.BorderColor = Color.Black;
            //iSelectedColorLegend.ShowMinMaxValues = false;
            //iSelectedColorLegend.SetLegendSize(10, 200);
            //iSelectedColorLegend.SetPosition(50F, 10F);
            //iSelectedColorLegend.SetLegendSize(0.02f, 0.2f);
            //iSelectedColorLegend.ShowColorEdgeSliders = false;
            //iSelectedColorLegend.ShowColorEdgeSliderValue = false;
            ////iSelectedColorLegend.ColorEdgeValuesChanged += new EventHandler(ColorLegendChanged);
            //choroMap.AddSubComponent(iSelectedColorLegend);


            iColorLegend          = new InteractiveColorLegend();
            iColorLegend.ColorMap = iColorMap;
            //iColorLegend.BorderColor = Color.Black;
            //iColorLegend.SliderTextColor = Color.Black;
            //iColorLegend.ShowMinMaxValues = true;
            iColorLegend.SetPosition(10, 10);
            iColorLegend.SetLegendSize(15, 200);
            iColorLegend.ShowColorEdgeSliders     = true;
            iColorLegend.ShowColorEdgeSliderValue = false;
            iColorLegend.ColorEdgeValuesChanged  += new EventHandler(ColorLegendChanged);

            //iColorLegend.ShowValueSliders = true;
            //iColorLegend.ShowValueSliderValue = true;
            //iColorLegend.ValueSliderValuesChanged += new EventHandler(ColorLegendChanged);
            //iColorLegend.SetEdgeSliders(InteractiveColorLegend.SliderLinePosition.Center, InteractiveColorLegend.TextPosition.RightOrBottom, true);


            choroMap.AddSubComponent(iColorLegend);
            renderer.Add(choroMap, iPanel);
        }
Ejemplo n.º 2
0
        private void InitializeInteractiveColorLegend()
        {
            //throw new NotImplementedException();

            interactiveColorLegend = new InteractiveColorLegend();
            interactiveColorLegend.Name = "ColorLegend";
            interactiveColorLegend.ColorMap = colorMap;
            interactiveColorLegend.ShowColorEdgeSliders = true;
            interactiveColorLegend.UseRelativePosition = true;
            interactiveColorLegend.SetPosition(0.1f,0.5f);
            interactiveColorLegend.UseRelativeSize = true;
            interactiveColorLegend.SetLegendSize(10,70);
            interactiveColorLegend.SetHeader(excelDataProvider.ColumnHeaders[choroplethMapSelectedIndex]);
            float [] globalEdge = {2f,0.9f};
            List<float> edges = new List<float>();
            edges.Add(0.4f);
            edges.Add(0.4f);
            edges.Add(0.2f);
            interactiveColorLegend.EdgeValuesList = edges;
            float min = 0;
            float max = 0;
            yearSliceDataTransformer.GetDataCube().GetColumnMaxMin(choroplethMapSelectedIndex, out max, out min);
            interactiveColorLegend.MaxValue = max;
            interactiveColorLegend.MinValue = min;

            interactiveColorLegend.ShowMinMaxValues = true;

            interactiveColorLegend.Enabled = true;
            interactiveColorLegend.ValueSliderValuesChanged += new EventHandler(interactiveColorLegend_ValueSliderValuesChanged);
            interactiveColorLegend.ColorEdgeValuesChanged += new EventHandler(interactiveColorLegend_ColorEdgeValuesChanged);
            interactiveColorLegend.ThresholdValuesChanged += new EventHandler(interactiveColorLegend_ThresholdValuesChanged);
        }