Package org.eclipse.birt.report.model.api.elements.structures

# Class CustomColor

java.lang.Object
org.eclipse.birt.report.model.core.Structure
org.eclipse.birt.report.model.core.ReferencableStructure
org.eclipse.birt.report.model.api.elements.structures.CustomColor

All Implemented Interfaces:
  `Cloneable`, `IStructure`, `org.eclipse.birt.report.model.core.IPropertySet`, `org.eclipse.birt.report.model.core.IReferencable`

public class CustomColor extends org.eclipse.birt.report.model.core.ReferencableStructure
Represents an custom color in the report's color palette.The use-defined color has a unique name and a valid RGB value for render.

This is a managed object, meaning that all changes should be made though the command layer so that they can be undone and redone. Each custom color has the following properties:

Name
  a custom color has a unique and required name, so the user can use the color name to identify a custom color.
color
  The color value of the color, it is preserved as the user typed in.
Resource Key
  a custom color has an optional display name ID to localize the display name.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected String`
`color`
The color value of the color, it is preserved as the user typed in.
`static final String`
`COLOR_MEMBER`
Name of the color value member.
`static final String`
`CUSTOM_COLOR_STRUCT`
Name of this structure.
`static final String`
`DISPLAY_NAME_ID_MEMBER`
Name of the display name ID member.
`static final String`
`DISPLAY_NAME_MEMBER`
Name of the display name member.
`protected String`
`displayName`
The display name for the color.
`protected String`
`displayNameID`
The message ID for the display name.
`protected String`
`name`
The internal color name such as "periwinkle".
`static final String`
`NAME_MEMBER`
Name of the color name member.

### Fields inherited from class org.eclipse.birt.report.model.core.ReferencableStructure

`clients, clientStructures, LIB_REFERENCE_MEMBER, libReference`

## Constructor Summary

Constructors
Constructor
Description
`CustomColor()`
Default constructor.
`CustomColor(String theName, String value)`
Constructs the custom color with a required name and RGB value.

## Method Summary

Modifier and Type
Method
Description
`String`
`getColor()`
Returns the color value as what the user has input.
`String`
`getDisplayName()`
Returns the color display name.
`String`
`getDisplayName(org.eclipse.birt.report.model.core.Module module)`
Return the display name of the color that can be showed to user.
`String`
`getDisplayNameID()`
Returns the color display name message ID.
`protected Object`
`getIntrinsicProperty(String valueName)`
Returns the value of a structure property represented as a member variable.
`String`
`getName()`
Returns the internal color name.
`String`
`getReferencableProperty()`
Gets the value of the referencable member.
`int`
`getRGB()`
Returns the color value as an integer RGB value.
`String`
`getStructName()`
Returns the name of the structure definition.
`protected StructureHandle`
`handle(SimpleValueHandle valueHandle, int index)`
Creates the specific handle of this structure.
`boolean`
`isReferencableProperty(String memberName)`
Checks whether the member of the input name is the referencable member or not.
`void`
`setColor(String colorValue)`
Sets the color value.
`void`
`setDisplayName(String displayName)`
Sets the color display name.
`void`
`setDisplayNameID(String displayNameID)`
Sets the color display name ID.
`protected void`
`setIntrinsicProperty(String valueName, Object value)`
Sets the value of of a structure property represented as a member variable.
`void`
`setName(String name)`
Sets the internal color name.
`List`
`validate(org.eclipse.birt.report.model.core.Module module, org.eclipse.birt.report.model.core.DesignElement element)`
Validates this structure.

### Methods inherited from class org.eclipse.birt.report.model.core.ReferencableStructure

`addClient, addClientStructure, broadcast, clone, dropClient, dropClientStructure, getClientList, getClientStructures, getLocalProperty, getProperty, hasReferences, isReferencable, updateReference`

### Methods inherited from class org.eclipse.birt.report.model.core.Structure

`checkStringMember, copy, equals, getCompatibleValue, getContext, getDefn, getElement, getExpressionProperty, getHandle, getHandle, getLocalProperty, getMemberDefn, getObjectDefn, getProperty, getStringProperty, isDesignTime, setContext, setExpressionProperty, setProperty, setProperty, setupContext, updateReference`

### Methods inherited from class java.lang.Object

`finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### CUSTOM_COLOR_STRUCT

public static final String CUSTOM_COLOR_STRUCT
Name of this structure. Matches the definition in the meta-data dictionary.

See Also:
  - Constant Field Values

### NAME_MEMBER

public static final String NAME_MEMBER
Name of the color name member.

See Also:
  - Constant Field Values

### COLOR_MEMBER

public static final String COLOR_MEMBER
Name of the color value member.

See Also:
  - Constant Field Values

### DISPLAY_NAME_MEMBER

public static final String DISPLAY_NAME_MEMBER
Name of the display name member.

See Also:
  - Constant Field Values

### DISPLAY_NAME_ID_MEMBER

public static final String DISPLAY_NAME_ID_MEMBER
Name of the display name ID member.

See Also:
  - Constant Field Values

### name

protected String name
The internal color name such as "periwinkle".

### color

protected String color
The color value of the color, it is preserved as the user typed in.

### displayName

