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> /// Construct a <see c_ref="ScaleState"/> from the specified <see c_ref="Axis"/> /// </summary> /// <param name="axis">The <see c_ref="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> /// 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 + 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; } */ Invalidate(); } }
/* #region events /// <summary> /// A delegate that allows full custom formatting of the Axis labels /// </summary> /// <param name="pane">The <see c_ref="GraphPane" /> for which the label is to be /// formatted</param> /// <param name="axis">The <see c_ref="Axis" /> for which the label is to be formatted</param> /// <param name="val">The value to be formatted</param> /// <param name="index">The zero-based index of the label to be formatted</param> /// <returns> /// A string value representing the label, or null if the ZedGraph should go ahead /// and generate the label according to the current settings</returns> /// <seealso c_ref="ScaleFormatEvent" /> public delegate string ScaleFormatHandler( GraphPane pane, Axis axis, double val, int index ); /// <summary> /// Subscribe to this event to handle custom formatting of the scale labels. /// </summary> public event ScaleFormatHandler ScaleFormatEvent; #endregion */ #region Methods /// <summary> /// Setup some temporary transform values in preparation for rendering the /// <see c_ref="Axis"/>. /// </summary> /// <remarks> /// This method is typically called by the parent <see c_ref="GraphPane"/> /// object as part of the <see c_ref="GraphPane.Draw"/> method. It is also /// called by <see c_ref="GraphPane.GeneralTransform(double,double,CoordType)"/> and /// <see c_ref="GraphPane.ReverseTransform( PointF, out double, out double )"/> /// methods to setup for coordinate transformations. /// </remarks> /// <param name="pane"> /// A reference to the <see c_ref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="axis"> /// The parent <see c_ref="Axis" /> for this <see c_ref="Scale" /> /// </param> virtual public void SetupScaleData( GraphPane pane, Axis axis ) { // save the ChartRect data for transforming scale values to pixels if ( axis is XAxis || axis is X2Axis ) { _minPix = pane.Chart._rect.Left; _maxPix = pane.Chart._rect.Right; } else { _minPix = pane.Chart._rect.Top; _maxPix = pane.Chart._rect.Bottom; } _minLinTemp = Linearize( _min ); _maxLinTemp = Linearize( _max ); }
/// <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 ) { }
/// <summary> /// Setup some temporary transform values in preparation for rendering the <see c_ref="Axis"/>. /// </summary> /// <remarks> /// This method is typically called by the parent <see c_ref="GraphPane"/> /// object as part of the <see c_ref="GraphPane.Draw"/> method. It is also /// called by <see c_ref="GraphPane.GeneralTransform(double,double,CoordType)"/> and /// <see c_ref="GraphPane.ReverseTransform( PointF, out double, out double )"/> /// methods to setup for coordinate transformations. /// </remarks> /// <param name="pane"> /// A reference to the <see c_ref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="axis"> /// The parent <see c_ref="Axis" /> for this <see c_ref="Scale" /> /// </param> override public 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> /// 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 ) { }
/// <summary> /// Basic constructor -- requires that the <see c_ref="Scale" /> object be intialized with /// a pre-existing owner <see c_ref="Axis" />. /// </summary> /// <param name="ownerAxis">The <see c_ref="Axis" /> object that is the owner of this /// <see c_ref="Scale" /> instance.</param> public Scale( Axis ownerAxis ) { _ownerAxis = ownerAxis; _min = 0.0; _max = 1.0; _majorStep = 0.1; _minorStep = 0.1; _exponent = 1.0; _mag = 0; _baseTic = PointPair.Missing; _minGrace = Default.MinGrace; _maxGrace = Default.MaxGrace; _minAuto = true; _maxAuto = true; _majorStepAuto = true; _minorStepAuto = true; _magAuto = true; _formatAuto = true; _isReverse = Default.IsReverse; _isUseTenPower = true; _isPreventLabelOverlap = true; _isVisible = true; _isSkipFirstLabel = false; _isSkipLastLabel = false; _isSkipCrossLabel = false; _majorUnit = DateUnit.Day; _minorUnit = DateUnit.Day; _format = null; _textLabels = null; _isLabelsInside = Default.IsLabelsInside; _align = Default.Align; _alignH = Default.AlignH; _fontSpec = new FontSpec( Default.FontFamily, Default.FontSize, Default.FontColor, Default.FontBold, Default.FontUnderline, Default.FontItalic, Default.FillColor, Default.FillBrush, Default.FillType ); _fontSpec.Border.IsVisible = false; _labelGap = Default.LabelGap; }
/// <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 ) { }
/// <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 ) { }
/// <summary> /// Default constructor that defines the owner <see c_ref="Axis" /> /// (containing object) for this new object. /// </summary> /// <param name="owner">The owner, or containing object, of this instance</param> public DateScale( Axis owner ) : base( 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 c_ref="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; }
public TextScale( Axis owner ) : base( owner ) { }
/// <summary> /// Draw all the <see c_ref="JapaneseCandleStick"/>'s to the specified <see c_ref="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 c_ref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see c_ref="JapaneseCandleStickItem"/> object representing the /// <see c_ref="JapaneseCandleStick"/>'s to be drawn.</param> /// <param name="baseAxis">The <see c_ref="Axis"/> class instance that defines the base (independent) /// axis for the <see c_ref="JapaneseCandleStick"/></param> /// <param name="valueAxis">The <see c_ref="Axis"/> class instance that defines the value (dependent) /// axis for the <see c_ref="JapaneseCandleStick"/></param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see c_ref="GraphPane"/> object using the /// <see c_ref="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, JapaneseCandleStickItem 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 ); Color tColor = _color; Color tFallingColor = _fallingColor; float tPenWidth = _width; Fill tRisingFill = _risingFill; Fill tFallingFill = _fallingFill; Border tRisingBorder = _risingBorder; Border tFallingBorder = _fallingBorder; if ( curve.IsSelected ) { tColor = Selection.Border.Color; tFallingColor = Selection.Border.Color; tPenWidth = Selection.Border.Width; tRisingFill = Selection.Fill; tFallingFill = Selection.Fill; tRisingBorder = Selection.Border; tFallingBorder = Selection.Border; } using ( Pen risingPen = new Pen( tColor, tPenWidth ) ) using ( Pen fallingPen = new Pen( tFallingColor, tPenWidth ) ) { // 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 && _gradientFill.IsGradientValueType ) { using ( Pen tPen = GetPen( pane, scaleFactor, pt ) ) Draw( g, pane, baseAxis is XAxis || baseAxis is X2Axis, pixBase, pixHigh, pixLow, pixOpen, pixClose, halfSize, scaleFactor, ( tPen ), ( close > open ? tRisingFill : tFallingFill ), ( close > open ? tRisingBorder : tFallingBorder ), pt ); } else Draw( g, pane, baseAxis is XAxis || baseAxis is X2Axis, pixBase, pixHigh, pixLow, pixOpen, pixClose, halfSize, scaleFactor, ( close > open ? risingPen : fallingPen ), ( close > open ? tRisingFill : tFallingFill ), ( close > open ? tRisingBorder : tFallingBorder ), pt ); } } } } }
/// <summary> /// Create a new clone of the current item, with a new owner assignment /// </summary> /// <param name="owner">The new <see c_ref="Axis" /> instance that will be /// the owner of the new Scale</param> /// <returns>A new <see c_ref="Scale" /> clone.</returns> abstract public Scale Clone( Axis owner );
/// <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; }
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; } } }
/// <summary> /// Create a new clone of the current item, with a new owner assignment /// </summary> /// <param name="owner">The new <see c_ref="Axis" /> instance that will be /// the owner of the new Scale</param> /// <returns>A new <see c_ref="Scale" /> clone.</returns> public override Scale Clone( Axis owner ) { return new DateScale( this, owner ); }
/// <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; }
/// <summary> /// Define suitable default ranges for an axis in the event that /// no data were available /// </summary> /// <param name="pane">The <see c_ref="GraphPane"/> of interest</param> /// <param name="axis">The <see c_ref="Axis"/> for which to set the range</param> internal void SetRange( GraphPane pane, Axis axis ) { if ( _rangeMin >= Double.MaxValue || _rangeMax <= Double.MinValue ) { // If this is a Y axis, and the main Y axis is valid, use it for defaults if ( axis != pane.XAxis && axis != pane.X2Axis && pane.YAxis.Scale._rangeMin < double.MaxValue && pane.YAxis.Scale._rangeMax > double.MinValue ) { _rangeMin = pane.YAxis.Scale._rangeMin; _rangeMax = pane.YAxis.Scale._rangeMax; } // Otherwise, if this is a Y axis, and the main Y2 axis is valid, use it for defaults else if ( axis != pane.XAxis && axis != pane.X2Axis && pane.Y2Axis.Scale._rangeMin < double.MaxValue && pane.Y2Axis.Scale._rangeMax > double.MinValue ) { _rangeMin = pane.Y2Axis.Scale._rangeMin; _rangeMax = pane.Y2Axis.Scale._rangeMax; } // Otherwise, just use 0 and 1 else { _rangeMin = 0; _rangeMax = 1; } } /* if ( yMinVal >= Double.MaxValue || yMaxVal <= Double.MinValue ) { if ( y2MinVal < Double.MaxValue && y2MaxVal > Double.MinValue ) { yMinVal = y2MinVal; yMaxVal = y2MaxVal; } else { yMinVal = 0; yMaxVal = 0.01; } } if ( y2MinVal >= Double.MaxValue || y2MaxVal <= Double.MinValue ) { if ( yMinVal < Double.MaxValue && yMaxVal > Double.MinValue ) { y2MinVal = yMinVal; y2MaxVal = yMaxVal; } else { y2MinVal = 0; y2MaxVal = 1; } } */ }
/// <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 ) { }
/// <summary> /// Draw the this <see c_ref="Bar"/> to the specified <see c_ref="Graphics"/> /// device as a bar at each defined point. This method /// is normally only called by the <see c_ref="BarItem.Draw"/> method of the /// <see c_ref="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 c_ref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see c_ref="CurveItem"/> object representing the /// <see c_ref="Bar"/>'s to be drawn.</param> /// <param name="baseAxis">The <see c_ref="Axis"/> class instance that defines the base (independent) /// axis for the <see c_ref="Bar"/></param> /// <param name="valueAxis">The <see c_ref="Axis"/> class instance that defines the value (dependent) /// axis for the <see c_ref="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 c_ref="GraphPane"/> object using the /// <see c_ref="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 ); }
/// <summary> /// Default constructor that defines the owner <see c_ref="Axis" /> /// (containing object) for this new object. /// </summary> /// <param name="owner">The owner, or containing object, of this instance</param> public LinearAsOrdinalScale( Axis owner ) : base( owner ) { }
/// <summary> /// Draw the specified single bar (an individual "point") of this series to the specified /// <see c_ref="Graphics"/> device. This method is not as efficient as /// <see c_ref="DrawBars"/>, which draws the bars for all points. It is intended to be used /// only for <see c_ref="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 c_ref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see c_ref="CurveItem"/> object representing the /// <see c_ref="Bar"/>'s to be drawn.</param> /// <param name="baseAxis">The <see c_ref="Axis"/> class instance that defines the base (independent) /// axis for the <see c_ref="Bar"/></param> /// <param name="valueAxis">The <see c_ref="Axis"/> class instance that defines the value (dependent) /// axis for the <see c_ref="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 c_ref="GraphPane"/> object using the /// <see c_ref="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> /// Create a new clone of the current item, with a new owner assignment /// </summary> /// <param name="owner">The new <see c_ref="Axis" /> instance that will be /// the owner of the new Scale</param> /// <returns>A new <see c_ref="Scale" /> clone.</returns> public override Scale Clone( Axis owner ) { return new LinearAsOrdinalScale( this, owner ); }
/// <summary> /// Protected internal routine that draws the specified single bar (an individual "point") /// of this series to the specified <see c_ref="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 c_ref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see c_ref="CurveItem"/> object representing the /// <see c_ref="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 c_ref="Axis"/> class instance that defines the base (independent) /// axis for the <see c_ref="Bar"/></param> /// <param name="valueAxis">The <see c_ref="Axis"/> class instance that defines the value (dependent) /// axis for the <see c_ref="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 c_ref="GraphPane"/> object using the /// <see c_ref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> virtual protected 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 ) Draw( g, pane, pixSide, pixSide + barWidth, pixLowVal, pixHiVal, scaleFactor, true, curve.IsSelected, curve.Points[index] ); else Draw( g, pane, pixLowVal, pixHiVal, pixSide, pixSide + barWidth, scaleFactor, true, curve.IsSelected, curve.Points[index] ); } }
/// <summary> /// Default constructor that defines the owner <see c_ref="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> /// Setup some temporary transform values in preparation for rendering the <see c_ref="Axis"/>. /// </summary> /// <remarks> /// This method is typically called by the parent <see c_ref="GraphPane"/> /// object as part of the <see c_ref="GraphPane.Draw"/> method. It is also /// called by <see c_ref="GraphPane.GeneralTransform(double,double,CoordType)"/> and /// <see c_ref="GraphPane.ReverseTransform( PointF, out double, out double )"/> /// methods to setup for coordinate transformations. /// </remarks> /// <param name="pane"> /// A reference to the <see c_ref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="axis"> /// The parent <see c_ref="Axis" /> for this <see c_ref="Scale" /> /// </param> override public void SetupScaleData( GraphPane pane, Axis axis ) { base.SetupScaleData( pane, axis ); _minLinTemp = Linearize( _min ); _maxLinTemp = Linearize( _max ); }
/// <summary> /// Create a new clone of the current item, with a new owner assignment /// </summary> /// <param name="owner">The new <see c_ref="Axis" /> instance that will be /// the owner of the new Scale</param> /// <returns>A new <see c_ref="Scale" /> clone.</returns> public override Scale Clone( Axis owner ) { return new ExponentScale( this, owner ); }
/// <summary> /// Default constructor that defines the owner <see c_ref="Axis" /> /// (containing object) for this new object. /// </summary> /// <param name="owner">The owner, or containing object, of this instance</param> public LogScale( Axis owner ) : base( owner ) { }