All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.tecsinapse.exporter.style.CssStyle Maven / Gradle / Ivy

There is a newer version: 3.1.8
Show newest version
/*
 * Tecsinapse Data Input and Output
 *
 * License: GNU Lesser General Public License (LGPL), version 3 or later
 * See the LICENSE file in the root directory or .
 */

package br.com.tecsinapse.exporter.style;

import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.hssf.util.HSSFColor.WHITE;

public enum CssStyle {
    BOLD("font-weight:bold;"),
    ITALIC("font-style:italic;"),
    UNDERLINE("text-decoration:underline;"),
    STRIKEOUT("text-decoration:line-through;");

    private final String css;

    CssStyle(String css) {
        this.css = css;
    }

    public String getCss() {
        return css;
    }

    public static String toBackgroundColor(HSSFColor hssfColor) {
        return toBackgroundColor(hssfColor, false);
    }

    public static String toBackgroundColor(HSSFColor hssfColor, boolean whiteAsTransparent) {
        if (hssfColor == null) {
            return "";
        }

        if (whiteAsTransparent && WHITE.hexString.equals(hssfColor.getHexString())) {
            return "";
        }

        return String.format("background-color:%s;", StyleColorUtil.toHexColor(hssfColor));
    }

    public static String toTextColor(HSSFColor hssfColor) {
        if (hssfColor == null) {
            return "";
        }
        return String.format("color:%s;", StyleColorUtil.toHexColor(hssfColor));
    }

    public static String toFontSize(int fontSize) {
        return String.format("font-size:%d;", fontSize);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy