Example usage for org.apache.poi.ss.usermodel BorderStyle DASHED

List of usage examples for org.apache.poi.ss.usermodel BorderStyle DASHED

Introduction

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

Prototype

BorderStyle DASHED

To view the source code for org.apache.poi.ss.usermodel BorderStyle DASHED.

Click Source Link

Document

dash border

Usage

From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.xls.helper.HSSFCellStyleProducer.java

License:Open Source License

/**
 * Tries to translate the given stroke width into one of the predefined excel border styles.
 *
 * @param widthRaw the AWT-Stroke-Width.
 * @return the translated excel border width.
 */// w  w  w .  ja  v  a2 s  .co  m
protected static org.apache.poi.ss.usermodel.BorderStyle translateStroke(
        final org.pentaho.reporting.engine.classic.core.style.BorderStyle borderStyle, final long widthRaw) {
    final double width = StrictGeomUtility.toExternalValue(widthRaw);

    if (org.pentaho.reporting.engine.classic.core.style.BorderStyle.NONE.equals(borderStyle)) {
        return BorderStyle.NONE;
    } else if (org.pentaho.reporting.engine.classic.core.style.BorderStyle.DASHED.equals(borderStyle)) {
        return width <= 1.5 ? BorderStyle.DASHED : BorderStyle.MEDIUM_DASHED;
    } else if (org.pentaho.reporting.engine.classic.core.style.BorderStyle.DOT_DOT_DASH.equals(borderStyle)) {
        return width <= 1.5 ? BorderStyle.DASH_DOT_DOT : BorderStyle.MEDIUM_DASH_DOT_DOT;
    } else if (org.pentaho.reporting.engine.classic.core.style.BorderStyle.DOT_DASH.equals(borderStyle)) {
        return width <= 1.5 ? BorderStyle.DASH_DOT : BorderStyle.MEDIUM_DASH_DOT;
    } else if (org.pentaho.reporting.engine.classic.core.style.BorderStyle.DOTTED.equals(borderStyle)) {
        return BorderStyle.DOTTED;
    } else if (org.pentaho.reporting.engine.classic.core.style.BorderStyle.DOUBLE.equals(borderStyle)) {
        return BorderStyle.DOUBLE;
    } else if (width == 0) {
        return BorderStyle.NONE;
    } else if (width <= 0.5) {
        return BorderStyle.HAIR;
    } else if (width <= 1) {
        return BorderStyle.THIN;
    } else if (width <= 1.5) {
        return BorderStyle.MEDIUM;
    } else {
        return BorderStyle.THICK;
    }
}

From source file:org.sysmodb.xml.XMLStyleGenerator.java

License:BSD License

private static Map<BorderStyle, String> createBorderMap() {
    Map<BorderStyle, String> result = new HashMap<BorderStyle, String>();
    result.put(BorderStyle.DASHED, "dashed 1pt");
    result.put(BorderStyle.DASH_DOT, "dashed 1pt");
    result.put(BorderStyle.DASH_DOT_DOT, "dashed 1pt");
    result.put(BorderStyle.DOTTED, "dotted 1pt");
    result.put(BorderStyle.DOUBLE, "double 3pt");
    result.put(BorderStyle.HAIR, "solid 1pt");
    result.put(BorderStyle.MEDIUM, "2pt solid");
    result.put(BorderStyle.MEDIUM_DASHED, "2pt dashed");
    result.put(BorderStyle.MEDIUM_DASH_DOT, "2pt dashed");
    result.put(BorderStyle.MEDIUM_DASH_DOT_DOT, "2pt dashed");
    result.put(BorderStyle.NONE, "none");
    result.put(BorderStyle.SLANTED_DASH_DOT, "dashed 2pt");
    result.put(BorderStyle.THICK, "solid 3pt");
    result.put(BorderStyle.THIN, "dashed 1pt");

    return Collections.unmodifiableMap(result);
}

From source file:org.unitime.timetable.export.XLSPrinter.java

License:Apache License

protected CellStyle getStyle(A f, boolean dashed, String format) {
    String styleId = (dashed ? "D" : "") + (f.has(F.BOLD) ? "b" : "") + (f.has(F.ITALIC) ? "i" : "")
            + (f.has(F.UNDERLINE) ? "u" : "") + (f.has(F.RIGHT) ? "R" : f.has(F.CENTER) ? "C" : "L")
            + (f.hasColor() ? "#" + Integer.toHexString(f.getColor().getRGB()) : "")
            + (format == null ? "" : "|" + format);
    CellStyle style = iStyles.get(styleId);
    if (style == null) {
        style = iWorkbook.createCellStyle();
        if (dashed) {
            style.setBorderTop(BorderStyle.DASHED);
            style.setTopBorderColor(IndexedColors.BLACK.getIndex());
        }/*w w w . j a  v  a 2  s  .c o  m*/
        style.setAlignment(f.has(F.RIGHT) ? HorizontalAlignment.RIGHT
                : f.has(F.CENTER) ? HorizontalAlignment.CENTER : HorizontalAlignment.LEFT);
        style.setVerticalAlignment(VerticalAlignment.TOP);
        style.setFont(getFont(f.has(F.BOLD), f.has(F.ITALIC), f.has(F.UNDERLINE), f.getColor()));
        style.setWrapText(true);
        if (format != null)
            style.setDataFormat(iWorkbook.createDataFormat().getFormat(format));
        iStyles.put(styleId, style);
    }
    return style;
}

From source file:uk.co.spudsoft.birt.emitters.excel.StyleManagerXUtils.java

License:Open Source License

/**
 * Converts a BIRT border style into a POI BorderStyle.
 * @param birtBorder//from w  w  w  .  j  a  v  a 2  s. c o  m
 * The BIRT border style.
 * @param width
 * The width of the border as understood by BIRT.
 * @return
 * A POI BorderStyle object.
 */
private BorderStyle poiBorderStyleFromBirt(String birtBorder, String width) {
    if ("none".equals(birtBorder)) {
        return BorderStyle.NONE;
    }
    double pxWidth = 3.0;
    if (CSSConstants.CSS_THIN_VALUE.equals(width)) {
        pxWidth = 1.0;
    } else if (CSSConstants.CSS_MEDIUM_VALUE.equals(width)) {
        pxWidth = 3.0;
    } else if (CSSConstants.CSS_THICK_VALUE.equals(width)) {
        pxWidth = 4.0;
    } else {
        DimensionType dim = DimensionType.parserUnit(width);
        if (dim != null) {
            if ("px".equals(dim.getUnits())) {
                pxWidth = dim.getMeasure();
            }
        }
    }
    if ("solid".equals(birtBorder)) {
        if (pxWidth < 2.9) {
            return BorderStyle.THIN;
        } else if (pxWidth < 3.1) {
            return BorderStyle.MEDIUM;
        } else {
            return BorderStyle.THICK;
        }
    } else if ("dashed".equals(birtBorder)) {
        if (pxWidth < 2.9) {
            return BorderStyle.DASHED;
        } else {
            return BorderStyle.MEDIUM_DASHED;
        }
    } else if ("dotted".equals(birtBorder)) {
        return BorderStyle.DOTTED;
    } else if ("double".equals(birtBorder)) {
        return BorderStyle.DOUBLE;
    }

    log.debug("Border style \"", birtBorder, "\" is not recognised.");
    return BorderStyle.NONE;
}