Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/27/09 18:21:22 (15 years ago)
Author:
shofstad
Message:

Legend implementation updated with position setting (#407)

File:
1 edited

Legend:

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

    r1388 r1461  
    5858          if (!row) {
    5959            CreateColumn(item, y);
    60             y -= 15;
     60            y -= Font.Height;
    6161          } else {
    6262            if (rowCounter >= numberOfItemsPerRow) {
    6363              x = ClippingArea.X1;
    64               y -= 25;
     64              y -= Font.Height+15;
    6565              rowCounter = 0;
    6666            }
     
    9090        }
    9191      }
    92       return 25*rowsToDraw;
     92      return (Font.Height+12)*rowsToDraw;
    9393    }
    9494
     
    109109    /// <param name="item"></param>
    110110    /// <returns></returns>
    111     private static int GetLabelLengthInPixel(LegendItem item) {
    112       int dummy = item.Label.Length*6 + 20;
     111    private int GetLabelLengthInPixel(LegendItem item) {
     112      int dummy = (int)(item.Label.Length*Font.Size + 20);
    113113      if (dummy < LegendItem.WIDTH) {
    114114        return LegendItem.WIDTH;
     
    124124    /// <param name="y">y axis to draw the item</param>
    125125    private void CreateRow(LegendItem item, double x, double y) {
    126       AddShape(new LineShape(x, y - 5, x + 20, y - 5, item.Color, item.Thickness, DrawingStyle.Solid));
     126      AddShape(new LineShape(x, y - (Font.Height / 2), x + 20, y - (Font.Height / 2), item.Color, item.Thickness, DrawingStyle.Solid));
    127127      AddShape(new TextShape(x + 25, y, item.Label, Font, Color));
    128128    }
     
    134134    /// <param name="y">y axis to draw the item</param>
    135135    private void CreateColumn(LegendItem item, double y) {
    136       AddShape(new LineShape(10, y - 10, 30, y - 10, item.Color, item.Thickness, DrawingStyle.Solid));
    137       AddShape(new TextShape(35, y, item.Label, Font, Color));
     136      AddShape(new LineShape(10, y - (Font.Height / 2), 30, y - (Font.Height / 2), item.Color, item.Thickness, DrawingStyle.Solid));
     137      AddShape(new TextShape(Font.Height+12, y, item.Label, Font, Color));
    138138    }
    139139
     
    147147
    148148    /// <summary>
    149     /// searches the longest label and returns it with the factor 6
     149    /// searches the longest label and returns it with factor of the the current font size
    150150    /// useful to set the width of the legend
    151151    /// </summary>
    152     /// <returns>max label length with factor 6</returns>
     152    /// <returns>max label length with factor of the current font size</returns>
    153153    public int GetMaxLabelLength() {
    154154      int maxLabelLength = 0;
     
    160160          }
    161161        }
    162         maxLabelLength = maxLabelLength*6;
     162        maxLabelLength = (int)(maxLabelLength*Font.Size);
    163163      }
    164164      return maxLabelLength < LegendItem.WIDTH ? LegendItem.WIDTH : maxLabelLength;
Note: See TracChangeset for help on using the changeset viewer.