Class GraphUtil

java.lang.Object
org.opentrafficsim.draw.graphs.GraphUtil

public final class GraphUtil extends Object
Contains some static utilities.

Copyright (c) 2013-2024 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
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    considerTrajectory(Trajectory<?> trajectory, org.djunits.value.vdouble.scalar.Length startPosition, org.djunits.value.vdouble.scalar.Length endPosition)
    Helper method for quick filtering of trajectories by checking if the position of the trajectory has overlap with the given range.
    static boolean
    considerTrajectory(Trajectory<?> trajectory, org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Time endTime)
    Helper method for quick filtering of trajectories by checking if the time of the trajectory has overlap with the given time.
    static double[]
    ensureCapacity(double[] data, int capacity)
    Ensures that the given capacity is available in the array.
    static float[]
    ensureCapacity(float[] data, int capacity)
    Ensures that the given capacity is available in the array.
    static int[]
    ensureCapacity(int[] data, int capacity)
    Ensures that the given capacity is available in the array.
    static <K> org.jfree.chart.ChartMouseListener
    getToggleSeriesByLegendListener(org.jfree.chart.LegendItemCollection legend, List<Boolean> visibility)
    Returns a chart listener that allows the series to be enabled and disabled by clicking on the respective legend item.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • considerTrajectory

      public static boolean considerTrajectory(Trajectory<?> trajectory, org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Time endTime)
      Helper method for quick filtering of trajectories by checking if the time of the trajectory has overlap with the given time.
      Parameters:
      trajectory - Trajectory<?>; trajectory
      startTime - Time; start time
      endTime - Time; end time
      Returns:
      boolean; true if the trajectory should be considered for the given time
    • considerTrajectory

      public static boolean considerTrajectory(Trajectory<?> trajectory, org.djunits.value.vdouble.scalar.Length startPosition, org.djunits.value.vdouble.scalar.Length endPosition)
      Helper method for quick filtering of trajectories by checking if the position of the trajectory has overlap with the given range.
      Parameters:
      trajectory - Trajectory<?>; trajectory
      startPosition - Length; start position
      endPosition - Length; end position
      Returns:
      boolean; true if the trajectory should be considered for the given time
    • ensureCapacity

      public static double[] ensureCapacity(double[] data, int capacity)
      Ensures that the given capacity is available in the array. The array may become or may be longer than the required capacity. This method assumes that the array has non-zero length, and that the capacity required is at most 1 more than what the array can provide.
      Parameters:
      data - double[]; data array
      capacity - int; required capacity
      Returns:
      double[]; array with at least the requested capacity
    • ensureCapacity

      public static float[] ensureCapacity(float[] data, int capacity)
      Ensures that the given capacity is available in the array. The array may become or may be longer than the required capacity. This method assumes that the array has non-zero length, and that the capacity required is at most 1 more than what the array can provide.
      Parameters:
      data - float[]; data array
      capacity - int; required capacity
      Returns:
      float[]; array with at least the requested capacity
    • ensureCapacity

      public static int[] ensureCapacity(int[] data, int capacity)
      Ensures that the given capacity is available in the array. The array may become or may be longer than the required capacity. This method assumes that the array has non-zero length, and that the capacity required is at most 1 more than what the array can provide.
      Parameters:
      data - int[]; data array
      capacity - int; required capacity
      Returns:
      int[]; array with at least the requested capacity
    • getToggleSeriesByLegendListener

      public static <K> org.jfree.chart.ChartMouseListener getToggleSeriesByLegendListener(org.jfree.chart.LegendItemCollection legend, List<Boolean> visibility)
      Returns a chart listener that allows the series to be enabled and disabled by clicking on the respective legend item.
      Type Parameters:
      K - underlying key type of the series
      Parameters:
      legend - LegendItemCollection; legend
      visibility - List<Boolean>; visibility of each series; the listener will store visibility in this list, which an AbstractRenderer can use in isSeriesVisible(series) to show or hide the series
      Returns:
      ChartMouseListener; listener that will allow series to be enabled and disabled by clicking on the respective legend item