protected Element createRectangleElement ( float x , float y , float width , float height , boolean stroke , boolean fill ) { float lineWidth = transformWidth ( getGraphicsState ( ) . getLineWidth ( ) ) ; float wcor = stroke ? lineWidth : 0.0f ; float strokeOffset = wcor == 0 ? 0 : wcor / 2 ; width = width - wcor < 0 ? 1 : width - wcor ; height = height - wcor < 0 ? 1 : height - wcor ; StringBuilder pstyle = new StringBuilder ( 50 ) ; pstyle . append ( "left:" ) . append ( style . formatLength ( x - strokeOffset ) ) . append ( ' ' ) ; pstyle . append ( "top:" ) . append ( style . formatLength ( y - strokeOffset ) ) . append ( ' ' ) ; pstyle . append ( "width:" ) . append ( style . formatLength ( width ) ) . append ( ' ' ) ; pstyle . append ( "height:" ) . append ( style . formatLength ( height ) ) . append ( ' ' ) ; if ( stroke ) { String color = colorString ( getGraphicsState ( ) . getStrokingColor ( ) ) ; pstyle . append ( "border:" ) . append ( style . formatLength ( lineWidth ) ) . append ( " solid " ) . append ( color ) . append ( ' ' ) ; } if ( fill ) { String fcolor = colorString ( getGraphicsState ( ) . getNonStrokingColor ( ) ) ; pstyle . append ( "background-color:" ) . append ( fcolor ) . append ( ' ' ) ; } Element el = doc . createElement ( "div" ) ; el . setAttribute ( "class" , "r" ) ; el . setAttribute ( "style" , pstyle . toString ( ) ) ; el . appendChild ( doc . createEntityReference ( "nbsp" ) ) ; return el ; }
Creates an element that represents a rectangle drawn at the specified coordinates in the page .