Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.1/sources/HeuristicLab.Charting/Primitives/FixedSizePrimitiveBase.cs @ 1449

Last change on this file since 1449 was 2, checked in by swagner, 17 years ago

Added HeuristicLab 3.0 sources from former SVN repository at revision 52

File size: 2.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Text;
25using System.Drawing;
26
27namespace HeuristicLab.Charting {
28  public abstract class FixedSizePrimitiveBase : PrimitiveBase {
29    private PointD myPoint;
30    public virtual PointD Point {
31      get { return myPoint; }
32    }
33    private Size mySize;
34    public virtual Size Size {
35      get { return mySize; }
36    }
37
38    protected FixedSizePrimitiveBase(IChart chart, PointD point, Size size)
39      : base(chart) {
40      myPoint = point;
41      mySize = size;
42    }
43    protected FixedSizePrimitiveBase(IChart chart, double x, double y, Size size)
44      : this(chart, new PointD(x, y), size) {
45    }
46    protected FixedSizePrimitiveBase(IChart chart, PointD point, Size size, Pen pen, Brush brush)
47      : base(chart, pen, brush) {
48      myPoint = point;
49      mySize = size;
50    }
51    protected FixedSizePrimitiveBase(IChart chart, double x, double y, Size size, Pen pen, Brush brush)
52      : this(chart, new PointD(x, y), size, pen, brush) {
53    }
54
55    public virtual void SetPosition(PointD point) {
56      myPoint = point;
57      OnUpdate();
58    }
59    public void SetPosition(double x, double y) {
60      SetPosition(new PointD(x, y));
61    }
62    public override void Move(Offset delta) {
63      SetPosition(Point + delta);
64    }
65
66    public override bool ContainsPoint(PointD point) {
67      SizeD size = Chart.TransformPixelToWorld(Size);
68      return (point.X >= Point.X - (size.Width / 2)) && (point.X <= Point.X + (size.Width / 2)) &&
69             (point.Y >= Point.Y - (size.Height / 2)) && (point.Y <= Point.Y + (size.Height / 2));
70    }
71  }
72}
Note: See TracBrowser for help on using the repository browser.