/// <summary> /// Copy constructor. /// </summary> /// <param name="a">The Axis to clone.</param> public Axis(Axis a) { Axis.DoClone(a, this); }
/// <summary> /// Helper method for Clone. Does all the copying - can be called by derived /// types so they don't need to implement this part of the copying themselves. /// also useful in constructor of derived types that extend Axis class. /// </summary> protected static void DoClone(Axis src, Axis dest) { // value items dest.embellishmentsScale = src.embellishmentsScale; dest.worldMax = src.worldMax; dest.worldMin = src.worldMin; dest.textAtTickOrigin = src.textAtTickOrigin; dest.hidden = src.hidden; dest.tickTextHidden = src.tickTextHidden; dest.tickAngle = src.tickAngle; dest.tickTextAngle = src.tickTextAngle; dest.minPhysicalLargeTickStep = src.minPhysicalLargeTickStep; dest.ticksIndependentOfPhysicalExtent = src.ticksIndependentOfPhysicalExtent; dest.largeTickSize = src.largeTickSize; dest.smallTickSize = src.smallTickSize; dest.ticksCrossAxis = src.ticksCrossAxis; dest.labelOffset = src.labelOffset; dest.labelOffsetAbsolute = src.labelOffsetAbsolute; dest.numberSmallTicks = src.numberSmallTicks; dest.largeTickValue = src.largeTickValue; dest.largeTickStep = src.largeTickStep; // reference items. dest.tickTextFont = (Font)src.tickTextFont.Clone(); dest.label = (string)src.label.Clone(); if (src.numberFormat != null) { dest.numberFormat = (string)src.numberFormat.Clone(); } else { dest.numberFormat = null; } dest.labelFont = (Font)src.labelFont.Clone(); dest.linePen = (Pen)src.linePen.Clone(); dest.tickTextBrush = (Brush)src.tickTextBrush.Clone(); dest.labelBrush = (Brush)src.labelBrush.Clone(); }
/// <summary> /// Sets the world extent of the current axis to be just large enough /// to encompas the current world extent of the axis, and the world /// extent of the passed in axis /// </summary> /// <param name="a">The other Axis instance.</param> public void LUB(Axis a) { if (a == null) { return; } // Minima if (!double.IsNaN(a.WorldMin)) { if (double.IsNaN(WorldMin)) { WorldMin = a.WorldMin; } else { if (a.WorldMin < WorldMin) { WorldMin = a.WorldMin; } } } // Maxima if (!double.IsNaN(a.WorldMax)) { if (double.IsNaN(WorldMax)) { WorldMax = a.WorldMax; } else { if (a.WorldMax > WorldMax) { WorldMax = a.WorldMax; } } } }
/// <summary> /// Deep copy of Axis. /// </summary> /// <remarks> /// This method includes a check that guards against derived classes forgetting /// to implement their own Clone method. If Clone is called on a object derived /// from Axis, and the Clone method hasn't been overridden by that object, then /// the test this.GetType == typeof(Axis) will fail. /// </remarks> /// <returns>A copy of the Axis Class</returns> public virtual object Clone() { // Check that this isn't being called on a derived type. If it is, then // the derived type didn't override this method as it should have done. if (this.GetType() != typeof(Axis)) { throw new CSPlotException("Clone method not overridden in Axis derived type"); } Axis a = new Axis(); DoClone(this, a); return a; }