/// <summary> /// /// </summary> /// <param name="visibilityHandler"></param> public void VisibilityChanged(IndexVisibilityHandler visibilityHandler) { foreach (Label label in labels) { bool visible = visibilityHandler.GetVisibility(label.id); label.visible = visible; if (visible) { //visible = true; // if selected we don't want to override that color if (!label.selected) { label.colorARGB = visibleTextColor.ToArgb(); } else // if visible and selected, then show it selected { label.colorARGB = selectedTextColor.ToArgb(); } } else { // NOTE: do not change the selected flag, so we can // put it back to selected when it's visible again //label.visible = false; label.colorARGB = notVisibleTextColor.ToArgb(); } } }
/// <summary> /// Draws the rectangle and its children /// </summary> /// <param name="aGraphics">the graphics container</param> public void Draw(Graphics aGraphics, IColorMap aColorMap, List <int> aSelectedIds, IndexVisibilityHandler aVisibility) { iVisibility = aVisibility; if (iHeight * iScale.Y <= 1) { return; } this.DrawChild(aGraphics, aColorMap, aSelectedIds, aVisibility); //foreach (TreeRectangle rectangle in iChildRectangles) //{ // rectangle.DrawChild(aGraphics, aColorMap); //} // }
// This method is called every time the map is rendered. protected override void InternalRender() { // If the input is null we cannot render. if (_input == null) { return; } // If the glyph is not inited, call InternalInit. if (!_inited) { InternalInit(_device); if (!_inited) { return; } } _device.RenderState.CullMode = Cull.None; // Loops through the regions in the map. for (int i = 0; i < _input.GetData().GetAxisLength(Axis.Y); i++) { // Resets the world transform. _device.Transform.World = _layerWorldMatrix; // If a glyph positioner (a class that moves the glyphs to the correct position) is set, use it. if (ActiveGlyphPositioner != null) { //Gets the position for the glyph with index i. Vector2 pos = ActiveGlyphPositioner.GetPosition(i); // Translates the world transform. _device.Transform.World *= Matrix.Translation( pos.X, pos.Y, 0 ); } if (IndexVisibilityHandler.GetVisibility(i)) { DrawAllGlyphs(i); } } }
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); }
/// <summary> /// /// </summary> /// <param name="aGraphics"></param> /// <param name="aColorMap"></param> private void DrawChild(Graphics aGraphics, IColorMap aColorMap, List <int> aSelectedIds, IndexVisibilityHandler aVisibility) { float height = iHeight * iScale.Y; if (height <= 1) { return; } UpdateRectangle(aColorMap); // Last level: Draw Label and Fill Rectangle if (iChildRectangles.Count == 0) { int amount = aColorMap.GetColors().GetLength(0); if (amount < iId) { iId = 0; } // *** If selected *** if (aSelectedIds != null && aSelectedIds.Contains(iId) && (aVisibility != null && aVisibility.GetVisibility(iId))) { System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush( iFillRectangle, aColorMap.GetColor(iId), Color.White, System.Drawing.Drawing2D.LinearGradientMode.Vertical); aGraphics.FillRectangle(brush, iFillRectangle); DrawLabel(aGraphics, iSelectedGroupLabelPen); Pen selectedPen = new Pen(Color.Cyan, 3); Pen selectedPen2 = new Pen(Color.Blue, 3); aGraphics.DrawRectangle(selectedPen, iBorderRectangle.X + 3, iBorderRectangle.Y + 3, iBorderRectangle.Width - 7, iBorderRectangle.Height - 7); aGraphics.DrawRectangle(selectedPen2, iBorderRectangle.X + 6, iBorderRectangle.Y + 6, iBorderRectangle.Width - 12, iBorderRectangle.Height - 12); } else { if (aVisibility != null && aVisibility.GetVisibility(iId)) { aGraphics.FillRectangle(iBrush, iFillRectangle); } else { aGraphics.FillRectangle(iGrayBrush, iFillRectangle); } DrawLabel(aGraphics); } } else { // Call children recursively foreach (TreeRectangle rectangle in iChildRectangles) { rectangle.DrawChild(aGraphics, aColorMap, aSelectedIds, aVisibility); } // Draw the The Group Rectangle (as a border) aGraphics.DrawRectangle(iPen, iBorderRectangle); // Draw the Group Label DrawGroupLabel(iFillRectangle, aGraphics, iBorderPen); } }