Esempio n. 1
0
            protected virtual XYPlotLayer SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYPlotLayer s = (o == null ? new XYPlotLayer(info) : (XYPlotLayer)o);

                info.GetBaseValueEmbedded(s, typeof(HostLayer), parent);

                // CoordinateSystem
                s.CoordinateSystem = (G2DCoordinateSystem)info.GetValue("CoordinateSystem", s);
                s.CoordinateSystem.UpdateAreaSize(s._cachedLayerSize);

                // Scales
                s.Scales = (ScaleCollection)info.GetValue("Scales", s);

                // Grid planes
                s.GridPlanes = (GridPlaneCollection)info.GetValue("GridPlanes", s);

                // Axis Styles
                s.AxisStyles = (AxisStyleCollection)info.GetValue("AxisStyles", s);

                // Data Clipping
                s.ClipDataToFrame = (LayerDataClipping)info.GetValue("DataClipping", s);

                // PlotItemCollection
                s.PlotItems = (PlotItemCollection)info.GetValue("Plots", s);

                return(s);
            }
Esempio n. 2
0
 private static void ProvideLinkedScalesWithLinkedLayerIndex(XYPlotLayer s, Main.RelDocNodeProxy linkedLayer, Altaxo.Serialization.Xml.IXmlDeserializationInfo info)
 {
     if (null != linkedLayer)
     {
         ProvideLinkedScalesWithLinkedLayerIndex(s, linkedLayer.DocumentPath, info);
     }
 }
Esempio n. 3
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYPlotLayer s = SDeserialize(o, info, parent);

                info.DeserializationFinished += s.EhDeserializationFinished;
                return(s);
            }
Esempio n. 4
0
 /// <summary>
 /// Adds a layer to this layer collection.
 /// </summary>
 /// <param name="l"></param>
 public void Add(XYPlotLayer l)
 {
     // we use List for adding since we want to have custom actions below
     List.Add(l);
     l.SetPrintableGraphBounds(m_PrintableBounds, false);
     // since we use List, we don't need to have OnLayerCollectionChanged here!
 }
Esempio n. 5
0
        /// <summary>
        /// Creates a new layer with bottom x axis and left y axis, which is not linked.
        /// </summary>
        public void CreateNewLayerNormalBottomXLeftY()
        {
            XYPlotLayer newlayer = new XYPlotLayer(DefaultLayerPosition, DefaultLayerSize);

            newlayer.CreateDefaultAxes();
            Layers.Add(newlayer);
        }
Esempio n. 6
0
		private static void FillDataListFromLayer(XYPlotLayer layer, List<List<DoubleColumn>> groupList)
		{
			var plotItems = layer.PlotItems;
			if (plotItems.Count == 0)
				return;

			if (plotItems[0] is Altaxo.Graph.Gdi.Plot.PlotItemCollection)
			{
				var list = GetColumnListFromPlotItemCollection((Altaxo.Graph.Gdi.Plot.PlotItemCollection)plotItems[0]);
				if (list.Count > 0)
					groupList.Add(list);
			}

			// additional 2nd group
			if (plotItems.Count >= 2 && plotItems[1] is Altaxo.Graph.Gdi.Plot.PlotItemCollection)
			{
				var list = GetColumnListFromPlotItemCollection((Altaxo.Graph.Gdi.Plot.PlotItemCollection)plotItems[1]);
				if (list.Count > 0)
					groupList.Add(list);
			}

			// if list is still empty, we try to flatten the root plot item
			if (groupList.Count == 0)
			{
				var list = GetColumnListFromPlotItemCollection(plotItems);
				if (list.Count > 0)
					groupList.Add(list);
			}
		}
Esempio n. 7
0
            protected virtual XYPlotLayer SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYPlotLayer s = (o == null ? new XYPlotLayer(info) : (XYPlotLayer)o);
                int         count;

                // size, position, rotation and scale
                var location = (XYPlotLayerPositionAndSize_V0)info.GetValue("LocationAndSize", s);

                s._cachedLayerSize     = (SizeF)info.GetValue("CachedSize", s);
                s._cachedLayerPosition = (PointF)info.GetValue("CachedPosition", s);
                s.Location             = location.ConvertToCurrentLocationVersion(s._cachedLayerSize, s._cachedLayerPosition);

                // CoordinateSystem
                s.CoordinateSystem = (G2DCoordinateSystem)info.GetValue("CoordinateSystem", s);
                s.CoordinateSystem.UpdateAreaSize(s._cachedLayerSize);

                // linked layers
                count = info.OpenArray("LinkedLayers");
                var linkedLayer = (Main.RelDocNodeProxy)info.GetValue("e", s);

                info.CloseArray(count);

                // Scales
                var linkedScales = (Altaxo.Graph.Scales.Deprecated.LinkedScaleCollection)info.GetValue("Scales", s);

                s.SetupOldAxes(linkedScales);
                ProvideLinkedScalesWithLinkedLayerIndex(s, linkedLayer, info);

                // Grid planes
                s.GridPlanes = (GridPlaneCollection)info.GetValue("GridPlanes", s);

                // Axis Styles
                s.AxisStyles = (AxisStyleCollection)info.GetValue("AxisStyles", s);

                // Legends
                var legends = (IList <IGraphicBase>)info.GetValue("Legends", s);

                // Graphic objects
                s.GraphObjects.AddRange((IEnumerable <IGraphicBase>)info.GetValue("GraphObjects", s));

                foreach (var item in legends)
                {
                    if (item is TextGraphic)
                    {
                        var l = new LegendText((TextGraphic)item);
                        s.GraphObjects.Add(l);
                    }
                }

                // Data Clipping
                s.ClipDataToFrame = (LayerDataClipping)info.GetValue("DataClipping", s);

                // PlotItemCollection
                s.PlotItems = (PlotItemCollection)info.GetValue("Plots", s);

                return(s);
            }
Esempio n. 8
0
            protected override XYPlotLayer SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYPlotLayer s = base.SDeserialize(o, info, parent);

                bool clipDataToFrame = info.GetBoolean("ClipDataToFrame");

                s.ClipDataToFrame = clipDataToFrame ? LayerDataClipping.StrictToCS : LayerDataClipping.None;
                return(s);
            }
    public AxisScaleController(XYPlotLayer layer, int axisnumber)
    {
      m_Layer = layer;
      m_axisNumber = axisnumber;
      m_Axis = m_Layer.LinkedScales.Scale(axisnumber);
      _tempAxis = (Scale)m_Axis.Clone();


      SetElements();
    }
