/** * Default Constructor that constructs generic bands. */ public BandElementFactory() { this( new Band() ); }
public ReportElement create() { return new Band(); } }
public ReportElement create() { final Band element = new Band(); element.setElementType( INSTANCE ); return element; }
public void testSerialize() throws Exception { final Band e = new Band(); final ByteArrayOutputStream bo = new ByteArrayOutputStream(); final ObjectOutputStream out = new ObjectOutputStream( bo ); out.writeObject( e ); final ObjectInputStream oin = new ObjectInputStream( new ByteArrayInputStream( bo.toByteArray() ) ); final Element e2 = (Element) oin.readObject(); assertNotNull( e2 ); // cannot assert equals, as this is not implemented. }
public BandReadHandler() { band = new Band(); this.bandFactory = new BandElementFactory( band ); this.items = new ArrayList(); }
public void testGetDefaultStyleSheet() { Band band = new Band(); assertThat( band.getDefaultStyleSheet(), is( notNullValue() ) ); }
public void testAddElementTooBigPosition() { try { Band band = new Band(); band.addElement( 10, mock( Element.class ) ); fail( "should throw exception" ); } catch ( IllegalArgumentException e ) { // expected } }
public void testAddElementWrongPosition() { try { Band band = new Band(); band.addElement( -1, mock( Element.class ) ); fail( "should throw exception" ); } catch ( IllegalArgumentException e ) { // expected } }
public static Band createAutoBox( final Element... boxes ) { final Band tableRow = new Band(); tableRow.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_AUTO ); for ( int i = 0; i < boxes.length; i++ ) { tableRow.addElement( boxes[i] ); } return tableRow; }
@Test( expected = NullPointerException.class ) public void testAddNullElement() { try { Band band = new Band(); band.addElement( 0, null ); fail( "should throw exception" ); } catch ( NullPointerException e ) { // expected } }
public void testFindElement() { final Band noLate = new Band(); noLate.setName( "noLate" ); final Band landScape = new Band(); landScape.setName( "landscape" ); landScape.addElement( noLate ); final ItemBand band = new ItemBand(); band.addElement( landScape ); assertEquals( noLate, FunctionUtilities.findElement( band, "noLate" ) ); } }
public static Band createTableBand( final String layout ) { final Band b = new Band(); b.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, layout ); b.getStyle().setStyleProperty( ElementStyleKeys.INVISIBLE_CONSUMES_SPACE, true ); final StyleResolver resolver = new SimpleStyleResolver(); final ResolverStyleSheet resolverTarget = new ResolverStyleSheet(); resolver.resolve( b, resolverTarget ); b.setComputedStyle( new SimpleStyleSheet( resolverTarget ) ); return b; }
public void testGetElement() { Band band = new Band(); try { band.getElement( null ); fail( "should throw exception" ); } catch ( NullPointerException e ) { // expected } Element elem = mock( Element.class ); doReturn( "test_name" ).when( elem ).getName(); band.addElement( elem ); assertEquals( 1, band.getElementCount() ); assertEquals( elem, band.getElement( "test_name" ) ); }
public static Band createTable( final TableLayout tableLayout ) { final Band b = new Band(); b.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE ); b.getStyle().setStyleProperty( ElementStyleKeys.INVISIBLE_CONSUMES_SPACE, true ); b.getStyle().setStyleProperty( BandStyleKeys.TABLE_LAYOUT, tableLayout ); final StyleResolver resolver = new SimpleStyleResolver(); final ResolverStyleSheet resolverTarget = new ResolverStyleSheet(); resolver.resolve( b, resolverTarget ); b.setComputedStyle( new SimpleStyleSheet( resolverTarget ) ); return b; }
public static Band createRow( final Element... boxes ) { final Band tableRow = new Band(); tableRow.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_ROW ); tableRow.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 100f ); tableRow.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); for ( int i = 0; i < boxes.length; i++ ) { tableRow.addElement( boxes[i] ); } return tableRow; }
public static Band createCell( final float width, final float height, final int rowSpan, final int colSpan ) { final Band tableCell = new Band(); tableCell.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_CELL ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, width ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, height ); tableCell.setAttribute( AttributeNames.Table.NAMESPACE, AttributeNames.Table.ROWSPAN, rowSpan ); tableCell.setAttribute( AttributeNames.Table.NAMESPACE, AttributeNames.Table.COLSPAN, colSpan ); return tableCell; } }
public static Band createCell( final int rowNumber, final int colNumber, final float cellWidth, final float cellHeight, final Element... elements ) { final Band cell = new Band(); cell.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_CELL ); cell.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, cellWidth ); cell.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, cellHeight ); cell.setName( "c-" + rowNumber + "-" + colNumber ); for ( int i = 0; i < elements.length; i++ ) { final Element element = elements[i]; cell.addElement( element ); } return cell; }
public static Band createCell( final Element dataItem, final int rowSpan, final int colSpan ) { final Band tableCell = new Band(); tableCell.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_CELL ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 150f ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); tableCell.setAttribute( AttributeNames.Table.NAMESPACE, AttributeNames.Table.ROWSPAN, rowSpan ); tableCell.setAttribute( AttributeNames.Table.NAMESPACE, AttributeNames.Table.COLSPAN, colSpan ); tableCell.addElement( dataItem ); return tableCell; }
public void testBandMethods() { final Band b = new Band(); assertTrue( b.isVisible() ); b.setVisible( false ); assertTrue( b.isVisible() == false ); b.setVisible( true ); assertTrue( b.isVisible() ); try { b.setDataSource( null ); fail(); } catch ( NullPointerException npe ) { // expected, ignored } b.toString(); }
@Test public void testDeepSubBandInlineSubReportDetection() { SubReport srInner = new SubReport(); Band band = new Band(); band.addElement( srInner ); SubReport sr = new SubReport(); sr.getReportHeader().addElement( band ); MasterReport report = new MasterReport(); report.getReportHeader().addSubReport( sr ); ReportStructureValidator v = new ReportStructureValidator(); Assert.assertFalse( v.isValidForFastProcessing( report ) ); }