Class SwitchableGTUColorer
- java.lang.Object
-
- org.opentrafficsim.core.animation.gtu.colorer.SwitchableGTUColorer
-
- All Implemented Interfaces:
Serializable,Colorer<GTU>,GTUColorer
- Direct Known Subclasses:
DefaultSwitchableGTUColorer,LmrsSwitchableColorer
public class SwitchableGTUColorer extends Object implements GTUColorer, Serializable
GTU colorer that uses a coloring method that can be switched by the user of the program.Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.- Version:
- $Revision: 4742 $, $LastChangedDate: 2018-11-18 20:48:30 +0100 (Sun, 18 Nov 2018) $, by $Author: averbraeck $,
initial version 28 mei 2015
- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSwitchableGTUColorer.BuilderBuilder for SwitchableGTUColorer.-
Nested classes/interfaces inherited from interface org.opentrafficsim.core.animation.gtu.colorer.GTUColorer
GTUColorer.LegendEntry
-
-
Constructor Summary
Constructors Constructor Description SwitchableGTUColorer(int activeIndex, GTUColorer... colorers)Construct a new Switchable GTUColorer based on a list of colorers.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SwitchableGTUColorer.Builderbuilder()Returns a builder for SwitchableGTUColorer.ColorgetColor(GTU gtu)Get the color, based on the Drawable object.List<GTUColorer>getColorers()List<GTUColorer.LegendEntry>getLegend()Return a list of legend entries (useful to make a legend of the colors used to render the GTUs).voidsetGTUColorer(int activeIndex)Replace the currently active GTUColorer.StringtoString()
-
-
-
Constructor Detail
-
SwitchableGTUColorer
public SwitchableGTUColorer(int activeIndex, GTUColorer... colorers) throws IndexOutOfBoundsExceptionConstruct a new Switchable GTUColorer based on a list of colorers.- Parameters:
activeIndex- int; the index of the initially active colorer in the list (0-based).colorers- GTUColorer...; the list of GTUColorer. List cannot be empty.- Throws:
IndexOutOfBoundsException- when activeIndex < 0 or larger than or equal to the number of colorers.
-
-
Method Detail
-
setGTUColorer
public final void setGTUColorer(int activeIndex) throws IndexOutOfBoundsExceptionReplace the currently active GTUColorer.- Parameters:
activeIndex- int; the index of the new active colorer in the list (0-based).- Throws:
IndexOutOfBoundsException- when activeIndex < 0 or larger than or equal to the number of colorers.
-
getLegend
public final List<GTUColorer.LegendEntry> getLegend()
Return a list of legend entries (useful to make a legend of the colors used to render the GTUs).- Specified by:
getLegendin interfaceGTUColorer- Returns:
- List<LegendEntry>; the list of legend entries; the caller should not (try to) modify this List
-
getColorers
public final List<GTUColorer> getColorers()
- Returns:
- the list of colorers.
-
builder
public static final SwitchableGTUColorer.Builder builder()
Returns a builder for SwitchableGTUColorer.- Returns:
- Builder; builder for SwitchableGTUColorer
-
-