@Test public void testSetStyleSheet() { StyleSheet style = null; wrapper.setStyleSheet( style ); verify( barcode, never() ).setFont( any( Font.class ) ); verify( barcode, never() ).setForeground( any( Color.class ) ); verify( barcode, never() ).setBackground( any( Color.class ) ); verify( barcode, never() ).setOpaque( anyBoolean() ); style = mock( StyleSheet.class ); wrapper.setStyleSheet( style ); verify( barcode, never() ).setFont( any( Font.class ) ); verify( barcode, never() ).setForeground( any( Color.class ) ); verify( barcode ).setBackground( BarcodeWrapper.ALPHA ); verify( barcode ).setOpaque( false ); doReturn( "font_name" ).when( style ).getStyleProperty( TextStyleKeys.FONT ); doReturn( 14 ).when( style ).getIntStyleProperty( TextStyleKeys.FONTSIZE, 0 ); doReturn( Color.RED ).when( style ).getStyleProperty( ElementStyleKeys.PAINT ); doReturn( Color.BLUE ).when( style ).getStyleProperty( ElementStyleKeys.BACKGROUND_COLOR ); wrapper.setStyleSheet( style ); verify( barcode ).setFont( any( Font.class ) ); verify( barcode ).setForeground( Color.RED ); verify( barcode ).setBackground( Color.BLUE ); verify( barcode ).setOpaque( false ); }
public void setStyleSheet( final StyleSheet style ) { if ( style != null ) { final String fontName = (String) style.getStyleProperty( TextStyleKeys.FONT ); final int fontSize = style.getIntStyleProperty( TextStyleKeys.FONTSIZE, 0 ); final boolean bold = style.getBooleanStyleProperty( TextStyleKeys.BOLD ); final boolean italics = style.getBooleanStyleProperty( TextStyleKeys.ITALIC ); final Color foregroundColor = (Color) style.getStyleProperty( ElementStyleKeys.PAINT ); final Color backgroundColor = (Color) style.getStyleProperty( ElementStyleKeys.BACKGROUND_COLOR ); if ( fontName != null && fontSize > 0 ) { int fontstyle = Font.PLAIN; if ( bold ) { fontstyle |= Font.BOLD; } if ( italics ) { fontstyle |= Font.ITALIC; } barcode.setFont( new Font( fontName, fontstyle, fontSize ) ); } if ( foregroundColor != null ) { barcode.setForeground( foregroundColor ); } if ( backgroundColor != null ) { barcode.setBackground( backgroundColor ); barcode.setOpaque( backgroundColor.getAlpha() == 255 ); } else { barcode.setBackground( ALPHA ); barcode.setOpaque( false ); } scale = style.getBooleanStyleProperty( ElementStyleKeys.SCALE ); keepAspectRatio = style.getBooleanStyleProperty( ElementStyleKeys.KEEP_ASPECT_RATIO ); } }
BarcodeWrapper implements ReportDrawable { public void setStyleSheet( final StyleSheet style ) { if ( style != null ) { final String fontName = (String) style.getStyleProperty( TextStyleKeys.FONT ); final int fontSize = style.getIntStyleProperty( TextStyleKeys.FONTSIZE, 0 ); final boolean bold = style.getBooleanStyleProperty( TextStyleKeys.BOLD ); final boolean italics = style.getBooleanStyleProperty( TextStyleKeys.ITALIC ); final Color foregroundColor = (Color) style.getStyleProperty( ElementStyleKeys.PAINT ); final Color backgroundColor = (Color) style.getStyleProperty( ElementStyleKeys.BACKGROUND_COLOR ); if ( fontName != null && fontSize > 0 ) { int fontstyle = Font.PLAIN; if ( bold ) { fontstyle |= Font.BOLD; } if ( italics ) { fontstyle |= Font.ITALIC; } barcode.setFont( new Font( fontName, fontstyle, fontSize ) ); } if ( foregroundColor != null ) { barcode.setForeground( foregroundColor ); } if ( backgroundColor != null ) { barcode.setBackground( backgroundColor ); barcode.setOpaque( backgroundColor.getAlpha() == 255 ); } else { barcode.setBackground( ALPHA ); barcode.setOpaque( false ); } scale = style.getBooleanStyleProperty( ElementStyleKeys.SCALE ); keepAspectRatio = style.getBooleanStyleProperty( ElementStyleKeys.KEEP_ASPECT_RATIO ); } } }
BarcodeWrapper implements ReportDrawable { public void setStyleSheet( final StyleSheet style ) { if ( style != null ) { final String fontName = (String) style.getStyleProperty( TextStyleKeys.FONT ); final int fontSize = style.getIntStyleProperty( TextStyleKeys.FONTSIZE, 0 ); final boolean bold = style.getBooleanStyleProperty( TextStyleKeys.BOLD ); final boolean italics = style.getBooleanStyleProperty( TextStyleKeys.ITALIC ); final Color foregroundColor = (Color) style.getStyleProperty( ElementStyleKeys.PAINT ); final Color backgroundColor = (Color) style.getStyleProperty( ElementStyleKeys.BACKGROUND_COLOR ); if ( fontName != null && fontSize > 0 ) { int fontstyle = Font.PLAIN; if ( bold ) { fontstyle |= Font.BOLD; } if ( italics ) { fontstyle |= Font.ITALIC; } barcode.setFont( new Font( fontName, fontstyle, fontSize ) ); } if ( foregroundColor != null ) { barcode.setForeground( foregroundColor ); } if ( backgroundColor != null ) { barcode.setBackground( backgroundColor ); barcode.setOpaque( backgroundColor.getAlpha() == 255 ); } else { barcode.setBackground( ALPHA ); barcode.setOpaque( false ); } scale = style.getBooleanStyleProperty( ElementStyleKeys.SCALE ); keepAspectRatio = style.getBooleanStyleProperty( ElementStyleKeys.KEEP_ASPECT_RATIO ); } } BarcodeWrapper( final Barcode barcode ); }
BarcodeWrapper implements ReportDrawable { public void setStyleSheet( final StyleSheet style ) { if ( style != null ) { final String fontName = (String) style.getStyleProperty( TextStyleKeys.FONT ); final int fontSize = style.getIntStyleProperty( TextStyleKeys.FONTSIZE, 0 ); final boolean bold = style.getBooleanStyleProperty( TextStyleKeys.BOLD ); final boolean italics = style.getBooleanStyleProperty( TextStyleKeys.ITALIC ); final Color foregroundColor = (Color) style.getStyleProperty( ElementStyleKeys.PAINT ); final Color backgroundColor = (Color) style.getStyleProperty( ElementStyleKeys.BACKGROUND_COLOR ); if ( fontName != null && fontSize > 0 ) { int fontstyle = Font.PLAIN; if ( bold ) { fontstyle |= Font.BOLD; } if ( italics ) { fontstyle |= Font.ITALIC; } barcode.setFont( new Font( fontName, fontstyle, fontSize ) ); } if ( foregroundColor != null ) { barcode.setForeground( foregroundColor ); } if ( backgroundColor != null ) { barcode.setBackground( backgroundColor ); barcode.setOpaque( backgroundColor.getAlpha() == 255 ); } else { barcode.setBackground( ALPHA ); barcode.setOpaque( false ); } scale = style.getBooleanStyleProperty( ElementStyleKeys.SCALE ); keepAspectRatio = style.getBooleanStyleProperty( ElementStyleKeys.KEEP_ASPECT_RATIO ); } } BarcodeWrapper( final Barcode barcode ); Barcode getBarcode(); boolean isPreserveAspectRatio(); Dimension getPreferredSize(); void draw( final Graphics2D g2, final Rectangle2D bounds ); void setConfiguration( final Configuration config ); void setStyleSheet( final StyleSheet style ); void setResourceBundleFactory( final ResourceBundleFactory bundleFactory ); ImageMap getImageMap( final Rectangle2D bounds ); }
BarcodeWrapper implements ReportDrawable { public void setStyleSheet( final StyleSheet style ) { if ( style != null ) { final String fontName = (String) style.getStyleProperty( TextStyleKeys.FONT ); final int fontSize = style.getIntStyleProperty( TextStyleKeys.FONTSIZE, 0 ); final boolean bold = style.getBooleanStyleProperty( TextStyleKeys.BOLD ); final boolean italics = style.getBooleanStyleProperty( TextStyleKeys.ITALIC ); final Color foregroundColor = (Color) style.getStyleProperty( ElementStyleKeys.PAINT ); final Color backgroundColor = (Color) style.getStyleProperty( ElementStyleKeys.BACKGROUND_COLOR ); if ( fontName != null && fontSize > 0 ) { int fontstyle = Font.PLAIN; if ( bold ) { fontstyle |= Font.BOLD; } if ( italics ) { fontstyle |= Font.ITALIC; } barcode.setFont( new Font( fontName, fontstyle, fontSize ) ); } if ( foregroundColor != null ) { barcode.setForeground( foregroundColor ); } if ( backgroundColor != null ) { barcode.setBackground( backgroundColor ); barcode.setOpaque( backgroundColor.getAlpha() == 255 ); } else { barcode.setBackground( ALPHA ); barcode.setOpaque( false ); } scale = style.getBooleanStyleProperty( ElementStyleKeys.SCALE ); keepAspectRatio = style.getBooleanStyleProperty( ElementStyleKeys.KEEP_ASPECT_RATIO ); } } BarcodeWrapper( final Barcode barcode ); Barcode getBarcode(); boolean isPreserveAspectRatio(); Dimension getPreferredSize(); void draw( final Graphics2D g2, final Rectangle2D bounds ); void setConfiguration( final Configuration config ); void setStyleSheet( final StyleSheet style ); void setResourceBundleFactory( final ResourceBundleFactory bundleFactory ); ImageMap getImageMap( final Rectangle2D bounds );  }