Exemplo n.º 1
0
        /// <summary>
        /// ラベル系列からデータを作成します
        /// </summary>
        /// <param name="labelSequence">ラベル系列</param>
        /// <param name="title">このデータに与えるタイトル</param>
        /// <param name="colorPalette">ラベル名からラベルの色を生成するディクショナリ</param>
        /// <returns></returns>
        public static SequenceData FromLabelSequence(ICSLabelSequence labelSequence, string title, IDictionary <string, Color> colorPalette)
        {
            if (labelSequence == null)
            {
                throw new ArgumentNullException("labelSequence", "'labelSequence' cannot be null");
            }
            TimeSeriesValues newSeqeunce = new TimeSeriesValues(title);
            LabelingBorders  newBorder   = new LabelingBorders();

            foreach (var label in labelSequence.EnumerateLabels())
            {
                newSeqeunce[label.BeginTime] = new decimal?[] { label.BeginTime };
                newBorder.SetBorder(label.BeginTime, label.LabelText);
            }
            newSeqeunce[labelSequence.Duration] = new decimal?[] { labelSequence.Duration };
            newBorder.SetBorder(labelSequence.Duration, newBorder.DefaultName);

            if (colorPalette != null)
            {
                foreach (var pair in colorPalette)
                {
                    newBorder.SetColor(pair.Key, pair.Value);
                }
            }

            SequenceData ret = new SequenceData(newSeqeunce, newBorder, title);

            ret.Type = SequenceType.Label;
            return(ret);
        }
Exemplo n.º 2
0
        /// <summary>
        /// ラベル系列を返します.
        /// </summary>
        /// <returns></returns>
        public ICSLabelSequence GetLabelSequence()
        {
            if (this.IsDisposed)
            {
                throw new ObjectDisposedException(this.GetType().ToString());
            }
            using (this.Lock.GetReadLock()) {
                if (this.Values.ColumnCount == 0)
                {
                    return(new ICSLabelSequence());
                }
                if (this.Borders.TargetColumnIndex >= this.Values.ColumnCount)
                {
                    this.Borders.TargetColumnIndex = this.Values.ColumnCount - 1;
                }
                decimal span = this.Values.EndTime;
                if (span <= 0)
                {
                    span = 1;
                }
                ICSLabelSequence ret      = new ICSLabelSequence(span);
                string           preLabel = null;
                int prevBorderIndex       = -1;
                foreach (var pair in this.Values.Enumerate())
                {
                    decimal?value = pair.Value[this.Borders.TargetColumnIndex];
                    int     borderIndex;
                    if (value.HasValue)
                    {
                        borderIndex = this.Borders.GetIndexFromValue(value.Value);
                    }
                    else
                    {
                        borderIndex = -1;
                    }

                    string label = this.Borders.GetLabelByValue(value);
                    if (prevBorderIndex != borderIndex)
                    {
                        if (pair.Key < span)
                        {
                            ret.SetLabel(pair.Key, span, label);
                        }
                        preLabel = label;
                    }
                    prevBorderIndex = borderIndex;
                }
                return(ret);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// ラベル系列からデータを作成します
 /// </summary>
 /// <param name="labelSequence">ラベル系列</param>
 /// <param name="title">このデータに与えるタイトル</param>
 /// <returns></returns>
 public static SequenceData FromLabelSequence(ICSLabelSequence labelSequence, string title)
 {
     return(FromLabelSequence(labelSequence, title, null));
 }