Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PlotLineSpan.cs
1using System;
3
5{
9 public class PlotLineSpan : PlotLine
10 {
11 private readonly string spanColor;
12 private Series min = null;
13 private Series max = null;
14
20 : base(Model)
21 {
22 this.spanColor = "Blue";
23 }
24
30 public PlotLineSpan(Model Model, string Color)
31 : this(Model, Color, Color)
32 {
33 }
34
41 public PlotLineSpan(Model Model, string Color, string SpanColor)
42 : base(Model, Color)
43 {
44 this.spanColor = SpanColor;
45 }
46
51 public override void Add(Statistic Record)
52 {
53 if (Record.Mean.HasValue)
54 {
55 this.AddPoint(this.GetStartTime(Record), Record.Mean.Value);
56 this.AddPoint(this.GetStopTime(Record), Record.Mean.Value);
57
58 if (Record.Min.HasValue && Record.Max.HasValue)
59 {
60 if (this.min is null)
61 {
62 this.min = new Series("Min" + this.Index.ToString());
63 this.max = new Series("Max" + this.Index.ToString());
64 }
65
66 this.min.Add(Record.Min.Value);
67 this.min.Add(Record.Min.Value);
68
69 this.max.Add(Record.Max.Value);
70 this.max.Add(Record.Max.Value);
71 }
72 }
73 else if (Record.Count > 0)
74 {
75 this.AddPoint(this.GetStartTime(Record), Record.Count);
76 this.AddPoint(this.GetStopTime(Record), Record.Count);
77 }
78 else
79 this.Break();
80 }
81
85 public override void Break()
86 {
87 if (!(this.min is null))
88 {
89 this.graph.AppendLine(this.min.EndSeries());
90 this.graph.AppendLine(this.max.EndSeries());
91
92 this.min = null;
93 this.max = null;
94 }
95
96 base.Break();
97 }
98
103 public override string GetPlotScript()
104 {
105 this.Break();
106
107 int i;
108
109 for (i = 1; i < this.Index; i++)
110 {
111 if (i > 1)
112 this.graph.Append('+');
113
114 this.graph.Append("polygon2d(join(x");
115 this.graph.Append(i.ToString());
116 this.graph.Append(",Reverse(x");
117 this.graph.Append(i.ToString());
118 this.graph.Append(")),join(Min");
119 this.graph.Append(i.ToString());
120 this.graph.Append(",Reverse(Max");
121 this.graph.Append(i.ToString());
122 this.graph.Append(")),alpha(\"");
123 this.graph.Append(this.spanColor);
124 this.graph.Append("\",16))");
125 }
126
127 for (i = 1; i < this.Index; i++)
128 {
129 this.graph.Append("+plot2dline(x");
130 this.graph.Append(i.ToString());
131 this.graph.Append(",Min");
132 this.graph.Append(i.ToString());
133 this.graph.Append(",alpha(\"");
134 this.graph.Append(this.spanColor);
135 this.graph.Append("\",32))");
136 this.graph.Append("+plot2dline(x");
137 this.graph.Append(i.ToString());
138 this.graph.Append(",Max");
139 this.graph.Append(i.ToString());
140 this.graph.Append(",alpha(\"");
141 this.graph.Append(this.spanColor);
142 this.graph.Append("\",32))");
143 }
144
145 if (this.Index > 1)
146 this.graph.Append('+');
147
148 return base.GetPlotScript();
149 }
150
151 }
152}
Root node of a simulation model
Definition: Model.cs:49
double GetStopTime(Statistic Record)
Gets the stop time of a statistic.
Definition: Plot.cs:37
double GetStartTime(Statistic Record)
Gets the start time of a statistic.
Definition: Plot.cs:27
void AddPoint(double X, double Y)
Adds a point to the graph.
Definition: PlotLine.cs:84
readonly StringBuilder graph
Graph being built.
Definition: PlotLine.cs:21
Plots a line graph with min-max span
Definition: PlotLineSpan.cs:10
override void Break()
Breaks the graph.
Definition: PlotLineSpan.cs:85
PlotLineSpan(Model Model, string Color, string SpanColor)
Plots a line graph with min-max span
Definition: PlotLineSpan.cs:41
override void Add(Statistic Record)
Adds a statistic to the plot.
Definition: PlotLineSpan.cs:51
PlotLineSpan(Model Model, string Color)
Plots a line graph with min-max span
Definition: PlotLineSpan.cs:30
override string GetPlotScript()
Gets the plot script
PlotLineSpan(Model Model)
Plots a line graph with min-max span
Definition: PlotLineSpan.cs:19
string EndSeries()
Ends the series.
Definition: Series.cs:43
void Add(double Value)
Adds a value to the series.
Definition: Series.cs:29
Represents collected statistical information from a small portion of time.
Definition: Statistic.cs:12
double? Min
Smallest value
Definition: Statistic.cs:117
double? Max
Largest value
Definition: Statistic.cs:122
long Count
Number of events
Definition: Statistic.cs:97