Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.1/sources/HeuristicLab.Charting/Primitives/AxisPrimitiveBase.cs @ 4539

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

Added HeuristicLab 3.0 sources from former SVN repository at revision 52

File size: 3.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 AxisPrimitiveBase : PrimitiveBase {
29    private AxisType myAxisType;
30    public AxisType AxisType {
31      get { return myAxisType; }
32    }
33    private PointD myPoint;
34    public virtual PointD Point {
35      get { return myPoint; }
36    }
37    private bool myShowGrid;
38    public bool ShowGrid {
39      get { return myShowGrid; }
40      set {
41        if (value != myShowGrid) {
42          myShowGrid = value;
43          OnUpdate();
44        }
45      }
46    }
47    private string myHorizontalLabel;
48    public string HorizontalLabel {
49      get { return myHorizontalLabel; }
50      set {
51        if (value != myHorizontalLabel) {
52          myHorizontalLabel = value;
53          OnUpdate();
54        }
55      }
56    }
57    private string myVerticalLabel;
58    public string VerticalLabel {
59      get { return myVerticalLabel; }
60      set {
61        if (value != myVerticalLabel) {
62          myVerticalLabel = value;
63          OnUpdate();
64        }
65      }
66    }
67
68    protected AxisPrimitiveBase(IChart chart, PointD point, AxisType axisType)
69      : base(chart) {
70      Brush = Brushes.Black;
71      myPoint = point;
72      myAxisType = axisType;
73      myShowGrid = true;
74    }
75    protected AxisPrimitiveBase(IChart chart, double x, double y, AxisType axisType)
76      : this(chart, new PointD(x, y), axisType) {
77    }
78    protected AxisPrimitiveBase(IChart chart, PointD point, AxisType axisType, Pen pen, Brush brush)
79      : base(chart, pen, brush) {
80      myPoint = point;
81      myAxisType = axisType;
82      myShowGrid = true;
83    }
84    protected AxisPrimitiveBase(IChart chart, double x, double y, AxisType axisType, Pen pen, Brush brush)
85      : this(chart, new PointD(x, y), axisType, pen, brush) {
86    }
87
88    public virtual void SetPosition(PointD point) {
89      myPoint = point;
90      OnUpdate();
91    }
92    public void SetPosition(double x, double y) {
93      SetPosition(new PointD(x, y));
94    }
95    public override void Move(Offset delta) {
96      SetPosition(Point + delta);
97    }
98
99    public override bool ContainsPoint(PointD point) {
100      SizeD size = Chart.TransformPixelToWorld(new Size(5, 5));
101      bool result = false;
102      if ((AxisType & AxisType.Horizontal) == AxisType.Horizontal)
103        result = result || (point.Y >= Point.Y - (size.Height / 2)) && (point.Y <= Point.Y + (size.Height / 2));
104      if ((AxisType & AxisType.Vertical) == AxisType.Vertical)
105        result = result || (point.X >= Point.X - (size.Height / 2)) && (point.X <= Point.X + (size.Height / 2));
106      return result;
107    }
108  }
109}
Note: See TracBrowser for help on using the repository browser.