Class SwitchableGtuColorer

    • Constructor Detail

      • SwitchableGtuColorer

        public SwitchableGtuColorer​(int activeIndex,
                                    GtuColorer... colorers)
                             throws IndexOutOfBoundsException
        Construct 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 IndexOutOfBoundsException
        Replace 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.
      • getColor

        public final 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 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:
        getLegend in interface GtuColorer
        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