- Timestamp:
- 04/08/14 23:54:27 (11 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs
r10730 r10732 111 111 112 112 foreach (var node in nodes) { 113 var pen = new Pen(Color.LightGray); 114 115 var visualNode = new VisualGenealogyGraphNode(Chart, x, y, x + diameter, y + diameter, pen, null) { 113 var pen = new Pen(Color.DarkGray); 114 var brush = new SolidBrush(node.GetColor()); 115 116 var visualNode = new VisualGenealogyGraphNode(Chart, x, y, x + diameter, y + diameter, pen, brush) { 116 117 Data = node, 117 118 ToolTipText = "Rank: " + node.Rank + nl + … … 129 130 130 131 // add arcs 131 foreach (var node in GenealogyGraph.Nodes .Cast<IGenealogyGraphNode>()) {132 if ( node.InArcs == null) continue;133 var visualNode = nodeMap[node];132 foreach (var node in GenealogyGraph.Nodes) { 133 if (!node.InArcs.Any()) continue; 134 var visualNode = GetMappedNode(node); 134 135 if (visualNode == null) continue; 135 136 foreach (var arc in node.InArcs) { … … 184 185 } 185 186 var visualNodes = Chart.GetAllPrimitives(e.Location).Where(p => p is VisualGenealogyGraphNode).ToList(); 186 if ( visualNodes.Count <= 0) {187 if (!visualNodes.Any()) { 187 188 SelectedVisualNode = null; 188 189 return; … … 201 202 } 202 203 // use a rectangle to highlight the currently selected genealogy graph node 203 var g Node = SelectedVisualNode.Data;204 var visualNode = GetMappedNode(g Node);204 var graphNode = SelectedVisualNode.Data; 205 var visualNode = GetMappedNode(graphNode); 205 206 206 207 DrawLineage(visualNode, n => SimpleLineages ? n.IncomingArcs.Take(1) : n.IncomingArcs, a => a.Source); 207 visualNode.Brush = null;208 208 DrawLineage(visualNode, n => n.OutgoingArcs, a => a.Target); 209 209 } … … 224 224 225 225 private static void DrawLineage(VisualGenealogyGraphNode node, Func<VisualGenealogyGraphNode, IEnumerable<VisualGenealogyGraphArc>> arcSelector, Func<VisualGenealogyGraphArc, VisualGenealogyGraphNode> nodeSelector) { 226 if (node.Brush != null) return;227 node.Brush = new SolidBrush(node.Data.GetColor());226 var brush = (SolidBrush)node.Brush; 227 brush.Color = node.Data.GetColor(); 228 228 var arcs = arcSelector(node).ToList(); 229 229 foreach (var arc in arcs) { … … 267 267 if (primitive is VisualGenealogyGraphArc) { 268 268 primitive.Pen.Brush = new SolidBrush(Color.Transparent); 269 } else { 270 primitive.Brush = null; 269 } else if (primitive is VisualGenealogyGraphNode) { 270 var brush = (SolidBrush)primitive.Brush; 271 brush.Color = Color.Transparent; 272 primitive.Pen.Color = Color.DarkGray; 271 273 } 272 274 } … … 303 305 internal static class Util { 304 306 public static Color GetColor(this IGenealogyGraphNode node) { 305 var colorIndex = (int)(node.Quality * ColorGradient.Colors.Count); 306 return colorIndex < ColorGradient.Colors.Count ? ColorGradient.Colors[colorIndex] : Color.Transparent; 307 var colorIndex = (int)Math.Round(node.Quality * ColorGradient.Colors.Count); 308 if (colorIndex >= ColorGradient.Colors.Count) return ColorGradient.Colors.Last(); 309 return ColorGradient.Colors[colorIndex]; 307 310 } 308 311 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicExpressionChartControl.cs
r10729 r10732 3 3 using System.Drawing.Drawing2D; 4 4 using System.Linq; 5 using System.Windows.Forms;6 5 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views; 7 6 using HeuristicLab.Visualization; … … 56 55 } 57 56 } 58 59 protected override void pictureBox_MouseUp(object sender, MouseEventArgs e) {60 base.pictureBox_MouseUp(sender, e);61 // get the selected primitive and update it's graphics62 var point = new Point(e.X, e.Y);63 64 var selectedPrimitives = Chart.GetAllPrimitives(point);65 if (!selectedPrimitives.Any()) return;66 67 foreach (var primitive in selectedPrimitives) {68 if (primitive is SymbolicExpressionTreeTile) continue;69 primitive.Pen = new Pen(Color.Blue) { Brush = new SolidBrush(Color.Blue) };70 }71 EnforceUpdate();72 }73 57 } 74 58 }
Note: See TracChangeset
for help on using the changeset viewer.