Package org.opentrafficsim.draw
Class Colors
java.lang.Object
org.opentrafficsim.draw.Colors
List of colors to use for various legends.
Copyright (c) 2023-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Peter Knoppers, Wouter Schakel
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Color[]10-color scale for enumeration.static final String[]Names of the enumerated colors.static final Color[]3-color scale from green to red.static final Color[]5-color scale from green to red with dark edges.static final Color[]6-color scale from magenta, through red-green, to blue. -
Method Summary
Modifier and TypeMethodDescriptionstatic ColorgetEnumerated(int index) Returns a color for the index.static ColorgetIdColor(String id, Color[] colors) Returns a color from an array, where the used index is determined based on the id.static Color[]hue(int n) Creates an array ofncolors with varying hue.static StringnameEnumerated(int index) Returns the name of a color for the index.static Color[]Reverses the color array.
-
Field Details
-
GREEN_RED
3-color scale from green to red. -
GREEN_RED_DARK
5-color scale from green to red with dark edges. -
ULTRA
6-color scale from magenta, through red-green, to blue. -
ENUMERATE
10-color scale for enumeration. -
ENUMERATE_NAMES
Names of the enumerated colors.
-
-
Method Details
-
reverse
Reverses the color array.- Parameters:
colors- array of colors- Returns:
- reversed color array
-
hue
Creates an array ofncolors with varying hue.- Parameters:
n- number of colors.- Returns:
- array of
ncolors with varying hue
-
getEnumerated
Returns a color for the index. Modulo is applied for indices outside of the normal range.- Parameters:
index- index.- Returns:
- color for index.
-
nameEnumerated
Returns the name of a color for the index. Modulo is applied for indices outside of the normal range.- Parameters:
index- index.- Returns:
- name of color for index.
-
getIdColor
Returns a color from an array, where the used index is determined based on the id. If the last character of the id is a digit, that value is used. Otherwise it is the absolute hash code of the id. The modulo of either of these values given the number of colors is the index in the array of the color returned.- Parameters:
id- object idcolors- colors to select from- Returns:
- color
-