1 package org.opentrafficsim.draw.graphs;
2
3 import java.awt.Color;
4
5 import org.djunits.unit.FrequencyUnit;
6 import org.djunits.value.vdouble.scalar.Frequency;
7 import org.opentrafficsim.core.dsol.OTSSimulatorInterface;
8 import org.opentrafficsim.draw.core.BoundsPaintScale;
9 import org.opentrafficsim.draw.graphs.ContourDataSource.ContourDataType;
10
11
12
13
14
15
16
17
18
19
20
21
22 public class ContourPlotFlow extends AbstractContourPlot<Frequency>
23 {
24
25
26 private static final long serialVersionUID = 20181010L;
27
28
29
30
31
32
33
34 public ContourPlotFlow(final String caption, final OTSSimulatorInterface simulator, final ContourDataSource<?> dataPool)
35 {
36 super(caption, simulator, dataPool, createPaintScale(), new Frequency(500.0, FrequencyUnit.PER_HOUR), "%.0f/h",
37 "flow %.1f veh/h");
38 }
39
40
41
42
43
44 private static BoundsPaintScale createPaintScale()
45 {
46 double[] boundaries = { 0.0, 500.0 / 3600, 1000.0 / 3600, 1500.0 / 3600, 2000.0 / 3600, 2500.0 / 3600, 3000.0 / 3600 };
47 Color[] colorValues = BoundsPaintScale.hue(7);
48 return new BoundsPaintScale(boundaries, colorValues);
49 }
50
51
52 @Override
53 public GraphType getGraphType()
54 {
55 return GraphType.FLOW_CONTOUR;
56 }
57
58
59 @Override
60 protected double scale(final double si)
61 {
62 return FrequencyUnit.PER_HOUR.getScale().fromStandardUnit(si);
63 }
64
65
66 @Override
67 protected double getValue(final int item, final double cellLength, final double cellSpan)
68 {
69 return getDataPool().getTotalDistance(item) / (cellLength * cellSpan);
70 }
71
72
73 @Override
74 protected ContourDataType<Frequency, ?> getContourDataType()
75 {
76 return null;
77 }
78
79
80 @Override
81 public String toString()
82 {
83 return "ContourPlotFlow []";
84 }
85
86 }