Package org.opentrafficsim.draw.graphs
Class GraphUtil
java.lang.Object
org.opentrafficsim.draw.graphs.GraphUtil
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 TypeMethodDescriptionstatic 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.
-
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<?>; 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, 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<?>; 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> 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; 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
-