Ejemplo n.º 1
0
 /// <summary>
 /// 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)
 {
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 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)
 {
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 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)
 {
 }
Ejemplo n.º 4
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="DateAsOrdinalScale" /> object from which to copy</param>
 /// <param name="owner">The <see cref="Axis" /> object that will own the
 /// new instance of <see cref="DateAsOrdinalScale" /></param>
 public DateAsOrdinalScale( Scale rhs, Axis owner )
     : base(rhs, owner)
 {
 }
Ejemplo n.º 5
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 = Scale.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;
        }
Ejemplo n.º 6
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 = Scale.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 = (double) 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 = Scale.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;
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 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)
 {
 }
Ejemplo n.º 8
0
 /// <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, _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" );
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 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 )
        {
            _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 = (FontSpec) rhs._fontSpec.Clone();

            _labelGap = rhs._labelGap;

            if ( rhs._textLabels != null )
                _textLabels = (string[])rhs._textLabels.Clone();
            else
                _textLabels = null;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 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)
 {
 }
Ejemplo n.º 11
0
        /// <summary>
        /// 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" );

            _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;
        }
Ejemplo n.º 12
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 = (AxisLabel) rhs.Title.Clone();

            _axisGap = rhs._axisGap;

            _minSpace = rhs.MinSpace;

            _color = rhs.Color;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 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()
        {
            _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;
        }
Ejemplo n.º 14
0
 /// <summary>
 /// 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)
 {
 }