Last change
on this file since 2396 was
635,
checked in by mstoeger, 16 years ago
|
Imported charting framework sources into HeuristicLab.Visualization (#294)
|
File size:
1.2 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Drawing;
|
---|
4 |
|
---|
5 | namespace HeuristicLab.Visualization {
|
---|
6 | public class CompositeShape : IShape {
|
---|
7 | protected readonly List<IShape> shapes = new List<IShape>();
|
---|
8 | protected RectangleD boundingBox = RectangleD.Empty;
|
---|
9 |
|
---|
10 | public virtual void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
|
---|
11 | foreach (IShape shape in shapes) {
|
---|
12 | shape.Draw(graphics, viewport, clippingArea);
|
---|
13 | }
|
---|
14 | }
|
---|
15 |
|
---|
16 | public RectangleD BoundingBox {
|
---|
17 | get {
|
---|
18 | if (shapes.Count == 0) {
|
---|
19 | throw new InvalidOperationException("No shapes, no bounding box.");
|
---|
20 | }
|
---|
21 |
|
---|
22 | return boundingBox;
|
---|
23 | }
|
---|
24 | }
|
---|
25 |
|
---|
26 | public void AddShape(IShape shape) {
|
---|
27 | if (shapes.Count == 0) {
|
---|
28 | boundingBox = shape.BoundingBox;
|
---|
29 | } else {
|
---|
30 | boundingBox = new RectangleD(Math.Min(boundingBox.X1, shape.BoundingBox.X1),
|
---|
31 | Math.Min(boundingBox.Y1, shape.BoundingBox.Y1),
|
---|
32 | Math.Max(boundingBox.X2, shape.BoundingBox.X2),
|
---|
33 | Math.Max(boundingBox.Y2, shape.BoundingBox.Y2));
|
---|
34 | }
|
---|
35 | shapes.Add(shape);
|
---|
36 | }
|
---|
37 | }
|
---|
38 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.