Example usage for org.apache.poi.xssf.usermodel XSSFColor getTint

List of usage examples for org.apache.poi.xssf.usermodel XSSFColor getTint

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFColor getTint.

Prototype

@Override
public double getTint() 

Source Link

Document

Specifies the tint value applied to the ctColor.

Usage

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  va2 s  .  co m
        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

private String styleColor(XSSFColor color) {
    return styleColor(color, color == null ? 0.0 : color.getTint());
}

From source file:org.bbreak.excella.core.test.util.TestUtil.java

License:Open Source License

private static String getXSSFColorString(XSSFColor color) {
    StringBuffer sb = new StringBuffer("[");
    if (color != null) {
        sb.append("Indexed=").append(color.getIndexed()).append(",");
        sb.append("Rgb=");
        if (color.getRGB() != null) {
            for (byte b : color.getRGB()) {
                sb.append(String.format("%02x", b).toUpperCase());
            }//  w ww  .  ja  va2 s .c  o m
        }
        sb.append(",");
        sb.append("Tint=").append(color.getTint()).append(",");
        sb.append("Theme=").append(color.getTheme()).append(",");
        sb.append("Auto=").append(color.isAuto());
    }
    return sb.append("]").toString();
}

From source file:org.bbreak.excella.reports.ReportsTestUtil.java

License:Open Source License

/**
 * XSSF????/*  ww w .  j ava 2  s  .co m*/
 * 
 * @param color XSSF
 * @return XSSF??
 */
private static String getXSSFColorString(XSSFColor color) {
    StringBuffer sb = new StringBuffer("[");
    if (color != null) {
        sb.append("Indexed=").append(color.getIndexed()).append(",");
        sb.append("Rgb=");
        if (color.getRGB() != null) {
            for (byte b : color.getRGB()) {
                sb.append(String.format("%02x", b).toUpperCase());
            }
        }
        sb.append(",");
        sb.append("Tint=").append(color.getTint()).append(",");
        sb.append("Theme=").append(color.getTheme()).append(",");
        sb.append("Auto=").append(color.isAuto());
    }
    return sb.append("]").toString();
}