public XYPlotStyleCollectionController(G2DPlotStyleCollection doc)
 {
   _doc = doc;
   _tempdoc = new System.Collections.ArrayList();
   for(int i=0;i<_doc.Count;i++)
     _tempdoc.Add(_doc[i]);
 }
示例#2
0
			public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
			{
				XYColumnPlotData pa = (XYColumnPlotData)info.GetValue("Data", null);
				XYLineScatterPlotStyle lsps = (XYLineScatterPlotStyle)info.GetValue("Style", null);
				if (lsps.XYPlotLineStyle != null)
					lsps.XYPlotLineStyle.UseSymbolGap = lsps.LineSymbolGap; // this has changed and is now hosted in the LineStyle itself

				G2DPlotStyleCollection ps = new G2DPlotStyleCollection(new IG2DPlotStyle[] { lsps.XYPlotLineStyle, lsps.ScatterStyle, lsps.XYPlotLabelStyle });
				if (lsps.XYPlotLabelStyle != null)
				{
					XmlSerializationSurrogate0 surr = new XmlSerializationSurrogate0();
					surr._item = pa;
					surr._label = lsps.XYPlotLabelStyle;
					info.DeserializationFinished += new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(surr.info_DeserializationFinished);
				}

				if (null == o)
				{
					return new XYColumnPlotItem(pa, ps);
				}
				else
				{
					XYColumnPlotItem s = (XYColumnPlotItem)o;
					s.Data = pa;
					s.Style = ps;
					return s;
				}
			}
示例#3
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                var pa   = (XYFunctionPlotData)info.GetValue("Data", null);
                var lsps = (XYLineScatterPlotStyle)info.GetValue("Style", null);

                var ps = new G2DPlotStyleCollection();

                if (null != lsps.ScatterStyle)
                {
                    ps.Add(new ScatterPlotStyle(lsps.ScatterStyle));
                }
                if (null != lsps.XYPlotLineStyle)
                {
                    ps.Add(new LinePlotStyle(lsps.XYPlotLineStyle));
                }

                if (null == o)
                {
                    return(new XYFunctionPlotItem(pa, ps));
                }
                else
                {
                    var s = (XYFunctionPlotItem)o;
                    s.Data  = pa;
                    s.Style = ps;
                    return(s);
                }
            }
示例#4
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYColumnPlotData       pa   = (XYColumnPlotData)info.GetValue("Data", typeof(XYColumnPlotData));
                XYLineScatterPlotStyle lsps = (XYLineScatterPlotStyle)info.GetValue("Style", typeof(XYLineScatterPlotStyle));

                if (lsps.XYPlotLineStyle != null)
                {
                    lsps.XYPlotLineStyle.LineSymbolGap = lsps.LineSymbolGap; // this has changed and is now hosted in the LineStyle itself
                }
                G2DPlotStyleCollection ps = new G2DPlotStyleCollection(new IG2DPlotStyle[] { lsps.XYPlotLineStyle, lsps.ScatterStyle, lsps.XYPlotLabelStyle });

                if (lsps.XYPlotLabelStyle != null)
                {
                    XmlSerializationSurrogate0 surr = new XmlSerializationSurrogate0();
                    surr._item  = pa;
                    surr._label = lsps.XYPlotLabelStyle;
                    info.DeserializationFinished += new Altaxo.Serialization.Xml.XmlDeserializationCallbackEventHandler(surr.info_DeserializationFinished);
                }



                if (null == o)
                {
                    return(new XYColumnPlotItem(pa, ps));
                }
                else
                {
                    XYColumnPlotItem s = (XYColumnPlotItem)o;
                    s.Data  = pa;
                    s.Style = ps;
                    return(s);
                }
            }
示例#5
0
		public static List<IGPlotItem> CreatePlotItems(DataTable table, IAscendingIntegerCollection selectedColumns, G2DPlotStyleCollection templatePlotStyle)
		{
			var selColumns = new List<DataColumn>(selectedColumns.Count);
			foreach (int i in selectedColumns)
				selColumns.Add(table[i]);

			return CreatePlotItems(selColumns, templatePlotStyle, table.GetPropertyContext());
		}
