Ejemplo n.º 1
0
		/// <summary>
		/// Create a <see c_ref="TextObj" /> for each bar in the <see c_ref="GraphPane" />.
		/// </summary>
		/// <remarks>
		/// This method will go through the bars, create a label that corresponds to the bar value,
		/// and place it on the graph depending on user preferences.  This works for horizontal or
		/// vertical bars in clusters or stacks, but only for <see c_ref="BarItem" /> types.  This method
		/// does not apply to <see c_ref="ErrorBarItem" /> or <see c_ref="HiLowBarItem" /> objects.
		/// Call this method only after calling <see c_ref="GraphPane.AxisChange()" />.
		/// </remarks>
		/// <param name="pane">The GraphPane in which to place the text labels.</param>
		/// <param name="isBarCenter">true to center the labels inside the bars, false to
		/// place the labels just above the top of the bar.</param>
		/// <param name="valueFormat">The double.ToString string format to use for creating
		/// the labels.
		/// </param>
		/// <param name="fontColor">The color in which to draw the labels</param>
		/// <param name="fontFamily">The string name of the font family to use for the labels</param>
		/// <param name="fontSize">The floating point size of the font, in scaled points</param>
		/// <param name="isBold">true for a bold font type, false otherwise</param>
		/// <param name="isItalic">true for an italic font type, false otherwise</param>
		/// <param name="isUnderline">true for an underline font type, false otherwise</param>
		public static void CreateBarLabels( GraphPane pane, bool isBarCenter, string valueFormat,
			string fontFamily, float fontSize, Color fontColor, bool isBold, bool isItalic,
			bool isUnderline )
		{
			bool isVertical = pane.BarSettings.Base == BarBase.X;

			// keep a count of the number of BarItems
			int curveIndex = 0;

			// Get a valuehandler to do some calculations for us
			ValueHandler valueHandler = new ValueHandler( pane, true );

			// Loop through each curve in the list
			foreach ( CurveItem curve in pane.CurveList )
			{
				// work with BarItems only
				BarItem bar = curve as BarItem;
				if ( bar != null )
				{
					IPointList points = curve.Points;

					// ADD JKB 9/21/07
					// The labelOffset should depend on whether the curve is YAxis or Y2Axis.
					// JHC - Generalize to any value axis
					// Make the gap between the bars and the labels = 1.5% of the axis range
					float labelOffset;

					Scale scale = curve.ValueAxis( pane ).Scale;
					labelOffset = (float)( scale._max - scale._min ) * 0.015f;

					// Loop through each point in the BarItem
					for ( int i = 0; i < points.Count; i++ )
					{
						// Get the high, low and base values for the current bar
						// note that this method will automatically calculate the "effective"
						// values if the bar is stacked
						double baseVal, lowVal, hiVal;
						valueHandler.GetValues( curve, i, out baseVal, out lowVal, out hiVal );

						// Get the value that corresponds to the center of the bar base
						// This method figures out how the bars are positioned within a cluster
						float centerVal = (float)valueHandler.BarCenterValue( bar,
							bar.GetBarWidth( pane ), i, baseVal, curveIndex );

						// Create a text label -- note that we have to go back to the original point
						// data for this, since hiVal and lowVal could be "effective" values from a bar stack
						string barLabelText = ( isVertical ? points[i].Y : points[i].X ).ToString( valueFormat );

						// Calculate the position of the label -- this is either the X or the Y coordinate
						// depending on whether they are horizontal or vertical bars, respectively
						float position;
						if ( isBarCenter )
							position = (float)( hiVal + lowVal ) / 2.0f;
						else if ( hiVal >= 0 )
							position = (float)hiVal + labelOffset;
						else
							position = (float)hiVal - labelOffset;

						// Create the new TextObj
						TextObj label;
						if ( isVertical )
							label = new TextObj( barLabelText, centerVal, position );
						else
							label = new TextObj( barLabelText, position, centerVal );

						label.FontSpec.Family = fontFamily;

						// Configure the TextObj

                  // CHANGE JKB 9/21/07
                  // CoordinateFrame should depend on whether curve is YAxis or Y2Axis.
						label.Location.CoordinateFrame =
							(isVertical && curve.IsY2Axis) ? CoordType.AxisXY2Scale : CoordType.AxisXYScale;

						label.FontSpec.Size = fontSize;
						label.FontSpec.FontColor = fontColor;
						label.FontSpec.IsItalic = isItalic;
						label.FontSpec.IsBold = isBold;
						label.FontSpec.IsUnderline = isUnderline;

						label.FontSpec.Angle = isVertical ? 90 : 0;
						label.Location.AlignH = isBarCenter ? AlignH.Center :
									( hiVal >= 0 ? AlignH.Left : AlignH.Right );
						label.Location.AlignV = AlignV.Center;
						label.FontSpec.Border.IsVisible = false;
						label.FontSpec.Fill.IsVisible = false;

						// Add the TextObj to the GraphPane
						pane.GraphObjList.Add( label );
					}
					curveIndex++;
				}
			}
		}
