Exemple #1
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see c_ref="ExponentScale" /> object from which to copy</param>
		/// <param name="owner">The <see c_ref="Axis" /> object that will own the
		/// new instance of <see c_ref="ExponentScale" /></param>
		public ExponentScale( Scale rhs, Axis owner )
			: base( rhs, owner )
		{
		}
Exemple #2
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see c_ref="DateScale" /> object from which to copy</param>
		/// <param name="owner">The <see c_ref="Axis" /> object that will own the
		/// new instance of <see c_ref="DateScale" /></param>
		public DateScale( Scale rhs, Axis owner )
			: base( rhs, owner )
		{
		}
Exemple #3
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see c_ref="LinearAsOrdinalScale" /> object from which to copy</param>
		/// <param name="owner">The <see c_ref="Axis" /> object that will own the
		/// new instance of <see c_ref="LinearAsOrdinalScale" /></param>
		public LinearAsOrdinalScale( Scale rhs, Axis owner )
			: base( rhs, owner )
		{
		}
Exemple #4
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see c_ref="LogScale" /> object from which to copy</param>
		/// <param name="owner">The <see c_ref="Axis" /> object that will own the
		/// new instance of <see c_ref="LogScale" /></param>
		public LogScale( Scale rhs, Axis owner )
			: base( rhs, owner )
		{
		}