示例#6
0
        public static G2DPlotStyleCollection PlotStyle_Bar(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
        {
            var result = new G2DPlotStyleCollection();
            var ps1    = new BarGraphPlotStyle(context);

            result.Add(ps1);
            return(result);
        }
示例#7
0
		protected override IEnumerable<Main.DocumentNodeAndName> GetDocumentNodeChildrenWithName()
		{
			if (null != _plotStyles)
				yield return new Main.DocumentNodeAndName(_plotStyles, () => _plotStyles = null, "Style");

			if (null != _localGroups)
				yield return new Main.DocumentNodeAndName(_localGroups, () => _localGroups = null, "LocalPlotGroupStyles");
		}
 public XYPlotStyleCollectionController(G2DPlotStyleCollection doc)
 {
     _doc     = doc;
     _tempdoc = new System.Collections.ArrayList();
     for (int i = 0; i < _doc.Count; i++)
     {
         _tempdoc.Add(_doc[i]);
     }
 }
示例#9
0
        public static G2DPlotStyleCollection PlotStyle_Symbol(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
        {
            var result = new G2DPlotStyleCollection
            {
                new ScatterPlotStyle(context)
            };

            return(result);
        }
示例#10
0
        /// <summary>
        /// Plots selected data columns of a table.
        /// </summary>
        /// <param name="table">The source table.</param>
        /// <param name="selectedColumns">The data columns of the table that should be plotted.</param>
        /// <param name="graph">The graph document to plot into.</param>
        /// <param name="templatePlotStyle">The plot style which is the template for all plot items.</param>
        /// <param name="groupStyles">The group styles for the newly built plot item collection.</param>
        public static Altaxo.Gui.Graph.Gdi.Viewing.IGraphController Plot(
            DataTable table,
            IAscendingIntegerCollection selectedColumns,
            Graph.Gdi.GraphDocument graph,
            G2DPlotStyleCollection templatePlotStyle,
            PlotGroupStyleCollection groupStyles)
        {
            List <IGPlotItem> pilist = CreatePlotItems(table, selectedColumns, templatePlotStyle);
            // now create a new Graph with this plot associations
            var gc      = Current.ProjectService.CreateNewGraph(graph);
            var xylayer = gc.Doc.RootLayer.Layers.OfType <Altaxo.Graph.Gdi.XYPlotLayer>().First();

            // Set x and y axes according to the first plot item in the list
            if (pilist.Count > 0 && (pilist[0] is XYColumnPlotItem))
            {
                var firstitem = (XYColumnPlotItem)pilist[0];
                if (firstitem.Data.XColumn is TextColumn)
                {
                    xylayer.Scales[0] = new TextScale();
                }
                else if (firstitem.Data.XColumn is DateTimeColumn)
                {
                    xylayer.Scales[0] = new DateTimeScale();
                }

                if (firstitem.Data.YColumn is TextColumn)
                {
                    xylayer.Scales[1] = new TextScale();
                }
                else if (firstitem.Data.YColumn is DateTimeColumn)
                {
                    xylayer.Scales[1] = new DateTimeScale();
                }
            }

            var newPlotGroup = new PlotItemCollection(xylayer.PlotItems);

            foreach (IGPlotItem pi in pilist)
            {
                newPlotGroup.Add(pi);
            }
            if (groupStyles != null)
            {
                newPlotGroup.GroupStyles = groupStyles;
            }
            else
            {
                newPlotGroup.CollectStyles(newPlotGroup.GroupStyles);
            }

            xylayer.PlotItems.Add(newPlotGroup);

            return(gc);
        }
示例#11
0
        protected override IEnumerable <Main.DocumentNodeAndName> GetDocumentNodeChildrenWithName()
        {
            if (null != _plotStyles)
            {
                yield return(new Main.DocumentNodeAndName(_plotStyles, () => _plotStyles = null, "Style"));
            }

            if (null != _localGroups)
            {
                yield return(new Main.DocumentNodeAndName(_localGroups, () => _localGroups = null, "LocalPlotGroupStyles"));
            }
        }
示例#12
0
        /// <summary>
        /// Plots selected data columns of a table.
        /// </summary>
        /// <param name="table">The source table.</param>
        /// <param name="selectedColumns">The data columns of the table that should be plotted.</param>
        /// <param name="graph">The graph document to plot into.</param>
        /// <param name="templatePlotStyle">The plot style which is the template for all plot items.</param>
        /// <param name="groupStyles">The group styles for the newly built plot item collection.</param>
        public static IGraphController Plot(DataTable table,
                                            IAscendingIntegerCollection selectedColumns,
                                            Graph.Gdi.GraphDocument graph,
                                            G2DPlotStyleCollection templatePlotStyle,
                                            PlotGroupStyleCollection groupStyles)
        {
            List <IGPlotItem> pilist = CreatePlotItems(table, selectedColumns, templatePlotStyle);

            // now create a new Graph with this plot associations
            Altaxo.Graph.GUI.IGraphController gc = Current.ProjectService.CreateNewGraph(graph);
            // Set x and y axes according to the first plot item in the list
            if (pilist.Count > 0 && (pilist[0] is XYColumnPlotItem))
            {
                XYColumnPlotItem firstitem = (XYColumnPlotItem)pilist[0];
                if (firstitem.Data.XColumn is TextColumn)
                {
                    gc.Doc.Layers[0].LinkedScales.SetScale(0, new Graph.Scales.TextScale());
                }
                else if (firstitem.Data.XColumn is DateTimeColumn)
                {
                    gc.Doc.Layers[0].LinkedScales.SetScale(0, new Graph.Scales.DateTimeScale());
                }

                if (firstitem.Data.YColumn is TextColumn)
                {
                    gc.Doc.Layers[0].LinkedScales.SetScale(1, new Graph.Scales.TextScale());
                }
                else if (firstitem.Data.YColumn is DateTimeColumn)
                {
                    gc.Doc.Layers[0].LinkedScales.SetScale(1, new Graph.Scales.DateTimeScale());
                }
            }


            PlotItemCollection newPlotGroup = new PlotItemCollection(gc.Doc.Layers[0].PlotItems);

            foreach (IGPlotItem pi in pilist)
            {
                newPlotGroup.Add(pi);
            }
            if (groupStyles != null)
            {
                newPlotGroup.GroupStyles = groupStyles;
            }
            else
            {
                newPlotGroup.CollectStyles(newPlotGroup.GroupStyles);
            }

            gc.Doc.Layers[0].PlotItems.Add(newPlotGroup);

            return(gc);
        }
示例#13
0
        /// <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";
        }
示例#14
0
        public static G2DPlotStyleCollection PlotStyle_LineArea(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
        {
            var result = new G2DPlotStyleCollection();
            var ps1    = new LinePlotStyle(context);
            var ps2    = new DropAreaPlotStyle(context)
            {
                FillDirection = Graph.CSPlaneID.Bottom
            };

            result.Add(ps1);
            result.Add(ps2);
            return(result);
        }
示例#15
0
        /// <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));
        }
示例#16
0
        /// <summary>
        /// Plots selected data columns of a table.
        /// </summary>
        /// <param name="table">The source table.</param>
        /// <param name="selectedColumns">The data columns of the table that should be plotted.</param>
        /// <param name="templatePlotStyle">The plot style which is the template for all plot items.</param>
        /// <param name="groupStyles">The group styles for the newly built plot item collection.</param>
        public static IGraphController Plot(DataTable table,
                                            IAscendingIntegerCollection selectedColumns,
                                            G2DPlotStyleCollection templatePlotStyle,
                                            PlotGroupStyleCollection groupStyles)
        {
            Altaxo.Graph.Gdi.GraphDocument graph = new Altaxo.Graph.Gdi.GraphDocument();
            Altaxo.Graph.Gdi.XYPlotLayer   layer = new Altaxo.Graph.Gdi.XYPlotLayer(graph.DefaultLayerPosition, graph.DefaultLayerSize);
            layer.CreateDefaultAxes();
            graph.Layers.Add(layer);
            Current.Project.GraphDocumentCollection.Add(graph);

            return(Plot(table, selectedColumns, graph, templatePlotStyle, groupStyles));
        }
示例#17
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                XYColumnPlotData       pa = (XYColumnPlotData)info.GetValue("Data", typeof(XYColumnPlotData));
                G2DPlotStyleCollection ps = (G2DPlotStyleCollection)info.GetValue("Style", typeof(G2DPlotStyleCollection));

                if (null == o)
                {
                    return(new XYColumnPlotItem(pa, ps));
                }
                else
                {
                    XYColumnPlotItem s = (XYColumnPlotItem)o;
                    s.Data  = pa;
                    s.Style = ps;
                    return(s);
                }
            }
        public void EhView_PredefinedStyleSelected(int selectedindex)
        {
            if (selectedindex == 0)
            {
                return;
            }

            G2DPlotStyleCollection template = G2DPlotStyleCollectionTemplates.GetTemplate(selectedindex - 1);

            _tempdoc.Clear();
            for (int i = 0; i < template.Count; i++)
            {
                _tempdoc.Add(template[i]);
            }

            UpdateStyleList(new int[0]);
            OnCollectionChangeCommit();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="XYNonlinearFitFunctionPlotItem"/> class.
        /// </summary>
        /// <param name="fitDocumentIdentifier">The fit document identifier.</param>
        /// <param name="fitDocument">The fit document. The document will be cloned before stored in this instance.</param>
        /// <param name="fitElementIndex">Index of the fit element.</param>
        /// <param name="dependentVariableIndex">Index of the dependent variable of the fit element.</param>
        /// <param name="dependentVariableTransformation">Transformation, which is applied to the result of the fit function to be then shown in the plot. Can be null.</param>
        /// <param name="ps">The ps.</param>
        public XYNonlinearFitFunctionPlotItem(string fitDocumentIdentifier, NonlinearFitDocument fitDocument, int fitElementIndex, int dependentVariableIndex, IVariantToVariantTransformation dependentVariableTransformation, int independentVariableIndex, IVariantToVariantTransformation independentVariableTransformation, G2DPlotStyleCollection ps)
            : base()
        {
            if (null == fitDocumentIdentifier)
            {
                throw new ArgumentNullException(nameof(fitDocumentIdentifier));
            }
            if (null == fitDocument)
            {
                throw new ArgumentNullException(nameof(fitDocument));
            }
            if (null == ps)
            {
                throw new ArgumentNullException(nameof(ps));
            }

            ChildSetMember(ref _plotData, new XYNonlinearFitFunctionPlotData(fitDocumentIdentifier, fitDocument, fitElementIndex, dependentVariableIndex, dependentVariableTransformation, independentVariableIndex, independentVariableTransformation));
            Style = ps;
        }
示例#20
0
        public override bool CopyFrom(object obj)
        {
            if (object.ReferenceEquals(this, obj))
            {
                return(true);
            }

            var copied = base.CopyFrom(obj);

            if (copied)
            {
                var from = obj as G2DPlotItem;
                if (from != null)
                {
                    Style = from.Style.Clone();
                }
            }
            return(copied);
        }
        public bool InitializeDocument(params object[] args)
        {
            if (args == null || args.Length == 0)
            {
                return(false);
            }
            G2DPlotStyleCollection doc = args[0] as G2DPlotStyleCollection;

            if (doc == null)
            {
                return(false);
            }

            _doc     = doc;
            _tempdoc = new System.Collections.ArrayList();
            for (int i = 0; i < _doc.Count; i++)
            {
                _tempdoc.Add(_doc[i]);
            }

            Initialize();
            return(true);
        }
示例#22
0
			public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
			{
				XYFunctionPlotData pa = (XYFunctionPlotData)info.GetValue("Data", null);
				XYLineScatterPlotStyle lsps = (XYLineScatterPlotStyle)info.GetValue("Style", null);

				G2DPlotStyleCollection ps = new G2DPlotStyleCollection();
				if (null != lsps.ScatterStyle)
					ps.Add(new ScatterPlotStyle(lsps.ScatterStyle));
				if (null != lsps.XYPlotLineStyle)
					ps.Add(new LinePlotStyle(lsps.XYPlotLineStyle));

				if (null == o)
				{
					return new XYFunctionPlotItem(pa, ps);
				}
				else
				{
					XYFunctionPlotItem s = (XYFunctionPlotItem)o;
					s.Data = pa;
					s.Style = ps;
					return s;
				}
			}
示例#23
0
		public override bool CopyFrom(object obj)
		{
			if (object.ReferenceEquals(this, obj))
				return true;

			var copied = base.CopyFrom(obj);
			if (copied)
			{
				var from = obj as G2DPlotItem;
				if (from != null)
				{
					this.Style = from.Style.Clone();
				}
			}
			return copied;
		}
示例#24
0
		public static G2DPlotStyleCollection PlotStyle_Line_Symbol(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
		{
			var result = new G2DPlotStyleCollection();
			result.Add(new ScatterPlotStyle(context));
			result.Add(new LinePlotStyle(context) { UseSymbolGap = true });
			return result;
		}
示例#25
0
        public static List <IGPlotItem> CreatePlotItems(DataTable table, IAscendingIntegerCollection selectedColumns, G2DPlotStyleCollection templatePlotStyle)
        {
            var selColumns = new List <DataColumn>(selectedColumns.Count);

            foreach (int i in selectedColumns)
            {
                selColumns.Add(table[i]);
            }

            return(CreatePlotItems(selColumns, templatePlotStyle, table.GetPropertyContext()));
        }
示例#26
0
 public XYFunctionPlotItem(IXYFunctionPlotData pa, G2DPlotStyleCollection ps)
 {
     Data  = pa;
     Style = ps;
 }
示例#27
0
 /// <summary>
 /// Creates a list of plot items from data columns, using a template plot style.
 /// </summary>
 /// <param name="selectedColumns">Columns for which to create plot items.</param>
 /// <param name="templatePlotStyle">The template plot style used to create the basic plot item.</param>
 /// <param name="processedColumns">On return, contains all columns that where used in creating the plot items. That are
 /// not only the columns given in the first argument, but maybe also columns that are right to those columns in the table and have special kinds, like
 /// labels, yerr, and so on.</param>
 /// <param name="context">Property context used to determine default values, e.g. for the pen width or symbol size.</param>
 /// <returns>List of plot items created.</returns>
 public static List <IGPlotItem> CreatePlotItems(IEnumerable <DataColumn> selectedColumns, G2DPlotStyleCollection templatePlotStyle, HashSet <DataColumn> processedColumns, Altaxo.Main.Properties.IReadOnlyPropertyBag context)
 {
     return(CreatePlotItems(selectedColumns, string.Empty, templatePlotStyle, processedColumns, context));
 }
 static G2DPlotStyleCollection CreateLabelStyle()
 {
   G2DPlotStyleCollection coll = new G2DPlotStyleCollection(LineScatterPlotStyleKind.Empty);
   coll.Add(new LabelPlotStyle());
   return coll;
 }
示例#29
0
		/// <summary>
		/// Plots selected data columns of a table.
		/// </summary>
		/// <param name="table">The source table.</param>
		/// <param name="selectedColumns">The data columns of the table that should be plotted.</param>
		/// <param name="graph">The graph document to plot into.</param>
		/// <param name="templatePlotStyle">The plot style which is the template for all plot items.</param>
		/// <param name="groupStyles">The group styles for the newly built plot item collection.</param>
		public static Altaxo.Gui.Graph.Gdi.Viewing.IGraphController Plot(
			DataTable table,
			IAscendingIntegerCollection selectedColumns,
			Graph.Gdi.GraphDocument graph,
			G2DPlotStyleCollection templatePlotStyle,
			PlotGroupStyleCollection groupStyles)
		{
			List<IGPlotItem> pilist = CreatePlotItems(table, selectedColumns, templatePlotStyle);
			// now create a new Graph with this plot associations
			var gc = Current.ProjectService.CreateNewGraph(graph);
			var xylayer = gc.Doc.RootLayer.Layers.OfType<Altaxo.Graph.Gdi.XYPlotLayer>().First();

			// Set x and y axes according to the first plot item in the list
			if (pilist.Count > 0 && (pilist[0] is XYColumnPlotItem))
			{
				XYColumnPlotItem firstitem = (XYColumnPlotItem)pilist[0];
				if (firstitem.Data.XColumn is TextColumn)
					xylayer.Scales[0] = new TextScale();
				else if (firstitem.Data.XColumn is DateTimeColumn)
					xylayer.Scales[0] = new DateTimeScale();

				if (firstitem.Data.YColumn is TextColumn)
					xylayer.Scales[1] = new TextScale();
				else if (firstitem.Data.YColumn is DateTimeColumn)
					xylayer.Scales[1] = new DateTimeScale();
			}

			PlotItemCollection newPlotGroup = new PlotItemCollection(xylayer.PlotItems);
			foreach (IGPlotItem pi in pilist)
			{
				newPlotGroup.Add(pi);
			}
			if (groupStyles != null)
				newPlotGroup.GroupStyles = groupStyles;
			else
				newPlotGroup.CollectStyles(newPlotGroup.GroupStyles);

			xylayer.PlotItems.Add(newPlotGroup);

			return gc;
		}
		private static G2DPlotStyleCollection CreateLabelStyle(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
		{
			G2DPlotStyleCollection coll = new G2DPlotStyleCollection(LineScatterPlotStyleKind.Empty, context);
			coll.Add(new LabelPlotStyle(context));
			return coll;
		}
    public static int GetIndexOfAvailableNamesPlusCustom(G2DPlotStyleCollection coll)
    {
      string name = GetName(coll);
      if (null == name)
        return 0;

      int result = _NamesInOrder.IndexOf(name);
      return result < 0 ? 0 : result + 1;
    }
示例#32
0
        public static List <IGPlotItem> CreatePlotItems(DataTable table, IAscendingIntegerCollection selectedColumns, G2DPlotStyleCollection templatePlotStyle)
        {
            int len        = selectedColumns.Count;
            int numColumns = table.DataColumnCount;

            List <IGPlotItem>          result = new List <IGPlotItem>();
            ErrorBarPlotStyle          unpairedPositiveError = null;
            ErrorBarPlotStyle          unpairedNegativeError = null;
            AscendingIntegerCollection processedColumns      = new AscendingIntegerCollection();

            int idx;

            for (int sci = 0; sci < len; sci++)
            {
                idx = selectedColumns[sci];
                if (processedColumns.Contains(idx))
                {
                    continue;
                }
                else
                {
                    processedColumns.Add(idx);
                }

                Altaxo.Data.DataColumn ycol = table[idx];
                Altaxo.Data.DataColumn xcol = table.DataColumns.FindXColumnOf(ycol);
                XYColumnPlotData       pa;
                if (null != xcol)
                {
                    pa = new XYColumnPlotData(xcol, ycol);
                }
                else
                {
                    pa = new XYColumnPlotData(new Altaxo.Data.IndexerColumn(), ycol);
                }

                G2DPlotStyleCollection ps = templatePlotStyle != null? (G2DPlotStyleCollection)templatePlotStyle.Clone() : new G2DPlotStyleCollection();

                bool foundMoreColumns = true;
                for (idx = idx + 1; foundMoreColumns && idx < numColumns; idx++)
                {
                    DataColumn col = table.DataColumns[idx];
                    switch (table.DataColumns.GetColumnKind(idx))
                    {
                    case ColumnKind.Label:
                        LabelPlotStyle labelStyle = new LabelPlotStyle(col);
                        ps.Insert(0, labelStyle);
                        break;

                    case ColumnKind.Err:
                        ErrorBarPlotStyle errStyle = new ErrorBarPlotStyle();
                        errStyle.PositiveErrorColumn = col as INumericColumn;
                        errStyle.NegativeErrorColumn = col as INumericColumn;
                        ps.Add(errStyle);
                        break;

                    case ColumnKind.pErr:
                        if (null != unpairedNegativeError)
                        {
                            unpairedNegativeError.PositiveErrorColumn = col as INumericColumn;;
                            unpairedNegativeError = null;
                        }
                        else
                        {
                            unpairedPositiveError = new ErrorBarPlotStyle();
                            unpairedPositiveError.PositiveErrorColumn = col as INumericColumn;
                            ps.Add(unpairedPositiveError);
                        }
                        break;

                    case ColumnKind.mErr:
                        if (null != unpairedPositiveError)
                        {
                            unpairedPositiveError.NegativeErrorColumn = col as INumericColumn;
                            unpairedPositiveError = null;
                        }
                        else
                        {
                            unpairedNegativeError = new ErrorBarPlotStyle();
                            unpairedNegativeError.NegativeErrorColumn = col as INumericColumn;
                            ps.Add(unpairedNegativeError);
                        }
                        break;

                    default:
                        foundMoreColumns = false;
                        break;
                    }

                    if (foundMoreColumns)
                    {
                        processedColumns.Add(idx);
                    }
                }

                result.Add(new XYColumnPlotItem(pa, ps));
            }

            return(result);
        }
示例#33
0
		public static G2DPlotStyleCollection PlotStyle_Bar(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
		{
			var result = new G2DPlotStyleCollection();
			BarGraphPlotStyle ps1 = new BarGraphPlotStyle(context);
			result.Add(ps1);
			return result;
		}
示例#34
0
		public static G2DPlotStyleCollection PlotStyle_Line(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
		{
			var result = new G2DPlotStyleCollection();
			result.Add(new LinePlotStyle(context));
			return result;
		}
    /// <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));
    }
 public static string GetName(G2DPlotStyleCollection coll)
 {
   return (string)_NamesByTypeArray[GetTypeArray(coll)];
 }
    /// <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";
    }
    static TypeArray GetTypeArray(G2DPlotStyleCollection coll)
    {
      System.Type[] types = new Type[coll.Count];
      for (int i = 0; i < types.Length; i++)
        types[i] = coll[i].GetType();

      return new TypeArray(types);
    }
示例#39
0
		/// <summary>
		/// Creates a list of plot items from data columns, using a template plot style.
		/// </summary>
		/// <param name="selectedColumns">Columns for which to create plot items.</param>
		/// <param name="templatePlotStyle">The template plot style used to create the basic plot item.</param>
		/// <param name="processedColumns">On return, contains all columns that where used in creating the plot items. That are
		/// not only the columns given in the first argument, but maybe also columns that are right to those columns in the table and have special kinds, like
		/// labels, yerr, and so on.</param>
		/// <param name="context">Property context used to determine default values, e.g. for the pen width or symbol size.</param>
		/// <returns>List of plot items created.</returns>
		public static List<IGPlotItem> CreatePlotItems(IEnumerable<DataColumn> selectedColumns, G2DPlotStyleCollection templatePlotStyle, HashSet<DataColumn> processedColumns, Altaxo.Main.Properties.IReadOnlyPropertyBag context)
		{
			return CreatePlotItems(selectedColumns, string.Empty, templatePlotStyle, processedColumns, context);
		}
示例#40
0
		public XYFunctionPlotItem(XYFunctionPlotData pa, G2DPlotStyleCollection ps)
		{
			this.Data = pa;
			this.Style = ps;
		}
    public bool InitializeDocument(params object[] args)
    {
      if (args == null || args.Length == 0)
        return false;
      G2DPlotStyleCollection doc = args[0] as G2DPlotStyleCollection;
      if (doc == null)
        return false;
      
      _doc = doc;
      _tempdoc = new System.Collections.ArrayList();
      for (int i = 0; i < _doc.Count; i++)
        _tempdoc.Add(_doc[i]);

      Initialize();
      return true;
    }
示例#42
0
        /// <summary>
        /// Creates a list of plot items from data columns, using a template plot style.
        /// </summary>
        /// <param name="selectedColumns">Columns for which to create plot items.</param>
        /// <param name="xColumnName">Name of the x column. If it is null or empty, or that column is not found in the table, the current assigned x column is used.</param>
        /// <param name="templatePlotStyle">The template plot style used to create the basic plot item.</param>
        /// <param name="processedColumns">On return, contains all columns that where used in creating the plot items. That are
        /// not only the columns given in the first argument, but maybe also columns that are right to those columns in the table and have special kinds, like
        /// labels, yerr, and so on.</param>
        /// <param name="context">Property context used to determine default values, e.g. for the pen width or symbol size.</param>
        /// <returns>List of plot items created.</returns>
        public static List <IGPlotItem> CreatePlotItems(IEnumerable <DataColumn> selectedColumns, string xColumnName, G2DPlotStyleCollection templatePlotStyle, HashSet <DataColumn> processedColumns, Altaxo.Main.Properties.IReadOnlyPropertyBag context)
        {
            var result = new List <IGPlotItem>();

            foreach (DataColumn ycol in selectedColumns)
            {
                if (processedColumns.Contains(ycol))
                {
                    continue;
                }
                else
                {
                    processedColumns.Add(ycol);
                }

                var table = DataColumnCollection.GetParentDataColumnCollectionOf(ycol);
                Altaxo.Data.DataColumn xcol;
                if (!string.IsNullOrEmpty(xColumnName) && null != table && table.ContainsColumn(xColumnName))
                {
                    xcol = table[xColumnName];
                }
                else
                {
                    xcol = null == table ? null : table.FindXColumnOf(ycol);
                }

                int groupNumber = table.GetColumnGroup(ycol);
                var parentTable = DataTable.GetParentDataTableOf(table);

                XYColumnPlotData pa;
                if (null != xcol)
                {
                    pa = new XYColumnPlotData(parentTable, groupNumber, xcol, ycol);
                }
                else
                {
                    pa = new XYColumnPlotData(parentTable, groupNumber, new Altaxo.Data.IndexerColumn(), ycol);
                }

                G2DPlotStyleCollection ps = templatePlotStyle != null?templatePlotStyle.Clone() : new G2DPlotStyleCollection();

                if (null == table)
                {
                    continue;
                }

                ErrorBarPlotStyle unpairedPositiveError = null;
                ErrorBarPlotStyle unpairedNegativeError = null;

                bool foundMoreColumns = true;
                for (int idx = 1 + table.GetColumnNumber(ycol); foundMoreColumns && idx < table.ColumnCount; idx++)
                {
                    DataColumn col = table[idx];
                    switch (table.GetColumnKind(idx))
                    {
                    case ColumnKind.Label:
                        var labelStyle = new LabelPlotStyle(col, context);
                        ps.Insert(0, labelStyle);
                        break;

                    case ColumnKind.Err:
                        ErrorBarPlotStyle errStyle = new ErrorBarYPlotStyle(context)
                        {
                            CommonErrorColumn = col as INumericColumn
                        };
                        ps.Add(errStyle);
                        break;

                    case ColumnKind.pErr:
                        if (null != unpairedNegativeError)
                        {
                            unpairedNegativeError.PositiveErrorColumn = col as INumericColumn;
                            ;
                            unpairedNegativeError = null;
                        }
                        else
                        {
                            unpairedPositiveError = new ErrorBarYPlotStyle(context)
                            {
                                UseCommonErrorColumn = false
                            };
                            unpairedPositiveError.PositiveErrorColumn = col as INumericColumn;
                            ps.Add(unpairedPositiveError);
                        }
                        break;

                    case ColumnKind.mErr:
                        if (null != unpairedPositiveError)
                        {
                            unpairedPositiveError.NegativeErrorColumn = col as INumericColumn;
                            unpairedPositiveError = null;
                        }
                        else
                        {
                            unpairedNegativeError = new ErrorBarYPlotStyle(context)
                            {
                                UseCommonErrorColumn = false
                            };
                            unpairedNegativeError.NegativeErrorColumn = col as INumericColumn;
                            ps.Add(unpairedNegativeError);
                        }
                        break;

                    default:
                        foundMoreColumns = false;
                        break;
                    }

                    if (foundMoreColumns)
                    {
                        processedColumns.Add(table[idx]);
                    }
                }

                result.Add(new XYColumnPlotItem(pa, ps));
            }
            return(result);
        }
示例#43
0
		public static G2DPlotStyleCollection PlotStyle_LineArea(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
		{
			G2DPlotStyleCollection result = new G2DPlotStyleCollection();
			var ps1 = new LinePlotStyle(context);
			var ps2 = new DropAreaPlotStyle(context) { FillDirection = Graph.CSPlaneID.Bottom };
			result.Add(ps1);
			result.Add(ps2);
			return result;
		}
示例#44
0
		/// <summary>
		/// Creates a list of plot items from data columns, using a template plot style.
		/// </summary>
		/// <param name="selectedColumns">Columns for which to create plot items.</param>
		/// <param name="xColumnName">Name of the x column. If it is null or empty, or that column is not found in the table, the current assigned x column is used.</param>
		/// <param name="templatePlotStyle">The template plot style used to create the basic plot item.</param>
		/// <param name="processedColumns">On return, contains all columns that where used in creating the plot items. That are
		/// not only the columns given in the first argument, but maybe also columns that are right to those columns in the table and have special kinds, like
		/// labels, yerr, and so on.</param>
		/// <param name="context">Property context used to determine default values, e.g. for the pen width or symbol size.</param>
		/// <returns>List of plot items created.</returns>
		public static List<IGPlotItem> CreatePlotItems(IEnumerable<DataColumn> selectedColumns, string xColumnName, G2DPlotStyleCollection templatePlotStyle, HashSet<DataColumn> processedColumns, Altaxo.Main.Properties.IReadOnlyPropertyBag context)
		{
			var result = new List<IGPlotItem>();
			foreach (DataColumn ycol in selectedColumns)
			{
				if (processedColumns.Contains(ycol))
					continue;
				else
					processedColumns.Add(ycol);

				DataColumnCollection table = DataColumnCollection.GetParentDataColumnCollectionOf(ycol);
				Altaxo.Data.DataColumn xcol;
				if (!string.IsNullOrEmpty(xColumnName) && null != table && table.ContainsColumn(xColumnName))
					xcol = table[xColumnName];
				else
					xcol = null == table ? null : table.FindXColumnOf(ycol);

				int groupNumber = table.GetColumnGroup(ycol);
				var parentTable = DataTable.GetParentDataTableOf(table);

				XYColumnPlotData pa;
				if (null != xcol)
					pa = new XYColumnPlotData(parentTable, groupNumber, xcol, ycol);
				else
					pa = new XYColumnPlotData(parentTable, groupNumber, new Altaxo.Data.IndexerColumn(), ycol);

				G2DPlotStyleCollection ps = templatePlotStyle != null ? (G2DPlotStyleCollection)templatePlotStyle.Clone() : new G2DPlotStyleCollection();

				if (null == table)
					continue;

				ErrorBarPlotStyle unpairedPositiveError = null;
				ErrorBarPlotStyle unpairedNegativeError = null;

				bool foundMoreColumns = true;
				for (int idx = 1 + table.GetColumnNumber(ycol); foundMoreColumns && idx < table.ColumnCount; idx++)
				{
					DataColumn col = table[idx];
					switch (table.GetColumnKind(idx))
					{
						case ColumnKind.Label:
							LabelPlotStyle labelStyle = new LabelPlotStyle(col, context);
							ps.Insert(0, labelStyle);
							break;

						case ColumnKind.Err:
							ErrorBarPlotStyle errStyle = new ErrorBarYPlotStyle(context);
							errStyle.PositiveErrorColumn = col as INumericColumn;
							errStyle.NegativeErrorColumn = col as INumericColumn;
							ps.Add(errStyle);
							break;

						case ColumnKind.pErr:
							if (null != unpairedNegativeError)
							{
								unpairedNegativeError.PositiveErrorColumn = col as INumericColumn; ;
								unpairedNegativeError = null;
							}
							else
							{
								unpairedPositiveError = new ErrorBarYPlotStyle(context);
								unpairedPositiveError.PositiveErrorColumn = col as INumericColumn;
								ps.Add(unpairedPositiveError);
							}
							break;

						case ColumnKind.mErr:
							if (null != unpairedPositiveError)
							{
								unpairedPositiveError.NegativeErrorColumn = col as INumericColumn;
								unpairedPositiveError = null;
							}
							else
							{
								unpairedNegativeError = new ErrorBarYPlotStyle(context);
								unpairedNegativeError.NegativeErrorColumn = col as INumericColumn;
								ps.Add(unpairedNegativeError);
							}
							break;

						default:
							foundMoreColumns = false;
							break;
					}

					if (foundMoreColumns)
						processedColumns.Add(table[idx]);
				}

				result.Add(new XYColumnPlotItem(pa, ps));
			}
			return result;
		}
示例#45
0
 public XYColumnPlotItem(XYColumnPlotData pa, G2DPlotStyleCollection ps)
 {
     this.Data  = pa;
     this.Style = ps;
 }
示例#46
0
		/// <summary>
		/// This plots a label plot into the provided layer.
		/// </summary>
		/// <param name="layer">The layer to plot into.</param>
		/// <param name="table">The table of PLS output data.</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.DataTable table, Altaxo.Data.DataColumn xcol, Altaxo.Data.DataColumn ycol, Altaxo.Data.DataColumn labelcol)
		{
			var context = layer.GetPropertyContext();

			var groupNumber = table.DataColumns.GetColumnGroup(ycol);
			XYColumnPlotData pa = new XYColumnPlotData(table, groupNumber, xcol, ycol);

			G2DPlotStyleCollection ps = new G2DPlotStyleCollection(LineScatterPlotStyleKind.Empty, layer.GetPropertyContext());
			LabelPlotStyle labelStyle = new LabelPlotStyle(labelcol, context);
			labelStyle.BackgroundStyle = new FilledRectangle(NamedColors.LightCyan);
			ps.Add(labelStyle);

			layer.PlotItems.Add(new XYColumnPlotItem(pa, ps));
		}