Example usage for org.apache.poi.ss.usermodel Font SS_NONE

List of usage examples for org.apache.poi.ss.usermodel Font SS_NONE

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Font SS_NONE.

Prototype

short SS_NONE

To view the source code for org.apache.poi.ss.usermodel Font SS_NONE.

Click Source Link

Document

no type offsetting (not super or subscript)

Usage

From source file:biz.webgate.dominoext.poi.component.kernel.WorkbookProcessor.java

License:Apache License

public synchronized void checkStyleConstantValues() {
    if (m_StyleConstantValues == null) {
        m_StyleConstantValues = new HashMap<String, Short>();
        m_StyleConstantValues.put("ALIGN_CENTER", CellStyle.ALIGN_CENTER);
        m_StyleConstantValues.put("ALIGN_CENTER_SELECTION", CellStyle.ALIGN_CENTER_SELECTION);
        m_StyleConstantValues.put("ALIGN_FILL", CellStyle.ALIGN_FILL);
        m_StyleConstantValues.put("ALIGN_GENERAL", CellStyle.ALIGN_GENERAL);
        m_StyleConstantValues.put("ALIGN_JUSTIFY", CellStyle.ALIGN_JUSTIFY);
        m_StyleConstantValues.put("ALIGN_LEFT", CellStyle.ALIGN_LEFT);
        m_StyleConstantValues.put("ALIGN_RIGHT", CellStyle.ALIGN_RIGHT);

        m_StyleConstantValues.put("BORDER_DASH_DOT", CellStyle.BORDER_DASH_DOT);
        m_StyleConstantValues.put("BORDER_DASH_DOT_DOT", CellStyle.BORDER_DASH_DOT_DOT);
        m_StyleConstantValues.put("BORDER_DASHED", CellStyle.BORDER_DASHED);
        m_StyleConstantValues.put("BORDER_DOTTED", CellStyle.BORDER_DOTTED);
        m_StyleConstantValues.put("BORDER_DOUBLE", CellStyle.BORDER_DOUBLE);
        m_StyleConstantValues.put("BORDER_HAIR", CellStyle.BORDER_HAIR);
        m_StyleConstantValues.put("BORDER_MEDIUM", CellStyle.BORDER_MEDIUM);
        m_StyleConstantValues.put("BORDER_MEDIUM_DASH_DOT", CellStyle.BORDER_MEDIUM_DASH_DOT);
        m_StyleConstantValues.put("BORDER_MEDIUM_DASH_DOT_DOT", CellStyle.BORDER_MEDIUM_DASH_DOT_DOT);
        m_StyleConstantValues.put("BORDER_MEDIUM_DASHED", CellStyle.BORDER_MEDIUM_DASHED);
        m_StyleConstantValues.put("BORDER_NONE", CellStyle.BORDER_NONE);
        m_StyleConstantValues.put("BORDER_SLANTED_DASH_DOT", CellStyle.BORDER_SLANTED_DASH_DOT);
        m_StyleConstantValues.put("BORDER_THICK", CellStyle.BORDER_THICK);
        m_StyleConstantValues.put("BORDER_THIN", CellStyle.BORDER_THIN);

        m_StyleConstantValues.put("ALT_BARS", CellStyle.ALT_BARS);
        m_StyleConstantValues.put("BIG_SPOTS", CellStyle.BIG_SPOTS);
        m_StyleConstantValues.put("BRICKS", CellStyle.BRICKS);
        m_StyleConstantValues.put("DIAMONDS", CellStyle.DIAMONDS);
        m_StyleConstantValues.put("FINE_DOTS", CellStyle.FINE_DOTS);
        m_StyleConstantValues.put("LEAST_DOTS", CellStyle.LEAST_DOTS);
        m_StyleConstantValues.put("LESS_DOTS", CellStyle.LESS_DOTS);
        m_StyleConstantValues.put("NO_FILL", CellStyle.NO_FILL);
        m_StyleConstantValues.put("SOLID_FOREGROUND", CellStyle.SOLID_FOREGROUND);
        m_StyleConstantValues.put("SPARSE_DOTS", CellStyle.SPARSE_DOTS);
        m_StyleConstantValues.put("SQUARES", CellStyle.SQUARES);
        m_StyleConstantValues.put("THICK_BACKWARD_DIAG", CellStyle.THICK_BACKWARD_DIAG);
        m_StyleConstantValues.put("THICK_FORWARD_DIAG", CellStyle.THICK_FORWARD_DIAG);
        m_StyleConstantValues.put("THICK_HORZ_BANDS", CellStyle.THICK_HORZ_BANDS);
        m_StyleConstantValues.put("THICK_VERT_BANDS", CellStyle.THICK_VERT_BANDS);
        m_StyleConstantValues.put("THIN_BACKWARD_DIAG", CellStyle.THIN_BACKWARD_DIAG);
        m_StyleConstantValues.put("THIN_FORWARD_DIAG", CellStyle.THIN_FORWARD_DIAG);
        m_StyleConstantValues.put("THIN_HORZ_BANDS", CellStyle.THIN_HORZ_BANDS);
        m_StyleConstantValues.put("THIN_VERT_BANDS", CellStyle.THIN_VERT_BANDS);

        m_StyleConstantValues.put("VERTICAL_BOTTOM", CellStyle.VERTICAL_BOTTOM);
        m_StyleConstantValues.put("VERTICAL_CENTER", CellStyle.VERTICAL_CENTER);
        m_StyleConstantValues.put("VERTICAL_JUSTIFY", CellStyle.VERTICAL_JUSTIFY);
        m_StyleConstantValues.put("VERTICAL_TOP", CellStyle.VERTICAL_TOP);

        m_StyleConstantValues.put("SS_NONE", Font.SS_NONE);
        m_StyleConstantValues.put("SS_SUPER", Font.SS_SUPER);
        m_StyleConstantValues.put("SS_SUB", Font.SS_SUB);

        m_StyleConstantValues.put("BOLDWEIGHT_BOLD", Font.BOLDWEIGHT_BOLD);
        m_StyleConstantValues.put("BOLDWEIGHT_NORMAL", Font.BOLDWEIGHT_NORMAL);

    }/*from   w w w .j  a  va2 s . com*/

    if (m_StyleByteConstantValues == null) {
        m_StyleByteConstantValues = new HashMap<String, Byte>();
        m_StyleByteConstantValues.put("U_NONE", Font.U_NONE);
        m_StyleByteConstantValues.put("U_SINGLE", Font.U_SINGLE);
        m_StyleByteConstantValues.put("U_DOUBLE", Font.U_DOUBLE);
        m_StyleByteConstantValues.put("U_SINGLE_ACCOUNTING", Font.U_SINGLE_ACCOUNTING);
        m_StyleByteConstantValues.put("U_DOUBLE_ACCOUNTING", Font.U_DOUBLE_ACCOUNTING);
    }
}

