Class GTUTypeColorer

  • All Implemented Interfaces:
    java.io.Serializable, Colorer<GTU>, GTUColorer

    public class GTUTypeColorer
    extends java.lang.Object
    implements GTUColorer, java.io.Serializable
    Color by GTU type, based on the GTUType id or the enum id from the defaults.

    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 17 jan. 2018
    Author:
    Alexander Verbraeck, Peter Knoppers, Wouter Schakel
    See Also:
    Serialized Form
    • Field Detail

      • DEFAULT

        public static final GTUTypeColorer DEFAULT
        Default instance with colors for common GTUTypes.
    • Constructor Detail

      • GTUTypeColorer

        public GTUTypeColorer()
    • Method Detail

      • add

        public GTUTypeColorer add​(GTUType.DEFAULTS gtuTypeEnum)
        Adds a GTU type to the list with color from the default list.
        Parameters:
        gtuTypeEnum - GTUType; GTU type
        Returns:
        this GTUTypeColorer
      • add

        public GTUTypeColorer add​(GTUType gtuType)
        Adds a GTU type to the list with color based on the type.
        Parameters:
        gtuType - GTUType; GTU type
        Returns:
        this GTUTypeColorer
      • add

        public GTUTypeColorer add​(GTUType gtuType,
                                  java.awt.Color color)
        Adds a GTU type to the list with given color.
        Parameters:
        gtuType - GTUType; GTU type
        color - Color; color
        Returns:
        this GTUTypeColorer
      • add

        public GTUTypeColorer add​(GTUType.DEFAULTS gtuTypeEnum,
                                  java.awt.Color color)
        Adds a GTU type based on its enum to the list with given color.
        Parameters:
        gtuTypeEnum - GTUType.DEFAULTS; GTU type default enum
        color - Color; color
        Returns:
        this GTUTypeColorer
      • getColor

        public java.awt.Color getColor​(GTU gtu)
        Get the color, based on the Drawable object.
        Specified by:
        getColor in interface Colorer<GTU>
        Parameters:
        gtu - D; the object to determine the color for
        Returns:
        the (fill, line) color of the drawable object
      • getLegend

        public java.util.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:
        getLegend in interface GTUColorer
        Returns:
        List<LegendEntry>; the list of legend entries; the caller should not (try to) modify this List
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object