Class GGradient

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class GGradient
    extends java.lang.Object
    implements java.lang.Cloneable
    This is a data holder class for gradient.
    Author:
    Christopher Mindus
    • Nested Class Summary

      Nested Classes 
      Modifier and TypeClassDescription
      static class GGradient.Swatch
      Inner class for a Swatch in a gradient.
    • Field Summary

      Fields 
      Modifier and TypeFieldDescription
      static GGradientNONE
      The no-swatches gradient.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidappendGradient​(SendTransaction trans)
      Appends the color to a transaction.
      GGradientclone()
      Clones this instance.
      static GGradientcreateGGradient​(java.lang.String string)
      Creates a GGradient from a String.
      booleanequals​(GGradient gradient)
      Checks if two gradient objects are equal.
      booleanequals​(java.lang.Object o)
      Checks if two color objects are equal.
      java.lang.StringgetCSSValue()
      Gets the CSS value String.
      intgetSize()
      Gets the size of a radial gradient (1-4096).
      intgetStart()
      Gets the start (0-7 for linear, 0-8 for radial).
      java.lang.StringgetString()
      Gets the color as a String in the form described below.
      GGradient.SwatchgetSwatch​(int index)
      Gets the swatch at specified index.
      intgetSwatchCount()
      Gets the swatch count.
      intgetType()
      Gets the type of the gradient, 0=linear, 1=radial.
      protected java.lang.StringparamString()
      Returns the parameter string representing the state of this event.
      java.lang.StringtoString()
      Returns a string representation of this class instance and its values.
      • Methods inherited from class java.lang.Object

        finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • NONE

        public static final GGradient NONE
        The no-swatches gradient.
    • Constructor Detail

      • GGradient

        public GGradient​(int start,
                         GGradient.Swatch[] swatches)
        Creates a linear gradient object.
         Start values:
           0  top left
           1  top
           2  top right 
           3  left 
           4  right
           5  bottom left
           6  bottom
           7  bottom right
         
        Parameters:
        start - The start 0-7.
        swatches - An array of swatches. This array must consist of at least two Swatch objects and maximum 32 objects.
        Throws:
        java.lang.IllegalArgumentException - For errors.
      • GGradient

        public GGradient​(int start,
                         int size,
                         GGradient.Swatch[] swatches)
        Creates a radial gradient object.
         Start values:
           0  top left
           1  top center
           2  top right
           3  middle left
           4  middle center
           5  middle right
           6  bottom left
           7  bottom center
           8  bottom right
        
         Size indications (it's percents):
           1  sub-petite
           5  petite
          10  extra small
          25  small
          50  medium
          75  large
          100  extra large
          200  jumbo
          400  colossal   
         
        Parameters:
        start - The start 0-7.
        size - The size in percent (1-4096).
        swatches - An array of swatches. This array must consist of at least two Swatch objects and maximum 32 objects.
        Throws:
        java.lang.IllegalArgumentException - For errors.
      • GGradient

        public GGradient​(int type,
                         int start,
                         int size,
                         GGradient.Swatch[] swatches)
        Creates a linear or radial gradient.
        Parameters:
        type - The type: 0=linear, 1=radial.
        start - Start of gradient (linear 0-7 or radial 0-8).
        size - Only for radial (1-4096).
        swatches - An array of swatches. This array must consist of at least two Swatch objects and maximum 32 objects.
        Throws:
        java.lang.IllegalArgumentException - For errors.
      • GGradient

        public GGradient​(java.lang.String string)
                  throws java.lang.IllegalArgumentException,
                         java.lang.NumberFormatException
        Creates a gradient from a String.
        Parameters:
        string - The string.
        Throws:
        java.lang.IllegalArgumentException - for errors in the string specification.
        java.lang.NumberFormatException - for invalid number formats.
      • GGradient

        public GGradient​(ReadTransaction trans)
        Creates a color from a transaction.
        Parameters:
        trans - The transaction.
    • Method Detail

      • createGGradient

        public static GGradient createGGradient​(java.lang.String string)
        Creates a GGradient from a String. If the string is null or empty, GGradient.NONE is returned, otherwise a new GGradient as if new GGradient(string) was called.
        Parameters:
        string - The string as 0xnnnnnnnn or decimal. It can be null or empty string too.
        Throws:
        java.lang.IllegalArgumentException - for errors in the string specification.
        java.lang.NumberFormatException - for invalid number formats.
      • appendGradient

        public void appendGradient​(SendTransaction trans)
        Appends the color to a transaction.
      • equals

        public boolean equals​(java.lang.Object o)
        Checks if two color objects are equal.
        Overrides:
        equals in class java.lang.Object
      • clone

        public GGradient clone()
        Clones this instance.
        Overrides:
        clone in class java.lang.Object
        Returns:
        As GGradient is immutable, cloning will return "this".
      • equals

        public boolean equals​(GGradient gradient)
        Checks if two gradient objects are equal.
        Parameters:
        gradient - another gradient object. If null, the gradients are not equal.
        Returns:
        true if equal, false otherwise.
      • getSwatchCount

        public int getSwatchCount()
        Gets the swatch count.
      • getSwatch

        public GGradient.Swatch getSwatch​(int index)
        Gets the swatch at specified index.
      • getType

        public int getType()
        Gets the type of the gradient, 0=linear, 1=radial.
      • getStart

        public int getStart()
        Gets the start (0-7 for linear, 0-8 for radial).
      • getSize

        public int getSize()
        Gets the size of a radial gradient (1-4096).
      • getString

        public java.lang.String getString()
        Gets the color as a String in the form described below.
        Returns:
        the String as described above.
      • paramString

        protected java.lang.String paramString()
        Returns the parameter string representing the state of this event. This string is useful for debugging. Subclasses adds extra information to the string by preceding it with a comma followed by the extra information.
        Returns:
        the parameter string of this event.
      • toString

        public java.lang.String toString()
        Returns a string representation of this class instance and its values.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of this class instance.
      • getCSSValue

        public java.lang.String getCSSValue()
        Gets the CSS value String.