EgtfEvent.java

  1. package org.opentrafficsim.core.egtf;

  2. import java.util.EventObject;

  3. /**
  4.  * EGTF event with progress and the ability to interrupt calculations.
  5.  * <p>
  6.  * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  7.  * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
  8.  * <p>
  9.  * @version $Revision$, $LastChangedDate$, by $Author$, initial version 8 okt. 2018 <br>
  10.  * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  11.  */
  12. public class EgtfEvent extends EventObject
  13. {

  14.     /** */
  15.     private static final long serialVersionUID = 20181008L;

  16.     /** Progress, a value in the range [0 ... 1]. */
  17.     private final double progress;

  18.     /**
  19.      * Constructor.
  20.      * @param egtf EGTF; egtf
  21.      * @param progress double; progress, a value in the range [0 ... 1]
  22.      */
  23.     EgtfEvent(final EGTF egtf, final double progress)
  24.     {
  25.         super(egtf);
  26.         this.progress = progress;
  27.     }

  28.     /**
  29.      * Returns the progress, a value in the range [0 ... 1].
  30.      * @return double; progress, a value in the range [0 ... 1]
  31.      */
  32.     public final double getProgress()
  33.     {
  34.         return this.progress;
  35.     }

  36.     /**
  37.      * Interrupts the filter. If a {@code filter()} calculation is ongoing, it will stop and return {@code null}.
  38.      */
  39.     public final void interrupt()
  40.     {
  41.         ((EGTF) getSource()).interrupt();
  42.     }

  43.     /** {@inheritDoc} */
  44.     @Override
  45.     public String toString()
  46.     {
  47.         return "EgtfEvent [progress=" + this.progress + "]";
  48.     }

  49. }