Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/WorldShape.cs @ 1195

Last change on this file since 1195 was 1182, checked in by mstoeger, 16 years ago

Implemented X/Y-Axes and a Grid. (#433)

File size: 1.4 KB
RevLine 
[635]1using System.Collections.Generic;
2using System.Drawing;
3using System.Drawing.Drawing2D;
4
5namespace HeuristicLab.Visualization {
6  public class WorldShape : IShape {
7    private RectangleD clippingArea;
8    private RectangleD boundingBox;
9
[1038]10    protected readonly List<IShape> shapes = new List<IShape>();
[635]11
[1182]12    public WorldShape()
13      : this(new RectangleD(0, 0, 1, 1), new RectangleD(0, 0, 1, 1)) {}
14
[635]15    public WorldShape(RectangleD clippingArea, RectangleD boundingBox) {
16      this.clippingArea = clippingArea;
17      this.boundingBox = boundingBox;
18    }
19
[1038]20    public virtual void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
[635]21      GraphicsState gstate = graphics.Save();
22
23      Rectangle innerViewport = Transform.ToScreen(boundingBox, viewport, clippingArea);
24
25      graphics.SetClip(innerViewport);
[984]26
[635]27      foreach (IShape shape in shapes) {
28        shape.Draw(graphics, innerViewport, this.clippingArea);
29      }
[984]30
[635]31      graphics.Restore(gstate);
32    }
33
34    public RectangleD BoundingBox {
35      get { return boundingBox; }
[1038]36      set { boundingBox = value; }
[635]37    }
38
[928]39    public RectangleD ClippingArea {
40      get { return clippingArea; }
41      set { clippingArea = value; }
42    }
43
[635]44    public void AddShape(IShape shape) {
45      shapes.Add(shape);
46    }
[984]47
48    public bool RemoveShape(IShape shape) {
49      return shapes.Remove(shape);
50    }
[635]51  }
[984]52}
Note: See TracBrowser for help on using the repository browser.