Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Axis"/> class. 
        /// Constructor for deserializing objects
        /// </summary>
        /// <param name="info">
        /// A <see cref="SerializationInfo"/> instance that defines the serialized data
        /// </param>
        /// <param name="context">
        /// A <see cref="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");

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

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

            this._isVisible = info.GetBoolean("isVisible");

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

            this._minSpace = info.GetSingle("minSpace");

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

            this._isAxisSegmentVisible = info.GetBoolean("isAxisSegmentVisible");

            this._axisGap = info.GetSingle("axisGap");

            this._scale = (Scale)info.GetValue("scale", typeof(Scale));
            this._scale._ownerAxis = this;
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Axis"/> class. Default constructor for <see cref="Axis"/> that sets all axis properties to default values as defined in the <see cref="Default"/> class.
        /// </summary>
        public Axis()
        {
            this._scale = new LinearScale(this);

            this._cross = 0.0;

            this._crossAuto = true;

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

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

            this._axisGap = Default.AxisGap;

            this._minSpace = Default.MinSpace;
            this._isVisible = true;

            this._isAxisSegmentVisible = Default.IsAxisSegmentVisible;

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

            this._title.FontSpec.Border.IsVisible = false;

            this._color = Default.Color;
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Axis"/> class. 
        /// The Copy Constructor.
        /// </summary>
        /// <param name="rhs">
        /// The Axis object from which to copy
        /// </param>
        public Axis(Axis rhs)
        {
            this._scale = rhs._scale.Clone(this);

            this._cross = rhs._cross;

            this._crossAuto = rhs._crossAuto;

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

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

            this._isVisible = rhs.IsVisible;

            this._isAxisSegmentVisible = rhs._isAxisSegmentVisible;

            this._title = rhs.Title.Clone();

            this._axisGap = rhs._axisGap;

            this._minSpace = rhs.MinSpace;

            this._color = rhs.Color;
        }
Пример #4
0
        /// <summary>
        /// Calculate a step size for a <see cref="AxisType.Date"/> scale. This method is used by <see cref="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 cref="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 cref="Scale.MajorUnit"/>,
        /// <see cref="Scale.MinorUnit"/>, <see cref="Scale.MinorStep"/>, and
        /// <see cref="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;
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DateScale"/> class. 
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">
 /// The <see cref="DateScale"/> object from which to copy
 /// </param>
 /// <param name="owner">
 /// The <see cref="Axis"/> object that will own the new instance of <see cref="DateScale"/>
 /// </param>
 public DateScale(Scale rhs, Axis owner)
     : base(rhs, owner)
 {
 }
Пример #6
0
        /// <summary>
        /// The pick scale.
        /// </summary>
        /// <param name="pane">
        /// The pane.
        /// </param>
        /// <param name="g">
        /// The g.
        /// </param>
        /// <param name="scaleFactor">
        /// The scale factor.
        /// </param>
        /// <param name="scale">
        /// The scale.
        /// </param>
        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;
                }
            }
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OrdinalScale"/> class. 
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">
 /// The <see cref="OrdinalScale"/> object from which to copy
 /// </param>
 /// <param name="owner">
 /// The <see cref="Axis"/> object that will own the new instance of <see cref="OrdinalScale"/>
 /// </param>
 public OrdinalScale(Scale rhs, Axis owner)
     : base(rhs, owner)
 {
 }