From source file:com.dua3.meja.model.poi.PoiWorkbook.java

License:Apache License

PoiFont getPoiFont(com.dua3.meja.model.Font font, Style style) {
    Map<String, String> properties = style.properties();

    if (properties.isEmpty() && font instanceof PoiFont && ((PoiFont) font).workbook == this) {
        return (PoiFont) font;
    }//  w  w w.  j  av a  2 s .c o m

    // FIXME JDK 8 
    // String name = properties.getOrDefault(Style.FONT_FAMILY, font.getFamily());
    String name = properties.get(Style.FONT_FAMILY);
    if (name == null) {
        name = font.getFamily();
    }

    String sSize = properties.get(Style.FONT_SIZE);
    short height = (short) Math
            .round(sSize == null ? font.getSizeInPoints() : MejaHelper.decodeFontSize(sSize));

    final String sStyle = properties.get(Style.FONT_STYLE);
    boolean italic = sStyle == null ? font.isItalic() : "italic".equals(sStyle);

    final String sWeight = properties.get(Style.FONT_WEIGHT);
    boolean bold = sWeight == null ? font.isBold() : "bold".equals(sWeight);

    String sDecoration = properties.get(Style.TEXT_DECORATION);
    boolean underline = sDecoration == null ? font.isUnderlined() : "underline".equals(sDecoration);
    boolean strikethrough = sDecoration == null ? font.isStrikeThrough() : "line-through".equals(sDecoration);

    String sColor = properties.get(Style.COLOR);
    Color color = sColor == null ? font.getColor() : Color.valueOf(sColor);

    // try to find existing font
    for (short i = 0; i < poiWorkbook.getNumberOfFonts(); i++) {
        Font poiFont = poiWorkbook.getFontAt(i);

        if (poiFont.getFontName().equalsIgnoreCase(name) && poiFont.getFontHeightInPoints() == height
                && poiFont.getBold() == bold && poiFont.getItalic() == italic
                && (poiFont.getUnderline() != Font.U_NONE) == underline
                && poiFont.getStrikeout() == strikethrough && getColor(poiFont, Color.BLACK).equals(color)
                && poiFont.getTypeOffset() == Font.SS_NONE) {
            return new PoiFont(this, poiFont);
        }
    }

    // if not found, create it
    return createFont(name, height, font.getColor(), bold, italic, underline, strikethrough);
}

