}
/**
- * A boolean value indicating if the ctColor has a tint or not
+ * A boolean value indicating if the ctColor has a alpha or not
*/
- public boolean hasTint() {
+ public boolean hasAlpha() {
if (! ctColor.isSetRgb()) {
return false;
}
return ctColor.getRgb().length == 4;
}
+ /**
+ * A boolean value indicating if the ctColor has a tint or not
+ */
+ public boolean hasTint() {
+ if (!ctColor.isSetTint()) {
+ return false;
+ }
+ return ctColor.getTint() != 0;
+ }
+
/**
* Indexed ctColor value. Only used for backwards compatibility. References a ctColor in indexedColors.
*/
assertEquals(null, indexed.getRGB());
assertEquals(null, indexed.getRGBWithTint());
assertEquals(null, indexed.getARGBHex());
+ assertFalse(indexed.hasAlpha());
+ assertFalse(indexed.hasTint());
// Now move to one with indexed rgb values
indexed.setIndexed(59);
// Now check the XSSFColor
assertEquals(0, rgb3.getIndexed());
assertEquals(-0.34999, rgb3.getTint(), 0.00001);
+ assertFalse(rgb3.hasAlpha());
+ assertTrue(rgb3.hasTint());
assertEquals("FFFFFFFF", rgb3.getARGBHex());
assertEquals(3, rgb3.getRGB().length);
// Set another, is fine
rgb3.setRGB(new byte[] {16,17,18});
+ assertFalse(rgb3.hasAlpha());
assertEquals("FF101112", rgb3.getARGBHex());
assertEquals(0x10, rgb3.getCTColor().getRgb()[0]);
assertEquals(0x11, rgb3.getCTColor().getRgb()[1]);
// Now check the XSSFColor
assertEquals(0, rgb4.getIndexed());
assertEquals(0.0, rgb4.getTint(), 0);
+ assertFalse(rgb4.hasTint());
+ assertTrue(rgb4.hasAlpha());
assertEquals("FFFF0000", rgb4.getARGBHex());
assertEquals(3, rgb4.getRGB().length);
// Turn on tinting, and check it behaves
// TODO These values are suspected to be wrong...
rgb4.setTint(0.4);
+ assertTrue(rgb4.hasTint());
assertEquals(0.4, rgb4.getTint(), 0);
assertEquals(3, rgb4.getRGBWithTint().length);