Package org.opentrafficsim.draw.core
Class BoundsPaintScale
- java.lang.Object
-
- org.opentrafficsim.draw.core.BoundsPaintScale
-
- All Implemented Interfaces:
java.io.Serializable,PaintScale,ColorPaintScale
public class BoundsPaintScale extends java.lang.Object implements ColorPaintScale, java.io.Serializable
Paint scale interpolating between colors at values.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 8 okt. 2018
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.awt.Color[]GREEN_RED3-color scale from green to red.static java.awt.Color[]GREEN_RED_DARK5-color scale from green to red with dark edges.
-
Constructor Summary
Constructors Constructor Description BoundsPaintScale(double[] bounds, java.awt.Color[] boundColors)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetLowerBound()java.awt.ColorgetPaint(double value)doublegetUpperBound()static java.awt.Color[]hue(int n)Creates an array ofncolors with varying hue.static java.awt.Color[]reverse(java.awt.Color[] colors)Reverses the color array.java.lang.StringtoString()
-
-
-
Constructor Detail
-
BoundsPaintScale
public BoundsPaintScale(double[] bounds, java.awt.Color[] boundColors) throws java.lang.IllegalArgumentExceptionConstructor.- Parameters:
bounds- double[]; value boundsboundColors- Color[]; colors at bounds- Throws:
java.lang.IllegalArgumentException- if less than 2 bounds, unequal number of bounds and colors, or duplicate bounds
-
-
Method Detail
-
reverse
public static java.awt.Color[] reverse(java.awt.Color[] colors)
Reverses the color array.- Parameters:
colors- Color[]; array of colors- Returns:
- Color[]; reversed color array
-
hue
public static java.awt.Color[] hue(int n)
Creates an array ofncolors with varying hue.- Parameters:
n- int; number of colors.- Returns:
- Color[]; array of
ncolors with varying hue
-
getPaint
public java.awt.Color getPaint(double value)
- Specified by:
getPaintin interfaceColorPaintScale- Specified by:
getPaintin interfacePaintScale
-
getLowerBound
public final double getLowerBound()
- Specified by:
getLowerBoundin interfacePaintScale
-
getUpperBound
public final double getUpperBound()
- Specified by:
getUpperBoundin interfacePaintScale
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-