From source file:guru.qas.martini.report.DefaultTraceabilityMatrix.java

License:Apache License

protected Font getHeaderFont(Workbook workbook) {
    Font font = workbook.findFont(true, // bold
            IndexedColors.BLACK.getIndex(), (short) 300, ARIAL, false, // italic
            false, // strikeout
            Font.SS_NONE, Font.U_NONE);

    if (null == font) {
        font = workbook.createFont();/*from w w w .  jav a  2 s.c om*/
        font.setBold(true);
        font.setColor(IndexedColors.BLACK.getIndex());
        font.setFontHeight((short) 300);
        font.setFontName(ARIAL);
        font.setItalic(false);
        font.setStrikeout(false);
        font.setTypeOffset(Font.SS_NONE);
        font.setUnderline(Font.U_NONE);
    }
    return font;
}

From source file:org.joeffice.spreadsheet.TableStyleable.java

License:Apache License

/**
 * Add the attribute as defined in {@link AttributedString} to the {@link MutableAttributeSet} for the JTextPane.
 *
 * @see java.awt.font.TextAttribute// www. ja va 2 s  .  c  o m
 */
protected void addAttribute(AttributedCharacterIterator.Attribute attribute, Object attributeValue, Cell cell) {
    CellStyle oldStyle = cell.getCellStyle();
    Workbook workbook = cell.getSheet().getWorkbook();
    CellStyle style = cell.getSheet().getWorkbook().createCellStyle();
    style.cloneStyleFrom(oldStyle);
    Font newFont = copyFont(cell);
    if (attribute == FAMILY) {
        newFont.setFontName((String) attributeValue);
        CellUtil.setFont(cell, workbook, newFont);
    } else if (attribute == FOREGROUND) {
        Color color = (Color) attributeValue;
        if (cell instanceof XSSFCell) {
            ((XSSFCellStyle) style).setFillForegroundColor(new XSSFColor(color));
        } else {
            HSSFWorkbook xlsWorkbook = (HSSFWorkbook) workbook;
            HSSFColor xlsColor = xlsWorkbook.getCustomPalette().findColor((byte) color.getRed(),
                    (byte) color.getGreen(), (byte) color.getBlue());
            if (xlsColor == null) {
                xlsColor = xlsWorkbook.getCustomPalette().addColor((byte) color.getRed(),
                        (byte) color.getGreen(), (byte) color.getBlue());
            }
            style.setFillForegroundColor(xlsColor.getIndex());
        }
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    } else if (attribute == BACKGROUND) {
        Color color = (Color) attributeValue;
        if (cell instanceof XSSFCell) {
            ((XSSFCellStyle) style).setFillBackgroundColor(new XSSFColor(color));
        } else {
            HSSFWorkbook xlsWorkbook = (HSSFWorkbook) workbook;
            HSSFColor xlsColor = xlsWorkbook.getCustomPalette().findColor((byte) color.getRed(),
                    (byte) color.getGreen(), (byte) color.getBlue());
            if (xlsColor == null) {
                xlsColor = xlsWorkbook.getCustomPalette().addColor((byte) color.getRed(),
                        (byte) color.getGreen(), (byte) color.getBlue());
            }
            style.setFillBackgroundColor(xlsColor.getIndex());
        }
    } else if (attribute == WEIGHT) {
        short boldValue = Font.BOLDWEIGHT_BOLD;
        if (newFont.getBoldweight() == Font.BOLDWEIGHT_BOLD) {
            boldValue = Font.BOLDWEIGHT_NORMAL;
        }
        newFont.setBoldweight(boldValue);
        CellUtil.setFont(cell, workbook, newFont);
    } else if (attribute == UNDERLINE) {
        byte underlineValue = Font.U_SINGLE;
        if (newFont.getUnderline() == Font.U_SINGLE) {
            underlineValue = Font.U_NONE;
        }
        newFont.setUnderline(underlineValue);
        CellUtil.setFont(cell, workbook, newFont);
    } else if (attribute == SUPERSCRIPT) {
        short superscriptValue = Font.SS_NONE;
        if (SUPERSCRIPT_SUB.equals(attributeValue)) {
            superscriptValue = Font.SS_SUB;
        } else if (SUPERSCRIPT_SUPER.equals(attributeValue)) {
            superscriptValue = Font.SS_SUPER;
        }
        newFont.setTypeOffset(superscriptValue);
        CellUtil.setFont(cell, workbook, newFont);
    } else if (attribute == STRIKETHROUGH) {
        boolean strikeThrough = true;
        if (newFont.getStrikeout()) {
            strikeThrough = false;
        }
        newFont.setStrikeout(strikeThrough);
        CellUtil.setFont(cell, workbook, newFont);
    } else if (attribute == POSTURE) {
        boolean italic = true;
        if (newFont.getItalic()) {
            italic = false;
        }
        newFont.setItalic(italic);
        CellUtil.setFont(cell, workbook, newFont);
    } else if (attribute == SIZE) {
        newFont.setFontHeightInPoints(((Number) attributeValue).shortValue());
        CellUtil.setFont(cell, workbook, newFont);
    } else if (attribute == JUSTIFICATION) {
        CellUtil.setAlignment(cell, workbook, CellStyle.ALIGN_JUSTIFY);
    } else if (attribute == ALIGNMENT) {
        if (attributeValue.equals(StyleConstants.ALIGN_LEFT)) {
            CellUtil.setAlignment(cell, workbook, CellStyle.ALIGN_LEFT);
        } else if (attributeValue.equals(StyleConstants.ALIGN_RIGHT)) {
            CellUtil.setAlignment(cell, workbook, CellStyle.ALIGN_RIGHT);
        } else if (attributeValue.equals(StyleConstants.ALIGN_CENTER)) {
            CellUtil.setAlignment(cell, workbook, CellStyle.ALIGN_CENTER);
        }
    } else if (attribute == INDENTATION) {
        style.setIndention(((Number) attributeValue).shortValue());
    } else if (attribute == TEXT_TRANSFORM) {
        String text = CellUtils.getFormattedText(cell);
        String transformedText = ((TextTransformer) attributeValue).transformText(text);
        cell.setCellValue(transformedText);
    }
}