Changeset 10831
- Timestamp:
- 05/09/14 15:14:38 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/Primitives/RectangularPrimitiveBase.cs
r10518 r10831 43 43 public string Text { get; set; } 44 44 public Font Font { get; set; } 45 public float MaximumFontSize { get; set; } 45 46 46 47 protected RectangularPrimitiveBase(IChart chart, PointD lowerLeft, PointD upperRight) … … 48 49 selectionRectangles = new Group(chart); 49 50 SetPosition(lowerLeft, upperRight); 51 52 MaximumFontSize = 12; 50 53 } 51 54 protected RectangularPrimitiveBase(IChart chart, double x1, double y1, double x2, double y2) … … 137 140 } 138 141 139 protected virtual void DrawText(Graphics graphics) { // draw the text in the center of the bounding rectangle4 142 protected virtual void DrawText(Graphics graphics) { 143 // draw the text in the center of the bounding rectangle 140 144 var p = Chart.TransformWorldToPixel(new PointD(LowerLeft.X, LowerLeft.Y)); 141 145 var s = Chart.TransformWorldToPixel(Size); 146 142 147 var stringSize = graphics.MeasureString(Text, Font); 143 var fontSize = Font.Size * s.Width / stringSize.Width;144 if (fontSize > 12) fontSize = 12; // limit maximum font size so that nodes look nicer148 float fontSize = (int)(Math.Round(Font.Size * s.Width / stringSize.Width)); 149 if (fontSize > MaximumFontSize) { fontSize = MaximumFontSize; } 145 150 Font = new Font(Font.FontFamily, fontSize, GraphicsUnit.Pixel); 146 151 stringSize = graphics.MeasureString(Text, Font);
Note: See TracChangeset
for help on using the changeset viewer.