Class ColorHandle


public class ColorHandle extends ComplexValueHandle
Handle to work with a color property. Works with element properties and structure members.

The application generally does not create color handles directly. It uses the method in other handle to get a color handle like:

A color property may be in the following format:

  • A hexadecimal number in Java or HTML format: "#rrggbb", "#rgb" or "0xRRGGBB"
  • A decimal number: "16711680"
  • A CSS color name: "Red", "Green".
  • A localized CSS color name.
  • CSS absolute or relative format: {rgb(r,g,b)} or {rgb(r%,g%,b%)}
  • A custom defined color.

 ColorHandle colorHandle = styleHandle.getColor();
 

Use ColorUtil.format(int, int)and ColorUtil.format(String, int)to do the formatting work on a color value.

See Also:
  • Constructor Details

    • ColorHandle

      public ColorHandle(DesignElementHandle element, org.eclipse.birt.report.model.core.StructureContext context)
      Constructs a color handle for a member in a structure. This member must be a color type.
      Parameters:
      element - the design element handle
      context - the context for the member property
    • ColorHandle

      @Deprecated public ColorHandle(DesignElementHandle element, org.eclipse.birt.report.model.core.MemberRef context)
      Deprecated.
      Constructs a color handle for a member in a structure. This member must be a color type.
      Parameters:
      element - the design element handle
      context - the context for the member property
    • ColorHandle

      public ColorHandle(DesignElementHandle element, org.eclipse.birt.report.model.metadata.ElementPropertyDefn thePropDefn)
      Constructs a color handle for a element property. This property must be a color type.
      Parameters:
      element - handle to the element that defined the property.
      thePropDefn - definition of the color property.
  • Method Details

    • getRGB

      public int getRGB()
      Returns the color value as an integer RGB value. Return -1 if color value is not set( value is null) or the value is not a valid internal value for a color.
      Returns:
      the color value as an integer RGB value
      See Also:
      • ColorPropertyType.toInteger(Module, Object)
    • setRGB

      public void setRGB(int rgbValue) throws SemanticException
      Sets a color with a given integer RGB value.
      Parameters:
      rgbValue - rgb color value.
      Throws:
      SemanticException - if the rgb value is invalid.
    • getCssValue

      public String getCssValue()
      Returns a CSS-compatible color value. It is a CSS-defined color name like "red", or a CSS absolute RGB value like RGB(255,0,0).
      Returns:
      a CSS-compatible color value
      See Also:
      • ColorPropertyType.toCSSCompatibleColor(ReportDesign, Object)
    • getColors

      public List getColors()
      Returns a list containing all the names of both standard(CSS) colors or user defined colors. The color names are localized.
      Returns:
      a list of localized color names, including both standard(CSS) colors and user defined colors.
    • getCSSColors

      public List getCSSColors()
      Returns a list containing standard(CSS) color names. The names are localized.
      Returns:
      a list of localized CSS color names.