示例#1
0
        private void init()
        {
            //Read map data into map data object
            _mapData = MapReader.Read(@"..\..\..\data\world3.map", @"..\..\..\data\world.dbf");

            //Create map layers and add them to choropleth map
            _polygonLayer.MapData = _mapData;

            indexMapper = new StringIndexMapper(_mapData.AllDbfFields["GMI_CNTRY"], _mainWindow.DataHandler.RawDataProvider.RowIds);
            _polygonLayer.IndexMapper = indexMapper;


            _mainChoroplethMap.AddLayer(_polygonLayer);

            _borderLayer.MapData = _mapData;
            _mainChoroplethMap.AddLayer(_borderLayer);

            _polygonLayer.ColorMap = _mainWindow.ColorMapHandler.MainColorMap;

            _mainChoroplethMap.Position = mapInitPos;
            _mainChoroplethMap.Zoom     = mapInitZoom;


            // index visibility manager
            _polygonLayer.IndexVisibilityManager = _mainWindow.SharedVisibilityManager;

            // selection colors
            _polygonLayer.SelectedPolygonColor = _mainWindow.ColorMapHandler.SelectionColor;

            // add tooltip to the map
            _gavToolTip                = new GavToolTip(_mainWindow);
            _gavToolTip.FadeTime       = 150;
            _hoverController           = new MouseHoverController(_mainWindow.getMapPanel(), 1, 5);
            _hoverController.Hover    += new EventHandler(_hoverController_Hover);
            _hoverController.HoverEnd += new EventHandler(_hoverController_HoverEnd);

            _mainWindow.SaPManager.AddComponent(_mainChoroplethMap);
            _mainWindow.SaPManager.AddComponent(_polygonLayer);

            _mainChoroplethMap.VizComponentMouseDown += new EventHandler <VizComponentMouseEventArgs>(_mainChoroplethMap_VizComponentMouseDown);
            _mainWindow.mapReset.Click += new EventHandler(mapReset_Click);

            //Add objects to view manager
            _mainWindow.ViewManager.Add(_mainChoroplethMap, _mainWindow.getMapPanel());
        }
示例#2
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);
        }
示例#3
0
        private void InitializeMap()
        {
            //throw new NotImplementedException();
            choroplethMap = new ChoroplethMap();

            mapBorderLayer = new MapBorderLayer();
            mapBorderLayer.MapData = mapData;

            mapPolygonLayer = new MapPolygonLayer();
            mapPolygonLayer.MapData = mapData;
            mapPolygonLayer.IndexMapper = stringIndexMapper;
            mapPolygonLayer.ColorMap = colorMap;
            choroplethMap.Position = new Vector2(0.5f, 0.23f);
            choroplethMap.Zoom = -(0.75f);

            choroplethMap.AddLayer(mapPolygonLayer);

            choroplethMap.AddLayer(mapBorderLayer);

            choroplethMap.AddSubComponent(interactiveColorLegend);
            choroplethMap.VizComponentMouseDown += new EventHandler<VizComponentMouseEventArgs>(choroplethMap_VizComponentMouseDown);
            choroplethMap.VizComponentMouseUp += new EventHandler<VizComponentMouseEventArgs>(choroplethMap_VizComponentMouseUp);
            choroplethMap.VizComponentMouseMove += new EventHandler<VizComponentMouseEventArgs>(choroplethMap_VizComponentMouseMove);
            choroplethMap.PositionInternallyChanged += new EventHandler(choroplethMap_PositionInternallyChanged);
            choroplethMap.ZoomInternallyChanged += new EventHandler(choroplethMap_ZoomInternallyChanged);
        }