ScaleState.cs
6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//============================================================================
//ZedGraph Class Library - A Flexible Line Graph/Bar Graph Library in C#
//Copyright © 2004 John Champion
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//=============================================================================
#region Using directives
using System;
using System.Text;
#endregion
namespace ZedGraph
{
/// <summary>
/// A class that captures an <see cref="Axis"/> scale range.
/// </summary>
/// <remarks>This structure is used by the <see cref="ZoomState"/> class to store
/// <see cref="Axis"/> scale range settings in a collection for later retrieval.
/// The class stores the <see cref="Scale.Min"/>, <see cref="Scale.Max"/>,
/// <see cref="Scale.MinorStep"/>, and <see cref="Scale.MajorStep"/> properties, along with
/// the corresponding auto-scale settings: <see cref="Scale.MinAuto"/>,
/// <see cref="Scale.MaxAuto"/>, <see cref="Scale.MinorStepAuto"/>,
/// and <see cref="Scale.MajorStepAuto"/>.</remarks>
/// <author> John Champion </author>
/// <version> $Revision: 3.2 $ $Date: 2007/02/19 08:05:24 $ </version>
public class ScaleState : ICloneable
{
/// <summary>
/// The axis range data for <see cref="Scale.Min"/>, <see cref="Scale.Max"/>,
/// <see cref="Scale.MinorStep"/>, and <see cref="Scale.MajorStep"/>
/// </summary>
private double _min, _minorStep, _majorStep, _max;
/// <summary>
/// The status of <see cref="Scale.MinAuto"/>,
/// <see cref="Scale.MaxAuto"/>, <see cref="Scale.MinorStepAuto"/>,
/// and <see cref="Scale.MajorStepAuto"/>
/// </summary>
private bool _minAuto, _minorStepAuto,
_majorStepAuto, _maxAuto,
_formatAuto, _magAuto;
/// <summary>
/// The status of <see cref="Scale.MajorUnit"/> and <see cref="Scale.MinorUnit"/>
/// </summary>
private DateUnit _minorUnit, _majorUnit;
private string _format;
private int _mag;
/// <summary>
/// Construct a <see cref="ScaleState"/> from the specified <see cref="Axis"/>
/// </summary>
/// <param name="axis">The <see cref="Axis"/> from which to collect the scale
/// range settings.</param>
public ScaleState( Axis axis )
{
_min = axis._scale._min;
_minorStep = axis._scale._minorStep;
_majorStep = axis._scale._majorStep;
_max = axis._scale._max;
_majorUnit = axis._scale._majorUnit;
_minorUnit = axis._scale._minorUnit;
_format = axis._scale._format;
_mag = axis._scale._mag;
//this.numDec = axis.NumDec;
_minAuto = axis._scale._minAuto;
_majorStepAuto = axis._scale._majorStepAuto;
_minorStepAuto = axis._scale._minorStepAuto;
_maxAuto = axis._scale._maxAuto;
_formatAuto = axis._scale._formatAuto;
_magAuto = axis._scale._magAuto;
}
/// <summary>
/// The Copy Constructor
/// </summary>
/// <param name="rhs">The <see cref="ScaleState"/> object from which to copy</param>
public ScaleState( ScaleState rhs )
{
_min = rhs._min;
_majorStep = rhs._majorStep;
_minorStep = rhs._minorStep;
_max = rhs._max;
_majorUnit = rhs._majorUnit;
_minorUnit = rhs._minorUnit;
_format = rhs._format;
_mag = rhs._mag;
_minAuto = rhs._minAuto;
_majorStepAuto = rhs._majorStepAuto;
_minorStepAuto = rhs._minorStepAuto;
_maxAuto = rhs._maxAuto;
_formatAuto = rhs._formatAuto;
_magAuto = rhs._magAuto;
}
/// <summary>
/// Implement the <see cref="ICloneable" /> interface in a typesafe manner by just
/// calling the typed version of <see cref="Clone" />
/// </summary>
/// <returns>A deep copy of this object</returns>
object ICloneable.Clone()
{
return this.Clone();
}
/// <summary>
/// Typesafe, deep-copy clone method.
/// </summary>
/// <returns>A new, independent copy of this class</returns>
public ScaleState Clone()
{
return new ScaleState( this );
}
/// <summary>
/// Copy the properties from this <see cref="ScaleState"/> out to the specified <see cref="Axis"/>.
/// </summary>
/// <param name="axis">The <see cref="Axis"/> reference to which the properties should be
/// copied</param>
public void ApplyScale( Axis axis )
{
axis._scale._min = _min;
axis._scale._majorStep = _majorStep;
axis._scale._minorStep = _minorStep;
axis._scale._max = _max;
axis._scale._majorUnit = _majorUnit;
axis._scale._minorUnit = _minorUnit;
axis._scale._format = _format;
axis._scale._mag = _mag;
// The auto settings must be made after the min/step/max settings, since setting those
// properties actually affects the auto settings.
axis._scale._minAuto = _minAuto;
axis._scale._minorStepAuto = _minorStepAuto;
axis._scale._majorStepAuto = _majorStepAuto;
axis._scale._maxAuto = _maxAuto;
axis._scale._formatAuto = _formatAuto;
axis._scale._magAuto = _magAuto;
}
/// <summary>
/// Determine if the state contained in this <see cref="ScaleState"/> object is different from
/// the state of the specified <see cref="Axis"/>.
/// </summary>
/// <param name="axis">The <see cref="Axis"/> object with which to compare states.</param>
/// <returns>true if the states are different, false otherwise</returns>
public bool IsChanged( Axis axis )
{
return axis._scale._min != _min ||
axis._scale._majorStep != _majorStep ||
axis._scale._minorStep != _minorStep ||
axis._scale._max != _max ||
axis._scale._minorUnit != _minorUnit ||
axis._scale._majorUnit != _majorUnit ||
axis._scale._minAuto != _minAuto ||
axis._scale._minorStepAuto != _minorStepAuto ||
axis._scale._majorStepAuto != _majorStepAuto ||
axis._scale._maxAuto != _maxAuto;
}
}
}