#region MigraDoc - Creating Documents on the Fly // // Authors: // Stefan Lange // Klaus Potzesny // David Stephensen // // Copyright (c) 2001-2017 empira Software GmbH, Cologne Area (Germany) // // http://www.pdfsharp.com // http://www.migradoc.com // http://sourceforge.net/projects/pdfsharp // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #endregion using MigraDoc.DocumentObjectModel.publics; namespace MigraDoc.DocumentObjectModel.Shapes.Charts { /// /// This class represents an axis in a chart. /// public class Axis : ChartObject { /// /// Initializes a new instance of the Axis class. /// public Axis() { } /// /// Initializes a new instance of the Axis class with the specified parent. /// public Axis(DocumentObject parent) : base(parent) { } #region Methods /// /// Creates a deep copy of this object. /// public new Axis Clone() { return (Axis)DeepCopy(); } /// /// Implements the deep copy of the object. /// protected override object DeepCopy() { Axis axis = (Axis)base.DeepCopy(); if (axis._title != null) { axis._title = axis._title.Clone(); axis._title._parent = axis; } if (axis._tickLabels != null) { axis._tickLabels = axis._tickLabels.Clone(); axis._tickLabels._parent = axis; } if (axis._lineFormat != null) { axis._lineFormat = axis._lineFormat.Clone(); axis._lineFormat._parent = axis; } if (axis._majorGridlines != null) { axis._majorGridlines = axis._majorGridlines.Clone(); axis._majorGridlines._parent = axis; } if (axis._minorGridlines != null) { axis._minorGridlines = axis._minorGridlines.Clone(); axis._minorGridlines._parent = axis; } return axis; } #endregion #region Properties /// /// Gets the title of the axis. /// public AxisTitle Title { get { return _title ?? (_title = new AxisTitle(this)); } set { SetParent(value); _title = value; } } [DV] public AxisTitle _title; /// /// Gets or sets the minimum value of the axis. /// public double MinimumScale { get { return _minimumScale.Value; } set { _minimumScale.Value = value; } } [DV] public NDouble _minimumScale = NDouble.NullValue; /// /// Gets or sets the maximum value of the axis. /// public double MaximumScale { get { return _maximumScale.Value; } set { _maximumScale.Value = value; } } [DV] public NDouble _maximumScale = NDouble.NullValue; /// /// Gets or sets the interval of the primary tick. /// public double MajorTick { get { return _majorTick.Value; } set { _majorTick.Value = value; } } [DV] public NDouble _majorTick = NDouble.NullValue; /// /// Gets or sets the interval of the secondary tick. /// public double MinorTick { get { return _minorTick.Value; } set { _minorTick.Value = value; } } [DV] public NDouble _minorTick = NDouble.NullValue; /// /// Gets or sets the type of the primary tick mark. /// public TickMarkType MajorTickMark { get { return (TickMarkType)_majorTickMark.Value; } set { _majorTickMark.Value = (int)value; } } [DV(Type = typeof(TickMarkType))] public NEnum _majorTickMark = NEnum.NullValue(typeof(TickMarkType)); /// /// Gets or sets the type of the secondary tick mark. /// public TickMarkType MinorTickMark { get { return (TickMarkType)_minorTickMark.Value; } set { _minorTickMark.Value = (int)value; } } [DV(Type = typeof(TickMarkType))] public NEnum _minorTickMark = NEnum.NullValue(typeof(TickMarkType)); /// /// Gets the label of the primary tick. /// public TickLabels TickLabels { get { return _tickLabels ?? (_tickLabels = new TickLabels(this)); } set { SetParent(value); _tickLabels = value; } } [DV] public TickLabels _tickLabels; /// /// Gets the format of the axis line. /// public LineFormat LineFormat { get { return _lineFormat ?? (_lineFormat = new LineFormat(this)); } set { SetParent(value); _lineFormat = value; } } [DV] public LineFormat _lineFormat; /// /// Gets the primary gridline object. /// public Gridlines MajorGridlines { get { return _majorGridlines ?? (_majorGridlines = new Gridlines(this)); } set { SetParent(value); _majorGridlines = value; } } [DV] public Gridlines _majorGridlines; /// /// Gets the secondary gridline object. /// public Gridlines MinorGridlines { get { return _minorGridlines ?? (_minorGridlines = new Gridlines(this)); } set { SetParent(value); _minorGridlines = value; } } [DV] public Gridlines _minorGridlines; /// /// Gets or sets, whether the axis has a primary gridline object. /// public bool HasMajorGridlines { get { return _hasMajorGridlines.Value; } set { _hasMajorGridlines.Value = value; } } [DV] public NBool _hasMajorGridlines = NBool.NullValue; /// /// Gets or sets, whether the axis has a secondary gridline object. /// public bool HasMinorGridlines { get { return _hasMinorGridlines.Value; } set { _hasMinorGridlines.Value = value; } } [DV] public NBool _hasMinorGridlines = NBool.NullValue; #endregion /// /// Determines whether the specified gridlines object is a MajorGridlines or an MinorGridlines. /// public string CheckGridlines(Gridlines gridlines) { if ((_majorGridlines != null) && (gridlines == _majorGridlines)) return "MajorGridlines"; if ((_minorGridlines != null) && (gridlines == _minorGridlines)) return "MinorGridlines"; return ""; } #region public /// /// Converts Axis into DDL. /// public override void Serialize(Serializer serializer) { Chart chartObject = _parent as Chart; serializer.WriteLine("\\" + chartObject.CheckAxis(this)); int pos = serializer.BeginAttributes(); if (!_minimumScale.IsNull) serializer.WriteSimpleAttribute("MinimumScale", MinimumScale); if (!_maximumScale.IsNull) serializer.WriteSimpleAttribute("MaximumScale", MaximumScale); if (!_majorTick.IsNull) serializer.WriteSimpleAttribute("MajorTick", MajorTick); if (!_minorTick.IsNull) serializer.WriteSimpleAttribute("MinorTick", MinorTick); if (!_hasMajorGridlines.IsNull) serializer.WriteSimpleAttribute("HasMajorGridLines", HasMajorGridlines); if (!_hasMinorGridlines.IsNull) serializer.WriteSimpleAttribute("HasMinorGridLines", HasMinorGridlines); if (!_majorTickMark.IsNull) serializer.WriteSimpleAttribute("MajorTickMark", MajorTickMark); if (!_minorTickMark.IsNull) serializer.WriteSimpleAttribute("MinorTickMark", MinorTickMark); if (!IsNull("Title")) _title.Serialize(serializer); if (!IsNull("LineFormat")) _lineFormat.Serialize(serializer); if (!IsNull("MajorGridlines")) _majorGridlines.Serialize(serializer); if (!IsNull("MinorGridlines")) _minorGridlines.Serialize(serializer); if (!IsNull("TickLabels")) _tickLabels.Serialize(serializer); serializer.EndAttributes(pos); } /// /// Returns the meta object of this instance. /// public override Meta Meta { get { return _meta ?? (_meta = new Meta(typeof(Axis))); } } static Meta _meta; #endregion } }