Exemple #5
0
		/// <summary>
		/// Calculate a step size for a <see c_ref="AxisType.Date"/> scale.
		/// This method is used by <see c_ref="PickScale"/>.
		/// </summary>
		/// <param name="range">The range of data in units of days</param>
		/// <param name="targetSteps">The desired "typical" number of steps
		/// to divide the range into</param>
		/// <param name="scale">
		/// The <see c_ref="Scale" /> object on which to calculate the Date step size.</param>
		/// <returns>The calculated step size for the specified data range.  Also
		/// calculates and sets the values for <see c_ref="Scale.MajorUnit"/>,
		/// <see c_ref="Scale.MinorUnit"/>, <see c_ref="Scale.MinorStep"/>, and
		/// <see c_ref="Scale.Format"/></returns>
		internal static double CalcDateStepSize( double range, double targetSteps, Scale scale )
		{
			// Calculate an initial guess at step size
			double tempStep = range / targetSteps;

			if ( range > Default.RangeYearYear )
			{
				scale._majorUnit = DateUnit.Year;
				if ( scale._formatAuto )
					scale._format = Default.FormatYearYear;

				tempStep = Math.Ceiling( tempStep / 365.0 );

				if ( scale._minorStepAuto )
				{
					scale._minorUnit = DateUnit.Year;
					if ( tempStep == 1.0 )
						scale._minorStep = 0.25;
					else
						scale._minorStep = CalcStepSize( tempStep, targetSteps );
				}
			}
			else if ( range > Default.RangeYearMonth )
			{
				scale._majorUnit = DateUnit.Year;
				if ( scale._formatAuto )
					scale._format = Default.FormatYearMonth;
				tempStep = Math.Ceiling( tempStep / 365.0 );

				if ( scale._minorStepAuto )
				{
					scale._minorUnit = DateUnit.Month;
					// Calculate the minor steps to give an estimated 4 steps
					// per major step.
					scale._minorStep = Math.Ceiling( range / ( targetSteps * 3 ) / 30.0 );
					// make sure the minorStep is 1, 2, 3, 6, or 12 months
					if ( scale._minorStep > 6 )
						scale._minorStep = 12;
					else if ( scale._minorStep > 3 )
						scale._minorStep = 6;
				}
			}
			else if ( range > Default.RangeMonthMonth )
			{
				scale._majorUnit = DateUnit.Month;
				if ( scale._formatAuto )
					scale._format = Default.FormatMonthMonth;
				tempStep = Math.Ceiling( tempStep / 30.0 );

				if ( scale._minorStepAuto )
				{
					scale._minorUnit = DateUnit.Month;
					scale._minorStep = tempStep * 0.25;
				}
			}
			else if ( range > Default.RangeDayDay )
			{
				scale._majorUnit = DateUnit.Day;
				if ( scale._formatAuto )
					scale._format = Default.FormatDayDay;
				tempStep = Math.Ceiling( tempStep );

				if ( scale._minorStepAuto )
				{
					scale._minorUnit = DateUnit.Day;
					scale._minorStep = tempStep * 0.25;
					// make sure the minorStep is 1, 2, 3, 6, or 12 hours
				}
			}
			else if ( range > Default.RangeDayHour )
			{
				scale._majorUnit = DateUnit.Day;
				if ( scale._formatAuto )
					scale._format = Default.FormatDayHour;
				tempStep = Math.Ceiling( tempStep );

				if ( scale._minorStepAuto )
				{
					scale._minorUnit = DateUnit.Hour;
					// Calculate the minor steps to give an estimated 4 steps
					// per major step.
					scale._minorStep = Math.Ceiling( range / ( targetSteps * 3 ) * XDate.HoursPerDay );
					// make sure the minorStep is 1, 2, 3, 6, or 12 hours
					if ( scale._minorStep > 6 )
						scale._minorStep = 12;
					else if ( scale._minorStep > 3 )
						scale._minorStep = 6;
					else
						scale._minorStep = 1;
				}
			}
			else if ( range > Default.RangeHourHour )
			{
				scale._majorUnit = DateUnit.Hour;
				tempStep = Math.Ceiling( tempStep * XDate.HoursPerDay );
				if ( scale._formatAuto )
					scale._format = Default.FormatHourHour;

				if ( tempStep > 12.0 )
					tempStep = 24.0;
				else if ( tempStep > 6.0 )
					tempStep = 12.0;
				else if ( tempStep > 2.0 )
					tempStep = 6.0;
				else if ( tempStep > 1.0 )
					tempStep = 2.0;
				else
					tempStep = 1.0;

				if ( scale._minorStepAuto )
				{
					scale._minorUnit = DateUnit.Hour;
					if ( tempStep <= 1.0 )
						scale._minorStep = 0.25;
					else if ( tempStep <= 6.0 )
						scale._minorStep = 1.0;
					else if ( tempStep <= 12.0 )
						scale._minorStep = 2.0;
					else
						scale._minorStep = 4.0;
				}
			}
			else if ( range > Default.RangeHourMinute )
			{
				scale._majorUnit = DateUnit.Hour;
				tempStep = Math.Ceiling( tempStep * XDate.HoursPerDay );

				if ( scale._formatAuto )
					scale._format = Default.FormatHourMinute;

				if ( scale._minorStepAuto )
				{
					scale._minorUnit = DateUnit.Minute;
					// Calculate the minor steps to give an estimated 4 steps
					// per major step.
					scale._minorStep = Math.Ceiling( range / ( targetSteps * 3 ) * XDate.MinutesPerDay );
					// make sure the minorStep is 1, 5, 15, or 30 minutes
					if ( scale._minorStep > 15.0 )
						scale._minorStep = 30.0;
					else if ( scale._minorStep > 5.0 )
						scale._minorStep = 15.0;
					else if ( scale._minorStep > 1.0 )
						scale._minorStep = 5.0;
					else
						scale._minorStep = 1.0;
				}
			}
			else if ( range > Default.RangeMinuteMinute )
			{
				scale._majorUnit = DateUnit.Minute;
				if ( scale._formatAuto )
					scale._format = Default.FormatMinuteMinute;

				tempStep = Math.Ceiling( tempStep * XDate.MinutesPerDay );
				// make sure the minute step size is 1, 5, 15, or 30 minutes
				if ( tempStep > 15.0 )
					tempStep = 30.0;
				else if ( tempStep > 5.0 )
					tempStep = 15.0;
				else if ( tempStep > 1.0 )
					tempStep = 5.0;
				else
					tempStep = 1.0;

				if ( scale._minorStepAuto )
				{
					scale._minorUnit = DateUnit.Minute;
					if ( tempStep <= 1.0 )
						scale._minorStep = 0.25;
					else if ( tempStep <= 5.0 )
						scale._minorStep = 1.0;
					else
						scale._minorStep = 5.0;
				}
			}
			else if ( range > Default.RangeMinuteSecond )
			{
				scale._majorUnit = DateUnit.Minute;
				tempStep = Math.Ceiling( tempStep * XDate.MinutesPerDay );

				if ( scale._formatAuto )
					scale._format = Default.FormatMinuteSecond;

				if ( scale._minorStepAuto )
				{
					scale._minorUnit = DateUnit.Second;
					// Calculate the minor steps to give an estimated 4 steps
					// per major step.
					scale._minorStep = Math.Ceiling( range / ( targetSteps * 3 ) * XDate.SecondsPerDay );
					// make sure the minorStep is 1, 5, 15, or 30 seconds
					if ( scale._minorStep > 15.0 )
						scale._minorStep = 30.0;
					else if ( scale._minorStep > 5.0 )
						scale._minorStep = 15.0;
					else if ( scale._minorStep > 1.0 )
						scale._minorStep = 5.0;
					else
						scale._minorStep = 1.0;
				}
			}
			else  if ( range > Default.RangeSecondSecond ) // SecondSecond
			{
				scale._majorUnit = DateUnit.Second;
				if ( scale._formatAuto )
					scale._format = Default.FormatSecondSecond;

				tempStep = Math.Ceiling( tempStep * XDate.SecondsPerDay );
				// make sure the second step size is 1, 5, 15, or 30 seconds
				if ( tempStep > 15.0 )
					tempStep = 30.0;
				else if ( tempStep > 5.0 )
					tempStep = 15.0;
				else if ( tempStep > 1.0 )
					tempStep = 5.0;
				else
					tempStep = 1.0;

				if ( scale._minorStepAuto )
				{
					scale._minorUnit = DateUnit.Second;
					if ( tempStep <= 1.0 )
						scale._minorStep = 0.25;
					else if ( tempStep <= 5.0 )
						scale._minorStep = 1.0;
					else
						scale._minorStep = 5.0;
				}
			}
			else // MilliSecond
			{
				scale._majorUnit = DateUnit.Millisecond;
				if ( scale._formatAuto )
					scale._format = Default.FormatMillisecond;

				tempStep = CalcStepSize( range * XDate.MillisecondsPerDay, Default.TargetXSteps );

				if ( scale._minorStepAuto )
				{
					scale._minorStep = CalcStepSize( tempStep,
							( scale._ownerAxis is XAxis || scale._ownerAxis is X2Axis ) ?
							Default.TargetMinorXSteps : Default.TargetMinorYSteps );
					scale._minorUnit = DateUnit.Millisecond;
				}
			}

			return tempStep;
		}
