View Javadoc
1   package org.opentrafficsim.road.network.factory.osm.events;
2   
3   import java.util.EventObject;
4   
5   /**
6    * <p>
7    * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
8    * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
9    * <p>
10   * $LastChangedDate: 2015-07-26 01:01:13 +0200 (Sun, 26 Jul 2015) $, @version $Revision: 1155 $, by $Author: averbraeck $,
11   * initial version 20.03.2015 <br>
12   * @author <a>Moritz Bergmann</a>
13   */
14  public class ProgressEvent extends EventObject
15  {
16      /** */
17      private static final long serialVersionUID = 1L;
18  
19      /** Time of first created progress event. */
20      private static Long first = null;
21  
22      /** Textual description of the progress made. */
23      private final String progressInformation;
24  
25      /** Time when the event occurred. */
26      private final long when;
27  
28      /**
29       * Construct a new ProgressEvent.
30       * @param source Object; the object from which the event originates
31       * @param description String; The progress information in a String
32       */
33      public ProgressEvent(final Object source, final String description)
34      {
35          super(source);
36          this.progressInformation = description;
37          this.when = System.currentTimeMillis();
38          if (null == first)
39          {
40              first = this.when;
41          }
42      }
43  
44      /**
45       * @return Progress Information in a String.
46       */
47      public final String getProgress()
48      {
49          return String.format("%8d ", (this.when - first) % 100000000L) + this.progressInformation;
50      }
51  
52      /** {@inheritDoc} */
53      @Override
54      public final String toString()
55      {
56          return "ProgressEvent [progressInformation=" + this.progressInformation + ", when=" + this.when + "]";
57      }
58  }