Class ContourDataSource

All Implemented Interfaces:
EventProducer

Class that contains data for contour plots. One data source can be shared between contour plots, in which case the granularity, path, sampler, update interval, and whether the data is smoothed (EGTF) are equal between the plots.

By default the source contains traveled time and traveled distance per cell.

Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Field Details

    • GRANULARITY

      public static final EventType GRANULARITY
      Granularity changed.
    • INTERPOLATE

      public static final EventType INTERPOLATE
      Interpolation changed.
    • SMOOTH

      public static final EventType SMOOTH
      Smooth changed.
    • SPACE_GRANULARITIES

      protected static final PlotSetting<org.djunits.value.vdouble.scalar.Length> SPACE_GRANULARITIES
      Space granularities.
    • TIME_GRANULARITIES

      protected static final PlotSetting<org.djunits.value.vdouble.scalar.Duration> TIME_GRANULARITIES
      Time granularities.
    • DEFAULT_LOWER_TIME_BOUND

      protected static final org.djunits.value.vdouble.scalar.Duration DEFAULT_LOWER_TIME_BOUND
      Initial lower bound for the time scale.
  • Constructor Details

    • ContourDataSource

      public ContourDataSource(SamplerData<?> samplerData, GraphPath<? extends LaneData<?>> path, PlotScheduler plotScheduler)
      Constructor using default granularities.
      Parameters:
      samplerData - sampler data
      path - path
      plotScheduler - plot scheduler
    • ContourDataSource

      public ContourDataSource(SamplerData<?> samplerData, org.djunits.value.vdouble.scalar.Duration delay, GraphPath<? extends LaneData<?>> path, PlotScheduler plotScheduler, PlotSetting<org.djunits.value.vdouble.scalar.Length> spaceGranularities, PlotSetting<org.djunits.value.vdouble.scalar.Duration> timeGranularities, org.djunits.value.vdouble.scalar.Duration start, org.djunits.value.vdouble.scalar.Duration initialEnd)
      Constructor for non-default input.
      Parameters:
      samplerData - sampler data
      delay - delay so critical future events have occurred, e.g. GTU's next move's to extend trajectories
      path - path
      plotScheduler - plot scheduler
      spaceGranularities - granularity options for space dimension
      timeGranularities - granularity options for time dimension
      start - start time
      initialEnd - initial end time of plots, will be expanded if simulation time exceeds it
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • addPlot

      public void addPlot(AbstractContourPlot<?> contourPlot)
      Description copied from class: PlotDelegate
      Add plot. Used to notify plots when data has changed.
      Overrides:
      addPlot in class PlotDelegate<AbstractContourPlot.ContourPaintState,AbstractContourPlot<?>>
      Parameters:
      contourPlot - plot
    • getGranularities

      public double[] getGranularities(ContourDataSource.Dimension dimension)
      Returns the available granularities that a linked plot may use.
      Parameters:
      dimension - space or time
      Returns:
      available granularities that a linked plot may use
    • getGranularity

      public double getGranularity(ContourDataSource.Dimension dimension)
      Returns the selected granularity that a linked plot should use.
      Parameters:
      dimension - space or time
      Returns:
      granularity that a linked plot should use
    • setGranularity

      public void setGranularity(ContourDataSource.Dimension dimension, double granularity)
      Sets the granularity of the plot. This will invalidate the plot triggering a redraw.
      Parameters:
      dimension - space or time
      granularity - granularity in space or time (SI unit)
    • setInterpolate

      public void setInterpolate(boolean interpolate)
      Sets bi-linear interpolation enabled or disabled. This will invalidate the plot triggering a redraw.
      Parameters:
      interpolate - whether to enable interpolation
    • setSmooth

      public void setSmooth(boolean smooth)
      Sets the adaptive smoothing enabled or disabled. This will invalidate the plot triggering a redraw.
      Parameters:
      smooth - whether to smooth the plot
    • calculatePaintStateUnsafe

      protected void calculatePaintStateUnsafe(org.djunits.value.vdouble.scalar.Duration t)
      Heart of the data pool. This method is invoked regularly by the worker thread of a plot, either for a scheduled update or due to user input. No two invocations can happen at the same time.

      This method regularly checks conditions that indicate the update should be interrupted as for example a setting has changed and repainting is required. Whenever a new invalidation causes PlotDelegate.invalidateTimeSpan() to be invoked, this method can stop as the full data needs to be recalculated. This can be set by any change of e.g. granularity or smoothing, during the update.

      Specified by:
      calculatePaintStateUnsafe in class PlotDelegate<AbstractContourPlot.ContourPaintState,AbstractContourPlot<?>>
      Parameters:
      t - time up to which to show data