Esempio n. 10
0
        /// <summary>
        /// Replace the old layer by the new one.
        /// </summary>
        /// <param name="oldlayer">Old layer, which should be replaced.</param>
        /// <param name="newlayer">New layer to replace the old one.</param>
        public virtual void Replace(XYPlotLayer oldlayer, XYPlotLayer newlayer)
        {
            int i = base.InnerList.IndexOf(oldlayer);

            if (i >= 0)
            {
                base.InnerList[i] = newlayer;
                newlayer.SetParentAndNumber(this, i);
                newlayer.SetPrintableGraphBounds(m_PrintableBounds, false);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Creates a new layer with top x axis, which is linked to the same position with top x axis and right y axis.
        /// </summary>
        public void CreateNewLayerLinkedTopX(int linklayernumber)
        {
            XYPlotLayer newlayer = new XYPlotLayer(DefaultLayerPosition, DefaultLayerSize);

            Layers.Add(newlayer); // it is neccessary to add the new layer this early since we must set some properties relative to the linked layer
            // link the new layer to the last old layer
            newlayer.LinkedLayer = (linklayernumber >= 0 && linklayernumber < Layers.Count)? Layers[linklayernumber] : null;
            newlayer.SetPosition(0, XYPlotLayerPositionType.RelativeThisNearToLinkedLayerNear, 0, XYPlotLayerPositionType.RelativeThisNearToLinkedLayerNear);
            newlayer.SetSize(1, XYPlotLayerSizeType.RelativeToLinkedLayer, 1, XYPlotLayerSizeType.RelativeToLinkedLayer);
            newlayer.AxisStyles.CreateDefault(new CSLineID(0, 1));
        }
Esempio n. 12
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYPlotLayerCollection s = null != o ? (XYPlotLayerCollection)o : new XYPlotLayerCollection();


                int count = info.OpenArray();

                for (int i = 0; i < count; i++)
                {
                    XYPlotLayer l = (XYPlotLayer)info.GetValue("XYPlotLayer", s);
                    s.Add(l);
                }
                info.CloseArray(count);

                return(s);
            }
Esempio n. 13
0
        /// <summary>
        /// Creates a new layer with bottom x axis and left y axis, which is not linked.
        /// </summary>
        public static void CreateNewLayerNormalBottomXLeftY(this GraphDocument doc)
        {
            var context  = doc.GetPropertyHierarchy();
            var location = new ItemLocationDirect
            {
                PositionX = RADouble.NewRel(HostLayer.DefaultChildLayerRelativePosition.X),
                PositionY = RADouble.NewRel(HostLayer.DefaultChildLayerRelativePosition.Y),
                SizeX     = RADouble.NewRel(HostLayer.DefaultChildLayerRelativeSize.X),
                SizeY     = RADouble.NewRel(HostLayer.DefaultChildLayerRelativeSize.Y)
            };

            var newlayer = new XYPlotLayer(doc.RootLayer, location);

            doc.RootLayer.Layers.Add(newlayer);
            newlayer.CreateDefaultAxes(context);
        }
Esempio n. 14
0
        /// <summary>
        /// Perform custom action if one element removed: renumber the remaining elements.
        /// </summary>
        /// <param name="idx">The index where the element was removed. </param>
        /// <param name="oldValue">The removed element.</param>
        protected override void OnRemoveComplete(int idx, object oldValue)
        {
            ((XYPlotLayer)oldValue).SetParentAndNumber(null, 0);

            // renumber the layers from i to count
            for (int i = idx; i < Count; i++)
            {
                this[i].SetParentAndNumber(this, i);

                // fix linked layer connections if neccessary
                if (XYPlotLayer.ReferenceEquals(oldValue, this[i]))
                {
                    this[i].LinkedLayer = null;
                }
            }
            OnLayerCollectionChanged();
        }
Esempio n. 15
0
        /// <summary>
        /// Perform custom action if one element is set: set parent and number of the newly
        /// set element.
        /// </summary>
        /// <param name="index">The index where the element is set.</param>
        /// <param name="oldValue">The old value of the list element.</param>
        /// <param name="newValue">The new value this list element is set to.</param>
        protected override void OnSetComplete(int index, object oldValue, object newValue)
        {
            ((XYPlotLayer)oldValue).SetParentAndNumber(null, 0);
            ((XYPlotLayer)newValue).SetParentAndNumber(this, index);
            ((XYPlotLayer)newValue).SetPrintableGraphBounds(this.PrintableGraphBounds, true);

            for (int i = 0; i < Count; i++)
            {
                // fix linked layer connections if neccessary
                if (XYPlotLayer.ReferenceEquals(oldValue, this[i]))
                {
                    this[i].LinkedLayer = null;
                }
            }

            OnLayerCollectionChanged();
        }
Esempio n. 16
0
        private static void ProvideLinkedScalesWithLinkedLayerIndex(XYPlotLayer s, Main.RelativeDocumentPath path, Altaxo.Serialization.Xml.IXmlDeserializationInfo info)
        {
            if (null != path && path.Count > 0)
            {
                var pathend = path[path.Count - 1];
                // extract layer number
                int layerNum = System.Xml.XmlConvert.ToInt32(pathend.Substring(1));
                foreach (var scaleAndTick in s.Scales)
                {
                    if (scaleAndTick is LinkedScale)
#pragma warning disable CS0612 // Type or member is obsolete
                    {
                        ((LinkedScale)scaleAndTick).SetLinkedLayerIndex(layerNum, info);
                    }
                }
#pragma warning restore CS0612 // Type or member is obsolete
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Handle the change notification from the child layers.
        /// </summary>
        /// <param name="sender">The sender of the change notification.</param>
        /// <param name="e">The change details.</param>
        public void EhChildChanged(object sender, System.EventArgs e)
        {
            if (_changeEventSuppressor.PeekDisabled)
            {
                XYPlotLayer child = sender as XYPlotLayer;
                if (child != null)
                {
                    if (_suspendedChilds == null)
                    {
                        _suspendedChilds = new Dictionary <XYPlotLayer, IDisposable>();
                    }

                    if (!_suspendedChilds.ContainsKey(child))
                    {
                        _suspendedChilds.Add(child, child.BeginUpdate());
                    }
                }
            }
            OnChanged(); // Fire the changed event
        }
Esempio n. 18
0
        private static XYPlotLayer CreateNewLayerAtSamePosition(this GraphDocument doc, IEnumerable <int> linklayernumber)
        {
            var isValidIndex = doc.RootLayer.IsValidIndex(linklayernumber, out var oldLayer);

            if (!isValidIndex)
            {
                throw new ArgumentOutOfRangeException("index was not valid");
            }

            IItemLocation location;

            if (oldLayer.Location is ItemLocationByGrid)
            {
                location = (IItemLocation)oldLayer.Location.Clone();
            }
            else if (oldLayer.Location is ItemLocationDirect)
            {
                // 1. check if it is possible to create a grid in the parent layer of the old layer
                if (null != oldLayer.ParentLayer && oldLayer.ParentLayer.CanCreateGridForLocation((ItemLocationDirect)oldLayer.Location))
                {
                    ItemLocationByGrid gridCell = oldLayer.ParentLayer.CreateGridForLocation((ItemLocationDirect)oldLayer.Location);
                    oldLayer.Location = gridCell.Clone();
                    location          = gridCell.Clone();
                }
                else // if we can not create a grid, then we must set the location to that of the the oldLayer, but of course then the two layer locations are not linked
                {
                    location = (IItemLocation)oldLayer.Location.Clone();
                }
            }
            else
            {
                throw new NotImplementedException("Location type not implemented");
            }

            var newLayer = new XYPlotLayer(oldLayer.ParentLayer, location);

            doc.RootLayer.InsertLast(linklayernumber, newLayer);

            return(newLayer);
        }
Esempio n. 19
0
 /// <summary>
 /// Creates a new layer with bottom x axis and left y axis, which is not linked.
 /// </summary>
 public void CreateNewLayerNormalBottomXLeftY()
 {
   XYPlotLayer newlayer= new XYPlotLayer(DefaultLayerPosition,DefaultLayerSize);
   newlayer.CreateDefaultAxes();
   Layers.Add(newlayer);
 }
Esempio n. 20
0
		private static void ProvideLinkedScalesWithLinkedLayerIndex(XYPlotLayer s, Main.RelDocNodeProxy linkedLayer, Altaxo.Serialization.Xml.IXmlDeserializationInfo info)
		{
			if (null != linkedLayer)
			{
				ProvideLinkedScalesWithLinkedLayerIndex(s, linkedLayer.DocumentPath, info);
			}
		}
    /// <summary>
    /// Plots the cross predicted versus actual Y (concentration) into a provided layer.
    /// </summary>
    /// <param name="table">The table of PLS output data.</param>
    /// <param name="layer">The layer to plot into.</param>
    /// <param name="whichY">The number of the component (y, concentration etc.) for which to plot the residuals.</param>
    /// <param name="numberOfFactors">The number of factors used for calculation of the residuals.</param>
    public static void PlotCrossPredictedVersusActualY(Altaxo.Data.DataTable table, XYPlotLayer layer, int whichY, int numberOfFactors)
    {
      string ypredcolname = WorksheetAnalysis.GetYCrossPredicted_ColumnName(whichY,numberOfFactors);
      string yactcolname = WorksheetAnalysis.GetYOriginal_ColumnName(whichY);
      if(table[ypredcolname]==null)
      {
        GetAnalysis(table).CalculateCrossPredictedAndResidual(table,whichY,numberOfFactors,true,false,false);
      }

      PlotOnlyLabel(layer,table[yactcolname],table[ypredcolname],table[WorksheetAnalysis.GetMeasurementLabel_ColumnName()]);

      layer.DefaultXAxisTitleString = string.Format("Y original{0}",whichY);
      layer.DefaultYAxisTitleString   = string.Format("Y cross predicted{0} (#factors:{1})",whichY,numberOfFactors);
    }
    /// <summary>
    /// This plots a label plot into the provided layer.
    /// </summary>
    /// <param name="layer">The layer to plot into.</param>
    /// <param name="xcol">The x column.</param>
    /// <param name="ycol">The y column.</param>
    /// <param name="labelcol">The label column.</param>
    public static void PlotOnlyLabel(XYPlotLayer layer, Altaxo.Data.DataColumn xcol, Altaxo.Data.DataColumn ycol, Altaxo.Data.DataColumn labelcol)  
    {
      XYColumnPlotData pa = new XYColumnPlotData(xcol,ycol);

      G2DPlotStyleCollection ps = new G2DPlotStyleCollection(LineScatterPlotStyleKind.Empty);
      LabelPlotStyle labelStyle = new LabelPlotStyle(labelcol);
      labelStyle.FontSize = 10;
      labelStyle.BackgroundStyle = new FilledRectangle(System.Drawing.Color.LightCyan);
      ps.Add(labelStyle);
      
      layer.PlotItems.Add(new XYColumnPlotItem(pa,ps));
    }
    void Initialize(bool initDocument)
    {
      if (initDocument)
      {
        m_Layer = Main.DocumentPath.GetRootNodeImplementing<XYPlotLayer>(_originalDoc);
      }

      if (_view != null)
      {
        _view.BeginUpdate();

        _view.Background = _doc.Background;

        _view.EditText = _doc.Text;

        _view.Position = _doc.Position;
        _view.Rotation = _doc.Rotation;

        // fill the font name combobox with all fonts
        _view.FontFamily = _doc.Font.FontFamily;

        _view.FontSize = _doc.Font.Size;

        // fill the font size combobox with reasonable values
        //this.m_cbFontSize.Items.AddRange(new string[] { "8", "9", "10", "11", "12", "14", "16", "18", "20", "22", "24", "26", "28", "36", "48", "72" });
        //this.m_cbFontSize.Text = m_TextObject.Font.Size.ToString();


        // fill the color dialog box
        _view.FontColor = this._doc.TextFillBrush;

        _view.EndUpdate();
      }
    }
 /// <summary>
 /// Replace the old layer by the new one.
 /// </summary>
 /// <param name="oldlayer">Old layer, which should be replaced.</param>
 /// <param name="newlayer">New layer to replace the old one.</param>
 public virtual void Replace(XYPlotLayer oldlayer, XYPlotLayer newlayer)
 {
   int i = base.InnerList.IndexOf(oldlayer);
   if (i >= 0)
   {
     base.InnerList[i] = newlayer;
     newlayer.SetParentAndNumber(this, i);
     newlayer.SetPrintableGraphBounds(m_PrintableBounds, false);
   }
 }
Esempio n. 25
0
 /// <summary>
 /// Fires the Invalidate event.
 /// </summary>
 /// <param name="sender">The layer which needs to be repainted.</param>
 protected internal virtual void OnInvalidate(XYPlotLayer sender)
 {
     OnChanged();
 }
Esempio n. 26
0
        /// <summary>
        /// Arranges the layers according to the provided options.
        /// </summary>
        /// <param name="activeLayer">Layer, whose siblings are about to be arranged. (Exception: If the root layer is the active layer, then the childs of the root layer will be arranged.</param>
        /// <param name="arrangement">The layer arrangement options (contain the information how to arrange the layers).</param>
        public static void ArrangeLayers(this HostLayer activeLayer, ArrangeLayersDocument arrangement)
        {
            var context     = activeLayer.GetPropertyContext();
            var parentLayer = activeLayer.ParentLayer ?? activeLayer;

            int numPresentLayers = parentLayer.Layers.Count;
            int numDestLayers    = arrangement.NumberOfColumns * arrangement.NumberOfRows;

            int additionalLayers = Math.Max(0, numDestLayers - numPresentLayers);

            if (null == parentLayer.Grid)
            {
                parentLayer.CreateDefaultGrid();
            }

            ArrangeGrid(arrangement, parentLayer.Grid);

            int nLayer = -1;

            for (int i = 0; i < arrangement.NumberOfRows; ++i)
            {
                for (int j = 0; j < arrangement.NumberOfColumns; ++j)
                {
                    nLayer++;

                    if (nLayer >= numPresentLayers)
                    {
                        var graph = Altaxo.Graph.Gdi.GraphTemplates.TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.CreateGraph(context, Guid.NewGuid().ToString(), "", false);

                        if (graph != null && graph.RootLayer.Layers.Count > 0)
                        {
                            var newLayer = (HostLayer)graph.RootLayer.Layers[0].Clone();
                            parentLayer.Layers.Add(newLayer);
                        }
                        else
                        {
                            var newLayer = new XYPlotLayer(parentLayer);
                            newLayer.CreateDefaultAxes(context);
                            parentLayer.Layers.Add(newLayer);
                        }
                    }

                    var oldSize = parentLayer.Layers[nLayer].Size;
                    parentLayer.Layers[nLayer].Location = new ItemLocationByGrid {
                        GridColumn = 2 * j + 1, GridRow = 2 * i + 1, GridColumnSpan = 1, GridRowSpan = 1
                    };
                    var newSize = parentLayer.Layers[nLayer].Size;
                }
            }

            // act now on superfluous layers
            if (numPresentLayers > numDestLayers)
            {
                switch (arrangement.SuperfluousLayersAction)
                {
                case SuperfluousLayersAction.Remove:
                    for (int i = numPresentLayers - 1; i >= numDestLayers; i--)
                    {
                        parentLayer.Layers.RemoveAt(i);
                    }
                    break;

                case SuperfluousLayersAction.OverlayFirstLayer:
                case SuperfluousLayersAction.OverlayLastLayer:

                    int template      = arrangement.SuperfluousLayersAction == SuperfluousLayersAction.OverlayFirstLayer ? 0 : numDestLayers - 1;
                    var templateLayer = parentLayer.Layers[template];

                    for (int i = numDestLayers; i < numPresentLayers; i++)
                    {
                        var oldSize = parentLayer.Layers[i].Size;
                        parentLayer.Layers[i].Location = (IItemLocation)templateLayer.Location.Clone();
                        var newSize = parentLayer.Layers[i].Size;
                    }

                    break;
                }
            }
        }
		/// <summary>
		/// Handles the MouseDown event when the plot point tool is selected
		/// </summary>
		/// <param name="position">Mouse position.</param>
		/// <param name="e">The mouse event args</param>
		public override void OnMouseDown(PointD2D position, MouseButtonEventArgs e)
		{
			base.OnMouseDown(position, e);

			var graphXY = _grac.ConvertMouseToRootLayerCoordinates(position);

			// search for a object first
			IHitTestObject clickedObject;
			int[] clickedLayerNumber = null;
			_grac.FindGraphObjectAtPixelPosition(position, true, out clickedObject, out clickedLayerNumber);
			if (null != clickedObject && clickedObject.HittedObject is XYColumnPlotItem)
			{
				_PlotItem = (XYColumnPlotItem)clickedObject.HittedObject;
				var transXY = clickedObject.Transformation.InverseTransformPoint(graphXY);

				this._layer = (XYPlotLayer)(clickedObject.ParentLayer);
				XYScatterPointInformation scatterPoint = _PlotItem.GetNearestPlotPoint(_layer, transXY);
				this._PlotItemNumber = GetPlotItemNumber(_layer, _PlotItem);

				if (null != scatterPoint)
				{
					this._PlotIndex = scatterPoint.PlotIndex;
					this._RowIndex = scatterPoint.RowIndex;
					// convert this layer coordinates first to PrintableAreaCoordinates
					var rootLayerCoord = clickedObject.ParentLayer.TransformCoordinatesFromHereToRoot(scatterPoint.LayerCoordinates);
					_positionOfCrossInRootLayerCoordinates = rootLayerCoord;
					// m_Cross.X -= _grac.GraphViewOffset.X;
					// m_Cross.Y -= _grac.GraphViewOffset.Y;

					var newPixelCoord = _grac.ConvertGraphToMouseCoordinates(rootLayerCoord);

					// TODO (Wpf)
					//var newCursorPosition = new Point((int)(Cursor.Position.X + newPixelCoord.X - mouseXY.X),(int)(Cursor.Position.Y + newPixelCoord.Y - mouseXY.Y));
					//SetCursorPos(newCursorPosition.X, newCursorPosition.Y);

					this.DisplayData(_PlotItem, scatterPoint.RowIndex,
						_PlotItem.XYColumnPlotData.XColumn[scatterPoint.RowIndex],
						_PlotItem.XYColumnPlotData.YColumn[scatterPoint.RowIndex]);

					// here we shoud switch the bitmap cache mode on and link us with the AfterPaint event
					// of the grac
					_grac.RenderOverlay(); // no refresh necessary, only invalidate to show the cross
				}
			}
		} // end of function
		/// <summary>
		/// Find the plot item number of a given plot item.
		/// </summary>
		/// <param name="layer">The layer in which this plot item resides.</param>
		/// <param name="plotitem">The plot item for which the number should be retrieved.</param>
		/// <returns></returns>
		private int GetPlotItemNumber(XYPlotLayer layer, XYColumnPlotItem plotitem)
		{
			if (null != layer)
			{
				for (int i = 0; i < layer.PlotItems.Flattened.Length; i++)
					if (object.ReferenceEquals(layer.PlotItems.Flattened[i], plotitem))
						return i;
			}
			return -1;
		}
		/// <summary>
		/// Moves the cross to the next plot item. If no plot item is found in this layer, it moves the cross to the next layer.
		/// </summary>
		/// <param name="increment"></param>
		private void MoveUpDown(int increment)
		{
			if (!TestMovementPresumtions())
				return;

			var layerList = _layer.SiblingLayers;
			int numlayers = layerList.Count;
			var nextlayer = _layer as XYPlotLayer;
			int indexOfNextLayer = layerList.IndexOf(_layer);
			int nextplotitemnumber = this._PlotItemNumber;

			XYScatterPointInformation scatterPoint = null;
			XYColumnPlotItem plotitem = null;
			do
			{
				nextplotitemnumber = nextplotitemnumber + Math.Sign(increment);
				if (nextplotitemnumber < 0) // then try to use the previous layer
				{
					--indexOfNextLayer;
					nextlayer = indexOfNextLayer >= 0 ? layerList[indexOfNextLayer] as XYPlotLayer : null;
					nextplotitemnumber = nextlayer == null ? int.MaxValue : nextlayer.PlotItems.Flattened.Length - 1;
				}
				else if (nextplotitemnumber >= nextlayer.PlotItems.Flattened.Length)
				{
					++indexOfNextLayer;
					nextlayer = indexOfNextLayer < layerList.Count ? layerList[indexOfNextLayer] as XYPlotLayer : null;
					nextplotitemnumber = 0;
				}
				// check if this results in a valid information
				if (indexOfNextLayer < 0 || indexOfNextLayer >= numlayers)
					break; // no more layers available

				if (nextlayer == null)
					continue; // this is not an XYPlotLayer

				if (nextplotitemnumber < 0 || nextplotitemnumber >= nextlayer.PlotItems.Flattened.Length)
					continue;

				plotitem = nextlayer.PlotItems.Flattened[nextplotitemnumber] as XYColumnPlotItem;
				if (null == plotitem)
					continue;

				scatterPoint = plotitem.GetNextPlotPoint(nextlayer, this._PlotIndex, 0);
			} while (scatterPoint == null);

			if (null != scatterPoint)
			{
				this._PlotItem = plotitem;
				this._layer = nextlayer;
				this._PlotItemNumber = nextplotitemnumber;
				this._PlotIndex = scatterPoint.PlotIndex;
				this._RowIndex = scatterPoint.RowIndex;

				ShowCross(scatterPoint);
			}
		}
 public LayerPositionController(XYPlotLayer layer)
 {
   m_Layer = layer;
   SetElements(true);
 }
    public void EhView_LinkedLayerChanged(SelectableListNode node)
    {
      XYPlotLayer oldLinkedLayer = m_LinkedLayer;
      m_LinkedLayer = (XYPlotLayer)node.Item;

      // we have to check if there is a need to update the type comboboxes
      if (oldLinkedLayer != null && m_LinkedLayer != null)
      {
      }
      else if (oldLinkedLayer == null && m_LinkedLayer != null)
      {
        InitializePositionTypes();
        InitializeSizeTypes();
      }
      else if (oldLinkedLayer != null && m_LinkedLayer == null)
      {
        if (m_LeftType != XYPlotLayerPositionType.AbsoluteValue && m_LeftType != XYPlotLayerPositionType.RelativeToGraphDocument)
          ChangeLeftType(XYPlotLayerPositionType.RelativeToGraphDocument);
        if (m_TopType != XYPlotLayerPositionType.AbsoluteValue && m_TopType != XYPlotLayerPositionType.RelativeToGraphDocument)
          ChangeTopType(XYPlotLayerPositionType.RelativeToGraphDocument);

        if (m_WidthType != XYPlotLayerSizeType.AbsoluteValue && m_WidthType != XYPlotLayerSizeType.RelativeToGraphDocument)
          ChangeWidthType(XYPlotLayerSizeType.RelativeToGraphDocument);
        if (m_HeightType != XYPlotLayerSizeType.AbsoluteValue && m_HeightType != XYPlotLayerSizeType.RelativeToGraphDocument)
          ChangeHeightType(XYPlotLayerSizeType.RelativeToGraphDocument);

        InitializeSizeTypes();
        InitializePositionTypes();
      }
    }
    public void SetElements(bool bInit)
    {


      if(bInit)
      {
        m_Height    = m_Layer.UserHeight;
        m_Width     = m_Layer.UserWidth;
        m_Left      = m_Layer.UserXPosition;
        m_Top       = m_Layer.UserYPosition;
        m_Rotation  = m_Layer.Rotation;
        m_Scale     = m_Layer.Scale;
        m_ClipDataToFrame = m_Layer.ClipDataToFrame == LayerDataClipping.StrictToCS;

        m_LeftType = m_Layer.UserXPositionType;
        m_TopType  = m_Layer.UserYPositionType;
        m_HeightType = m_Layer.UserHeightType;
        m_WidthType = m_Layer.UserWidthType;
        m_LinkedLayer = m_Layer.LinkedLayer;


        m_XAxisLink = new AxisLinkController(m_Layer,true);
        m_YAxisLink = new AxisLinkController(m_Layer,false);
      }

      if(View!=null)
      {

        InitializeWidthValue();
        InitializeHeightValue();

        InitializeLeftValue();
        InitializeTopValue();

        View.InitializeRotation((float)m_Rotation);
        View.InitializeScale(Serialization.GUIConversion.GetPercentMeasureText(m_Scale));
        View.InitializeClipDataToFrame(m_ClipDataToFrame);

        InitializePositionTypes();
        InitializeSizeTypes();
        InitializeLinkedAxisChoices();

        // initialize the axis link properties
        m_XAxisLink.View = View.GetXAxisLink();
        m_YAxisLink.View = View.GetYAxisLink();

      }

    }
Esempio n. 33
0
            protected virtual XYPlotLayer SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYPlotLayer s = (o == null ? new XYPlotLayer(info) : (XYPlotLayer)o);
                int         count;

                // Background
                var bgs = (IBackgroundStyle)info.GetValue("Background", s);

                if (null != bgs)
                {
                    if (!s.GridPlanes.Contains(CSPlaneID.Front))
                    {
                        s.GridPlanes.Add(new GridPlane(CSPlaneID.Front));
                    }
                    s.GridPlanes[CSPlaneID.Front].Background = bgs.Brush;
                }

                // size, position, rotation and scale
                var location = (XYPlotLayerPositionAndSize_V0)info.GetValue("LocationAndSize", s);

                s._cachedLayerSize     = (SizeF)info.GetValue("CachedSize", s);
                s._cachedLayerPosition = (PointF)info.GetValue("CachedPosition", s);
                s._coordinateSystem.UpdateAreaSize(s._cachedLayerSize);
                s.Location = location.ConvertToCurrentLocationVersion(s._cachedLayerSize, s._cachedLayerPosition);

                // LayerProperties
                bool clipDataToFrame = info.GetBoolean("ClipDataToFrame");

                s._dataClipping = clipDataToFrame ? LayerDataClipping.StrictToCS : LayerDataClipping.None;

                // axis related
                var linkedScales = (Altaxo.Graph.Scales.Deprecated.LinkedScaleCollection)info.GetValue("AxisProperties", s);

                s.SetupOldAxes(linkedScales);

                // Styles
                var ssc    = (G2DScaleStyleCollection)info.GetValue("AxisStyles", s);
                var gplane = new GridPlane(CSPlaneID.Front);

                gplane.GridStyle[0] = ssc.ScaleStyle(0).GridStyle;
                gplane.GridStyle[1] = ssc.ScaleStyle(1).GridStyle;
                s.GridPlanes.Add(gplane);
                foreach (AxisStyle ax in ssc.AxisStyles)
                {
                    s._axisStyles.Add(ax);
                }

                // Legends
                count = info.OpenArray("Legends");
                var legend = (TextGraphic)info.GetValue("e", s);

                info.CloseArray(count);

                // XYPlotLayer specific
                count = info.OpenArray("LinkedLayers");
                var linkedLayer = (Main.RelDocNodeProxy)info.GetValue("e", s);

                info.CloseArray(count);
                ProvideLinkedScalesWithLinkedLayerIndex(s, linkedLayer, info);

                s.GraphObjects.AddRange((IEnumerable <IGraphicBase>)info.GetValue("GraphicGlyphs", s));
                if (null != legend)
                {
                    var legend1 = new LegendText(legend);
                    s.GraphObjects.Add(legend1);
                }
                s.PlotItems = (PlotItemCollection)info.GetValue("Plots", s);

                return(s);
            }
Esempio n. 34
0
    LayerController(XYPlotLayer layer, string currentPage, int axisScaleIdx, CSLineID id)
    {
      _originalDoc = layer;
      _doc = (XYPlotLayer)layer.Clone();
      _docSuspendLock = _doc.BeginUpdate();

      SetCoordinateSystemDependentObjects(id);

      _currentScale = axisScaleIdx;
      _currentAxisID = id;
      _currentPlaneID = CSPlaneID.Front;
      _currentPageName = currentPage;
      if (null != View)
        SetViewElements();
    }
Esempio n. 35
0
 /// <summary>
 /// Fires the Invalidate event.
 /// </summary>
 /// <param name="sender">The layer which needs to be repainted.</param>
 protected internal virtual void OnInvalidate(XYPlotLayer sender)
 {
     EhSelfChanged(EventArgs.Empty);
 }
Esempio n. 36
0
 public LayerController(XYPlotLayer layer)
   : this(layer, "Scale", 1, null)
 {
 }
 /// <summary>
 /// Adds a layer to this layer collection.
 /// </summary>
 /// <param name="l"></param>
 public void Add(XYPlotLayer l)
 {
   // we use List for adding since we want to have custom actions below
   List.Add(l);
   l.SetPrintableGraphBounds(m_PrintableBounds,false);
   // since we use List, we don't need to have OnLayerCollectionChanged here!
 }
Esempio n. 38
0
 public static bool ShowDialog(XYPlotLayer layer)
 {
   return ShowDialog( layer, "Scale", new CSLineID(0, 0));
 }
    /// <summary>
    /// Plots the x (spectral) leverage into a provided layer.
    /// </summary>
    /// <param name="table">The table of PLS output data.</param>
    /// <param name="layer">The layer to plot into.</param>
    /// <param name="preferredNumberOfFactors">The number of factors used for leverage calculation.</param>
    public static void PlotXLeverage(Altaxo.Data.DataTable table, XYPlotLayer layer, int preferredNumberOfFactors)
    {
      string xcolname = WorksheetAnalysis.GetMeasurementLabel_ColumnName();
      string ycolname = WorksheetAnalysis.GetXLeverage_ColumnName(preferredNumberOfFactors);
      
      if(table[ycolname]==null)
      {
        GetAnalysis(table).CalculateXLeverage(table,preferredNumberOfFactors);
      }

      PlotOnlyLabel(layer,table[xcolname],table[ycolname],table[WorksheetAnalysis.GetMeasurementLabel_ColumnName()]);

      layer.DefaultXAxisTitleString = string.Format("Measurement");
      layer.DefaultYAxisTitleString   = string.Format("Score leverage (#factors:{0})",preferredNumberOfFactors);
    }
Esempio n. 40
0
 /// <summary>
 /// Fires the Invalidate event.
 /// </summary>
 /// <param name="sender">The layer which needs to be repainted.</param>
 protected internal virtual void OnInvalidate(XYPlotLayer sender)
 {
   OnChanged();
 }
    /// <summary>
    /// Plots the x (spectral) residuals into a provided layer.
    /// </summary>
    /// <param name="table">The table of PLS output data.</param>
    /// <param name="layer">The layer to plot into.</param>
    /// <param name="whichY">The number of the component (y, concentration etc.) for which to plot the residuals.</param>
    /// <param name="numberOfFactors">The number of factors used for calculation of the residuals.</param>
    public static void PlotXResiduals(Altaxo.Data.DataTable table, XYPlotLayer layer, int whichY, int numberOfFactors)
    {
      string xresidualcolname = WorksheetAnalysis.GetXResidual_ColumnName(whichY,numberOfFactors);
      string yactcolname = WorksheetAnalysis.GetYOriginal_ColumnName(whichY);
      
      if(table[xresidualcolname]==null)
      {
        GetAnalysis(table).CalculateXResidual(table,whichY,numberOfFactors);
      }

      PlotOnlyLabel(layer,table[yactcolname],table[xresidualcolname],table[WorksheetAnalysis.GetMeasurementLabel_ColumnName()]);

      layer.DefaultXAxisTitleString = string.Format("Y original{0}",whichY);
      layer.DefaultYAxisTitleString   = string.Format("X residual{0} (#factors:{1})",whichY,numberOfFactors);
    }
Esempio n. 42
0
 /// <summary>
 /// The copy constructor.
 /// </summary>
 /// <param name="from"></param>
 public XYPlotLayer(XYPlotLayer from)
 {
   _changeEventSuppressor = new Altaxo.Main.EventSuppressor(EhChangeEventResumed);
   CopyFrom(from);
 }
    /// <summary>
    /// Plots the cross PRESS value into a provided layer.
    /// </summary>
    /// <param name="table">The table of PLS output data.</param>
    /// <param name="layer">The layer to plot into.</param>
    public static void PlotCrossPRESSValue(Altaxo.Data.DataTable table, XYPlotLayer layer)
    {
      Altaxo.Data.DataColumn ycol = table[WorksheetAnalysis.GetCrossPRESSValue_ColumnName()];
      Altaxo.Data.DataColumn xcol = table[WorksheetAnalysis.GetNumberOfFactors_ColumnName()];

      XYColumnPlotData pa = new XYColumnPlotData(xcol,ycol);
      G2DPlotStyleCollection ps = new G2DPlotStyleCollection(LineScatterPlotStyleKind.LineAndScatter);
      layer.PlotItems.Add(new XYColumnPlotItem(pa,ps));

      layer.DefaultXAxisTitleString = "Number of factors";
      layer.DefaultYAxisTitleString   = "Cross PRESS value";
    }
Esempio n. 44
0
    public static bool ShowDialog(XYPlotLayer layer, string currentPage, CSLineID currentEdge)
    {
      LayerController ctrl = new LayerController(layer, currentPage, currentEdge);
      LayerControl view = new LayerControl();
      ctrl.View = view;

      return Current.Gui.ShowDialog(ctrl, layer.Name, true);
    }
Esempio n. 45
0
		private static void ProvideLinkedScalesWithLinkedLayerIndex(XYPlotLayer s, Main.RelativeDocumentPath path, Altaxo.Serialization.Xml.IXmlDeserializationInfo info)
		{
			if (null != path && path.Count > 0)
			{
				var pathend = path[path.Count - 1];
				// extract layer number
				int layerNum = System.Xml.XmlConvert.ToInt32(pathend.Substring(1));
				foreach (var scaleAndTick in s.Scales)
					if (scaleAndTick is LinkedScale)
#pragma warning disable CS0612 // Type or member is obsolete
						((LinkedScale)scaleAndTick).SetLinkedLayerIndex(layerNum, info);
#pragma warning restore CS0612 // Type or member is obsolete
			}
		}
Esempio n. 46
0
 public static bool ShowDialog( XYPlotLayer layer, string currentPage)
 {
   return ShowDialog(layer, currentPage, new CSLineID(0, 0));
 }
Esempio n. 47
0
    /// <summary>
    /// Creates a new layer with bottom x axis and left y axis, which is linked to the same position with top x axis and right y axis. The x axis is linked straight to the x axis of the linked layer.
    /// </summary>
    public void CreateNewLayerLinkedTopXRightY_XAxisStraight(int linklayernumber)
    {
      XYPlotLayer newlayer= new XYPlotLayer(DefaultLayerPosition,DefaultLayerSize);
      Layers.Add(newlayer); // it is neccessary to add the new layer this early since we must set some properties relative to the linked layer
      // link the new layer to the last old layer
      newlayer.LinkedLayer = (linklayernumber>=0 && linklayernumber<Layers.Count)? Layers[linklayernumber] : null;
      newlayer.SetPosition(0,XYPlotLayerPositionType.RelativeThisNearToLinkedLayerNear,0,XYPlotLayerPositionType.RelativeThisNearToLinkedLayerNear);
      newlayer.SetSize(1,XYPlotLayerSizeType.RelativeToLinkedLayer,1,XYPlotLayerSizeType.RelativeToLinkedLayer);

      // set enabling of axis
      newlayer.AxisStyles.CreateDefault(new CSLineID(0, 1));
      newlayer.AxisStyles.CreateDefault(new CSLineID(1, 1));
      

      newlayer.LinkedScales.X.AxisLinkType = ScaleLinkType.Straight;
    }
Esempio n. 48
0
 public LayerController(XYPlotLayer layer, string currentPage, CSLineID id)
   : this(layer, currentPage, id.ParallelAxisNumber, id)
 {
 }
Esempio n. 49
0
 /// <summary>
 /// Checks if the provided layer or a linked layer of it is dependent on this layer.
 /// </summary>
 /// <param name="layer">The layer to check.</param>
 /// <returns>True if the provided layer or one of its linked layers is dependend on this layer.</returns>
 public bool IsLayerDependentOnMe(XYPlotLayer layer)
 {
   while (null != layer)
   {
     if (XYPlotLayer.ReferenceEquals(layer, this))
     {
       // this means a circular dependency, so return true
       return true;
     }
     layer = layer.LinkedLayer;
   }
   return false; // no dependency detected
 }
Esempio n. 50
0
 /// <summary>
 /// Returns the document name of the layer at index i. Actually, this is a name of the form L0, L1, L2 and so on.
 /// </summary>
 /// <param name="i">The layer index.</param>
 /// <returns>The name of the layer at index i.</returns>
 public static string GetNameOfLayer(int i)
 {
     return(XYPlotLayer.GetDefaultNameOfLayer(i));
 }
Esempio n. 51
0
    public void CopyFrom(XYPlotLayer from)
    {
      using (IDisposable updateLock = BeginUpdate())
      {
        // XYPlotLayer style
        //this.LayerBackground = from._layerBackground == null ? null : (LayerBackground)from._layerBackground.Clone();

        // size, position, rotation and scale
        this.Location = from._location.Clone();
        this._cachedLayerSize = from._cachedLayerSize;
        this._cachedLayerPosition = from._cachedLayerPosition;
        this._cachedPrintableGraphBounds = from._cachedPrintableGraphBounds;

        this.CoordinateSystem = (G2DCoordinateSystem)from.CoordinateSystem.Clone();


        // axis related

        this.LinkedScales = (LinkedScaleCollection)from._linkedScales.Clone();

        this._dataClipping = from._dataClipping;

        this.GridPlanes = from._gridPlanes.Clone();

        // Styles

        this.AxisStyles = (AxisStyleCollection)from._axisStyles.Clone();

        this.Legends = from._legends == null ? new GraphicCollection() : new GraphicCollection(from._legends);

        // XYPlotLayer specific
        this.LinkedLayerLink = from._linkedLayer.ClonePathOnly(this);

        this.GraphObjects = null == from._graphObjects ? null : new GraphicCollection(from._graphObjects);

        this.PlotItems = null == from._plotItems ? null : new PlotItemCollection(this, from._plotItems);


        _cachedForwardMatrix = new Matrix();
        _cachedReverseMatrix = new Matrix();
        CalculateMatrix();

        OnChanged(); // make sure that the change event is called
      }

      this._parent = from._parent; // outside the update, because clone operations should not cause an update of the old parent

    }
Esempio n. 52
0
            protected virtual XYPlotLayer SDeserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYPlotLayer s = null != o ? (XYPlotLayer)o : new XYPlotLayer(info);

                bool fillLayerArea      = info.GetBoolean("FillLayerArea");
                var  layerAreaFillBrush = (BrushX)info.GetValue("LayerAreaFillBrush", s);

                if (fillLayerArea)
                {
                    if (!s.GridPlanes.Contains(CSPlaneID.Front))
                    {
                        s.GridPlanes.Add(new GridPlane(CSPlaneID.Front));
                    }
                    s.GridPlanes[CSPlaneID.Front].Background = layerAreaFillBrush;
                }

                // size, position, rotation and scale

                var widthType  = (XYPlotLayerSizeType)info.GetValue("WidthType", s);
                var heightType = (XYPlotLayerSizeType)info.GetValue("HeightType", s);
                var width      = info.GetDouble("Width");
                var height     = info.GetDouble("Height");

                s._cachedLayerSize = (SizeF)info.GetValue("CachedSize", s);
                s._coordinateSystem.UpdateAreaSize(s._cachedLayerSize);

                var xPositionType = (XYPlotLayerPositionType)info.GetValue("XPositionType", s);
                var yPositionType = (XYPlotLayerPositionType)info.GetValue("YPositionType", s);
                var xPosition     = info.GetDouble("XPosition");
                var yPosition     = info.GetDouble("YPosition");

                s._cachedLayerPosition = (PointF)info.GetValue("CachedPosition", s);
                var rotation = info.GetSingle("Rotation");
                var scale    = info.GetSingle("Scale");

                s.Location = new XYPlotLayerPositionAndSize_V0(widthType, width, heightType, height, xPositionType, xPosition, yPositionType, yPosition, rotation, scale).ConvertToCurrentLocationVersion(s._cachedLayerSize, s._cachedLayerPosition);

                // axis related

                var    xAxis     = (Altaxo.Graph.Scales.Deprecated.Scale)info.GetValue("XAxis", s);
                var    yAxis     = (Altaxo.Graph.Scales.Deprecated.Scale)info.GetValue("YAxis", s);
                bool   xIsLinked = info.GetBoolean("LinkXAxis");
                bool   yIsLinked = info.GetBoolean("LinkYAxis");
                double xOrgA     = info.GetDouble("LinkXAxisOrgA");
                double xOrgB     = info.GetDouble("LinkXAxisOrgB");
                double xEndA     = info.GetDouble("LinkXAxisEndA");
                double xEndB     = info.GetDouble("LinkXAxisEndB");
                double yOrgA     = info.GetDouble("LinkYAxisOrgA");
                double yOrgB     = info.GetDouble("LinkYAxisOrgB");
                double yEndA     = info.GetDouble("LinkYAxisEndA");
                double yEndB     = info.GetDouble("LinkYAxisEndB");

                s.SetupOldAxis(0, xAxis, xIsLinked, xOrgA, xOrgB, xEndA, xEndB);
                s.SetupOldAxis(1, yAxis, yIsLinked, yOrgA, yOrgB, yEndA, yEndB);

                // Styles
                bool showLeft   = info.GetBoolean("ShowLeftAxis");
                bool showBottom = info.GetBoolean("ShowBottomAxis");
                bool showRight  = info.GetBoolean("ShowRightAxis");
                bool showTop    = info.GetBoolean("ShowTopAxis");

                s._axisStyles.AxisStyleEnsured(CSLineID.Y0).AxisLineStyle = (AxisLineStyle)info.GetValue("LeftAxisStyle", s);
                s._axisStyles.AxisStyleEnsured(CSLineID.X0).AxisLineStyle = (AxisLineStyle)info.GetValue("BottomAxisStyle", s);
                s._axisStyles.AxisStyleEnsured(CSLineID.Y1).AxisLineStyle = (AxisLineStyle)info.GetValue("RightAxisStyle", s);
                s._axisStyles.AxisStyleEnsured(CSLineID.X1).AxisLineStyle = (AxisLineStyle)info.GetValue("TopAxisStyle", s);

                s._axisStyles[CSLineID.Y0].MajorLabelStyle = (AxisLabelStyle)info.GetValue("LeftLabelStyle", s);
                s._axisStyles[CSLineID.X0].MajorLabelStyle = (AxisLabelStyle)info.GetValue("BottomLabelStyle", s);
                s._axisStyles[CSLineID.Y1].MajorLabelStyle = (AxisLabelStyle)info.GetValue("RightLabelStyle", s);
                s._axisStyles[CSLineID.X1].MajorLabelStyle = (AxisLabelStyle)info.GetValue("TopLabelStyle", s);

                // Titles and legend
                s._axisStyles[CSLineID.Y0].Title = (TextGraphic)info.GetValue("LeftAxisTitle", s);
                s._axisStyles[CSLineID.X0].Title = (TextGraphic)info.GetValue("BottomAxisTitle", s);
                s._axisStyles[CSLineID.Y1].Title = (TextGraphic)info.GetValue("RightAxisTitle", s);
                s._axisStyles[CSLineID.X1].Title = (TextGraphic)info.GetValue("TopAxisTitle", s);

                if (!showLeft)
                {
                    s._axisStyles.Remove(CSLineID.Y0);
                }
                if (!showRight)
                {
                    s._axisStyles.Remove(CSLineID.Y1);
                }
                if (!showBottom)
                {
                    s._axisStyles.Remove(CSLineID.X0);
                }
                if (!showTop)
                {
                    s._axisStyles.Remove(CSLineID.X1);
                }

                var legend = (TextGraphic)info.GetValue("Legend", s);

                // XYPlotLayer specific
                object linkedLayer = info.GetValue("LinkedLayer", s);

                if (linkedLayer is Main.AbsoluteDocumentPath)
                {
                    ProvideLinkedScalesWithLinkedLayerIndex(s, (Main.AbsoluteDocumentPath)linkedLayer, info);
                }
                else if (linkedLayer is Main.RelativeDocumentPath)
                {
                    ProvideLinkedScalesWithLinkedLayerIndex(s, (Main.RelativeDocumentPath)linkedLayer, info);
                }
                s.GraphObjects.AddRange((IEnumerable <IGraphicBase>)info.GetValue("GraphObjects", s));

                s._plotItems = (PlotItemCollection)info.GetValue("Plots", s);
                if (null != s._plotItems)
                {
                    s._plotItems.ParentObject = s;
                }

                if (null != legend)
                {
                    var legend1 = new LegendText(legend);
                    s._graphObjects.Add(legend1);
                }

                return(s);
            }