Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1285


Ignore:
Timestamp:
03/07/09 15:57:16 (15 years ago)
Author:
mstoeger
Message:

Implemented multiple Y-Axes. (#433) Panning & Zooming is broken.

Location:
trunk/sources
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization.Test/LineChartTests.cs

    r1243 r1285  
    7575
    7676      IDataRow row1 = new DataRow();
     77      IDataRow row2 = new DataRow();
    7778
    7879      row1.Color = Color.Red;
     
    8081      row1.Style = DrawingStyle.Solid;
    8182
     83      row2.Color = Color.Green;
     84      row2.Thickness = 3;
     85      row2.Style = DrawingStyle.Solid;
     86
    8287      model.AddDataRow(row1);
     88      model.AddDataRow(row2);
    8389
    84       row1.AddValue(10);
    85       row1.AddValue(5);
    86       row1.AddValue(7);
    87       row1.AddValue(3);
    88       row1.AddValue(10);
    89       row1.AddValue(2);
     90      Random rand = new Random(42);
     91     
     92      for (int i = 0; i < 10; i++) {
     93        row1.AddValue(rand.NextDouble()*10);
     94        row2.AddValue(rand.NextDouble()*10);
     95      }
    9096
    9197      f.ShowDialog();
  • trunk/sources/HeuristicLab.Visualization/ChartDataRowsModel.cs

    r1194 r1285  
    116116      rows.Remove(row);
    117117      OnDataRowRemoved(row);
     118    }
     119
     120    // TODO implement calculation of max data row values
     121    public int MaxDataRowValues {
     122      get {
     123        int max = 0;
     124
     125        foreach (IDataRow row in rows) {
     126          max = Math.Max(max, row.Count);
     127        }
     128
     129        return max;
     130      }
    118131    }
    119132
  • trunk/sources/HeuristicLab.Visualization/DataRow.cs

    r1233 r1285  
    2525    private ILabelProvider labelProvider = new ContinuousLabelProvider("0.##");
    2626
     27    // TODO implement calculation of min and max values
     28    private double minValue = double.MaxValue;
     29    private double maxValue = double.MinValue;
     30
    2731    public DataRowType LineType{
    2832      get { return lineType; }
     
    115119
    116120    public void AddValue(double value) {
     121      UpdateMinMaxValue(value);
     122
    117123      dataRow.Add(value);
    118124      OnValueChanged(value, dataRow.Count - 1, Action.Added);
     
    223229      }
    224230    }
     231
     232    public double MinValue {
     233      get { return minValue; }
     234    }
     235
     236    public double MaxValue {
     237      get { return maxValue; }
     238    }
     239
     240    private void UpdateMinMaxValue(double value) {
     241      maxValue = Math.Max(value, maxValue);
     242      minValue = Math.Min(value, minValue);
     243    }
    225244  }
    226245}
  • trunk/sources/HeuristicLab.Visualization/IChartDataRowsModel.cs

    r1194 r1285  
    2323    //void RemoveLabels(int index, int count);
    2424
     25    int MaxDataRowValues { get; }
     26
    2527    event ModelChangedHandler ModelChanged;
    2628    event DataRowAddedHandler DataRowAdded;
  • trunk/sources/HeuristicLab.Visualization/IDataRow.cs

    r1233 r1285  
    3535    double this[int index] { get; set; }
    3636
     37    double MinValue { get; }
     38    double MaxValue { get; }
     39
    3740    event ValuesChangedHandler ValuesChanged;
    3841    event ValueChangedHandler ValueChanged;
  • trunk/sources/HeuristicLab.Visualization/LineChart.cs

    r1283 r1285  
    1212    private readonly Canvas canvas;
    1313
    14     private int maxDataRowCount;
    15     private double minDataValue;
    16     private double maxDataValue;
    17 
    18     private readonly TextShape titleShape;
    19     private readonly LinesShape linesShape;
    20     private readonly LegendShape legendShape;
    21 
    22     private readonly XAxis xAxis;
    23     private readonly YAxis yAxis;
    24     private readonly Grid grid;
    25 
    26     private readonly Stack<RectangleD> clippingAreaHistory = new Stack<RectangleD>();
    27     private readonly WorldShape userInteractionShape;
    28     private readonly RectangleShape rectangleShape;
     14    private readonly TextShape titleShape = new TextShape("Title");
     15    private readonly LegendShape legendShape = new LegendShape();
     16    private readonly XAxis xAxis = new XAxis();
     17    private readonly List<RowEntry> rowEntries = new List<RowEntry>();
     18
     19    private readonly Dictionary<IDataRow, RowEntry> rowToRowEntry = new Dictionary<IDataRow, RowEntry>();
     20
     21//    private readonly Stack<RectangleD> clippingAreaHistory = new Stack<RectangleD>();
     22    private readonly WorldShape userInteractionShape = new WorldShape();
     23    private readonly RectangleShape rectangleShape = new RectangleShape(0, 0, 0, 0, Color.FromArgb(50, 0, 0, 255));
    2924    private IMouseEventListener mouseEventListener;
     25
     26    private const int YAxisWidth = 100;
     27    private const int XAxisHeight = 20;
     28
    3029    private bool zoomToFullView;
    3130
     
    4847      canvas = canvasUI.Canvas;
    4948
    50       grid = new Grid();
    51       canvas.AddShape(grid);
    52 
    53       linesShape = new LinesShape();
    54       canvas.AddShape(linesShape);
    55 
    56       xAxis = new XAxis();
    57       canvas.AddShape(xAxis);
    58 
    59       yAxis = new YAxis();
    60       canvas.AddShape(yAxis);
    61 
    62       titleShape = new TextShape(0, 0, model.Title, 15);
    63       canvas.AddShape(titleShape);
    64 
    65       //  horizontalLineShape = new HorizontalLineShape(this.maxDataValue, Color.Yellow, 4, DrawingStyle.Solid);
    66       //  root.AddShape(horizontalLineShape);
    67 
    68       legendShape = new LegendShape();
    69       canvas.AddShape(legendShape);
    70 
    71       userInteractionShape = new WorldShape();
    72       canvas.AddShape(userInteractionShape);
    73 
    74       rectangleShape = new RectangleShape(0, 0, 0, 0, Color.Blue);
    75       rectangleShape.Opacity = 50;
    76 
    77       maxDataRowCount = 0;
    7849      this.model = model;
     50
    7951      Item = model;
    8052
     
    8254      canvasUI.Resize += delegate { UpdateLayout(); };
    8355
    84       //The whole data rows are shown per default
    85       if (zoomToFullView) {
    86         ZoomToFullView();
    87       }
     56      ZoomToFullView();
    8857    }
    8958
     
    9261    /// </summary>
    9362    private void UpdateLayout() {
     63      canvas.ClearShapes();
     64
     65      foreach (RowEntry rowEntry in rowEntries) {
     66        canvas.AddShape(rowEntry.Grid);
     67      }
     68
     69      foreach (RowEntry rowEntry in rowEntries) {
     70        canvas.AddShape(rowEntry.LinesShape);
     71      }
     72
     73      canvas.AddShape(xAxis);
     74
     75      foreach (RowEntry rowEntry in rowEntries) {
     76        canvas.AddShape(rowEntry.YAxis);
     77      }
     78
     79      canvas.AddShape(titleShape);
     80      canvas.AddShape(legendShape);
     81
     82      canvas.AddShape(userInteractionShape);
     83
    9484      titleShape.X = 10;
    9585      titleShape.Y = canvasUI.Height - 10;
    9686
    97       const int yAxisWidth = 100;
    98       const int xAxisHeight = 20;
    99 
    100       linesShape.BoundingBox = new RectangleD(yAxisWidth,
    101                                               xAxisHeight,
    102                                               canvasUI.Width,
    103                                               canvasUI.Height);
    104 
    105       userInteractionShape.BoundingBox = linesShape.BoundingBox;
     87      int yAxesWidth = 0;
     88
     89      foreach (RowEntry rowEntry in rowEntries) {
     90        if (rowEntry.YAxis.Visible) {
     91          yAxesWidth += YAxisWidth;
     92        }
     93      }
     94
     95      RectangleD linesAreaBoundingBox = new RectangleD(yAxesWidth,
     96                                                       XAxisHeight,
     97                                                       canvasUI.Width,
     98                                                       canvasUI.Height);
     99
     100      foreach (RowEntry rowEntry in rowEntries) {
     101        rowEntry.LinesShape.BoundingBox = linesAreaBoundingBox;
     102        rowEntry.Grid.BoundingBox = linesAreaBoundingBox;
     103      }
     104
     105      int yAxisLeft = 0;
     106      foreach (RowEntry rowEntry in rowEntries) {
     107        rowEntry.YAxis.BoundingBox = new RectangleD(yAxisLeft,
     108                                                    linesAreaBoundingBox.Y1,
     109                                                    yAxisLeft + YAxisWidth,
     110                                                    linesAreaBoundingBox.Y2);
     111        yAxisLeft += YAxisWidth;
     112      }
     113
     114      userInteractionShape.BoundingBox = linesAreaBoundingBox;
    106115      userInteractionShape.ClippingArea = new RectangleD(0, 0, userInteractionShape.BoundingBox.Width, userInteractionShape.BoundingBox.Height);
    107116
    108       grid.BoundingBox = linesShape.BoundingBox;
    109 
    110 
    111       yAxis.BoundingBox = new RectangleD(0,
    112                                          linesShape.BoundingBox.Y1,
    113                                          linesShape.BoundingBox.X1,
    114                                          linesShape.BoundingBox.Y2);
    115 
    116       xAxis.BoundingBox = new RectangleD(linesShape.BoundingBox.X1,
     117      xAxis.BoundingBox = new RectangleD(linesAreaBoundingBox.X1,
    117118                                         0,
    118                                          linesShape.BoundingBox.X2,
    119                                          linesShape.BoundingBox.Y1);
     119                                         linesAreaBoundingBox.X2,
     120                                         linesAreaBoundingBox.Y1);
    120121
    121122      legendShape.BoundingBox = new RectangleD(10, 10, 110, canvasUI.Height - 50);
    122123      legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width,
    123124                                                legendShape.BoundingBox.Height);
     125
     126      canvasUI.Invalidate();
    124127    }
    125128
     
    130133
    131134    public void OnDataRowChanged(IDataRow row) {
    132       foreach (LineShape ls in rowToLineShapes[row]) {
    133         ls.LSColor = row.Color;
    134         ls.LSThickness = row.Thickness;
    135         ls.LSDrawingStyle = row.Style;
    136       }
     135      RowEntry rowEntry = rowToRowEntry[row];
     136
     137      rowEntry.LinesShape.UpdateStyle(row);
     138
    137139      canvasUI.Invalidate();
    138140    }
    139141
    140142    #region Add-/RemoveItemEvents
    141 
    142     private readonly IDictionary<IDataRow, List<LineShape>> rowToLineShapes =
    143       new Dictionary<IDataRow, List<LineShape>>();
    144143
    145144    protected override void AddItemEvents() {
     
    168167      row.DataRowChanged += OnDataRowChanged;
    169168
    170       if (row.Count > maxDataRowCount) {
    171         maxDataRowCount = row.Count;
    172         //   UpdateSingleValueRows();
    173       }
    174 
    175169      legendShape.AddLegendItem(new LegendItem(row.Label, row.Color, row.Thickness));
    176170      legendShape.CreateLegend();
     171
    177172      InitLineShapes(row);
     173
     174      UpdateLayout();
    178175    }
    179176
     
    182179      row.ValuesChanged -= OnRowValuesChanged;
    183180      row.DataRowChanged -= OnDataRowChanged;
     181
     182      rowToRowEntry.Remove(row);
     183      rowEntries.RemoveAll(delegate(RowEntry rowEntry) { return rowEntry.DataRow == row; });
     184
     185      UpdateLayout();
    184186    }
    185187
     
    187189
    188190    public void ZoomToFullView() {
    189       RectangleD newClippingArea = new RectangleD(-0.1,
    190                                                   minDataValue - ((maxDataValue - minDataValue)*0.05),
    191                                                   maxDataRowCount - 0.9,
    192                                                   maxDataValue + ((maxDataValue - minDataValue)*0.05));
    193 
    194       SetLineClippingArea(newClippingArea, true);
     191      SetClipX(-0.1, model.MaxDataRowValues - 0.9);
     192
     193      foreach (RowEntry rowEntry in rowEntries) {
     194        IDataRow row = rowEntry.DataRow;
     195
     196        SetClipY(rowEntry,
     197                 row.MinValue - ((row.MaxValue - row.MinValue)*0.05),
     198                 row.MaxValue + ((row.MaxValue - row.MinValue)*0.05));
     199      }
    195200
    196201      zoomToFullView = true;
    197     }
    198 
    199     /// <summary>
    200     /// Sets the clipping area of the data to display.
    201     /// </summary>
    202     /// <param name="clippingArea"></param>
    203     /// <param name="pushToHistoryStack"></param>
    204     private void SetLineClippingArea(RectangleD clippingArea, bool pushToHistoryStack) {
    205       zoomToFullView = false;
    206 
    207       if (pushToHistoryStack) {
    208         int count = clippingAreaHistory.Count;
    209 
    210         if (count > 40) {
    211           RectangleD[] clippingAreas = clippingAreaHistory.ToArray();
    212           clippingAreaHistory.Clear();
    213 
    214           for (int i = count - 20; i < count; i++) {
    215             clippingAreaHistory.Push(clippingAreas[i]);
    216           }
    217         }
    218 
    219         clippingAreaHistory.Push(clippingArea);
    220       }
    221 
    222       linesShape.ClippingArea = clippingArea;
    223 
    224       grid.ClippingArea = linesShape.ClippingArea;
    225 
    226       // horizontalLineShape.ClippingArea = linesShape.ClippingArea;
    227 
    228 
    229       xAxis.ClippingArea = new RectangleD(linesShape.ClippingArea.X1,
    230                                           xAxis.BoundingBox.Y1,
    231                                           linesShape.ClippingArea.X2,
    232                                           xAxis.BoundingBox.Y2);
    233 
    234       yAxis.ClippingArea = new RectangleD(yAxis.BoundingBox.X1,
    235                                           linesShape.ClippingArea.Y1,
    236                                           yAxis.BoundingBox.X2,
    237                                           linesShape.ClippingArea.Y2);
    238 
    239       canvasUI.Invalidate();
     202
     203      canvasUI.Invalidate();
     204    }
     205
     206    private void SetClipX(double x1, double x2) {
     207      xAxis.ClippingArea = new RectangleD(x1,
     208                                          0,
     209                                          x2,
     210                                          XAxisHeight);
     211
     212      foreach (RowEntry rowEntry in rowEntries) {
     213        rowEntry.LinesShape.ClippingArea = new RectangleD(x1,
     214                                                          rowEntry.LinesShape.ClippingArea.Y1,
     215                                                          x2,
     216                                                          rowEntry.LinesShape.ClippingArea.Y2);
     217        rowEntry.Grid.ClippingArea = new RectangleD(x1,
     218                                                    rowEntry.Grid.ClippingArea.Y1,
     219                                                    x2,
     220                                                    rowEntry.Grid.ClippingArea.Y2);
     221        rowEntry.YAxis.ClippingArea = new RectangleD(0,
     222                                                     rowEntry.YAxis.ClippingArea.Y1,
     223                                                     YAxisWidth,
     224                                                     rowEntry.YAxis.ClippingArea.Y2);
     225      }
     226    }
     227
     228    private static void SetClipY(RowEntry rowEntry, double y1, double y2) {
     229      rowEntry.LinesShape.ClippingArea = new RectangleD(rowEntry.LinesShape.ClippingArea.X1,
     230                                                        y1,
     231                                                        rowEntry.LinesShape.ClippingArea.X2,
     232                                                        y2);
     233      rowEntry.Grid.ClippingArea = new RectangleD(rowEntry.Grid.ClippingArea.X1,
     234                                                  y1,
     235                                                  rowEntry.Grid.ClippingArea.X2,
     236                                                  y2);
     237      rowEntry.YAxis.ClippingArea = new RectangleD(rowEntry.YAxis.ClippingArea.X1,
     238                                                   y1,
     239                                                   rowEntry.YAxis.ClippingArea.X2,
     240                                                   y2);
    240241    }
    241242
    242243    private void InitLineShapes(IDataRow row) {
    243       List<LineShape> lineShapes = new List<LineShape>();
    244       if (rowToLineShapes.Count == 0) {
    245         minDataValue = Double.PositiveInfinity;
    246         maxDataValue = Double.NegativeInfinity;
    247       }
    248       if ((row.Count > 0)) {
    249         maxDataValue = Math.Max(row[0], maxDataValue);
    250         minDataValue = Math.Min(row[0], minDataValue);
    251       }
     244      RowEntry rowEntry = new RowEntry(row);
     245      rowEntries.Add(rowEntry);
     246      rowToRowEntry[row] = rowEntry;
     247
    252248      if ((row.LineType == DataRowType.SingleValue)) {
    253249        if (row.Count > 0) {
    254250          LineShape lineShape = new HorizontalLineShape(0, row[0], double.MaxValue, row[0], row.Color, row.Thickness,
    255251                                                        row.Style);
    256           lineShapes.Add(lineShape);
    257           // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently.
    258           linesShape.AddShape(lineShape);
     252          rowEntry.LinesShape.AddShape(lineShape);
    259253        }
    260254      } else {
    261255        for (int i = 1; i < row.Count; i++) {
    262256          LineShape lineShape = new LineShape(i - 1, row[i - 1], i, row[i], row.Color, row.Thickness, row.Style);
    263           lineShapes.Add(lineShape);
    264           // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently.
    265           linesShape.AddShape(lineShape);
    266           maxDataValue = Math.Max(row[i], maxDataValue);
    267           minDataValue = Math.Min(row[i], minDataValue);
    268         }
    269       }
    270       //horizontalLineShape.YVal = maxDataValue;
    271       rowToLineShapes[row] = lineShapes;
     257          rowEntry.LinesShape.AddShape(lineShape);
     258        }
     259      }
    272260
    273261      ZoomToFullView();
    274262    }
    275263
    276     // TODO use action parameter
    277264    private void OnRowValueChanged(IDataRow row, double value, int index, Action action) {
    278       List<LineShape> lineShapes = rowToLineShapes[row];
    279       maxDataValue = Math.Max(value, maxDataValue);
    280       minDataValue = Math.Min(value, minDataValue);
     265      RowEntry rowEntry = rowToRowEntry[row];
     266
    281267      if (row.LineType == DataRowType.SingleValue) {
    282268        if (action == Action.Added) {
    283269          LineShape lineShape = new HorizontalLineShape(0, row[0], double.MaxValue, row[0], row.Color, row.Thickness,
    284270                                                        row.Style);
    285           lineShapes.Add(lineShape);
    286           // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently.
    287           linesShape.AddShape(lineShape);
     271          rowEntry.LinesShape.AddShape(lineShape);
    288272        } else {
    289           // lineShapes[0].X2 = maxDataRowCount;
    290           lineShapes[0].Y1 = value;
    291           lineShapes[0].Y2 = value;
     273          LineShape lineShape = rowEntry.LinesShape.GetShape(0);
     274          lineShape.Y1 = value;
     275          lineShape.Y2 = value;
    292276        }
    293277      } else {
    294         //  horizontalLineShape.YVal = maxDataValue;
    295         if (index > lineShapes.Count + 1) {
     278        if (index > rowEntry.LinesShape.Count + 1) {
    296279          throw new NotImplementedException();
    297280        }
    298281
    299282        // new value was added
    300         if (index > 0 && index == lineShapes.Count + 1) {
    301           if (maxDataRowCount < row.Count) {
    302             maxDataRowCount = row.Count;
    303             //  UpdateSingleValueRows();
    304           }
    305           LineShape lineShape = new LineShape(index - 1, row[index - 1], index, row[index], row.Color, row.Thickness,
    306                                         row.Style);
    307           lineShapes.Add(lineShape);
    308           // TODO each DataRow needs its own WorldShape so Y Axes can be zoomed independently.
    309           linesShape.AddShape(lineShape);
     283        if (index > 0 && index == rowEntry.LinesShape.Count + 1) {
     284          LineShape lineShape = new LineShape(index - 1, row[index - 1], index, row[index], row.Color, row.Thickness, row.Style);
     285          rowEntry.LinesShape.AddShape(lineShape);
    310286        }
    311287
    312288        // not the first value
    313289        if (index > 0) {
    314           lineShapes[index - 1].Y2 = value;
     290          rowEntry.LinesShape.GetShape(index - 1).Y2 = value;
    315291        }
    316292
    317293        // not the last value
    318294        if (index > 0 && index < row.Count - 1) {
    319           lineShapes[index].Y1 = value;
     295          rowEntry.LinesShape.GetShape(index).Y1 = value;
    320296        }
    321297      }
     
    324300    }
    325301
    326     // TODO remove (see ticket #501)
    327     public IList<IDataRow> GetRows() {
    328       return model.Rows;
    329     }
    330 
    331 
    332     // TODO use action parameter
    333302    private void OnRowValuesChanged(IDataRow row, double[] values, int index, Action action) {
    334303      foreach (double value in values) {
     
    368337
    369338    private void Pan(Point startPoint, Point endPoint) {
    370       RectangleD clippingArea = CalcPanClippingArea(startPoint, endPoint);
    371       SetLineClippingArea(clippingArea, false);
     339      zoomToFullView = false;
     340
     341      foreach (RowEntry rowEntry in rowEntries) {
     342        RectangleD clippingArea = CalcPanClippingArea(startPoint, endPoint, rowEntry.LinesShape);
     343
     344        SetClipX(clippingArea.X1, clippingArea.X1);
     345        SetClipY(rowEntry, clippingArea.Y1, clippingArea.Y2);
     346      }
     347
     348      canvasUI.Invalidate();
    372349    }
    373350
    374351    private void PanEnd(Point startPoint, Point endPoint) {
    375       RectangleD clippingArea = CalcPanClippingArea(startPoint, endPoint);
    376       SetLineClippingArea(clippingArea, true);
    377     }
    378 
    379     private RectangleD CalcPanClippingArea(Point startPoint, Point endPoint) {
     352      zoomToFullView = false;
     353
     354      foreach (RowEntry rowEntry in rowEntries) {
     355        RectangleD clippingArea = CalcPanClippingArea(startPoint, endPoint, rowEntry.LinesShape);
     356
     357        SetClipX(clippingArea.X1, clippingArea.X1);
     358        SetClipY(rowEntry, clippingArea.Y1, clippingArea.Y2);
     359      }
     360
     361      canvasUI.Invalidate();
     362    }
     363
     364    private static RectangleD CalcPanClippingArea(Point startPoint, Point endPoint, LinesShape linesShape) {
    380365      return Translate.ClippingArea(startPoint, endPoint, linesShape.ClippingArea, linesShape.Viewport);
    381366    }
    382367
    383368    private void SetClippingArea(Rectangle rectangle) {
    384       RectangleD clippingArea = Transform.ToWorld(rectangle, linesShape.Viewport, linesShape.ClippingArea);
    385 
    386       SetLineClippingArea(clippingArea, true);
     369      foreach (RowEntry rowEntry in rowEntries) {
     370        RectangleD clippingArea = Transform.ToWorld(rectangle, rowEntry.LinesShape.Viewport, rowEntry.LinesShape.ClippingArea);
     371
     372        SetClipX(clippingArea.X1, clippingArea.X1);
     373        SetClipY(rowEntry, clippingArea.Y1, clippingArea.Y2);
     374      }
     375
    387376      userInteractionShape.RemoveShape(rectangleShape);
     377      canvasUI.Invalidate();
    388378    }
    389379
     
    394384
    395385    private void canvasUI1_KeyDown(object sender, KeyEventArgs e) {
    396       if (e.KeyCode == Keys.Back && clippingAreaHistory.Count > 1) {
    397         clippingAreaHistory.Pop();
    398 
    399         RectangleD clippingArea = clippingAreaHistory.Peek();
    400 
    401         SetLineClippingArea(clippingArea, false);
    402       }
     386//      if (e.KeyCode == Keys.Back && clippingAreaHistory.Count > 1) {
     387//        clippingAreaHistory.Pop();
     388//
     389//        RectangleD clippingArea = clippingAreaHistory.Peek();
     390//
     391//        SetLineClippingArea(clippingArea, false);
     392//      }
    403393    }
    404394
     
    446436        double zoomFactor = (e.Delta > 0) ? 0.9 : 1.1;
    447437
    448         RectangleD clippingArea = ZoomListener.ZoomClippingArea(linesShape.ClippingArea, zoomFactor);
    449 
    450         SetLineClippingArea(clippingArea, true);
     438        foreach (RowEntry rowEntry in rowEntries) {
     439          RectangleD clippingArea = ZoomListener.ZoomClippingArea(rowEntry.LinesShape.ClippingArea, zoomFactor);
     440         
     441          SetClipX(clippingArea.X1, clippingArea.X1);
     442          SetClipY(rowEntry, clippingArea.Y1, clippingArea.Y2);
     443        }
    451444      }
    452445    }
     
    454447    #endregion
    455448
    456     #region Nested type: LinesShape
    457 
    458     internal class LinesShape : WorldShape {}
    459 
    460     #endregion
     449    private class LinesShape : WorldShape {
     450      public void UpdateStyle(IDataRow row) {
     451        foreach (IShape shape in shapes) {
     452          LineShape lineShape = shape as LineShape;
     453          if (lineShape != null) {
     454            lineShape.LSColor = row.Color;
     455            lineShape.LSDrawingStyle = row.Style;
     456            lineShape.LSThickness = row.Thickness;
     457          }
     458        }
     459      }
     460
     461      public int Count {
     462        get { return shapes.Count; }
     463      }
     464
     465      public LineShape GetShape(int index) {
     466        return (LineShape)shapes[index];
     467      }
     468    }
     469
     470    private class RowEntry {
     471      private readonly IDataRow dataRow;
     472
     473      private readonly Grid grid = new Grid();
     474      private readonly YAxis yAxis = new YAxis();
     475      private readonly LinesShape linesShape = new LinesShape();
     476
     477      public RowEntry(IDataRow dataRow) {
     478        this.dataRow = dataRow;
     479      }
     480
     481      public IDataRow DataRow {
     482        get { return dataRow; }
     483      }
     484
     485      public Grid Grid {
     486        get { return grid; }
     487      }
     488
     489      public YAxis YAxis {
     490        get { return yAxis; }
     491      }
     492
     493      public LinesShape LinesShape {
     494        get { return linesShape; }
     495      }
     496    }
    461497  }
    462498}
  • trunk/sources/HeuristicLab.Visualization/TextShape.cs

    r1240 r1285  
    2222    private AnchorPositionX anchorPositionX = AnchorPositionX.Left;
    2323    private AnchorPositionY anchorPositionY = AnchorPositionY.Top;
     24
     25    public TextShape(string text) : this(0, 0, text, 14) {}
    2426
    2527    public TextShape(double x, double y, string text) : this(x, y, text, 8) {}
  • trunk/sources/HeuristicLab.Visualization/WorldShape.cs

    r1240 r1285  
    1313    private IShape parent;
    1414
    15     private readonly List<IShape> shapes = new List<IShape>();
     15    protected readonly List<IShape> shapes = new List<IShape>();
    1616
    1717    public WorldShape() {
  • trunk/sources/HeuristicLab.Visualization/YAxis.cs

    r1240 r1285  
    77
    88    private ILabelProvider labelProvider = new ContinuousLabelProvider("e4");
     9    private bool visible = true;
    910
    1011    public ILabelProvider LabelProvider {
     
    1314    }
    1415
     16    public bool Visible {
     17      get { return visible; }
     18      set { visible = value; }
     19    }
     20
    1521    public override void Draw(Graphics graphics) {
    1622      ClearShapes();
    1723
    18       foreach (double y in AxisTicks.GetTicks(PixelsPerInterval, Parent.Viewport.Height,
    19                                               ClippingArea.Height,
    20                                               ClippingArea.Y1)) {
    21         TextShape label = new TextShape(ClippingArea.X2 - 3, y,
    22                                         labelProvider.GetLabel(y));
    23         label.AnchorPositionX = AnchorPositionX.Right;
    24         label.AnchorPositionY = AnchorPositionY.Middle;
    25         AddShape(label);
     24      if (Visible) {
     25        foreach (double y in AxisTicks.GetTicks(PixelsPerInterval, Parent.Viewport.Height,
     26                                                ClippingArea.Height,
     27                                                ClippingArea.Y1)) {
     28          TextShape label = new TextShape(ClippingArea.X2 - 3, y,
     29                                          labelProvider.GetLabel(y));
     30          label.AnchorPositionX = AnchorPositionX.Right;
     31          label.AnchorPositionY = AnchorPositionY.Middle;
     32          AddShape(label);
     33        }
    2634      }
    2735
Note: See TracChangeset for help on using the changeset viewer.