Class SwitchableGTUColorer

    • Constructor Detail

      • SwitchableGTUColorer

        public SwitchableGTUColorer​(int activeIndex,
                                    GTUColorer... colorers)
                             throws java.lang.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:
        java.lang.IndexOutOfBoundsException - when activeIndex < 0 or larger than or equal to the number of colorers.
    • Method Detail

      • setGTUColorer

        public final void setGTUColorer​(int activeIndex)
                                 throws java.lang.IndexOutOfBoundsException
        Replace the currently active GTUColorer.
        Parameters:
        activeIndex - int; the index of the new active colorer in the list (0-based).
        Throws:
        java.lang.IndexOutOfBoundsException - when activeIndex < 0 or larger than or equal to the number of colorers.
      • getColor

        public final 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 final 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 final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getColorers

        public final java.util.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