@Test public void testDraw() throws OutputException { Graphics2D g2d = mock( Graphics2D.class ); Rectangle2D bounds = mock( Rectangle2D.class ); doReturn( g2d ).when( g2d ).create(); doReturn( 200.0 ).when( bounds ).getWidth(); doReturn( 600.0 ).when( bounds ).getHeight(); doReturn( 10.0 ).when( bounds ).getX(); doReturn( 20.0 ).when( bounds ).getY(); wrapper.draw( g2d, bounds ); verify( g2d ).clip( bounds ); verify( g2d, never() ).scale( anyDouble(), anyDouble() ); verify( barcode ).draw( g2d, 10, 20 ); verify( g2d ).dispose(); }
public void draw( final Graphics2D g2, final Rectangle2D bounds ) { final Graphics2D gr2 = (Graphics2D) g2.create(); try { gr2.clip( bounds ); if ( scale ) { final Dimension size = barcode.getPreferredSize(); final double horzScale = bounds.getWidth() / size.getWidth(); final double vertScale = bounds.getHeight() / size.getHeight(); if ( keepAspectRatio ) { final double scale = Math.min( horzScale, vertScale ); gr2.scale( scale, scale ); } else { gr2.scale( horzScale, vertScale ); } } barcode.draw( gr2, (int) bounds.getX(), (int) bounds.getY() ); } catch ( OutputException e ) { logger.error( "Unable to draw barcode element", e ); } finally { gr2.dispose(); } }
BarcodeWrapper implements ReportDrawable { public void draw( final Graphics2D g2, final Rectangle2D bounds ) { final Graphics2D gr2 = (Graphics2D) g2.create(); try { gr2.clip( bounds ); if ( scale ) { final Dimension size = barcode.getPreferredSize(); final double horzScale = bounds.getWidth() / size.getWidth(); final double vertScale = bounds.getHeight() / size.getHeight(); if ( keepAspectRatio ) { final double scale = Math.min( horzScale, vertScale ); gr2.scale( scale, scale ); } else { gr2.scale( horzScale, vertScale ); } } barcode.draw( gr2, (int) bounds.getX(), (int) bounds.getY() ); } catch ( OutputException e ) { logger.error( "Unable to draw barcode element", e ); } finally { gr2.dispose(); } } }
BarcodeWrapper implements ReportDrawable { public void draw( final Graphics2D g2, final Rectangle2D bounds ) { final Graphics2D gr2 = (Graphics2D) g2.create(); try { gr2.clip( bounds ); if ( scale ) { final Dimension size = barcode.getPreferredSize(); final double horzScale = bounds.getWidth() / size.getWidth(); final double vertScale = bounds.getHeight() / size.getHeight(); if ( keepAspectRatio ) { final double scale = Math.min( horzScale, vertScale ); gr2.scale( scale, scale ); } else { gr2.scale( horzScale, vertScale ); } } barcode.draw( gr2, (int) bounds.getX(), (int) bounds.getY() ); } catch ( OutputException e ) { logger.error( "Unable to draw barcode element", e ); } finally { gr2.dispose(); } } BarcodeWrapper( final Barcode barcode ); }
BarcodeWrapper implements ReportDrawable { public void draw( final Graphics2D g2, final Rectangle2D bounds ) { final Graphics2D gr2 = (Graphics2D) g2.create(); try { gr2.clip( bounds ); if ( scale ) { final Dimension size = barcode.getPreferredSize(); final double horzScale = bounds.getWidth() / size.getWidth(); final double vertScale = bounds.getHeight() / size.getHeight(); if ( keepAspectRatio ) { final double scale = Math.min( horzScale, vertScale ); gr2.scale( scale, scale ); } else { gr2.scale( horzScale, vertScale ); } } barcode.draw( gr2, (int) bounds.getX(), (int) bounds.getY() ); } catch ( OutputException e ) { logger.error( "Unable to draw barcode element", e ); } finally { gr2.dispose(); } } 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 draw( final Graphics2D g2, final Rectangle2D bounds ) { final Graphics2D gr2 = (Graphics2D) g2.create(); try { gr2.clip( bounds ); if ( scale ) { final Dimension size = barcode.getPreferredSize(); final double horzScale = bounds.getWidth() / size.getWidth(); final double vertScale = bounds.getHeight() / size.getHeight(); if ( keepAspectRatio ) { final double scale = Math.min( horzScale, vertScale ); gr2.scale( scale, scale ); } else { gr2.scale( horzScale, vertScale ); } } barcode.draw( gr2, (int) bounds.getX(), (int) bounds.getY() ); } catch ( OutputException e ) { logger.error( "Unable to draw barcode element", e ); } finally { gr2.dispose(); } } 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 );  }