Exemple #6
0
		/// <summary>
		/// The Copy Constructor.
		/// </summary>
		/// <param name="rhs">The Axis object from which to copy</param>
		public Axis( Axis rhs )
		{
			_scale = rhs._scale.Clone( this );

			_cross = rhs._cross;

			_crossAuto = rhs._crossAuto;

			_majorTic = rhs.MajorTic.Clone();
			_minorTic = rhs.MinorTic.Clone();

			_majorGrid = rhs._majorGrid.Clone();
			_minorGrid = rhs._minorGrid.Clone();

			_isVisible = rhs.IsVisible;

			_isAxisSegmentVisible = rhs._isAxisSegmentVisible;

			_title = rhs.Title.Clone();

			_axisGap = rhs._axisGap;

			_minSpace = rhs.MinSpace;

			_color = rhs.Color;
		}
Exemple #7
0
		/// <summary>
		/// Constructor for deserializing objects
		/// </summary>
		/// <param name="info">A <see c_ref="SerializationInfo"/> instance that defines the serialized data
		/// </param>
		/// <param name="context">A <see c_ref="StreamingContext"/> instance that contains the serialized data
		/// </param>
		protected Axis( SerializationInfo info, StreamingContext context )
		{
			// The schema value is just a file version parameter.  You can use it to make future versions
			// backwards compatible as new member variables are added to classes
			int sch = info.GetInt32( "schema" );

			_cross = info.GetDouble( "cross" );
			_crossAuto = info.GetBoolean( "crossAuto" );

			_majorTic = (MajorTic)info.GetValue( "MajorTic", typeof( MajorTic ) );
			_minorTic = (MinorTic)info.GetValue( "MinorTic", typeof( MinorTic ) );
			_majorGrid = (MajorGrid)info.GetValue( "majorGrid", typeof( MajorGrid ) );
			_minorGrid = (MinorGrid)info.GetValue( "minorGrid", typeof( MinorGrid ) );

			_isVisible = info.GetBoolean( "isVisible" );

			_title = (AxisLabel) info.GetValue( "title", typeof( AxisLabel ) );

			_minSpace = info.GetSingle( "minSpace" );

			_color = (Color)info.GetValue( "color", typeof( Color ) );

			_isAxisSegmentVisible = info.GetBoolean( "isAxisSegmentVisible" );


			_axisGap = info.GetSingle( "axisGap" );

			_scale = (Scale)info.GetValue( "scale", typeof( Scale ) );
			_scale._ownerAxis = this;

		}
