Class GraphUtil


  • public final class GraphUtil
    extends Object
    Contains some static utilities.

    Copyright (c) 2013-2020 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 15 okt. 2018
    Author:
    Alexander Verbraeck, Peter Knoppers, Wouter Schakel
    • Method Detail

      • considerTrajectory

        public static boolean considerTrajectory​(Trajectory<?> trajectory,
                                                 Time startTime,
                                                 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,
                                                 Length startPosition,
                                                 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> ChartMouseListener getToggleSeriesByLegendListener​(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