Changeset 10797 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views
- Timestamp:
- 05/05/14 17:04:25 (10 years ago)
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.