Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10732


Ignore:
Timestamp:
04/08/14 23:54:27 (9 years ago)
Author:
bburlacu
Message:

#1772: Some improvements on the way the genealogy graph and the lineages are drawn.

Location:
branches/HeuristicLab.EvolutionTracking
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs

    r10730 r10732  
    111111
    112112        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) {
    116117            Data = node,
    117118            ToolTipText = "Rank: " + node.Rank + nl +
     
    129130
    130131      // 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);
    134135        if (visualNode == null) continue;
    135136        foreach (var arc in node.InArcs) {
     
    184185      }
    185186      var visualNodes = Chart.GetAllPrimitives(e.Location).Where(p => p is VisualGenealogyGraphNode).ToList();
    186       if (visualNodes.Count <= 0) {
     187      if (!visualNodes.Any()) {
    187188        SelectedVisualNode = null;
    188189        return;
     
    201202        }
    202203        // use a rectangle to highlight the currently selected genealogy graph node
    203         var gNode = SelectedVisualNode.Data;
    204         var visualNode = GetMappedNode(gNode);
     204        var graphNode = SelectedVisualNode.Data;
     205        var visualNode = GetMappedNode(graphNode);
    205206
    206207        DrawLineage(visualNode, n => SimpleLineages ? n.IncomingArcs.Take(1) : n.IncomingArcs, a => a.Source);
    207         visualNode.Brush = null;
    208208        DrawLineage(visualNode, n => n.OutgoingArcs, a => a.Target);
    209209      }
     
    224224
    225225    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();
    228228      var arcs = arcSelector(node).ToList();
    229229      foreach (var arc in arcs) {
     
    267267        if (primitive is VisualGenealogyGraphArc) {
    268268          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;
    271273        }
    272274      }
     
    303305  internal static class Util {
    304306    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];
    307310    }
    308311  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicExpressionChartControl.cs

    r10729 r10732  
    33using System.Drawing.Drawing2D;
    44using System.Linq;
    5 using System.Windows.Forms;
    65using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
    76using HeuristicLab.Visualization;
     
    5655      }
    5756    }
    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 graphics
    62       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     }
    7357  }
    7458}
Note: See TracChangeset for help on using the changeset viewer.