public class CT_Color extends OFDElement
本标准中定义的颜色是一个广义的概念,包括基本颜色、底纹和渐变
基本颜色支持两种指定方式:一种是通过设定颜色个通道值指定颜色空间的某个颜色, 另一种是通过索引值取得颜色空间中的一个预定义颜色。
由于不同颜色空间下,颜色通道的含义、数目各不相同,因此对颜色空间的类型、颜色值的 描述格式等作出了详细的说明,见表 27。BitsPerComponent(简称 BPC)由效时, 颜色通道值的取值下限是 0,上限由 BitsPerComponent 决定,取值区间 [0, 2^BPC - 1] 内的整数,采用 10 进制或 16 进制的形式表示,采用 16 进制表示时,应以“#”加以标识。 当颜色通道的值超出了相应区间,则按照默认颜色来处理。
8.3.2 基本颜色 图 25 表 26
proxy| 限定符 | 构造器和说明 |
|---|---|
|
CT_Color() |
|
CT_Color(ColorClusterType color) |
|
CT_Color(org.dom4j.Element proxy) |
protected |
CT_Color(String name) |
| 限定符和类型 | 方法和说明 |
|---|---|
Integer |
getAlpha()
【可选 属性】
获取 颜色透明度
范围在 0~255 之间取值。
|
ColorClusterType |
getColor()
【可选】
获取 颜色
|
<T extends ColorClusterType> |
getColorByType()
【可选】
获取 指定类型的颜色
|
ST_RefID |
getColorSpace()
【可选 属性】
获取 引用资源文件中颜色空间的标识
默认值为文档设定的颜色空间
|
Integer |
getIndex()
【可选 属性】
获取 调色板中颜色的编号,非负整数
将从当前颜色空间的调色板中取出相应索引的预定义颜色用来描绘。
|
ST_Array |
getValue()
【可选 属性】
获取 颜色值
指定了当前颜色空间下各通道的取值。
|
static CT_Color |
rgb(int[] rgb) |
static CT_Color |
rgb(int r,
int g,
int b)
RGB颜色值
其中颜色空间(CT_ColorSpace)的通道使用位数(BitsPerComponent)为 8
采用10进制表示方式
|
CT_Color |
setAlpha(Integer alpha)
【可选 属性】
设置 颜色透明度
范围在 0~255 之间取值。
|
CT_Color |
setColor(ColorClusterType color)
【可选】
设置 颜色
|
CT_Color |
setColorSpace(ST_RefID colorSpace)
【可选 属性】
设置 引用资源文件中颜色空间的标识
默认值为文档设定的颜色空间
|
CT_Color |
setIndex(Integer index)
【可选 属性】
设置 调色板中颜色的编号,非负整数
将从当前颜色空间的调色板中取出相应索引的预定义颜色用来描绘。
|
CT_Color |
setValue(ST_Array value)
【可选 属性】
设置 颜色值
指定了当前颜色空间下各通道的取值。
|
addOFDEntity, getElements, getInstance, getObjID, getOFDElement, getOFDElement, getOFDElements, getOFDElementText, getQualifiedName, removeAll, removeAttr, removeOFDElemByNames, set, setObjID, setObjID, setOFDEntity, setOFDNameaccept, add, add, add, add, add, add, add, add, add, addAttribute, addAttribute, addCDATA, addComment, addElement, addElement, addElement, addEntity, additionalNamespaces, addNamespace, addProcessingInstruction, addProcessingInstruction, addText, appendAttributes, appendContent, asXML, asXPathResult, attribute, attribute, attribute, attributeCount, attributeIterator, attributes, attributeValue, attributeValue, attributeValue, attributeValue, clearContent, clone, content, createCopy, createCopy, createCopy, createXPath, declaredNamespaces, detach, element, element, elementByID, elementIterator, elementIterator, elementIterator, elements, elements, elements, elementText, elementText, elementTextTrim, elementTextTrim, equals, getData, getDocument, getName, getNamespace, getNamespaceForPrefix, getNamespaceForURI, getNamespacePrefix, getNamespacesForURI, getNamespaceURI, getNodeType, getNodeTypeName, getParent, getPath, getPath, getProxy, getQName, getQName, getStringValue, getText, getTextTrim, getUniquePath, getUniquePath, getXPathResult, hasContent, hasMixedContent, indexOf, isReadOnly, isRootElement, isTextOnly, matches, node, nodeCount, nodeIterator, normalize, numberValueOf, processingInstruction, processingInstructions, processingInstructions, remove, remove, remove, remove, remove, remove, remove, remove, remove, removeProcessingInstruction, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setAttributes, setAttributeValue, setAttributeValue, setContent, setData, setDocument, setName, setParent, setProcessingInstructions, setProxy, setQName, setText, supportsParent, valueOf, writepublic CT_Color(org.dom4j.Element proxy)
public CT_Color()
public CT_Color(ColorClusterType color)
color - 颜色族中的颜色protected CT_Color(String name)
public static CT_Color rgb(int r, int g, int b)
其中颜色空间(CT_ColorSpace)的通道使用位数(BitsPerComponent)为 8
采用10进制表示方式
r - 红色 0~255g - 绿色 0~255b - 蓝色 0~255public static CT_Color rgb(int[] rgb)
public CT_Color setValue(ST_Array value)
指定了当前颜色空间下各通道的取值。Value 的取值应 符合"通道 1 通道 2 通道 3 ..."格式。此属性不出现时, 应采用 Index 属性从颜色空间的调色板中的取值。二者都不 出现时,改颜色各通道的值全部为 0
颜色表示:
Gray - 通过一个通道来表明灰度值;例如 "#FF 255"
RGB - 包含3个通道,一次是红、绿、蓝;例如 "#11 #22 #33"、"17 34 51"
CMYK - 包含4个通道,依次是青、黄、品红、黑;例如 "#11 #22 #33 # 44"、"17 34 51 68"
value - 颜色值public ST_Array getValue()
指定了当前颜色空间下各通道的取值。Value 的取值应 符合"通道 1 通道 2 通道 3 ..."格式。此属性不出现时, 应采用 Index 属性从颜色空间的调色板中的取值。二者都不 出现时,改颜色各通道的值全部为 0
颜色表示:
Gray - 通过一个通道来表明灰度值;例如 "#FF 255"
RGB - 包含3个通道,一次是红、绿、蓝;例如 "#11 #22 #33"、"17 34 51"
CMYK - 包含4个通道,依次是青、黄、品红、黑;例如 "#11 #22 #33 # 44"、"17 34 51 68"
public CT_Color setIndex(Integer index)
将从当前颜色空间的调色板中取出相应索引的预定义颜色用来描绘。 索引从 0 开始
index - 调色板中颜色的编号public Integer getIndex()
将从当前颜色空间的调色板中取出相应索引的预定义颜色用来描绘。 索引从 0 开始
public CT_Color setColorSpace(ST_RefID colorSpace)
默认值为文档设定的颜色空间
colorSpace - 颜色空间的标识public ST_RefID getColorSpace()
默认值为文档设定的颜色空间
public CT_Color setAlpha(Integer alpha)
范围在 0~255 之间取值。
默认为 255,完全不透明。
alpha - 颜色透明度public Integer getAlpha()
范围在 0~255 之间取值。
默认为 255,完全不透明。
public CT_Color setColor(ColorClusterType color)
color - 颜色族public ColorClusterType getColor()
public <T extends ColorClusterType> T getColorByType()
T - 颜色类型Copyright © 2021. All rights reserved.