Package org.opentrafficsim.draw.graphs
Class GraphUtil
- java.lang.Object
-
- org.opentrafficsim.draw.graphs.GraphUtil
-
public final class GraphUtil extends java.lang.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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.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.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> ChartMouseListener
getToggleSeriesByLegendListener(LegendItemCollection legend, java.util.List<java.lang.Boolean> visibility)
Returns a chart listener that allows the series to be enabled and disabled by clicking on the respective legend item.
-
-
-
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<?>; trajectorystartTime
- Time; start timeendTime
- 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<?>; trajectorystartPosition
- Length; start positionendPosition
- 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 arraycapacity
- 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 arraycapacity
- 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 arraycapacity
- int; required capacity- Returns:
- int[]; array with at least the requested capacity
-
getToggleSeriesByLegendListener
public static <K> ChartMouseListener getToggleSeriesByLegendListener(LegendItemCollection legend, java.util.List<java.lang.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; legendvisibility
- List<Boolean>; visibility of each series; the listener will store visibility in this list, which anAbstractRenderer
can use inisSeriesVisible(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
-
-