FixedColor.java

  1. package org.opentrafficsim.road.gtu.colorer;

  2. import java.awt.Color;
  3. import java.io.Serializable;
  4. import java.util.ArrayList;
  5. import java.util.List;

  6. import org.opentrafficsim.core.animation.gtu.colorer.GTUColorer;
  7. import org.opentrafficsim.core.gtu.GTU;

  8. /**
  9.  * Fixed color colorer.
  10.  * <p>
  11.  * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  12.  * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
  13.  * <p>
  14.  * @version $Revision$, $LastChangedDate$, by $Author$, initial version 17 jan. 2018 <br>
  15.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  16.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  17.  * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  18.  */
  19. public class FixedColor implements GTUColorer, Serializable
  20. {

  21.     /** */
  22.     private static final long serialVersionUID = 20180117L;

  23.     /** The color. */
  24.     private final Color color;

  25.     /** Color name. */
  26.     private final String name;

  27.     /**
  28.      * Constructor.
  29.      * @param color Color; the color
  30.      * @param name String; color name
  31.      */
  32.     public FixedColor(final Color color, final String name)
  33.     {
  34.         this.color = color;
  35.         this.name = name;
  36.     }

  37.     /**
  38.      * Constructor.
  39.      * @param color Color; the color
  40.      */
  41.     public FixedColor(final Color color)
  42.     {
  43.         this(color, "Fixed color");
  44.     }

  45.     /** {@inheritDoc} */
  46.     @Override
  47.     public Color getColor(final GTU gtu)
  48.     {
  49.         return this.color;
  50.     }

  51.     /** {@inheritDoc} */
  52.     @Override
  53.     public List<LegendEntry> getLegend()
  54.     {
  55.         return new ArrayList<>();
  56.     }

  57.     /** {@inheritDoc} */
  58.     @Override
  59.     public String toString()
  60.     {
  61.         return this.name;
  62.     }

  63. }