@Override public void setFontColor(Color color) { XSSFColor xcolor = XSSFColor.toXSSFColor(color); if (xcolor == null) { _font.getColorList().clear(); } else if(_font.sizeOfColorArray() == 0) { _font.addNewColor().setRgb(xcolor.getRGB()); } else { _font.setColorArray(0, xcolor.getCTColor()); } }
/** * set the color for the font in Standard Alpha Red Green Blue color value * * @param color - color to use */ public void setColor(XSSFColor color) { if(color == null) _ctFont.setColorArray(null); else { CTColor ctColor = _ctFont.sizeOfColorArray() == 0 ? _ctFont.addNewColor() : _ctFont.getColorArray(0); if (ctColor.isSetIndexed()) { ctColor.unsetIndexed(); } ctColor.setRgb(color.getRGB()); } }
private static Color createColor( final XSSFColor color ) { if ( color == null ) { return null; } final byte[] rgb = color.getRGB(); return new Color( 0xFF & rgb[0], 0xFF & rgb[1], 0xFF & rgb[2] ); }
public void styleColor(Formatter out, String attr, Color color) { XSSFColor xSSFColor = (XSSFColor) color; if (color == null || xSSFColor.isAuto()) return; byte[] rgb = xSSFColor.getRGB(); if (rgb == null) { return; } out.format(" %s: #%02x%02x%02x;%n", attr, rgb[0], rgb[1], rgb[2]); } }
@Override public void styleColor(Formatter out, String attr, Color color) { XSSFColor xSSFColor = (XSSFColor) color; if (color == null || xSSFColor.isAuto()) { return; } byte[] rgb = xSSFColor.getRGB(); if (rgb == null) { return; } out.format(" %s: #%02x%02x%02x;%n", attr, rgb[0], rgb[1], rgb[2]); } }
private void styleColor(Formatter out, String attr, XSSFColor color) { if (color == null || color.isAuto()) { return; } byte[] rgb = color.getRGB(); if (rgb == null) { return; } // This is done twice -- rgba is new with CSS 3, and browser that don't // support it will ignore the rgba specification and stick with the // solid color, which is declared first out.format(" %s: #%02x%02x%02x;%n", attr, rgb[0], rgb[1], rgb[2]); byte[] argb = color.getARGB(); if (argb == null) { return; } out.format(" %s: rgba(0x%02x, 0x%02x, 0x%02x, 0x%02x);%n", attr, argb[3], argb[0], argb[1], argb[2]); } }
public static short[] toRgb(Color color) { if (color == null) { return null; } if (color instanceof HSSFColor) { return ((HSSFColor) color).getTriplet(); } else if (color instanceof XSSFColor) { byte[] rgb = ((XSSFColor) color).getRGB(); // Byte to short if (rgb != null) { return applyTint(rgb, ((XSSFColor) color).getTint()); } } return null; }
@Override public void setFontColor(Color color) { XSSFColor xcolor = XSSFColor.toXSSFColor(color); if (xcolor == null) { _font.getColorList().clear(); } else if(_font.sizeOfColorArray() == 0) { _font.addNewColor().setRgb(xcolor.getRGB()); } else { _font.setColorArray(0, xcolor.getCTColor()); } }
/** * set the color for the font in Standard Alpha Red Green Blue color value * * @param color - color to use */ public void setColor(XSSFColor color) { if(color == null) _ctFont.setColorArray(null); else { CTColor ctColor = _ctFont.sizeOfColorArray() == 0 ? _ctFont.addNewColor() : _ctFont.getColorArray(0); if (ctColor.isSetIndexed()) { ctColor.unsetIndexed(); } ctColor.setRgb(color.getRGB()); } }