TotalDesireColorer.java

  1. package org.opentrafficsim.animation.colorer;

  2. import java.awt.Color;

  3. import org.opentrafficsim.base.parameters.Parameters;
  4. import org.opentrafficsim.core.gtu.Gtu;
  5. import org.opentrafficsim.road.gtu.lane.tactical.util.lmrs.LmrsParameters;

  6. /**
  7.  * Colorer for total desire.
  8.  * <p>
  9.  * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  10.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  11.  * </p>
  12.  * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
  13.  * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
  14.  * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
  15.  */
  16. public class TotalDesireColorer extends DesireColorer
  17. {

  18.     /** */
  19.     private static final long serialVersionUID = 20170414L;

  20.     @Override
  21.     public final Color getColor(final Gtu gtu)
  22.     {
  23.         Parameters params = gtu.getParameters();
  24.         Double dLeft = params.getParameterOrNull(LmrsParameters.DLEFT);
  25.         Double dRight = params.getParameterOrNull(LmrsParameters.DRIGHT);
  26.         if (dLeft == null || dRight == null)
  27.         {
  28.             return NA;
  29.         }
  30.         return getColor(dLeft, dRight);
  31.     }

  32.     @Override
  33.     public final String getName()
  34.     {
  35.         return "Total desire";
  36.     }

  37. }