//============================================================================ //ZedGraph Class Library - A Flexible Line Graph/Bar Graph Library in C# //Copyright ?2004 John Champion // //This library is free software; you can redistribute it and/or //modify it under the terms of the GNU Lesser General Public //License as published by the Free Software Foundation; either //version 2.1 of the License, or (at your option) any later version. // //This library is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //Lesser General Public License for more details. // //You should have received a copy of the GNU Lesser General Public //License along with this library; if not, write to the Free Software //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //============================================================================= using System; using System.Drawing; using System.Runtime.Serialization; using System.Security.Permissions; namespace DrawGraph { /// /// inherits from , and defines the /// special characteristics of a vertical axis, specifically located on /// the right side of the of the /// object /// /// /// John Champion /// $Revision: 3.16 $ $Date: 2007/04/16 00:03:06 $ [Serializable] public class YAxis : Axis, ICloneable, ISerializable { #region Defaults /// /// A simple struct that defines the /// default property values for the class. /// public new struct Default { // Default Y Axis properties /// /// The default display mode for the /// ( property). true to display the scale /// values, title, tic marks, false to hide the axis entirely. /// public static bool IsVisible = true; /// /// Determines if a line will be drawn at the zero value for the /// , that is, a line that /// divides the negative values from positive values. /// . /// public static bool IsZeroLine = true; } #endregion #region Constructors /// /// Default constructor that sets all properties to /// default values as defined in the class /// public YAxis() : this( "Y Axis" ) { } /// /// Default constructor that sets all properties to /// default values as defined in the class, except /// for the axis title /// /// The for this axis public YAxis( string title ) : base( title ) { _isVisible = Default.IsVisible; _majorGrid._isZeroLine = Default.IsZeroLine; _scale._fontSpec.Angle = 90.0F; _title._fontSpec.Angle = -180F; } /// /// The Copy Constructor /// /// The YAxis object from which to copy public YAxis( YAxis rhs ) : base( rhs ) { } /// /// Implement the interface in a typesafe manner by just /// calling the typed version of /// /// A deep copy of this object object ICloneable.Clone() { return this.Clone(); } /// /// Typesafe, deep-copy clone method. /// /// A new, independent copy of this class public YAxis Clone() { return new YAxis( this ); } #endregion #region Serialization /// /// Current schema value that defines the version of the serialized file /// public const int schema2 = 10; /// /// Constructor for deserializing objects /// /// A instance that defines the serialized data /// /// A instance that contains the serialized data /// protected YAxis( SerializationInfo info, StreamingContext context ) : base( info, 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( "schema2" ); } /// /// Populates a instance with the data needed to serialize the target object /// /// A instance that defines the serialized data /// A instance that contains the serialized data [SecurityPermissionAttribute( SecurityAction.Demand, SerializationFormatter = true )] public override void GetObjectData( SerializationInfo info, StreamingContext context ) { base.GetObjectData( info, context ); info.AddValue( "schema2", schema2 ); } #endregion #region Methods /// /// Setup the Transform Matrix to handle drawing of this /// /// /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// /// /// A reference to the object that is the parent or /// owner of this object. /// /// /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent object using the /// method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// override public void SetTransformMatrix( Graphics g, GraphPane pane, float scaleFactor ) { // Move the origin to the TopLeft of the ChartRect, which is the left // side of the axis (facing from the label side) g.TranslateTransform( pane.Chart._rect.Left, pane.Chart._rect.Top ); // rotate so this axis is in the left-right direction g.RotateTransform( 90 ); } /// /// Determines if this object is a "primary" one. /// /// /// The primary axes are the (always), the first /// in the /// ( = 0), and the first /// in the /// ( = 0). Note that /// and /// always reference the primary axes. /// /// /// A reference to the object that is the parent or /// owner of this object. /// /// true for a primary , false otherwise override internal bool IsPrimary( GraphPane pane ) { return this == pane.YAxis; } /// /// Calculate the "shift" size, in pixels, in order to shift the axis from its default /// location to the value specified by . /// /// /// A reference to the object that is the parent or /// owner of this object. /// /// The shift amount measured in pixels internal override float CalcCrossShift( GraphPane pane ) { double effCross = EffectiveCrossValue( pane ); if ( !_crossAuto ) return pane.XAxis.Scale._minPix - pane.XAxis.Scale.Transform( effCross ); else return 0; } /* override internal bool IsCrossed( GraphPane pane ) { return !this.crossAuto && this.cross > pane.XAxis.Min && this.cross < pane.XAxis.Max; } */ /// /// Gets the "Cross" axis that corresponds to this axis. /// /// /// The cross axis is the axis which determines the of this Axis when the /// Axis.Cross property is used. The /// cross axis for any or /// is always the primary , and /// the cross axis for any or is /// always the primary . /// /// /// A reference to the object that is the parent or /// owner of this object. /// override public Axis GetCrossAxis( GraphPane pane ) { return pane.XAxis; } // override internal float GetMinPix( GraphPane pane ) // { // return pane.Chart._rect.Top; // } #endregion } }