Last change
on this file since 1236 was
1234,
checked in by mstoeger, 15 years ago
|
Added Xml comments for IShape, WorldShape and Transforms. (#406)
|
File size:
1.3 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 parentViewport, RectangleD parentClippingArea) {
|
---|
11 | foreach (IShape shape in shapes) {
|
---|
12 | shape.Draw(graphics, parentViewport, parentClippingArea);
|
---|
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 ClearShapes() {
|
---|
27 | shapes.Clear();
|
---|
28 | boundingBox = RectangleD.Empty;
|
---|
29 | }
|
---|
30 |
|
---|
31 | public void AddShape(IShape shape) {
|
---|
32 | if (shapes.Count == 0) {
|
---|
33 | boundingBox = shape.BoundingBox;
|
---|
34 | } else {
|
---|
35 | boundingBox = new RectangleD(Math.Min(boundingBox.X1, shape.BoundingBox.X1),
|
---|
36 | Math.Min(boundingBox.Y1, shape.BoundingBox.Y1),
|
---|
37 | Math.Max(boundingBox.X2, shape.BoundingBox.X2),
|
---|
38 | Math.Max(boundingBox.Y2, shape.BoundingBox.Y2));
|
---|
39 | }
|
---|
40 | shapes.Add(shape);
|
---|
41 | }
|
---|
42 | }
|
---|
43 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.