protected String displayName
The display name for the color.

### displayNameID

protected String displayNameID
The message ID for the display name. Allows the display name to be localized.

## Constructor Details

### CustomColor

public CustomColor()
Default constructor.

### CustomColor

public CustomColor(String theName, String value)
Constructs the custom color with a required name and RGB value.

Parameters:
  `theName` - the internal color name
  `value` - the color value

## Method Details

### getStructName

public String getStructName()
Description copied from interface: `IStructure`
Returns the name of the structure definition. The name is the one used to define the structure in the meta-data dictionary.

Returns:
  the internal name of the structure a defined in the meta-data dictionary.

### getIntrinsicProperty

protected Object getIntrinsicProperty(String valueName)
Description copied from class: `org.eclipse.birt.report.model.core.Structure`
Returns the value of a structure property represented as a member variable.

Overrides:
  `getIntrinsicProperty` in class `org.eclipse.birt.report.model.core.ReferencableStructure`
Parameters:
  `valueName` - name of the property
Returns:
  the value of the property, or null if the property is not set

### setIntrinsicProperty

protected void setIntrinsicProperty(String valueName, Object value)
Description copied from class: `org.eclipse.birt.report.model.core.Structure`
Sets the value of of a structure property represented as a member variable.

Overrides:
  `setIntrinsicProperty` in class `org.eclipse.birt.report.model.core.ReferencableStructure`
Parameters:
  `valueName` - the name of the property to set
  `value` - the property value

### getRGB

public int getRGB()
Returns the color value as an integer RGB value. If the color value is of a valid color representation, then return its numeric RGB value as integer. Otherwise, return `-1` indicates that the value is not valid.

The color value can contain any of the valid color representations:

- A decimal number: An integer with a valid RGB color value.
- A hexadecimal number in Java or HTML style: "0xRRGGBB, #RRGGBB or #RGB
- CSS absolute: RGB(r,g,b)
- CSS relative: RGB(r%,g%,b%)
- One of the css color name: red, green, black.

Returns:
  the color value as an integer RGB value. Return `-1` if the color value is not valid or the color value is `null`.
See Also:
  - `ColorUtil.parseColor(String)`

### getName

public String getName()
Returns the internal color name.

Returns:
  the internal color name

### getColor

public String getColor()
Returns the color value as what the user has input.

Returns:
  the color value as what the user has input.

### getDisplayNameID

public String getDisplayNameID()
Returns the color display name message ID.

Returns:
  the display name message ID

### getDisplayName

public String getDisplayName()
Returns the color display name.

Returns:
  the display name

### getDisplayName

public String getDisplayName(org.eclipse.birt.report.model.core.Module module)
Return the display name of the color that can be showed to user. If the custom translations has defined a translation for `displayNameID`, then the localized text for the current locale is returned; Otherwise return the `displayName` property if is not null or blank; Else, return the internal name of the color.

Parameters:
  `module` - the module
Returns:
  the display name of the color

### handle

protected StructureHandle handle(SimpleValueHandle valueHandle, int index)
Description copied from class: `org.eclipse.birt.report.model.core.Structure`
Creates the specific handle of this structure. This handle is always created.

Specified by:
  `handle` in class `org.eclipse.birt.report.model.core.Structure`
Parameters:
  `valueHandle` - the value handle of this structure list property this structure is in
  `index` - the position of this structure in structure list
Returns:
  the handle of this structure.

### setName

public void setName(String name)
Sets the internal color name.

Parameters:
  `name` - the internal color name

### setDisplayName

public void setDisplayName(String displayName)
Sets the color display name.

Parameters:
  `displayName` - the display name

### setColor

public void setColor(String colorValue)
Sets the color value.

Parameters:
  `colorValue` - the color value to be set.

### setDisplayNameID

public void setDisplayNameID(String displayNameID)
Sets the color display name ID.

Parameters:
  `displayNameID` - the display name ID to set

### validate

public List validate(org.eclipse.birt.report.model.core.Module module, org.eclipse.birt.report.model.core.DesignElement element)
Validates this structure. The following are the rules:

- The color name is required.
- The color value can not be the same as a CSS color name.

Overrides:
  `validate` in class `org.eclipse.birt.report.model.core.ReferencableStructure`
Parameters:
  `module` - the module
  `element` - the element contains this structure
Returns:
  the semantic error list
See Also:
  - `Structure.validate(Module, org.eclipse.birt.report.model.core.DesignElement)`

### isReferencableProperty

public boolean isReferencableProperty(String memberName)
Description copied from class: `org.eclipse.birt.report.model.core.ReferencableStructure`
Checks whether the member of the input name is the referencable member or not.

Specified by:
  `isReferencableProperty` in class `org.eclipse.birt.report.model.core.ReferencableStructure`
Parameters:
  `memberName` - the member name to check
Returns:
  true if the member with the given name is referencable, otherwise false

### getReferencableProperty

public String getReferencableProperty()
Description copied from class: `org.eclipse.birt.report.model.core.Structure`
Gets the value of the referencable member.

Overrides:
  `getReferencableProperty` in class `org.eclipse.birt.report.model.core.Structure`
Returns:
  the value of the referencable member