1 package org.opentrafficsim.road.gtu.colorer;
2
3 import java.awt.Color;
4 import java.io.Serializable;
5 import java.util.ArrayList;
6 import java.util.List;
7
8 import org.opentrafficsim.core.animation.gtu.colorer.GTUColorer;
9 import org.opentrafficsim.core.gtu.GTU;
10
11 /**
12 * Fixed color colorer.
13 * <p>
14 * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15 * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
16 * <p>
17 * @version $Revision$, $LastChangedDate$, by $Author$, initial version 17 jan. 2018 <br>
18 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
19 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
20 * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
21 */
22 public class FixedColor implements GTUColorer, Serializable
23 {
24
25 /** */
26 private static final long serialVersionUID = 20180117L;
27
28 /** The color. */
29 private final Color color;
30
31 /** Color name. */
32 private final String name;
33
34 /**
35 * Constructor.
36 * @param color Color; the color
37 * @param name String; color name
38 */
39 public FixedColor(final Color color, final String name)
40 {
41 this.color = color;
42 this.name = name;
43 }
44
45 /**
46 * Constructor.
47 * @param color Color; the color
48 */
49 public FixedColor(final Color color)
50 {
51 this(color, "Fixed color");
52 }
53
54 /** {@inheritDoc} */
55 @Override
56 public Color getColor(final GTU gtu)
57 {
58 return this.color;
59 }
60
61 /** {@inheritDoc} */
62 @Override
63 public List<LegendEntry> getLegend()
64 {
65 return new ArrayList<>();
66 }
67
68 /** {@inheritDoc} */
69 @Override
70 public String toString()
71 {
72 return this.name;
73 }
74
75 }