Exemple #8
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see c_ref="TextScale" /> object from which to copy</param>
		/// <param name="owner">The <see c_ref="Axis" /> object that will own the
		/// new instance of <see c_ref="TextScale" /></param>
		public TextScale( Scale rhs, Axis owner )
			: base( rhs, owner )
		{
		}
Exemple #9
0
		/// <summary>
		/// Default constructor for <see c_ref="Axis"/> that sets all axis properties
		/// to default values as defined in the <see c_ref="Default"/> class.
		/// </summary>
		public Axis()
		{
			_scale = new LinearScale( this );

			_cross = 0.0;

			_crossAuto = true;

			_majorTic = new MajorTic();
			_minorTic = new MinorTic();

			_majorGrid = new MajorGrid();
			_minorGrid = new MinorGrid();

			_axisGap = Default.AxisGap;

			_minSpace = Default.MinSpace;
			_isVisible = true;

			_isAxisSegmentVisible = Default.IsAxisSegmentVisible;

			_title = new AxisLabel( "", Default.TitleFontFamily, Default.TitleFontSize,
					Default.TitleFontColor, Default.TitleFontBold,
					Default.TitleFontUnderline, Default.TitleFontItalic );
			_title.FontSpec.Fill = new Fill( Default.TitleFillColor, Default.TitleFillBrush,
					Default.TitleFillType );

			_title.FontSpec.Border.IsVisible = false;


			_color = Default.Color;

		}
Exemple #10
0
/*
		/// <summary>
		/// Implement the <see c_ref="ICloneable" /> interface in a typesafe manner by just
		/// calling the typed version of Clone />
		/// </summary>
		/// <remarks>
		/// Note that this method must be called with an explicit cast to ICloneable, and
		/// that it is inherently virtual.  For example:
		/// <code>
		/// ParentClass foo = new ChildClass();
		/// ChildClass bar = (ChildClass) ((ICloneable)foo).Clone();
		/// </code>
		/// Assume that ChildClass is inherited from ParentClass.  Even though foo is declared with
		/// ParentClass, it is actually an instance of ChildClass.  Calling the ICloneable implementation
		/// of Clone() on foo actually calls ChildClass.Clone() as if it were a virtual function.
		/// </remarks>
		/// <returns>A deep copy of this object</returns>
		object ICloneable.Clone()
		{
			throw new NotImplementedException( "Can't clone an abstract base type -- child types must implement ICloneable" );
			//return new PaneBase( this );
		}
*/

		/// <summary>
		/// A construction method that creates a new <see c_ref="Scale"/> object using the
		/// properties of an existing <see c_ref="Scale"/> object, but specifying a new
		/// <see c_ref="AxisType"/>.
		/// </summary>
		/// <remarks>
		/// This constructor is used to change the type of an existing <see c_ref="Axis" />.
		/// By specifying the old <see c_ref="Scale"/> object, you are giving a set of properties
		/// (which encompasses all fields associated with the scale, since the derived types
		/// have no fields) to be used in creating a new <see c_ref="Scale"/> object, only this
		/// time having the newly specified object type.</remarks>
		/// <param name="oldScale">The existing <see c_ref="Scale" /> object from which to
		/// copy the field data.</param>
		/// <param name="type">An <see c_ref="AxisType"/> representing the type of derived type
		/// of new <see c_ref="Scale" /> object to create.</param>
		/// <returns>The new <see c_ref="Scale"/> object.</returns>
		public Scale MakeNewScale( Scale oldScale, AxisType type )
		{
			switch ( type )
			{
				case AxisType.Linear:
					return new LinearScale( oldScale, _ownerAxis );
				case AxisType.Date:
					return new DateScale( oldScale, _ownerAxis );
				case AxisType.Log:
					return new LogScale( oldScale, _ownerAxis );
				case AxisType.Exponent:
					return new ExponentScale( oldScale, _ownerAxis );
				case AxisType.Ordinal:
					return new OrdinalScale( oldScale, _ownerAxis );
				case AxisType.Text:
					return new TextScale( oldScale, _ownerAxis );
				case AxisType.DateAsOrdinal:
					return new DateAsOrdinalScale( oldScale, _ownerAxis );
				case AxisType.LinearAsOrdinal:
					return new LinearAsOrdinalScale( oldScale, _ownerAxis );
				default:
					throw new Exception( "Implementation Error: Invalid AxisType" );
			}
		}