Пример #8
0
 /*
 /// <summary>
 /// Implement the <see cref="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 cref="Scale"/> object using the properties of an existing <see cref="Scale"/> object, but specifying
 /// a new
 /// <see cref="AxisType"/>.
 /// </summary>
 /// <remarks>
 /// This constructor is used to change the type of an existing <see cref="Axis"/>. By specifying the old <see cref="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 cref="Scale"/> object, only this time having the newly specified object type.
 /// </remarks>
 /// <param name="oldScale">
 /// The existing <see cref="Scale"/> object from which to copy the field data.
 /// </param>
 /// <param name="type">
 /// An <see cref="AxisType"/> representing the type of derived type of new <see cref="Scale"/> object to create.
 /// </param>
 /// <returns>
 /// The new <see cref="Scale"/> object.
 /// </returns>
 public Scale MakeNewScale(Scale oldScale, AxisType type)
 {
     switch (type)
     {
         case AxisType.Linear:
             return new LinearScale(oldScale, this._ownerAxis);
         case AxisType.Date:
             return new DateScale(oldScale, this._ownerAxis);
         case AxisType.Log:
             return new LogScale(oldScale, this._ownerAxis);
         case AxisType.Exponent:
             return new ExponentScale(oldScale, this._ownerAxis);
         case AxisType.Ordinal:
             return new OrdinalScale(oldScale, this._ownerAxis);
         case AxisType.Text:
             return new TextScale(oldScale, this._ownerAxis);
         case AxisType.DateAsOrdinal:
             return new DateAsOrdinalScale(oldScale, this._ownerAxis);
         case AxisType.LinearAsOrdinal:
             return new LinearAsOrdinalScale(oldScale, this._ownerAxis);
         default:
             throw new Exception("Implementation Error: Invalid AxisType");
     }
 }
Пример #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Scale"/> class. 
        /// Copy Constructor.  Create a new <see cref="Scale"/> object based on the specified existing one.
        /// </summary>
        /// <param name="rhs">
        /// The <see cref="Scale"/> object to be copied.
        /// </param>
        /// <param name="owner">
        /// The <see cref="Axis"/> object that will own the new instance of <see cref="Scale"/>
        /// </param>
        public Scale(Scale rhs, Axis owner)
        {
            this._ownerAxis = owner;

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

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

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

            this._mag = rhs._mag;

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

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

            this._format = rhs._format;

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

            this._fontSpec = rhs._fontSpec.Clone();

            this._labelGap = rhs._labelGap;

            if (rhs._textLabels != null)
            {
                this._textLabels = (string[])rhs._textLabels.Clone();
            }
            else
            {
                this._textLabels = null;
            }
        }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinearAsOrdinalScale"/> class. 
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">
 /// The <see cref="LinearAsOrdinalScale"/> object from which to copy
 /// </param>
 /// <param name="owner">
 /// The <see cref="Axis"/> object that will own the new instance of <see cref="LinearAsOrdinalScale"/>
 /// </param>
 public LinearAsOrdinalScale(Scale rhs, Axis owner)
     : base(rhs, owner)
 {
 }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinearScale"/> class. 
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">
 /// The <see cref="LinearScale"/> object from which to copy
 /// </param>
 /// <param name="owner">
 /// The <see cref="Axis"/> object that will own the new instance of <see cref="LinearScale"/>
 /// </param>
 public LinearScale(Scale rhs, Axis owner)
     : base(rhs, owner)
 {
 }
Пример #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogScale"/> class. 
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">
 /// The <see cref="LogScale"/> object from which to copy
 /// </param>
 /// <param name="owner">
 /// The <see cref="Axis"/> object that will own the new instance of <see cref="LogScale"/>
 /// </param>
 public LogScale(Scale rhs, Axis owner)
     : base(rhs, owner)
 {
 }
Пример #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExponentScale"/> class. 
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">
 /// The <see cref="ExponentScale"/> object from which to copy
 /// </param>
 /// <param name="owner">
 /// The <see cref="Axis"/> object that will own the new instance of <see cref="ExponentScale"/>
 /// </param>
 public ExponentScale(Scale rhs, Axis owner)
     : base(rhs, owner)
 {
 }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextScale"/> class. 
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">
 /// The <see cref="TextScale"/> object from which to copy
 /// </param>
 /// <param name="owner">
 /// The <see cref="Axis"/> object that will own the new instance of <see cref="TextScale"/>
 /// </param>
 public TextScale(Scale rhs, Axis owner)
     : base(rhs, owner)
 {
 }