Ejemplo n.º 2
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="ggn">The <see c_ref="GasGaugeNeedle"/> object from which to copy</param>
		public GasGaugeNeedle( GasGaugeNeedle ggn )
			: base( ggn )
		{
			NeedleValue = ggn.NeedleValue;
			NeedleColor = ggn.NeedleColor;
			NeedleWidth = ggn.NeedleWidth;
			SweepAngle = ggn.SweepAngle;
			_border = ggn.Border.Clone();
			_labelDetail = ggn.LabelDetail.Clone();
			_labelDetail.FontSpec.Size = ggn.LabelDetail.FontSpec.Size;
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Constructor for deserializing objects
		/// </summary>
		/// <param name="info">A <see c_ref="SerializationInfo"/> instance that defines the serialized data
		/// </param>
		/// <param name="context">A <see c_ref="StreamingContext"/> instance that contains the serialized data
		/// </param>
		protected GasGaugeNeedle( 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" );

			_labelDetail = (TextObj)info.GetValue( "labelDetail", typeof( TextObj ) );
			_fill = (Fill)info.GetValue( "fill", typeof( Fill ) );
			_border = (Border)info.GetValue( "border", typeof( Border ) );
			_needleValue = info.GetDouble( "needleValue" );
			_boundingRectangle = (RectangleF)info.GetValue( "boundingRectangle", typeof( RectangleF ) );
			_slicePath = (GraphicsPath)info.GetValue( "slicePath", typeof( GraphicsPath ) );
			_sweepAngle = (float)info.GetDouble( "sweepAngle" );
			_color = (Color)info.GetValue( "color", typeof( Color ) );
		}
Ejemplo n.º 4
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="ggr">The <see c_ref="GasGaugeRegion"/> object from which to copy</param>
		public GasGaugeRegion( GasGaugeRegion ggr )
			: base( ggr )
		{
			_minValue = ggr._minValue;
			_maxValue = ggr._maxValue;
			_color = ggr._color;
			_startAngle = ggr._startAngle;
			_sweepAngle = ggr._sweepAngle;
			_border = ggr._border.Clone();
			_labelDetail = ggr._labelDetail.Clone();
		}
Ejemplo n.º 5
0
		/// <summary>
		/// Create a new <see c_ref="GasGaugeNeedle"/>
		/// </summary>
		/// <param name="label">The value associated with this <see c_ref="GasGaugeNeedle"/>
		/// instance.</param>
		/// <param name="color">The display color for this <see c_ref="GasGaugeNeedle"/>
		/// instance.</param>
		/// <param name="val">The value of this <see c_ref="GasGaugeNeedle"/>.</param>
		public GasGaugeNeedle( string label, double val, Color color )
			: base( label )
		{
			NeedleValue = val;
			NeedleColor = color;
			NeedleWidth = Default.NeedleWidth;
			SweepAngle = 0f;
			_border = new Border( Default.BorderColor, Default.BorderWidth );
			_labelDetail = new TextObj();
			_labelDetail.FontSpec.Size = Default.FontSize;
			_slicePath = null;
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Constructor for deserializing objects
		/// </summary>
		/// <param name="info">A <see c_ref="SerializationInfo"/> instance that defines the serialized data
		/// </param>
		/// <param name="context">A <see c_ref="StreamingContext"/> instance that contains the serialized data
		/// </param>
		protected PieItem( 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" );

			_displacement = info.GetDouble( "displacement" );
			_labelDetail = (TextObj)info.GetValue( "labelDetail", typeof( TextObj ) );
			_fill = (Fill)info.GetValue( "fill", typeof( Fill ) );
			_border = (Border)info.GetValue( "border", typeof( Border ) );
			_pieValue = info.GetDouble( "pieValue" );
			_labelType = (PieLabelType)info.GetValue( "labelType", typeof( PieLabelType ) );
			_intersectionPoint = (PointF)info.GetValue( "intersectionPoint", typeof( PointF ) );
			_boundingRectangle = (RectangleF)info.GetValue( "boundingRectangle", typeof( RectangleF ) );
			_pivotPoint = (PointF)info.GetValue( "pivotPoint", typeof( PointF ) );
			_endPoint = (PointF)info.GetValue( "endPoint", typeof( PointF ) );
			// _slicePath = (GraphicsPath)info.GetValue( "slicePath", typeof( GraphicsPath ) );
			_startAngle = (float)info.GetDouble( "startAngle" );
			_sweepAngle = (float)info.GetDouble( "sweepAngle" );
			_midAngle = (float)info.GetDouble( "midAngle" );
			_labelStr = info.GetString( "labelStr" );
			_valueDecimalDigits = info.GetInt32( "valueDecimalDigits" );
			_percentDecimalDigits = info.GetInt32( "percentDecimalDigits" );
		}
Ejemplo n.º 7
0
		/// <summary>
		/// Create a new <see c_ref="GasGaugeRegion"/>
		/// </summary>
		/// <param name="label">The value associated with this <see c_ref="GasGaugeRegion"/> instance.</param>
		/// <param name="color">The display color for this <see c_ref="GasGaugeRegion"/> instance.</param>
		/// <param name="minVal">The minimum value of this <see c_ref="GasGaugeNeedle"/>.</param>
		/// <param name="maxVal">The maximum value of this <see c_ref="GasGaugeNeedle"/>.</param>
		public GasGaugeRegion( string label, double minVal, double maxVal, Color color )
			: base( label )
		{
			MinValue = minVal;
			MaxValue = maxVal;
			RegionColor = color;
			StartAngle = 0f;
			SweepAngle = 0f;
			_border = new Border( Default.BorderColor, Default.BorderWidth );
			_labelDetail = new TextObj();
			_labelDetail.FontSpec.Size = Default.FontSize;
			_slicePath = null;
		}
Ejemplo n.º 8
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see c_ref="PieItem"/> object from which to copy</param>
		public PieItem( PieItem rhs )
			: base( rhs )
		{
			_pieValue = rhs._pieValue;
			_fill = rhs._fill.Clone();
			Border = rhs._border.Clone();
			_displacement = rhs._displacement;
			_labelDetail = rhs._labelDetail.Clone();
			_labelType = rhs._labelType;
			_valueDecimalDigits = rhs._valueDecimalDigits;
			_percentDecimalDigits = rhs._percentDecimalDigits;
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Create a new <see c_ref="PieItem"/>.
		/// </summary>
		/// <param name="pieValue">The value associated with this <see c_ref="PieItem"/> instance.</param>
		/// <param name="color">The display color for this <see c_ref="PieItem"/> instance.</param>
		/// <param name="displacement">The amount this <see c_ref="PieItem"/>  instance will be 
		/// displaced from the center point.</param>
		/// <param name="label">Text label for this <see c_ref="PieItem"/> instance.</param>
		public PieItem( double pieValue, Color color, double displacement, string label )
			: base( label )
		{
			_pieValue = pieValue;
			_fill = new Fill( color.IsEmpty ? _rotator.NextColor : color );
			_displacement = displacement;
			_border = new Border( Default.BorderColor, Default.BorderWidth );
			_labelDetail = new TextObj();
			_labelDetail.FontSpec.Size = Default.FontSize;
			_labelType = Default.LabelType;
			_valueDecimalDigits = Default.ValueDecimalDigits;
			_percentDecimalDigits = Default.PercentDecimalDigits;
			_slicePath = null;
		}
Ejemplo n.º 10
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see c_ref="TextObj"/> object from which to copy</param>
		public TextObj( TextObj rhs ) : base( rhs )
		{
			_text = rhs.Text;
			_fontSpec = new FontSpec( rhs.FontSpec );
		}
Ejemplo n.º 11
0
        /// <summary>
        /// Create a <see c_ref="TextObj" /> for each bar in the <see c_ref="GraphPane" />.
        /// </summary>
        /// <remarks>
        /// This method will go through the bars, create a label that corresponds to the bar value,
        /// and place it on the graph depending on user preferences.  This works for horizontal or
        /// vertical bars in clusters or stacks, but only for <see c_ref="BarItem" /> types.  This method
        /// does not apply to <see c_ref="ErrorBarItem" /> or <see c_ref="HiLowBarItem" /> objects.
        /// Call this method only after calling <see c_ref="GraphPane.AxisChange()" />.
        /// </remarks>
        /// <param name="pane">The GraphPane in which to place the text labels.</param>
        /// <param name="isBarCenter">true to center the labels inside the bars, false to
        /// place the labels just above the top of the bar.</param>
        /// <param name="valueFormat">The double.ToString string format to use for creating
        /// the labels.
        /// </param>
        /// <param name="fontColor">The color in which to draw the labels</param>
        /// <param name="fontFamily">The string name of the font family to use for the labels</param>
        /// <param name="fontSize">The floating point size of the font, in scaled points</param>
        /// <param name="isBold">true for a bold font type, false otherwise</param>
        /// <param name="isItalic">true for an italic font type, false otherwise</param>
        /// <param name="isUnderline">true for an underline font type, false otherwise</param>
        public static void CreateBarLabels(GraphPane pane, bool isBarCenter, string valueFormat,
                                           string fontFamily, float fontSize, Color fontColor, bool isBold, bool isItalic,
                                           bool isUnderline)
        {
            bool isVertical = pane.BarSettings.Base == BarBase.X;

            // keep a count of the number of BarItems
            int curveIndex = 0;

            // Get a valuehandler to do some calculations for us
            ValueHandler valueHandler = new ValueHandler(pane, true);

            // Loop through each curve in the list
            foreach (CurveItem curve in pane.CurveList)
            {
                // work with BarItems only
                BarItem bar = curve as BarItem;
                if (bar != null)
                {
                    IPointList points = curve.Points;

                    // ADD JKB 9/21/07
                    // The labelOffset should depend on whether the curve is YAxis or Y2Axis.
                    // JHC - Generalize to any value axis
                    // Make the gap between the bars and the labels = 1.5% of the axis range
                    float labelOffset;

                    Scale scale = curve.ValueAxis(pane).Scale;
                    labelOffset = (float)(scale._max - scale._min) * 0.015f;

                    // Loop through each point in the BarItem
                    for (int i = 0; i < points.Count; i++)
                    {
                        // Get the high, low and base values for the current bar
                        // note that this method will automatically calculate the "effective"
                        // values if the bar is stacked
                        double baseVal, lowVal, hiVal;
                        valueHandler.GetValues(curve, i, out baseVal, out lowVal, out hiVal);

                        // Get the value that corresponds to the center of the bar base
                        // This method figures out how the bars are positioned within a cluster
                        float centerVal = (float)valueHandler.BarCenterValue(bar,
                                                                             bar.GetBarWidth(pane), i, baseVal, curveIndex);

                        // Create a text label -- note that we have to go back to the original point
                        // data for this, since hiVal and lowVal could be "effective" values from a bar stack
                        string barLabelText = (isVertical ? points[i].Y : points[i].X).ToString(valueFormat);

                        // Calculate the position of the label -- this is either the X or the Y coordinate
                        // depending on whether they are horizontal or vertical bars, respectively
                        float position;
                        if (isBarCenter)
                        {
                            position = (float)(hiVal + lowVal) / 2.0f;
                        }
                        else if (hiVal >= 0)
                        {
                            position = (float)hiVal + labelOffset;
                        }
                        else
                        {
                            position = (float)hiVal - labelOffset;
                        }

                        // Create the new TextObj
                        TextObj label;
                        if (isVertical)
                        {
                            label = new TextObj(barLabelText, centerVal, position);
                        }
                        else
                        {
                            label = new TextObj(barLabelText, position, centerVal);
                        }

                        label.FontSpec.Family = fontFamily;

                        // Configure the TextObj

                        // CHANGE JKB 9/21/07
                        // CoordinateFrame should depend on whether curve is YAxis or Y2Axis.
                        label.Location.CoordinateFrame =
                            (isVertical && curve.IsY2Axis) ? CoordType.AxisXY2Scale : CoordType.AxisXYScale;

                        label.FontSpec.Size        = fontSize;
                        label.FontSpec.FontColor   = fontColor;
                        label.FontSpec.IsItalic    = isItalic;
                        label.FontSpec.IsBold      = isBold;
                        label.FontSpec.IsUnderline = isUnderline;

                        label.FontSpec.Angle  = isVertical ? 90 : 0;
                        label.Location.AlignH = isBarCenter ? AlignH.Center :
                                                (hiVal >= 0 ? AlignH.Left : AlignH.Right);
                        label.Location.AlignV           = AlignV.Center;
                        label.FontSpec.Border.IsVisible = false;
                        label.FontSpec.Fill.IsVisible   = false;

                        // Add the TextObj to the GraphPane
                        pane.GraphObjList.Add(label);
                    }
                    curveIndex++;
                }
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see c_ref="TextObj"/> object from which to copy</param>
 public TextObj(TextObj rhs) : base(rhs)
 {
     _text     = rhs.Text;
     _fontSpec = new FontSpec(rhs.FontSpec);
 }