Exemple #11
0
		/// <summary>
		/// Copy Constructor.  Create a new <see c_ref="Scale" /> object based on the specified
		/// existing one.
		/// </summary>
		/// <param name="rhs">The <see c_ref="Scale" /> object to be copied.</param>
		/// <param name="owner">The <see c_ref="Axis" /> object that will own the
		/// new instance of <see c_ref="Scale" /></param>
		public Scale( Scale rhs, Axis owner )
		{
			_ownerAxis = owner;

			_min = rhs._min;
			_max = rhs._max;
			_majorStep = rhs._majorStep;
			_minorStep = rhs._minorStep;
			_exponent = rhs._exponent;
			_baseTic = rhs._baseTic;

			_minAuto = rhs._minAuto;
			_maxAuto = rhs._maxAuto;
			_majorStepAuto = rhs._majorStepAuto;
			_minorStepAuto = rhs._minorStepAuto;
			_magAuto = rhs._magAuto;
			_formatAuto = rhs._formatAuto;

			_minGrace = rhs._minGrace;
			_maxGrace = rhs._maxGrace;

			_mag = rhs._mag;

			_isUseTenPower = rhs._isUseTenPower;
			_isReverse = rhs._isReverse;
			_isPreventLabelOverlap = rhs._isPreventLabelOverlap;
			_isVisible = rhs._isVisible;
			_isSkipFirstLabel = rhs._isSkipFirstLabel;
			_isSkipLastLabel = rhs._isSkipLastLabel;
			_isSkipCrossLabel = rhs._isSkipCrossLabel;

			_majorUnit = rhs._majorUnit;
			_minorUnit = rhs._minorUnit;

			_format = rhs._format;

			_isLabelsInside = rhs._isLabelsInside;
			_align = rhs._align;
			_alignH = rhs._alignH;

			_fontSpec = rhs._fontSpec.Clone();

			_labelGap = rhs._labelGap;

			if ( rhs._textLabels != null )
				_textLabels = (string[])rhs._textLabels.Clone();
			else
				_textLabels = null;
		}
Exemple #12
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see c_ref="OrdinalScale" /> object from which to copy</param>
		/// <param name="owner">The <see c_ref="Axis" /> object that will own the
		/// new instance of <see c_ref="OrdinalScale" /></param>
		public OrdinalScale( Scale rhs, Axis owner )
			: base( rhs, owner )
		{
		}
Exemple #13
0
		internal static void PickScale( GraphPane pane, Graphics g, float scaleFactor, Scale scale )
		{
			// Test for trivial condition of range = 0 and pick a suitable default
			if ( scale._max - scale._min < 1.0 )
			{
				if ( scale._maxAuto )
					scale._max = scale._min + 0.5;
				else
					scale._min = scale._max - 0.5;
			}
			else
			{
				// Calculate the new step size
				if ( scale._majorStepAuto )
				{
					// Calculate the step size based on targetSteps
					scale._majorStep = CalcStepSize( scale._max - scale._min,
						( scale._ownerAxis is XAxis || scale._ownerAxis is X2Axis ) ?
								Default.TargetXSteps : Default.TargetYSteps );

					if ( scale.IsPreventLabelOverlap )
					{
						// Calculate the maximum number of labels
						double maxLabels = scale.CalcMaxLabels( g, pane, scaleFactor );

						// Calculate a step size based on the width of the labels
						double tmpStep = Math.Ceiling( ( scale._max - scale._min ) / maxLabels );

						// Use the greater of the two step sizes
						if ( tmpStep > scale._majorStep )
							scale._majorStep = tmpStep;
					}

				}

				scale._majorStep = (int)scale._majorStep;
				if ( scale._majorStep < 1.0 )
					scale._majorStep = 1.0;

				// Calculate the new minor step size
				if ( scale._minorStepAuto )
					scale._minorStep = CalcStepSize( scale._majorStep,
						( scale._ownerAxis is XAxis || scale._ownerAxis is X2Axis ) ?
								Default.TargetMinorXSteps : Default.TargetMinorYSteps );

				if ( scale._minAuto )
					scale._min -= 0.5;
				if ( scale._maxAuto )
					scale._max += 0.5;
			}
		}
Exemple #14
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see c_ref="LinearScale" /> object from which to copy</param>
		/// <param name="owner">The <see c_ref="Axis" /> object that will own the
		/// new instance of <see c_ref="LinearScale" /></param>
		public LinearScale( Scale rhs, Axis owner )
			: base( rhs, owner )
		{
		}