com.supermap.data

Class Colors



  • public class Colors
    extends InternalHandleDisposable

    The Colors class.

    This class is mainly for providing the color scheme as well as generating all kinds of gradient and random colors.

    This colors object can be used to set colors in those thematic maps such as ThemeUnique, ThemeRange, ThemeGraph, ThemeGraduatedSymbol, ThemeLabel, ThemeDotDensity and those geometric objects such asGeometry etc.

    • Constructor Summary

      Constructors 
      Constructor and Description
      Colors()
      Constructs a new Colors object.
      Colors(Color[] colors)
      Creates a new Colors object according to given parameters.
      Colors(Colors colors)
      Constructs a new object identical to the given Colors.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int add(Color color)
      This method is used to add a color element to the Colors, that is, add the specified color to current colors object.
      int addRange(Color[] colors)
      Adds the colors array to the current Colors.
      void clear()
      Clears all the colors in Colors.
      void dispose()
      Disposes the resources occupied by the object.
      Color get(int index)
      Returns the a single color from the Colors with the specified index.
      int getCount()
      Returns the number of the colors in the Colors object.
      boolean insert(int index, Color color)
      Inserts a specified color value at a specified position.
      static Colors makeGradient(int count, Color[] gradientColors)
      Generates gradient colors with the specified gradient color count and the gradient colors.
      static Colors makeGradient(int count, ColorGradientType type, boolean reverse)
      This method is used to generate gradient colors predefined by system.
      static Colors makeRandom(int count)
      Generate a set of random colors.
      Colors makeRandom(int count, Color[] color)
      Generate a set of random colors.
      boolean remove(int index)
      Removes one color starting at a specified index in the collection.
      void set(int index, Color value)
      Sets the a single color from the Colors with the specified index.
      Color[] toArray()
      Converts current colors object to a color array.
      java.lang.String toString()
      Returns a string that indicates the current Colors.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Colors

        public Colors()
        Constructs a new Colors object.
      • Colors

        public Colors(Color[] colors)
        Creates a new Colors object according to given parameters.
        Parameters:
        colors - the specified colors array of the Color.
      • Colors

        public Colors(Colors colors)
        Constructs a new object identical to the given Colors.
        Parameters:
        colors - the given Colors object.
    • Method Detail

      • get

        public Color get(int index)
        Returns the a single color from the Colors with the specified index.
        Parameters:
        index - the specified index of the color value, which begin with zero.
        Returns:
        the single color from the Colors with the specified index.
      • set

        public void set(int index,
                        Color value)
        Sets the a single color from the Colors with the specified index.
        Parameters:
        index - the specified index of the color value, which begin with zero.
        value - The color value of point.
      • getCount

        public int getCount()
        Returns the number of the colors in the Colors object.
        Returns:
        the number of the colors in the Colors object.
        Default:
        The default value is 0.
      • add

        public int add(Color color)
        This method is used to add a color element to the Colors, that is, add the specified color to current colors object. If successful, the color will be placed at the end of the Colors collection.
        Parameters:
        color - a color that represents the new color value to be added.
        Returns:
        the new index of color in Colors.
      • addRange

        public int addRange(Color[] colors)
        Adds the colors array to the current Colors.
        Parameters:
        colors - a colors array to be added to the instance of the Colors.
        Returns:
        the count of addition.
      • insert

        public boolean insert(int index,
                              Color color)
        Inserts a specified color value at a specified position.
        Parameters:
        index - The specified index where a color value is to be inserted.
        color - The specified color value to be inserted.
        Returns:
        Returns true If successful; otherwise false.
      • remove

        public boolean remove(int index)
        Removes one color starting at a specified index in the collection.
        Parameters:
        index - the specified index of the color.
        Returns:
        returns true If successful; otherwise false.
        See Also:
        clear()
      • clear

        public void clear()
        Clears all the colors in Colors.
      • makeRandom

        public static Colors makeRandom(int count)
        Generate a set of random colors.
        Parameters:
        count - the gradient color count being generated.
        Returns:
        a new random colors of this colors.
      • makeGradient

        public static Colors makeGradient(int count,
                                          Color[] gradientColors)
        Generates gradient colors with the specified gradient color count and the gradient colors.
        Parameters:
        count - the specified gradient color count being generated. Where, user can set the count of colors among the different gradient colors.
        gradientColors - the specified gradient colors which are the control colors user customized.
        Returns:
        a new random color instance of this colors.
      • makeGradient

        public static Colors makeGradient(int count,
                                          ColorGradientType type,
                                          boolean reverse)
        This method is used to generate gradient colors predefined by system.
        Parameters:
        count - the count of gradient colors to be generated.
        type - the type of gradient colors.
        reverse - whether to generate gradient colors reversely.
        Returns:
        a new gradient colors of the colors class.
        See Also:
        ColorGradientType
      • toArray

        public Color[] toArray()
        Converts current colors object to a color array.
        Returns:
        converts current colors object to a color array.
      • toString

        public java.lang.String toString()
        Returns a string that indicates the current Colors. The format is {Count=}.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string that represents the colors.
      • dispose

        public void dispose()
        Disposes the resources occupied by the object. After calling this method, this object will not be usable.
      • makeRandom

        public Colors makeRandom(int count,
                                 Color[] color)
        Generate a set of random colors.
        Parameters:
        count - The number of intervals.
        color - Control color collection.
        Returns:
        the random colors generated with the interval number and the control colors.