/// <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 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; }
/// <summary> /// Draw all the <see cref="OHLCBar"/>'s to the specified <see cref="Graphics"/> /// device as a candlestick at each defined point. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="OHLCBarItem"/> object representing the /// <see cref="OHLCBar"/>'s to be drawn.</param> /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent) /// axis for the <see cref="OHLCBar"/></param> /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent) /// axis for the <see cref="OHLCBar"/></param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public void Draw( Graphics g, GraphPane pane, OHLCBarItem curve, Axis baseAxis, Axis valueAxis, float scaleFactor ) { //ValueHandler valueHandler = new ValueHandler( pane, false ); float pixBase, pixHigh, pixLow, pixOpen, pixClose; if ( curve.Points != null ) { //float halfSize = _size * scaleFactor; float halfSize = GetBarWidth( pane, baseAxis, scaleFactor ); using ( Pen pen = !curve.IsSelected ? new Pen( _color, _width ) : new Pen( Selection.Border.Color, Selection.Border.Width ) ) // using ( Pen pen = new Pen( _color, _penWidth ) ) { // Loop over each defined point for ( int i = 0; i < curve.Points.Count; i++ ) { PointPair pt = curve.Points[i]; double date = pt.X; double high = pt.Y; double low = pt.Z; double open = PointPair.Missing; double close = PointPair.Missing; if ( pt is StockPt ) { open = ( pt as StockPt ).Open; close = ( pt as StockPt ).Close; } // Any value set to double max is invalid and should be skipped // This is used for calculated values that are out of range, divide // by zero, etc. // Also, any value <= zero on a log scale is invalid if ( !curve.Points[i].IsInvalid3D && ( date > 0 || !baseAxis._scale.IsLog ) && ( ( high > 0 && low > 0 ) || !valueAxis._scale.IsLog ) ) { pixBase = (int)( baseAxis.Scale.Transform( curve.IsOverrideOrdinal, i, date ) + 0.5 ); //pixBase = baseAxis.Scale.Transform( curve.IsOverrideOrdinal, i, date ); pixHigh = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, i, high ); pixLow = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, i, low ); if ( PointPair.IsValueInvalid( open ) ) pixOpen = Single.MaxValue; else pixOpen = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, i, open ); if ( PointPair.IsValueInvalid( close ) ) pixClose = Single.MaxValue; else pixClose = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, i, close ); if ( !curve.IsSelected && this._gradientFill.IsGradientValueType ) { using ( Pen tPen = GetPen( pane, scaleFactor, pt ) ) Draw( g, pane, baseAxis is XAxis || baseAxis is X2Axis, pixBase, pixHigh, pixLow, pixOpen, pixClose, halfSize, tPen ); } else Draw( g, pane, baseAxis is XAxis || baseAxis is X2Axis, pixBase, pixHigh, pixLow, pixOpen, pixClose, halfSize, pen ); } } } } }
/// <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; }
/// <summary> /// Draw all the <see cref="ErrorBar"/>'s to the specified <see cref="Graphics"/> /// device as a an error bar at each defined point. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="CurveItem"/> object representing the /// <see cref="Bar"/>'s to be drawn.</param> /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent) /// axis for the <see cref="Bar"/></param> /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent) /// axis for the <see cref="Bar"/></param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public void Draw( Graphics g, GraphPane pane, ErrorBarItem curve, Axis baseAxis, Axis valueAxis, float scaleFactor ) { ValueHandler valueHandler = new ValueHandler( pane, false ); float pixBase, pixValue, pixLowValue; double scaleBase, scaleValue, scaleLowValue; if ( curve.Points != null && this.IsVisible ) { using ( Pen pen = !curve.IsSelected ? new Pen( _color, _penWidth ) : new Pen( Selection.Border.Color, Selection.Border.Width ) ) { // Loop over each defined point for ( int i = 0; i < curve.Points.Count; i++ ) { valueHandler.GetValues( curve, i, out scaleBase, out scaleLowValue, out scaleValue ); // Any value set to double max is invalid and should be skipped // This is used for calculated values that are out of range, divide // by zero, etc. // Also, any value <= zero on a log scale is invalid if ( !curve.Points[i].IsInvalid3D && ( scaleBase > 0 || !baseAxis._scale.IsLog ) && ( ( scaleValue > 0 && scaleLowValue > 0 ) || !valueAxis._scale.IsLog ) ) { pixBase = baseAxis.Scale.Transform( curve.IsOverrideOrdinal, i, scaleBase ); pixValue = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, i, scaleValue ); pixLowValue = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, i, scaleLowValue ); //if ( this.fill.IsGradientValueType ) // brush = fill.MakeBrush( _rect, _points[i] ); this.Draw( g, pane, baseAxis is XAxis || baseAxis is X2Axis, pixBase, pixValue, pixLowValue, scaleFactor, pen, curve.IsSelected, curve.Points[i] ); } } } } }
public TextScale( Axis owner ) : base(owner) { }
/// <summary> /// Zoom the specified axis by the specified amount, with the center of the zoom at the /// (optionally) specified point. /// </summary> /// <remarks> /// This method is used for MouseWheel zoom operations</remarks> /// <param name="axis">The <see cref="Axis" /> to be zoomed.</param> /// <param name="zoomFraction">The zoom fraction, less than 1.0 to zoom in, greater than 1.0 to /// zoom out. That is, a value of 0.9 will zoom in such that the scale length is 90% of what /// it previously was.</param> /// <param name="centerVal">The location for the center of the zoom. This is only used if /// <see paramref="IsZoomOnMouseCenter" /> is true.</param> /// <param name="isZoomOnCenter">true if the zoom is to be centered at the /// <see paramref="centerVal" /> screen position, false for the zoom to be centered within /// the <see cref="Chart.Rect" />. /// </param> protected void ZoomScale( Axis axis, double zoomFraction, double centerVal, bool isZoomOnCenter ) { if ( axis != null && zoomFraction > 0.0001 && zoomFraction < 1000.0 ) { Scale scale = axis._scale; /* if ( axis.Scale.IsLog ) { double ratio = Math.Sqrt( axis._scale._max / axis._scale._min * zoomFraction ); if ( !isZoomOnCenter ) centerVal = Math.Sqrt( axis._scale._max * axis._scale._min ); axis._scale._min = centerVal / ratio; axis._scale._max = centerVal * ratio; } else { */ double minLin = axis._scale._minLinearized; double maxLin = axis._scale._maxLinearized; double range = ( maxLin - minLin ) * zoomFraction / 2.0; if ( !isZoomOnCenter ) centerVal = ( maxLin + minLin ) / 2.0; axis._scale._minLinearized = centerVal - range; axis._scale._maxLinearized = centerVal + range; // } axis._scale._minAuto = false; axis._scale._maxAuto = false; } }
/// <summary> /// Make a string label that corresponds to a user scale value. /// </summary> /// <param name="axis">The axis from which to obtain the scale value. This determines /// if it's a date value, linear, log, etc.</param> /// <param name="val">The value to be made into a label</param> /// <param name="iPt">The ordinal position of the value</param> /// <param name="isOverrideOrdinal">true to override the ordinal settings of the axis, /// and prefer the actual value instead.</param> /// <returns>The string label.</returns> protected string MakeValueLabel( Axis axis, double val, int iPt, bool isOverrideOrdinal ) { if ( axis != null ) { if ( axis.Scale.IsDate || axis.Scale.Type == AxisType.DateAsOrdinal ) { return XDate.ToString( val, _pointDateFormat ); } else if ( axis._scale.IsText && axis._scale._textLabels != null ) { int i = iPt; if ( isOverrideOrdinal ) i = (int)( val - 0.5 ); if ( i >= 0 && i < axis._scale._textLabels.Length ) return axis._scale._textLabels[i]; else return ( i + 1 ).ToString(); } else if ( axis.Scale.IsAnyOrdinal && axis.Scale.Type != AxisType.LinearAsOrdinal && !isOverrideOrdinal ) { return iPt.ToString( _pointValueFormat ); } else return val.ToString( _pointValueFormat ); } else return ""; }
/// <summary> /// Setup some temporary transform values in preparation for rendering the <see cref="Axis"/>. /// </summary> /// <remarks> /// This method is typically called by the parent <see cref="GraphPane"/> /// object as part of the <see cref="GraphPane.Draw"/> method. It is also /// called by <see cref="GraphPane.GeneralTransform(double,double,CoordType)"/> and /// <see cref="GraphPane.ReverseTransform( PointF, out double, out double )"/> /// methods to setup for coordinate transformations. /// </remarks> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="axis"> /// The parent <see cref="Axis" /> for this <see cref="Scale" /> /// </param> public override void SetupScaleData( GraphPane pane, Axis axis ) { base.SetupScaleData( pane, axis ); if ( _exponent > 0 ) { _minLinTemp = Linearize( _min ); _maxLinTemp = Linearize( _max ); } else if ( _exponent < 0 ) { _minLinTemp = Linearize( _max ); _maxLinTemp = Linearize( _min ); } }
/// <summary> /// Default constructor that defines the owner <see cref="Axis" /> /// (containing object) for this new object. /// </summary> /// <param name="owner">The owner, or containing object, of this instance</param> public DateAsOrdinalScale( Axis owner ) : base(owner) { }
/// <summary> /// Protected internal routine that draws the specified single bar (an individual "point") /// of this series to the specified <see cref="Graphics"/> device. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="CurveItem"/> object representing the /// <see cref="Bar"/>'s to be drawn.</param> /// <param name="index"> /// The zero-based index number for the single bar to be drawn. /// </param> /// <param name="pos"> /// The ordinal position of the this bar series (0=first bar, 1=second bar, etc.) /// in the cluster of bars. /// </param> /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent) /// axis for the <see cref="Bar"/></param> /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent) /// axis for the <see cref="Bar"/></param> /// <param name="barWidth"> /// The width of each bar, in pixels. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> protected virtual void DrawSingleBar( Graphics g, GraphPane pane, CurveItem curve, int index, int pos, Axis baseAxis, Axis valueAxis, float barWidth, float scaleFactor ) { // pixBase = pixel value for the bar center on the base axis // pixHiVal = pixel value for the bar top on the value axis // pixLowVal = pixel value for the bar bottom on the value axis float pixBase, pixHiVal, pixLowVal; float clusterWidth = pane.BarSettings.GetClusterWidth(); //float barWidth = curve.GetBarWidth( pane ); float clusterGap = pane._barSettings.MinClusterGap * barWidth; float barGap = barWidth * pane._barSettings.MinBarGap; // curBase = the scale value on the base axis of the current bar // curHiVal = the scale value on the value axis of the current bar // curLowVal = the scale value of the bottom of the bar double curBase, curLowVal, curHiVal; ValueHandler valueHandler = new ValueHandler( pane, false ); valueHandler.GetValues( curve, index, out curBase, out curLowVal, out curHiVal ); // Any value set to double max is invalid and should be skipped // This is used for calculated values that are out of range, divide // by zero, etc. // Also, any value <= zero on a log scale is invalid if ( !curve.Points[index].IsInvalid ) { // calculate a pixel value for the top of the bar on value axis pixLowVal = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, index, curLowVal ); pixHiVal = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, index, curHiVal ); // calculate a pixel value for the center of the bar on the base axis pixBase = baseAxis.Scale.Transform( curve.IsOverrideOrdinal, index, curBase ); // Calculate the pixel location for the side of the bar (on the base axis) float pixSide = pixBase - clusterWidth / 2.0F + clusterGap / 2.0F + pos * ( barWidth + barGap ); // Draw the bar if ( pane._barSettings.Base == BarBase.X ) this.Draw( g, pane, pixSide, pixSide + barWidth, pixLowVal, pixHiVal, scaleFactor, true, curve.IsSelected, curve.Points[index] ); else this.Draw( g, pane, pixLowVal, pixHiVal, pixSide, pixSide + barWidth, scaleFactor, true, curve.IsSelected, curve.Points[index] ); } }
/// <summary> /// Draw the specified single bar (an individual "point") of this series to the specified /// <see cref="Graphics"/> device. This method is not as efficient as /// <see cref="DrawBars"/>, which draws the bars for all points. It is intended to be used /// only for <see cref="BarType.SortedOverlay"/>, which requires special handling of each bar. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="CurveItem"/> object representing the /// <see cref="Bar"/>'s to be drawn.</param> /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent) /// axis for the <see cref="Bar"/></param> /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent) /// axis for the <see cref="Bar"/></param> /// <param name="pos"> /// The ordinal position of the this bar series (0=first bar, 1=second bar, etc.) /// in the cluster of bars. /// </param> /// <param name="index"> /// The zero-based index number for the single bar to be drawn. /// </param> /// <param name="barWidth"> /// The width of each bar, in pixels. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public void DrawSingleBar( Graphics g, GraphPane pane, CurveItem curve, Axis baseAxis, Axis valueAxis, int pos, int index, float barWidth, float scaleFactor ) { // Make sure that a bar value exists for the current curve and current ordinal position if ( index >= curve.Points.Count ) return; // For Overlay and Stack bars, the position is always zero since the bars are on top // of eachother if ( pane._barSettings.Type == BarType.Overlay || pane._barSettings.Type == BarType.Stack || pane._barSettings.Type == BarType.PercentStack ) pos = 0; // Draw the specified bar DrawSingleBar( g, pane, curve, index, pos, baseAxis, valueAxis, barWidth, scaleFactor ); }
/// <summary> /// Draw the this <see cref="Bar"/> to the specified <see cref="Graphics"/> /// device as a bar at each defined point. This method /// is normally only called by the <see cref="BarItem.Draw"/> method of the /// <see cref="BarItem"/> object /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="CurveItem"/> object representing the /// <see cref="Bar"/>'s to be drawn.</param> /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent) /// axis for the <see cref="Bar"/></param> /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent) /// axis for the <see cref="Bar"/></param> /// <param name="barWidth"> /// The width of each bar, in pixels. /// </param> /// <param name="pos"> /// The ordinal position of the this bar series (0=first bar, 1=second bar, etc.) /// in the cluster of bars. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public void DrawBars( Graphics g, GraphPane pane, CurveItem curve, Axis baseAxis, Axis valueAxis, float barWidth, int pos, float scaleFactor ) { // For non-cluster bar types, the position is always zero since the bars are on top // of eachother BarType barType = pane._barSettings.Type; if ( barType == BarType.Overlay || barType == BarType.Stack || barType == BarType.PercentStack || barType == BarType.SortedOverlay ) pos = 0; // Loop over each defined point and draw the corresponding bar for ( int i=0; i<curve.Points.Count; i++ ) DrawSingleBar( g, pane, curve, i, pos, baseAxis, valueAxis, barWidth, scaleFactor ); }
private void SetSpace( Axis axis, float clientSize, ref float spaceNorm, ref float spaceAlt ) { //spaceNorm = 0; //spaceAlt = 0; float crossFrac = axis.CalcCrossFraction( this ); float crossPix = crossFrac * ( 1 + crossFrac ) * ( 1 + crossFrac * crossFrac ) * clientSize; if ( !axis.IsPrimary( this ) && axis.IsCrossShifted( this ) ) axis._tmpSpace = 0; if ( axis._tmpSpace < crossPix ) axis._tmpSpace = 0; else if ( crossPix > 0 ) axis._tmpSpace -= crossPix; if ( axis._scale._isLabelsInside && ( axis.IsPrimary( this ) || ( crossFrac != 0.0 && crossFrac != 1.0 ) ) ) spaceAlt = axis._tmpSpace; else spaceNorm = axis._tmpSpace; }
private void ForceNumTics( Axis axis, int numTics ) { if ( axis._scale.MaxAuto ) { int nTics = axis._scale.CalcNumTics(); if ( nTics < numTics ) axis._scale._maxLinearized += axis._scale._majorStep * ( numTics - nTics ); } }
private void SetScroll( ScrollBar scrollBar, Axis axis, double scrollMin, double scrollMax ) { if ( scrollBar != null && axis != null ) { scrollBar.Minimum = 0; scrollBar.Maximum = _ScrollControlSpan - 1; if ( scrollMin > axis._scale._min ) scrollMin = axis._scale._min; if ( scrollMax < axis._scale._max ) scrollMax = axis._scale._max; int val = 0; Scale scale = axis._scale; double minLinearized = scale._minLinearized; double maxLinearized = scale._maxLinearized; scrollMin = scale.Linearize( scrollMin ); scrollMax = scale.Linearize( scrollMax ); double scrollMin2 = scrollMax - ( maxLinearized - minLinearized ); /* if ( axis.Scale.IsLog ) scrollMin2 = scrollMax / ( axis._scale._max / axis._scale._min ); else scrollMin2 = scrollMax - ( axis._scale._max - axis._scale._min ); */ if ( scrollMin >= scrollMin2 ) { //scrollBar.Visible = false; scrollBar.Enabled = false; scrollBar.Value = 0; } else { double ratio = ( maxLinearized - minLinearized ) / ( scrollMax - scrollMin ); /* if ( axis.Scale.IsLog ) ratio = ( Math.Log( axis._scale._max ) - Math.Log( axis._scale._min ) ) / ( Math.Log( scrollMax ) - Math.Log( scrollMin ) ); else ratio = ( axis._scale._max - axis._scale._min ) / ( scrollMax - scrollMin ); */ int largeChange = (int)( ratio * _ScrollControlSpan + 0.5 ); if ( largeChange < 1 ) largeChange = 1; scrollBar.LargeChange = largeChange; int smallChange = largeChange / _ScrollSmallRatio; if ( smallChange < 1 ) smallChange = 1; scrollBar.SmallChange = smallChange; int span = _ScrollControlSpan - largeChange; val = (int)( ( minLinearized - scrollMin ) / ( scrollMin2 - scrollMin ) * span + 0.5 ); /* if ( axis.Scale.IsLog ) val = (int)( ( Math.Log( axis._scale._min ) - Math.Log( scrollMin ) ) / ( Math.Log( scrollMin2 ) - Math.Log( scrollMin ) ) * span + 0.5 ); else val = (int)( ( axis._scale._min - scrollMin ) / ( scrollMin2 - scrollMin ) * span + 0.5 ); */ if ( val < 0 ) val = 0; else if ( val > span ) val = span; //if ( ( axis is XAxis && axis.IsReverse ) || ( ( ! axis is XAxis ) && ! axis.IsReverse ) ) if ( ( axis is XAxis ) == axis.Scale.IsReverse ) val = span - val; if ( val < scrollBar.Minimum ) val = scrollBar.Minimum; if ( val > scrollBar.Maximum ) val = scrollBar.Maximum; scrollBar.Value = val; scrollBar.Enabled = true; //scrollBar.Visible = true; } } }
private void Synchronize( Axis source, Axis dest ) { dest._scale._min = source._scale._min; dest._scale._max = source._scale._max; dest._scale._majorStep = source._scale._majorStep; dest._scale._minorStep = source._scale._minorStep; dest._scale._minAuto = source._scale._minAuto; dest._scale._maxAuto = source._scale._maxAuto; dest._scale._majorStepAuto = source._scale._majorStepAuto; dest._scale._minorStepAuto = source._scale._minorStepAuto; }
/// <summary> /// Default constructor that defines the owner <see cref="Axis" /> /// (containing object) for this new object. /// </summary> /// <param name="owner">The owner, or containing object, of this instance</param> public ExponentScale( Axis owner ) : base(owner) { }
/// <summary> /// Handle a panning operation for the specified <see cref="Axis" />. /// </summary> /// <param name="axis">The <see cref="Axis" /> to be panned</param> /// <param name="startVal">The value where the pan started. The scale range /// will be shifted by the difference between <see paramref="startVal" /> and /// <see paramref="endVal" />. /// </param> /// <param name="endVal">The value where the pan ended. The scale range /// will be shifted by the difference between <see paramref="startVal" /> and /// <see paramref="endVal" />. /// </param> protected void PanScale( Axis axis, double startVal, double endVal ) { if ( axis != null ) { Scale scale = axis._scale; double delta = scale.Linearize( startVal ) - scale.Linearize( endVal ); scale._minLinearized += delta; scale._maxLinearized += delta; scale._minAuto = false; scale._maxAuto = false; /* if ( axis.Type == AxisType.Log ) { axis._scale._min *= startVal / endVal; axis._scale._max *= startVal / endVal; } else { axis._scale._min += startVal - endVal; axis._scale._max += startVal - endVal; } */ } }
/// <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) { }
/// <summary> /// Create a new clone of the current item, with a new owner assignment /// </summary> /// <param name="owner">The new <see cref="Axis" /> instance that will be /// the owner of the new Scale</param> /// <returns>A new <see cref="Scale" /> clone.</returns> public override Scale Clone( Axis owner ) { return new TextScale( this, owner ); }
/// <summary> /// Create a new clone of the current item, with a new owner assignment /// </summary> /// <param name="owner">The new <see cref="Axis" /> instance that will be /// the owner of the new Scale</param> /// <returns>A new <see cref="Scale" /> clone.</returns> public override Scale Clone( Axis owner ) { return new OrdinalScale( this, owner ); }
/// <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) { }
/// <summary> /// Default constructor that defines the owner <see cref="Axis" /> /// (containing object) for this new object. /// </summary> /// <param name="owner">The owner, or containing object, of this instance</param> public OrdinalScale( Axis owner ) : base(owner) { }
/// <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> /// 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) { }
/// <summary> /// Determine the minimum increment between individual points to be used for /// calculating a bar size that fits without overlapping /// </summary> /// <param name="list">The <see cref="IPointList" /> list of points for the bar /// of interest</param> /// <param name="baseAxis">The base axis for the bar</param> /// <returns>The minimum increment between bars along the base axis</returns> internal static double GetMinStepSize( IPointList list, Axis baseAxis ) { double minStep = Double.MaxValue; if ( list.Count <= 0 || baseAxis._scale.IsAnyOrdinal ) return 1.0; PointPair lastPt = list[0]; for ( int i = 1; i < list.Count; i++ ) { PointPair pt = list[i]; if ( !pt.IsInvalid || !lastPt.IsInvalid ) { double step; if ( baseAxis is XAxis || baseAxis is X2Axis ) step = pt.X - lastPt.X; else step = pt.Y - lastPt.Y; if ( step > 0 && step < minStep ) minStep = step; } lastPt = pt; } double range = baseAxis.Scale._maxLinearized - baseAxis.Scale._minLinearized; if ( range <= 0 ) minStep = 1.0; // else if ( minStep <= 0 || minStep < 0.001 * range || minStep > range ) else if ( minStep <= 0 || minStep > range ) minStep = 0.1 * range; return minStep; }
/* /// <summary> /// Use the MouseCaptureChanged as an indicator for the start and end of a scrolling operation /// </summary> private void ScrollBarMouseCaptureChanged( object sender, EventArgs e ) { return; ScrollBar scrollBar = sender as ScrollBar; if ( scrollBar != null ) { // If this is the start of a new scroll, then Capture will be true if ( scrollBar.Capture ) { // save the original zoomstate //_zoomState = new ZoomState( this.GraphPane, ZoomState.StateType.Scroll ); ZoomStateSave( this.GraphPane, ZoomState.StateType.Scroll ); } else { // push the prior saved zoomstate, since the scale ranges have already been changed on // the fly during the scrolling operation if ( _zoomState != null && _zoomState.IsChanged( this.GraphPane ) ) { //this.GraphPane.ZoomStack.Push( _zoomState ); ZoomStatePush( this.GraphPane ); // Provide Callback to notify the user of pan events if ( this.ScrollDoneEvent != null ) this.ScrollDoneEvent( this, scrollBar, _zoomState, new ZoomState( this.GraphPane, ZoomState.StateType.Scroll ) ); _zoomState = null; } } } } */ private void HandleScroll( Axis axis, int newValue, double scrollMin, double scrollMax, int largeChange, bool reverse ) { if ( axis != null ) { if ( scrollMin > axis._scale._min ) scrollMin = axis._scale._min; if ( scrollMax < axis._scale._max ) scrollMax = axis._scale._max; int span = _ScrollControlSpan - largeChange; if ( span <= 0 ) return; if ( reverse ) newValue = span - newValue; Scale scale = axis._scale; double delta = scale._maxLinearized - scale._minLinearized; double scrollMin2 = scale.Linearize( scrollMax ) - delta; scrollMin = scale.Linearize( scrollMin ); //scrollMax = scale.Linearize( scrollMax ); double val = scrollMin + (double)newValue / (double)span * ( scrollMin2 - scrollMin ); scale._minLinearized = val; scale._maxLinearized = val + delta; /* if ( axis.Scale.IsLog ) { double ratio = axis._scale._max / axis._scale._min; double scrollMin2 = scrollMax / ratio; double val = scrollMin * Math.Exp( (double)newValue / (double)span * ( Math.Log( scrollMin2 ) - Math.Log( scrollMin ) ) ); axis._scale._min = val; axis._scale._max = val * ratio; } else { double delta = axis._scale._max - axis._scale._min; double scrollMin2 = scrollMax - delta; double val = scrollMin + (double)newValue / (double)span * ( scrollMin2 - scrollMin ); axis._scale._min = val; axis._scale._max = val + delta; } */ this.Invalidate(); } }
/// <summary> /// Returns the width of the candleStick, in pixels, based on the settings for /// <see cref="Size"/> and <see cref="IsAutoSize"/>. /// </summary> /// <param name="pane">The parent <see cref="GraphPane"/> object.</param> /// <param name="baseAxis">The <see cref="Axis"/> object that /// represents the bar base (independent axis).</param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> /// <returns>The width of each bar, in pixel units</returns> public float GetBarWidth( GraphPane pane, Axis baseAxis, float scaleFactor ) { float width; if ( _isAutoSize ) width = baseAxis._scale.GetClusterWidth( _userScaleSize ) / ( 1.0F + pane._barSettings.MinClusterGap ) / 2.0f; else width = (float)( _size * scaleFactor ) / 2.0f; // use integral size return (int)(width + 0.5f); }
/// <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; }