From 0b871a08c5031f9953f7e9a6e8dabfecb2f5cb70 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 21 Dec 2021 15:55:01 +0000 Subject: add more XSSFColor constructors git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1896249 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/xssf/usermodel/XSSFColor.java | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFColor.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFColor.java index 327099acb2..904dba2eed 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFColor.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFColor.java @@ -22,7 +22,6 @@ import org.apache.poi.ss.usermodel.Color; import org.apache.poi.ss.usermodel.ExtendedColor; import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.util.Internal; -import org.apache.poi.util.Removal; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor; /** @@ -34,21 +33,37 @@ public class XSSFColor extends ExtendedColor { /** * @param color The ooxml color object to use - * @param map The IndexedColorMap to use instead of the default one + * @param map The IndexedColorMap to use instead of the default one (can be null) * @return null if color is null, new instance otherwise */ public static XSSFColor from(CTColor color, IndexedColorMap map) { return color == null ? null : new XSSFColor(color, map); } + /** + * @param color The ooxml color object to use + * @return null if color is null, new instance otherwise + * @since POI 5.2.0 + */ + public static XSSFColor from(CTColor color) { + return color == null ? null : new XSSFColor(color, null); + } + private XSSFColor(CTColor color, IndexedColorMap map) { this.ctColor = color; this.indexedColorMap = map; } + /** + * @since POI 5.2.0 + */ + public XSSFColor() { + this(CTColor.Factory.newInstance(), null); + } + /** * new color with the given indexed color map - * @param colorMap The IndexedColorMap to use instead of the default one + * @param colorMap The IndexedColorMap to use instead of the default one (can be null) */ public XSSFColor(IndexedColorMap colorMap) { this(CTColor.Factory.newInstance(), colorMap); @@ -57,7 +72,7 @@ public class XSSFColor extends ExtendedColor { /** * TEST ONLY * @param clr awt Color - * @param map The IndexedColorMap to use instead of the default one + * @param map The IndexedColorMap to use instead of the default one (can be null) */ public XSSFColor(java.awt.Color clr, IndexedColorMap map) { this(map); @@ -65,15 +80,22 @@ public class XSSFColor extends ExtendedColor { } /** - * * @param rgb The RGB-byte-values for the Color - * @param colorMap The IndexedColorMap to use instead of the default one + * @param colorMap The IndexedColorMap to use instead of the default one (can be null) */ public XSSFColor(byte[] rgb, IndexedColorMap colorMap) { this(CTColor.Factory.newInstance(), colorMap); ctColor.setRgb(rgb); } + /** + * @param rgb The RGB-byte-values for the Color + * @since POI 5.2.0 + */ + public XSSFColor(byte[] rgb) { + this(rgb, null); + } + /** * @param indexedColor color index (Enum named for default colors) * @param colorMap The IndexedColorMap to use instead of the default one @@ -90,6 +112,7 @@ public class XSSFColor extends ExtendedColor { public boolean isAuto() { return ctColor.getAuto(); } + /** * @param auto true if the ctColor is automatic and system ctColor dependent. */ -- cgit v1.2.3