Java Code Examples for org.apache.poi.ss.usermodel.BorderStyle#HAIR

The following examples show how to use org.apache.poi.ss.usermodel.BorderStyle#HAIR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JRXlsMetadataExporter.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 *
 */
protected static BorderStyle getBorderStyle(JRPen pen) {
	float lineWidth = pen.getLineWidth();

	if (lineWidth > 0f) {
		switch (pen.getLineStyleValue()) {
			case DOUBLE : {
				return BorderStyle.DOUBLE;
			}
			case DOTTED : {
				return BorderStyle.DOTTED;
			}
			case DASHED : {
				if (lineWidth >= 1f) {
					return BorderStyle.MEDIUM_DASHED;
				}
				return BorderStyle.DASHED;
			}
			case SOLID :
			default : {
				if (lineWidth >= 2f) {
					return BorderStyle.THICK;
				}
				else if (lineWidth >= 1f) {
					return BorderStyle.MEDIUM;
				} else if (lineWidth >= 0.5f) {
					return BorderStyle.THIN;
				}
				return BorderStyle.HAIR;
			}
		}
	}
	return BorderStyle.NONE;
}
 
Example 2
Source File: HSSFCellStyleProducer.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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.
 */
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;
  }
}
 
Example 3
Source File: JRXlsExporter.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 *
 */
protected static BorderStyle getBorderStyle(JRPen pen)
{
	float lineWidth = pen.getLineWidth();

	if (lineWidth > 0f)
	{
		switch (pen.getLineStyleValue())
		{
			case DOUBLE :
			{
				return BorderStyle.DOUBLE;
			}
			case DOTTED :
			{
				return BorderStyle.DOTTED;
			}
			case DASHED :
			{
				if (lineWidth >= 1f)
				{
					return BorderStyle.MEDIUM_DASHED;
				}

				return BorderStyle.DASHED;
			}
			case SOLID :
			default :
			{
				if (lineWidth >= 2f)
				{
					return BorderStyle.THICK;
				}
				else if (lineWidth >= 1f)
				{
					return BorderStyle.MEDIUM;
				}
				else if (lineWidth >= 0.5f)
				{
					return BorderStyle.THIN;
				}

				return BorderStyle.HAIR;
			}
		}
	}

	return BorderStyle.NONE;
}