Changeset 10797
- Timestamp:
- 05/05/14 17:04:25 (11 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeTile.cs
r10752 r10797 24 24 using System.Drawing; 25 25 using System.Drawing.Drawing2D; 26 using System.Drawing.Text; 26 27 using System.Linq; 27 28 using HeuristicLab.Common; … … 38 39 public int PreferredNodeWidth { get; set; } 39 40 public int PreferredNodeHeight { get; set; } 41 42 private const int labelHeight = 30; 43 40 44 public ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> LayoutEngine { get; set; } 41 45 private readonly Dictionary<IPrimitive, ISymbolicExpressionTreeNode> primitivesToNodes; 42 46 private readonly Dictionary<ISymbolicExpressionTreeNode, IPrimitive> nodesToPrimitives; 47 48 private string label; 49 public string Label { 50 get { return label; } 51 set { label = value; } 52 } 43 53 44 54 private Size size; … … 142 152 143 153 RectangularPrimitiveBase rectangularPrimitive; 144 var label = ShortenLabel(node);154 var shortenedLabel = ShortenLabel(node); 145 155 if (node.SubtreeCount == 0) { 146 rectangularPrimitive = new Rectangle(Chart, lowerLeft, upperRight) { Font = font, Text = label };156 rectangularPrimitive = new Rectangle(Chart, lowerLeft, upperRight) { Font = font, Text = shortenedLabel }; 147 157 } else { 148 rectangularPrimitive = new Ellipse(Chart, lowerLeft, upperRight) { Font = font, Text = label };158 rectangularPrimitive = new Ellipse(Chart, lowerLeft, upperRight) { Font = font, Text = shortenedLabel }; 149 159 } 150 160 … … 174 184 if (ymax < rpb.UpperRight.Y) ymax = (int)Math.Ceiling(rpb.UpperRight.Y); 175 185 } 176 Size = new Size(xmax - xmin, ymax - ymin); 177 var width = Size.Width; 178 var height = Size.Height; 186 int width = xmax - xmin; 187 int height = ymax - ymin; 188 189 // draw a primitive to display the label 190 var labelRect = new Rectangle(this.Chart, new PointD(0, height), new PointD(width, height + labelHeight)) { 191 Pen = new Pen(Color.Black), 192 Brush = new SolidBrush(Color.Transparent), 193 Text = Label, 194 Font = new Font(FontFamily.GenericSansSerif, 12) 195 }; 196 this.Add(labelRect); 197 179 198 // draw a rectangle to mark the countour of this tile 180 var rectangle = new Rectangle(this.Chart, new PointD(0, 0), new PointD(width, height)) { 199 Size = new Size(width, height + labelHeight); 200 201 var rectangle = new Rectangle(this.Chart, new PointD(0, 0), new PointD(Size.Width, Size.Height)) { 181 202 Pen = new Pen(Color.Gray), 182 203 Brush = new SolidBrush(Color.Transparent) … … 188 209 var rpb = primitive as RectangularPrimitiveBase; 189 210 if (rpb != null) { 190 rpb.SetPosition(rpb.LowerLeft.X, height - rpb.UpperRight.Y, rpb.UpperRight.X, height - rpb.LowerLeft.Y);211 rpb.SetPosition(rpb.LowerLeft.X, Size.Height - rpb.UpperRight.Y, rpb.UpperRight.X, Size.Height - rpb.LowerLeft.Y); 191 212 192 213 } else { 193 214 var line = primitive as LinearPrimitiveBase; 194 215 if (line != null) { 195 line.SetPosition(line.Start.X, height - line.Start.Y, line.End.X, height - line.End.Y);216 line.SetPosition(line.Start.X, Size.Height - line.Start.Y, line.End.X, Size.Height - line.End.Y); 196 217 } 197 218 } … … 201 222 public override void Draw(Graphics graphics) { 202 223 graphics.SmoothingMode = SmoothingMode.HighQuality; 224 graphics.TextRenderingHint = TextRenderingHint.AntiAlias; 203 225 base.Draw(graphics); 204 226 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/FragmentGraphView.cs
r10755 r10797 2 2 using System.Drawing; 3 3 using System.Linq; 4 using HeuristicLab.Common;5 4 using HeuristicLab.Core.Views; 6 5 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; … … 51 50 var tile = new SymbolicExpressionTreeTile(chart); 52 51 tile.LayoutEngine = symbolicExpressionEngine; 52 tile.Label = "Generation " + node.Rank; 53 53 tile.Root = node.Content.Root; 54 54 var tileNode = new TileLayoutNode { Tile = tile }; … … 94 94 var aPos = aTile.Position; 95 95 96 if (node.Rank.IsAlmost(0)) { 97 foreach (var s in node.Content.Root.IterateNodesPrefix()) { 96 if (node.Content.Index1 > 0) { 97 var subtree = node.Content.Root.NodeAt(node.Content.Index1); 98 foreach (var s in subtree.IterateNodesPrefix()) { 98 99 var primitive = aTile.GetPrimitive(s); 99 100 if (primitive != null) { 100 101 var rpb = primitive as RectangularPrimitiveBase; 101 102 if (rpb != null) { 102 rpb.Pen = new Pen(Color.ForestGreen); 103 } 104 } 105 } 106 } else { 107 108 if (node.Content.Index1 > 0) { 109 var subtree = node.Content.Root.NodeAt(node.Content.Index1); 110 foreach (var s in subtree.IterateNodesPrefix()) { 111 var primitive = aTile.GetPrimitive(s); 112 if (primitive != null) { 113 var rpb = primitive as RectangularPrimitiveBase; 114 if (rpb != null) { 115 rpb.Pen = new Pen(Color.RoyalBlue); 116 } 103 rpb.Pen = new Pen(Color.RoyalBlue); 117 104 } 118 105 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionTracing.cs
r10755 r10797 86 86 } 87 87 var right = Trace(node.Parents.Last(), fragment.Index2, fragmentNode); // trace fragment 88 foreach (var v in left.Concat(right)) { 89 yield return v; 90 } 88 foreach (var v in left.Concat(right)) { yield return v; } 91 89 break; 92 90 } else {
Note: See TracChangeset
for help on using the changeset viewer.