Free cookie consent management tool by TermsFeed Policy Generator

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

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

File:
1 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  }
Note: See TracChangeset for help on using the changeset viewer.