List of usage examples for org.apache.poi.xssf.usermodel XSSFColor getARGB
@Override public byte[] getARGB()
From source file:cc.landking.converter.office.excel.XSSFHtmlHelper.java
License:Apache License
private void styleColor(Formatter out, String attr, XSSFColor color) { if (color == null || color.isAuto()) return;/*w w w . ja v a 2 s .c o m*/ 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]); }
From source file:com.aiutil.report.utils.XSSFHtmlHelper.java
License:Apache License
private void styleColor(Formatter out, String attr, XSSFColor color) { if (color == null || color.isAuto()) { return;//from w w w. j a v a 2 s .c o m } 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]); }
From source file:com.vaadin.addon.spreadsheet.XSSFColorConverter.java
License:Open Source License
@Override public String getBorderColorCSS(BorderSide borderSide, String attr, CellStyle cellStyle) { StringBuilder sb = new StringBuilder(); XSSFColor color; if (cellStyle instanceof XSSFCellStyle && !((XSSFCellStyle) cellStyle).getCoreXf().getApplyBorder()) { // ApplyBorder is not working for Excel themes, so need to get the // color manually color = getBorderColor((XSSFCellStyle) cellStyle, borderSide); } else {/*from w ww . j a v a 2s . c om*/ color = ((XSSFCellStyle) cellStyle).getBorderColor(borderSide); } sb.append(attr); sb.append(":"); if (color == null || color.isAuto()) { sb.append("#000;"); return sb.toString(); } byte[] argb = color.getARGB(); if (argb == null) { sb.append("#000;"); return sb.toString(); } final double tint = color.getTint(); if (tint != 0.0) { argb[1] = applyTint(argb[1] & 0xFF, tint); argb[2] = applyTint(argb[2] & 0xFF, tint); argb[3] = applyTint(argb[3] & 0xFF, tint); } try { String temp = toRGBA(argb); sb.append(temp); } catch (NumberFormatException nfe) { LOGGER.log(Level.FINE, nfe.getMessage() + " " + nfe.getCause(), nfe); sb.append(String.format("#%02x%02x%02x;", argb[1], argb[2], argb[3])); } return sb.toString(); }
From source file:com.vaadin.addon.spreadsheet.XSSFColorConverter.java
License:Open Source License
@Override public String getBorderColorCSS(BorderSide borderSide, String attr, BorderFormatting format) { XSSFBorderFormatting casted = (XSSFBorderFormatting) format; // getXBorderColor methods are useless with XSSF, so we need to dig // deeper./* www. j av a2 s . co m*/ CTColor color = getBorderColor(casted, borderSide); StringBuilder sb = new StringBuilder(); sb.append(attr); sb.append(":"); if (color == null || color.getAuto()) { sb.append("#000;"); return sb.toString(); } byte[] argb; if (color.isSetTheme()) { XSSFColor themeColor = workbook.getTheme().getThemeColor((int) color.getTheme()); argb = themeColor.getARGB(); } else { argb = color.getRgb(); } if (argb == null) { sb.append("#000;"); return sb.toString(); } final double tint = color.getTint(); if (tint != 0.0) { argb[1] = applyTint(argb[1] & 0xFF, tint); argb[2] = applyTint(argb[2] & 0xFF, tint); argb[3] = applyTint(argb[3] & 0xFF, tint); } try { String temp = toRGBA(argb); sb.append(temp); } catch (NumberFormatException nfe) { LOGGER.log(Level.FINE, nfe.getMessage() + " " + nfe.getCause(), nfe); sb.append(String.format("#%02x%02x%02x;", argb[1], argb[2], argb[3])); } return sb.toString(); }
From source file:com.vaadin.addon.spreadsheet.XSSFColorConverter.java
License:Open Source License
private String styleColor(XSSFColor color, double tint) { if (color == null || color.isAuto()) { return null; }// w ww . j ava2 s. c om byte[] argb = color.getARGB(); if (argb == null) { return null; } if (tint != 0.0) { argb[1] = applyTint(argb[1] & 0xFF, tint); argb[2] = applyTint(argb[2] & 0xFF, tint); argb[3] = applyTint(argb[3] & 0xFF, tint); } try { String temp = toRGBA(argb); return temp; } catch (NumberFormatException nfe) { LOGGER.log(Level.FINE, nfe.getMessage() + " " + nfe.getCause(), nfe); return String.format("#%02x%02x%02x;", argb[1], argb[2], argb[3]); } }
From source file:ru.spb.nicetu.tableviewer.server.XSSFHtmlHelper.java
License:Apache License
private void styleColor(Formatter out, String attr, XSSFColor color, boolean isBuiltIn) { if (color == null || color.isAuto()) return;//from ww w . j a v a 2 s. c o m 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 if (!isBuiltIn) out.format(" "); out.format("%s: #%02x%02x%02x;", attr, rgb[0], rgb[1], rgb[2]); if (!isBuiltIn) out.format("%n"); byte[] argb = color.getARgb(); if (argb == null) { return; } if (!isBuiltIn) out.format(" "); out.format("%s: rgba(0x%02x, 0x%02x, 0x%02x, 0x%02x);", attr, argb[3], argb[0], argb[1], argb[2]); if (!isBuiltIn) out.format("%n"); }
From source file:uk.co.spudsoft.birt.emitters.excel.StyleManagerXUtils.java
License:Open Source License
@Override public Font correctFontColorIfBackground(FontManager fm, Workbook wb, BirtStyle birtStyle, Font font) { CSSValue bgColour = birtStyle.getProperty(StyleConstants.STYLE_BACKGROUND_COLOR); int bgRgb[] = parseColour(bgColour == null ? null : bgColour.getCssText(), "white"); XSSFColor colour = ((XSSFFont) font).getXSSFColor(); int fgRgb[] = rgbOnly(colour.getARgb()); if ((fgRgb[0] == 255) && (fgRgb[1] == 255) && (fgRgb[2] == 255)) { fgRgb[0] = fgRgb[1] = fgRgb[2] = 0; } else if ((fgRgb[0] == 0) && (fgRgb[1] == 0) && (fgRgb[2] == 0)) { fgRgb[0] = fgRgb[1] = fgRgb[2] = 255; }/*from w w w . j av a 2 s . c o m*/ if ((bgRgb[0] == fgRgb[0]) && (bgRgb[1] == fgRgb[1]) && (bgRgb[2] == fgRgb[2])) { IStyle addedStyle = new AreaStyle(fm.getCssEngine()); addedStyle.setColor(contrastColour(bgRgb)); return fm.getFontWithExtraStyle(font, addedStyle); } else { return font; } }