View Javadoc
1   package org.opentrafficsim.animation.graphs;
2   
3   import org.djunits.value.vdouble.scalar.Duration;
4   
5   /**
6    * Interface between plots (subclasses of {@link AbstractPlot}) and some source that knows about time in the context, e.g. a
7    * simulator, or a data loader which knows all time has past. For offline purposes, {@code PlotScheduler.OFFLINE} can be used.
8    * <p>
9    * Copyright (c) 2023-2026 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 Wouter Schakel
13   */
14  public interface PlotScheduler
15  {
16  
17      /**
18       * Default offline scheduler. This will only provide an infinite time, causing {@link AbstractPlot#update} to be invoked on
19       * all plots once.
20       */
21      PlotScheduler OFFLINE = new PlotScheduler()
22      {
23          @Override
24          public Duration getTime()
25          {
26              return Duration.ofSI(Double.MAX_VALUE);
27          }
28      };
29  
30      /**
31       * Returns the time.
32       * @return time
33       */
34      Duration getTime();
35  
36      /**
37       * Cancel event on plot.
38       * <p>
39       * The default implementation does nothing, allowing non-verbose anonymous extensions.
40       * @param abstractPlot plot
41       */
42      default void cancelEvent(final AbstractPlot<?> abstractPlot)
43      {
44          //
45      }
46  
47      /**
48       * Schedule {@link AbstractPlot#update} call on {@code abstractPlot}.
49       * <p>
50       * The default implementation does nothing, allowing non-verbose anonymous extensions.
51       * @param time time.
52       * @param abstractPlot plot.
53       */
54      default void scheduleUpdate(final Duration time, final AbstractPlot<?> abstractPlot)
55      {
56          //
57      }
58  
59      /**
60       * Schedule {@link AbstractPlot#update} call on {@code abstractPlot} now.
61       * <p>
62       * The default implementation does nothing, allowing non-verbose anonymous extensions.
63       * @param abstractPlot plot.
64       */
65      default void scheduleUpdateNow(final AbstractPlot<?> abstractPlot)
66      {
67          //
68      }
69  
70  }