View Javadoc
1   package org.opentrafficsim.draw.egtf;
2   
3   import java.util.EventObject;
4   
5   /**
6    * EGTF event with progress and the ability to interrupt calculations.
7    * <p>
8    * Copyright (c) 2013-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 EgtfEvent extends EventObject
14  {
15  
16      /** */
17      private static final long serialVersionUID = 20181008L;
18  
19      /** Progress, a value in the range [0 ... 1]. */
20      private final double progress;
21  
22      /**
23       * Constructor.
24       * @param egtf EGTF; egtf
25       * @param progress double; progress, a value in the range [0 ... 1]
26       */
27      EgtfEvent(final Egtf egtf, final double progress)
28      {
29          super(egtf);
30          this.progress = progress;
31      }
32  
33      /**
34       * Returns the progress, a value in the range [0 ... 1].
35       * @return double; progress, a value in the range [0 ... 1]
36       */
37      public final double getProgress()
38      {
39          return this.progress;
40      }
41  
42      /**
43       * Interrupts the filter. If a {@code filter()} calculation is ongoing, it will stop and return {@code null}.
44       */
45      public final void interrupt()
46      {
47          ((Egtf) getSource()).interrupt();
48      }
49  
50      /** {@inheritDoc} */
51      @Override
52      public String toString()
53      {
54          return "EgtfEvent [progress=" + this.progress + "]";
55      }
56  
57  }