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

The following examples show how to use org.apache.poi.ss.usermodel.BorderStyle#THIN . 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: XLSXWriter.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private static CellStyle createBorderedStyle(Workbook wb){
  BorderStyle thin = BorderStyle.THIN;
  short black = IndexedColors.GREY_50_PERCENT.getIndex();
  
  CellStyle style = wb.createCellStyle();
  style.setBorderRight(thin);
  style.setRightBorderColor(black);
  style.setBorderBottom(thin);
  style.setBottomBorderColor(black);
  style.setBorderLeft(thin);
  style.setLeftBorderColor(black);
  style.setBorderTop(thin);
  style.setTopBorderColor(black);
  return style;
}
 
Example 2
Source File: XLSXWriter.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private static CellStyle createBorderedStyle(Workbook wb){
  BorderStyle thin = BorderStyle.THIN;
  short black = IndexedColors.GREY_50_PERCENT.getIndex();
  
  CellStyle style = wb.createCellStyle();
  style.setBorderRight(thin);
  style.setRightBorderColor(black);
  style.setBorderBottom(thin);
  style.setBottomBorderColor(black);
  style.setBorderLeft(thin);
  style.setLeftBorderColor(black);
  style.setBorderTop(thin);
  style.setTopBorderColor(black);
  return style;
}
 
Example 3
Source File: CellStyleContext.java    From ureport with Apache License 2.0 5 votes vote down vote up
private BorderStyle getBorderStyle(Border border){
	if(border.getStyle().equals(com.bstek.ureport.definition.BorderStyle.solid)){
		return BorderStyle.THIN;
	}else if(border.getStyle().equals(com.bstek.ureport.definition.BorderStyle.dashed)){
		return BorderStyle.DASHED;
	}else if(border.getStyle().equals(com.bstek.ureport.definition.BorderStyle.doublesolid)){
		return BorderStyle.DOUBLE;
	}
	return null;
}
 
Example 4
Source File: CellStyleContext.java    From ureport with Apache License 2.0 5 votes vote down vote up
private BorderStyle getBorderStyle(Border border){
	if(border.getStyle().equals(com.bstek.ureport.definition.BorderStyle.solid)){
		return BorderStyle.THIN;
	}else if(border.getStyle().equals(com.bstek.ureport.definition.BorderStyle.dashed)){
		return BorderStyle.DASHED;
	}else if(border.getStyle().equals(com.bstek.ureport.definition.BorderStyle.doublesolid)){
		return BorderStyle.DOUBLE;
	}
	return null;
}
 
Example 5
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 6
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 7
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;
}
 
Example 8
Source File: StyleManagerXUtils.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Converts a BIRT border style into a POI BorderStyle.
 * @param birtBorder
 * 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;
}