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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Text;
|
---|
25 | using System.Drawing;
|
---|
26 | using HeuristicLab.Charting;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Charting.Data {
|
---|
29 | public class Datachart : Chart {
|
---|
30 | private IList<DataRowType> dataRowTypes;
|
---|
31 |
|
---|
32 | private string myTitle;
|
---|
33 | public string Title {
|
---|
34 | get { return myTitle; }
|
---|
35 | set {
|
---|
36 | if (myTitle != value) {
|
---|
37 | myTitle = value;
|
---|
38 | OnUpdate();
|
---|
39 | }
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | public Datachart(PointD lowerLeft, PointD upperRight)
|
---|
44 | : base(lowerLeft, upperRight) {
|
---|
45 | dataRowTypes = new List<DataRowType>();
|
---|
46 | }
|
---|
47 | public Datachart(double x1, double y1, double x2, double y2)
|
---|
48 | : this(new PointD(x1, y1), new PointD(x2, y2)) {
|
---|
49 | }
|
---|
50 |
|
---|
51 | public void AddDataRow(DataRowType dataRowType, Pen pen, Brush brush) {
|
---|
52 | Group group = new Group(this);
|
---|
53 | group.Pen = pen;
|
---|
54 | group.Brush = brush;
|
---|
55 | Group.Add(group);
|
---|
56 | dataRowTypes.Add(dataRowType);
|
---|
57 | if (dataRowType == DataRowType.Lines) {
|
---|
58 | Group lines = new Group(this);
|
---|
59 | group.Add(lines);
|
---|
60 | Group points = new Group(this);
|
---|
61 | group.Add(points);
|
---|
62 | }
|
---|
63 | }
|
---|
64 | public void RemoveDataRow(int index) {
|
---|
65 | Group.Remove(Group.Primitives[index]);
|
---|
66 | dataRowTypes.RemoveAt(index);
|
---|
67 | }
|
---|
68 |
|
---|
69 | public void AddDataPoint(int dataRowIndex, PointD point) {
|
---|
70 | DataRowType dataRowType = dataRowTypes[dataRowIndex];
|
---|
71 | Group group = (Group)Group.Primitives[dataRowIndex];
|
---|
72 |
|
---|
73 | switch (dataRowType) {
|
---|
74 | case DataRowType.Lines:
|
---|
75 | Group lines = (Group)group.Primitives[1];
|
---|
76 | Group points = (Group)group.Primitives[0];
|
---|
77 | if (points.Primitives.Count > 0) {
|
---|
78 | FixedSizeRectangle lastRect = (FixedSizeRectangle)points.Primitives[0];
|
---|
79 | Line line = new Line(this, lastRect.Point, point, group.Pen);
|
---|
80 | lines.Add(line);
|
---|
81 | }
|
---|
82 | FixedSizeRectangle rect = new FixedSizeRectangle(this, point, new Size(5, 5), group.Pen, group.Brush);
|
---|
83 | rect.ToolTipText = "(" + point.X.ToString() + " ; " + point.Y.ToString() + ")";
|
---|
84 | points.Add(rect);
|
---|
85 | break;
|
---|
86 | case DataRowType.Bars:
|
---|
87 | break;
|
---|
88 | case DataRowType.Points:
|
---|
89 | FixedSizeRectangle p = new FixedSizeRectangle(this, point, new Size(5, 5), group.Pen, group.Brush);
|
---|
90 | p.ToolTipText = "(" + point.X.ToString() + " ; " + point.Y.ToString() + ")";
|
---|
91 | group.Add(p);
|
---|
92 | break;
|
---|
93 | }
|
---|
94 | }
|
---|
95 | public void AddDataPoint(int dataRowIndex, double x, double y) {
|
---|
96 | AddDataPoint(dataRowIndex, new PointD(x, y));
|
---|
97 | }
|
---|
98 | }
|
---|
99 | }
|
---|