Class ContourDataSource<G extends GtuDataInterface>

java.lang.Object
org.opentrafficsim.draw.graphs.ContourDataSource<G>
Type Parameters:
G - gtu type data

public class ContourDataSource<G extends GtuDataInterface>
extends java.lang.Object
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-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Version:
$Revision$, $LastChangedDate$, by $Author$, initial version 5 okt. 2018
Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Field Details

  • Constructor Details

    • ContourDataSource

      public ContourDataSource​(Sampler<G> sampler, GraphPath<KpiLaneDirection> path)
      Constructor using default granularities.
      Parameters:
      sampler - Sampler<G>; sampler
      path - GraphPath<KpiLaneDirection>; path
    • ContourDataSource

      public ContourDataSource​(Sampler<G> sampler, Duration delay, GraphPath<KpiLaneDirection> path, double[] spaceGranularity, int initSpaceIndex, double[] timeGranularity, int initTimeIndex, Time start, Time initialEnd)
      Constructor for non-default input.
      Parameters:
      sampler - Sampler<G>; sampler
      delay - Duration; delay so critical future events have occurred, e.g. GTU's next move's to extend trajectories
      path - GraphPath<KpiLaneDirection>; path
      spaceGranularity - double[]; granularity options for space dimension
      initSpaceIndex - int; initial selected space granularity
      timeGranularity - double[]; granularity options for time dimension
      initTimeIndex - int; initial selected time granularity
      start - Time; start time
      initialEnd - Time; initial end time of plots, will be expanded if simulation time exceeds it
  • Method Details

    • getSampler

      public final Sampler<G> getSampler()
      Returns the sampler for an AbstractContourPlot using this ContourDataSource.
      Returns:
      Sampler<G>; the sampler
    • getGranularities

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

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

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

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

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

      public double getSpeed​(int item)
      Returns the speed of the cell pertaining to plot item.
      Parameters:
      item - int; plot item
      Returns:
      double; speed of the cell, calculated as 'total distance' / 'total space'.
    • getTotalDistance

      public double getTotalDistance​(int item)
      Returns the total distance traveled in the cell pertaining to plot item.
      Parameters:
      item - int; plot item
      Returns:
      double; total distance traveled in the cell
    • getTotalTime

      public double getTotalTime​(int item)
      Returns the total time traveled in the cell pertaining to plot item.
      Parameters:
      item - int; plot item
      Returns:
      double; total time traveled in the cell
    • get

      public double get​(int item, ContourDataSource.ContourDataType<?,​?> contourDataType)
      Returns data of the given ContourDataType for a specific item.
      Parameters:
      item - int; plot item
      contourDataType - ContourDataType<?, ?>; contour data type
      Returns:
      data of the given ContourDataType for a specific item
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object