FixedColor.java

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

  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.gtu.GTU;
  7. import org.opentrafficsim.core.gtu.animation.GTUColorer;

  8. /**
  9.  * Fixed color colorer.
  10.  * <p>
  11.  * Copyright (c) 2013-2018 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.     /**
  39.      * Constructor.
  40.      * @param color Color; the color
  41.      */
  42.     public FixedColor(final Color color)
  43.     {
  44.         this(color, "Fixed color");
  45.     }

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

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

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

  64. }