Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/3.2/CompositeShape.cs @ 1591

Last change on this file since 1591 was 1559, checked in by dwagner, 16 years ago

Added functionality: Markers on every datapoint. (#581)

File size: 1.9 KB
RevLine 
[635]1using System;
2using System.Collections.Generic;
3using System.Drawing;
4
5namespace HeuristicLab.Visualization {
6  public class CompositeShape : IShape {
[1240]7    private IShape parent;
[1559]8    private bool showChildShapes = true;
[1240]9
[635]10    protected readonly List<IShape> shapes = new List<IShape>();
11    protected RectangleD boundingBox = RectangleD.Empty;
12
[1559]13
14
[1240]15    public virtual void Draw(Graphics graphics) {
[1559]16      if(!showChildShapes)
17        return;
[635]18      foreach (IShape shape in shapes) {
[1240]19        shape.Draw(graphics);
[635]20      }
21    }
22
23    public RectangleD BoundingBox {
24      get {
25        if (shapes.Count == 0) {
26          throw new InvalidOperationException("No shapes, no bounding box.");
27        }
28
29        return boundingBox;
30      }
31    }
32
[1240]33    public RectangleD ClippingArea {
34      get { return Parent.ClippingArea; }
35    }
36
37    public Rectangle Viewport {
38      get { return Parent.Viewport; }
39    }
40
41    public IShape Parent {
42      get { return parent; }
43      set { parent = value; }
44    }
45
[1559]46    public bool ShowChildShapes {
47      get { return showChildShapes; }
48      set { showChildShapes = value; }
49    }
50
[987]51    public void ClearShapes() {
52      shapes.Clear();
53      boundingBox = RectangleD.Empty;
54    }
55
[1559]56    public IShape GetShape(int index) {
57      return shapes[index];
58    }
59
[635]60    public void AddShape(IShape shape) {
[1240]61      shape.Parent = this;
62
[635]63      if (shapes.Count == 0) {
64        boundingBox = shape.BoundingBox;
65      } else {
66        boundingBox = new RectangleD(Math.Min(boundingBox.X1, shape.BoundingBox.X1),
67                                     Math.Min(boundingBox.Y1, shape.BoundingBox.Y1),
68                                     Math.Max(boundingBox.X2, shape.BoundingBox.X2),
69                                     Math.Max(boundingBox.Y2, shape.BoundingBox.Y2));
70      }
71      shapes.Add(shape);
72    }
73  }
74}
Note: See TracBrowser for help on using the repository browser.