Author: fanningpj
Date: Sun May 11 09:56:45 2025
New Revision: 1925495
URL: http://svn.apache.org/viewvc?rev=1925495&view=rev
Log:
reformat
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFColor.java
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFColor.java
URL:
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFColor.java?rev=1925495&r1=1925494&r2=1925495&view=diff
==============================================================================
---
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFColor.java
(original)
+++
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFColor.java
Sun May 11 09:56:45 2025
@@ -33,7 +33,7 @@ public class XSSFColor extends ExtendedC
/**
* @param color The ooxml color object to use
- * @param map The IndexedColorMap to use instead of the default one (can
be null)
+ * @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) {
@@ -63,6 +63,7 @@ public class XSSFColor extends ExtendedC
/**
* new color with the given indexed color map
+ *
* @param colorMap The IndexedColorMap to use instead of the default one
(can be null)
*/
public XSSFColor(IndexedColorMap colorMap) {
@@ -71,6 +72,7 @@ public class XSSFColor extends ExtendedC
/**
* TEST ONLY
+ *
* @param clr awt Color
* @param map The IndexedColorMap to use instead of the default one (can
be null)
*/
@@ -80,7 +82,7 @@ public class XSSFColor extends ExtendedC
}
/**
- * @param rgb The RGB-byte-values for the Color
+ * @param rgb The RGB-byte-values for the Color
* @param colorMap The IndexedColorMap to use instead of the default one
(can be null)
*/
public XSSFColor(byte[] rgb, IndexedColorMap colorMap) {
@@ -98,7 +100,7 @@ public class XSSFColor extends ExtendedC
/**
* @param indexedColor color index (Enum named for default colors)
- * @param colorMap The IndexedColorMap to use instead of the default one
+ * @param colorMap The IndexedColorMap to use instead of the default
one
*/
public XSSFColor(IndexedColors indexedColor, IndexedColorMap colorMap) {
this(CTColor.Factory.newInstance(), colorMap);
@@ -163,8 +165,9 @@ public class XSSFColor extends ExtendedC
*/
@Override
public short getIndex() {
- return (short)ctColor.getIndexed();
+ return (short) ctColor.getIndexed();
}
+
/**
* @return Indexed ctColor value. Only used for backwards compatibility.
References a ctColor in indexedColors.
*/
@@ -174,82 +177,84 @@ public class XSSFColor extends ExtendedC
/**
* Indexed ctColor value. Only used for backwards compatibility.
References a ctColor in indexedColors.
+ *
* @param indexed color index
*/
public void setIndexed(int indexed) {
ctColor.setIndexed(indexed);
}
- /**
- * Standard Red Green Blue ctColor value (RGB).
- * If there was an A (Alpha) value, it will be stripped.
- */
- @Override
- public byte[] getRGB() {
- byte[] rgb = getRGBOrARGB();
- if(rgb == null) {
- return null;
- }
-
- // Need to trim off the alpha
- return rgb.length == 4 ? Arrays.copyOfRange(rgb, 1, 4) : rgb;
- }
-
- /**
- * Standard Alpha Red Green Blue ctColor value (ARGB).
- */
- @Override
- public byte[] getARGB() {
- byte[] rgb = getRGBOrARGB();
- if(rgb == null) {
- return null;
- }
-
- if(rgb.length == 3) {
- // Pad with the default Alpha
- byte[] tmp = new byte[4];
- tmp[0] = -1;
- System.arraycopy(rgb, 0, tmp, 1, 3);
- return tmp;
- } else {
- return rgb;
- }
- }
-
- @Override
- protected byte[] getStoredRGB() {
- return ctColor.getRgb();
- }
-
- @Override
- protected byte[] getIndexedRGB() {
- if (isIndexed()) {
- if (indexedColorMap != null) return
indexedColorMap.getRGB(getIndex());
- return DefaultIndexedColorMap.getDefaultRGB(getIndex());
- }
- return null;
- }
+ /**
+ * Standard Red Green Blue ctColor value (RGB).
+ * If there was an A (Alpha) value, it will be stripped.
+ */
+ @Override
+ public byte[] getRGB() {
+ byte[] rgb = getRGBOrARGB();
+ if (rgb == null) {
+ return null;
+ }
+
+ // Need to trim off the alpha
+ return rgb.length == 4 ? Arrays.copyOfRange(rgb, 1, 4) : rgb;
+ }
/**
* Standard Alpha Red Green Blue ctColor value (ARGB).
*/
- @Override
+ @Override
+ public byte[] getARGB() {
+ byte[] rgb = getRGBOrARGB();
+ if (rgb == null) {
+ return null;
+ }
+
+ if (rgb.length == 3) {
+ // Pad with the default Alpha
+ byte[] tmp = new byte[4];
+ tmp[0] = -1;
+ System.arraycopy(rgb, 0, tmp, 1, 3);
+ return tmp;
+ } else {
+ return rgb;
+ }
+ }
+
+ @Override
+ protected byte[] getStoredRGB() {
+ return ctColor.getRgb();
+ }
+
+ @Override
+ protected byte[] getIndexedRGB() {
+ if (isIndexed()) {
+ if (indexedColorMap != null) return
indexedColorMap.getRGB(getIndex());
+ return DefaultIndexedColorMap.getDefaultRGB(getIndex());
+ }
+ return null;
+ }
+
+ /**
+ * Standard Alpha Red Green Blue ctColor value (ARGB).
+ */
+ @Override
public void setRGB(byte[] rgb) {
- ctColor.setRgb(rgb);
+ ctColor.setRgb(rgb);
}
/**
- * Index into the {@code clrScheme} collection, referencing a particular
{@code sysClr} or
+ * Index into the {@code cslrScheme} collection, referencing a particular
{@code sysClr} or
* {@code srgbClr} value expressed in the Theme part.
*/
- @Override
- public int getTheme() {
- return (int)ctColor.getTheme();
+ @Override
+ public int getTheme() {
+ return (int) ctColor.getTheme();
}
/**
* Index into the {@code clrScheme} collection, referencing a particular
{@code sysClr} or
* {@code srgbClr} value expressed in the Theme part.
+ *
* @param theme index
*/
public void setTheme(int theme) {
@@ -354,7 +359,7 @@ public class XSSFColor extends ExtendedC
* @return the underlying XML bean
*/
@Internal
- public CTColor getCTColor(){
+ public CTColor getCTColor() {
return ctColor;
}
@@ -372,11 +377,11 @@ public class XSSFColor extends ExtendedC
if (color != null && !(color instanceof XSSFColor)) {
throw new IllegalArgumentException("Only XSSFColor objects are
supported, but had " + color.getClass());
}
- return (XSSFColor)color;
+ return (XSSFColor) color;
}
@Override
- public int hashCode(){
+ public int hashCode() {
return ctColor.toString().hashCode();
}
@@ -387,35 +392,39 @@ public class XSSFColor extends ExtendedC
}
return false;
}
+
private boolean sameARGB(XSSFColor other) {
if (isRGB() == other.isRGB()) {
return !isRGB() || Arrays.equals(getARGB(), other.getARGB());
}
return false;
}
+
private boolean sameTheme(XSSFColor other) {
if (isThemed() == other.isThemed()) {
return !isThemed() || getTheme() == other.getTheme();
}
return false;
}
+
private boolean sameTint(XSSFColor other) {
if (hasTint() == other.hasTint()) {
return !hasTint() || getTint() == other.getTint();
}
return false;
}
+
private boolean sameAuto(XSSFColor other) {
return isAuto() == other.isAuto();
}
@Override
- public boolean equals(Object o){
- if(!(o instanceof XSSFColor)) {
+ public boolean equals(Object o) {
+ if (!(o instanceof XSSFColor)) {
return false;
}
- XSSFColor other = (XSSFColor)o;
+ XSSFColor other = (XSSFColor) o;
// Compare each field in ctColor.
// Cannot compare ctColor's XML string representation because
equivalent
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]