Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/23/09 08:38:37 (15 years ago)
Author:
shofstad
Message:

Legend implementation updated (#407)

Location:
trunk/sources/HeuristicLab.Visualization/3.2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/3.2/Legend/LegendItem.cs

    r1342 r1877  
    44  public class LegendItem {
    55
     6    // default width
     7    // every legend under 100 gets the default width
    68    public static readonly int WIDTH = 100;
    79
     10    /// <summary>
     11    /// a legend item object with its properties
     12    /// </summary>
     13    /// <param name="label">the label of the legend</param>
     14    /// <param name="color">the color of the legend line</param>
     15    /// <param name="thickness">the thickness of the legend line</param>
    816    public LegendItem(string label, Color color, int thickness) {
    917      Label = label;
  • trunk/sources/HeuristicLab.Visualization/3.2/Legend/LegendShape.cs

    r1665 r1877  
    1 using System;
    21using System.Collections.Generic;
    32using System.Drawing;
     
    1413    private readonly IList<LegendItem> legendItems = new List<LegendItem>();
    1514    // legend draw default value: column
    16     private bool row;
    17     private bool top;
    1815
    1916    private Color color = Color.Blue;
    2017    private Font font = new Font("Arial", 8);
    2118
     19    public bool Row { get; set; }
     20    public bool Top { get; set; }
     21
    2222    public LegendShape() {
    2323      CreateLegend();
    24     }
    25 
    26     public bool Row {
    27       set { row = value; }
    28       get { return row; }
    29     }
    30 
    31     public bool Top {
    32       set { top = value; }
    33       get { return top; }
    3424    }
    3525
     
    4737        double y = ClippingArea.Y2;
    4838
    49         if (row && !top) {
     39        if (Row && !Top) {
    5040          y = GetOptimalBottomHeight();
    5141        }
    5242        int legendItemCounter = 1;
    5343        foreach (LegendItem item in legendItems) {
    54           if (!row) {
     44          if (!Row) {
    5545            CreateColumn(item, y);
    5646            y -= Font.Height;
     
    6858    }
    6959
     60    /// <summary>
     61    /// calculates the optimal height, when the legend shall be draw at the bottom
     62    /// </summary>
     63    /// <returns>optimal bottom height</returns>
    7064    private double GetOptimalBottomHeight() {
    7165      int rowsToDraw = 1;
     
    7872    }
    7973
    80     ///// <summary>
    81     ///// returns the maximum number of items per row to paint
    82     ///// </summary>
    83     ///// <returns>number of items per row</returns>
    84     //public int GetNrOfItemsPerRow() {
    85     //  double sum = 0;
    86     //  double caw = ClippingArea.Width;
    87     //  int items = 0;
    88     //  foreach (var item in legendItems) {
    89     //    sum += GetLabelLengthInPixel(item);
    90     //    if (sum < caw) {
    91     //      items++;
    92     //    }
    93     //  }
    94     //  if (items == 0) {
    95     //    items++;
    96     //  }
    97     //  return items;
    98     //}
    99 
    100     /// <summary>
    101     /// returns the maximum number of items per row to paint
    102     /// </summary>
    103     /// <returns>number of items per row</returns>
     74    /// <summary>
     75    /// returns a boolean value, if the new legend item has to be paint in a
     76    /// new row
     77    /// </summary>
     78    /// <returns>
     79    ///   true, draw legend item in a new row
     80    ///   false, draw the legend item in the current row
     81    /// </returns>
    10482    private bool IsNewRow(int toCurrentItem) {
    10583      double sum = 0;
     
    11795    /// returns the length of the current legenditem in pixel
    11896    /// </summary>
    119     /// <param name="item"></param>
    120     /// <returns></returns>
     97    /// <param name="item">legend item to calculate the length</param>
     98    /// <returns>length of the legend item</returns>
    12199    private int GetLabelLengthInPixel(LegendItem item) {
    122100      int dummy = (int)(item.Label.Length*Font.Size + 20);
     
    145123    private void CreateColumn(LegendItem item, double y) {
    146124      AddShape(new LineShape(10, y - (Font.Height / 2), 30, y - (Font.Height / 2), item.Color, item.Thickness, DrawingStyle.Solid));
    147       AddShape(new TextShape(Font.Height+12, y, item.Label, Font, Color));
     125      AddShape(new TextShape(35, y, item.Label, Font, Color));//Font.Height+12
    148126    }
    149127
     
    158136    /// <summary>
    159137    /// searches the longest label and returns it with factor of the the current font size
    160     /// useful to set the width of the legend
     138    /// useful to set the width of the legend area on the left or right side
    161139    /// </summary>
    162140    /// <returns>max label length with factor of the current font size</returns>
  • trunk/sources/HeuristicLab.Visualization/3.2/Options/ViewSettings.cs

    r1389 r1877  
    2424      xAxisColor = Color.Blue;
    2525
    26       legendPosition = LegendPosition.Bottom;
     26      legendPosition = LegendPosition.Right;
    2727    }
    2828
Note: See TracChangeset for help on using the changeset viewer.