1 package org.opentrafficsim.draw.graphs;
2
3 import java.awt.Color;
4
5 import org.djunits.unit.SpeedUnit;
6 import org.djunits.value.vdouble.scalar.Speed;
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 ContourPlotSpeed extends AbstractContourPlot<Speed>
23 {
24
25
26 private static final long serialVersionUID = 20181004L;
27
28
29
30
31
32
33
34 public ContourPlotSpeed(final String caption, final OTSSimulatorInterface simulator, final ContourDataSource<?> dataPool)
35 {
36 super(caption, simulator, dataPool, createPaintScale(), new Speed(30.0, SpeedUnit.KM_PER_HOUR), "%.0fkm/h",
37 "speed %.1f km/h");
38 }
39
40
41
42
43
44 private static BoundsPaintScale createPaintScale()
45 {
46 double[] boundaries = { 0.0, 30.0 / 3.6, 60.0 / 3.6, 110.0 / 3.6, 160.0 / 3.6 };
47 Color[] colorValues = BoundsPaintScale.reverse(BoundsPaintScale.GREEN_RED_DARK);
48 return new BoundsPaintScale(boundaries, colorValues);
49 }
50
51
52 @Override
53 public GraphType getGraphType()
54 {
55 return GraphType.SPEED_CONTOUR;
56 }
57
58
59 @Override
60 protected double scale(final double si)
61 {
62 return SpeedUnit.KM_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().getSpeed(item);
70 }
71
72
73 @Override
74 protected ContourDataType<Speed, ?> getContourDataType()
75 {
76 return null;
77 }
78
79
80 @Override
81 public String toString()
82 {
83 return "ContourPlotSpeed []";
84 }
85
86 }