StringBuffer styleString = new StringBuffer(); if (component != null) { final Color fgColor = component.getForeground(); final Color bgcolor = component.getBackground(); final SFont font = component.getFont(); final SDimension dim = component.getPreferredSize();  if (bgcolor != null) styleString.append("background-color:#").append(toColorString(bgcolor)).append(";");  if (fgColor != null) { styleString.append("color:#").append(toColorString(fgColor)).append(";"); }  if (font != null) { int style = font.getStyle(); styleString.append("font-size:").append(font.getSize()).append("pt;"); styleString.append("font-style:").append((style & Font.ITALIC) > 0 ? "italic;" : "normal;"); styleString.append("font-weight:").append((style & Font.BOLD) > 0 ? "bold;" : "normal;"); styleString.append("font-family:").append(font.getFace()).append(";"); }  if (dim != null) { if (dim.isWidthDefined()) styleString.append("width:").append(dim.getWidth()).append(";"); if (dim.isHeightDefined()) styleString.append("height:").append(dim.getHeight()).append(";"); } }
final StringBuffer styleString = generateCSSInlinePreferredSize(component != null ? component.getPreferredSize() : null); appendCSSComponentInlineColorStyle(styleString, component); appendCSSComponentInlineFontStyle(styleString, component);
    public static StringBuffer generateCSSComponentInlineStyle(SComponent component) {        StringBuffer styleString = new StringBuffer();        if (component != null) {            final Color fgColor = component.getForeground();            final Color bgcolor = component.getBackground();            final SFont font = component.getFont();            final SDimension dim = component.getPreferredSize();            if (bgcolor != null)                styleString.append("background-color:#").append(toColorString(bgcolor)).append(";");            if (fgColor != null) {                styleString.append("color:#").append(toColorString(fgColor)).append(";");            }            if (font != null) {                int style = font.getStyle();                styleString.append("font-size:").append(font.getSize()).append("pt;");                styleString.append("font-style:").append((style & Font.ITALIC) > 0 ? "italic;" : "normal;");                styleString.append("font-weight:").append((style & Font.BOLD) > 0 ? "bold;" : "normal;");                styleString.append("font-family:").append(font.getFace()).append(";");            }            if (dim != null) {                if (dim.isWidthDefined()) styleString.append("width:").append(dim.getWidth()).append(";");                if (dim.isHeightDefined()) styleString.append("height:").append(dim.getHeight()).append(";");            }        }        return styleString;    }