AnimationPriorityData.java

  1. package org.opentrafficsim.animation.data;

  2. import org.djutils.draw.point.Point2d;
  3. import org.opentrafficsim.draw.road.PriorityAnimation.PriorityData;
  4. import org.opentrafficsim.road.network.lane.CrossSectionLink;

  5. /**
  6.  * Priority data for animation.
  7.  * <p>
  8.  * Copyright (c) 2024-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  9.  * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  10.  * </p>
  11.  * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
  12.  */
  13. public class AnimationPriorityData implements PriorityData
  14. {

  15.     /** Link. */
  16.     final private CrossSectionLink link;

  17.     /**
  18.      * Constructor.
  19.      * @param link CrossSectionLink; link.
  20.      */
  21.     public AnimationPriorityData(final CrossSectionLink link)
  22.     {
  23.         this.link = link;
  24.     }

  25.     /** {@inheritDoc} */
  26.     @Override
  27.     public Point2d getLocation()
  28.     {
  29.         return this.link.getDesignLine().getLocationFractionExtended(0.5);
  30.     }

  31.     /** {@inheritDoc} */
  32.     @Override
  33.     public boolean isAllStop()
  34.     {
  35.         return this.link.getPriority().isAllStop();
  36.     }

  37.     /** {@inheritDoc} */
  38.     @Override
  39.     public boolean isBusStop()
  40.     {
  41.         return this.link.getPriority().isBusStop();
  42.     }

  43.     /** {@inheritDoc} */
  44.     @Override
  45.     public boolean isNone()
  46.     {
  47.         return this.link.getPriority().isNone();
  48.     }

  49.     /** {@inheritDoc} */
  50.     @Override
  51.     public boolean isPriority()
  52.     {
  53.         return this.link.getPriority().isPriority();
  54.     }

  55.     /** {@inheritDoc} */
  56.     @Override
  57.     public boolean isStop()
  58.     {
  59.         return this.link.getPriority().isStop();
  60.     }

  61.     /** {@inheritDoc} */
  62.     @Override
  63.     public boolean isYield()
  64.     {
  65.         return this.link.getPriority().isYield();
  66.     }

  67.     /** {@inheritDoc} */
  68.     @Override
  69.     public String toString()
  70.     {
  71.         return "Priority " + this.link.getId();
  72.     }

  73. }