Java Code Examples for org.pentaho.reporting.engine.classic.core.MasterReport#getReportHeader()
The following examples show how to use
org.pentaho.reporting.engine.classic.core.MasterReport#getReportHeader() .
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: ReplacedContentIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testReplacedContentRel() throws Exception { final MasterReport basereport = new MasterReport(); basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) ); final URL target = LayoutIT.class.getResource( "replaced-content-relative.xml" ); final ResourceManager rm = new ResourceManager(); rm.registerDefaults(); final Resource directly = rm.createDirectly( target, MasterReport.class ); final MasterReport report = (MasterReport) directly.getResource(); PageFormat pageFormat = report.getPageDefinition().getPageFormat( 0 ); DebugLog.log( PageFormatFactory.printPageFormat( pageFormat ) ); final Band containerBand = report.getReportHeader(); // Each character (regarless of font or font-size) will be 8pt high and 4pt wide. // this makes this test independent of the fonts installed on the system we run on. final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, containerBand, true, false ); // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000 // and that only two lines exist for each // ModelPrinter.INSTANCE.print(logicalPageBox); new ValidateRelativeRunner().startValidation( logicalPageBox ); }
Example 2
Source File: Prd4634Test.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testReportHeader() throws Exception { final URL resource = getClass().getResource( "Prd-4634.prpt" ); assertNotNull( resource ); final ResourceManager mgr = new ResourceManager(); mgr.registerDefaults(); final MasterReport report = (MasterReport) mgr.createDirectly( resource, MasterReport.class ).getResource(); final GlobalAuthenticationStore globalAuthenticationStore = new GlobalAuthenticationStore(); final ReportRenderContext reportContext = new ReportRenderContext( report, report, null, globalAuthenticationStore ); final TestRootBandRenderer r = new TestRootBandRenderer( report.getReportHeader(), reportContext ); final ValidateTextGraphics graphics2D = new ValidateTextGraphics( 468, 108 ); graphics2D.expect( "Interactive", "Report" ); assertTrue( graphics2D.hitClip( 10, 10, 1, 1 ) ); r.draw( graphics2D ); }
Example 3
Source File: Prd3239IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testReport() throws ResourceException { final URL url = getClass().getResource( "Prd-3239.prpt" ); assertNotNull( url ); final ResourceManager resourceManager = new ResourceManager(); resourceManager.registerDefaults(); final Resource directly = resourceManager.createDirectly( url, MasterReport.class ); final MasterReport report = (MasterReport) directly.getResource(); final ReportHeader rh = report.getReportHeader(); // rh.removeSubreport(rh.getSubReport(1)); rh.removeSubreport( rh.getSubReport( 1 ) ); rh.removeSubreport( rh.getSubReport( 1 ) ); rh.removeSubreport( rh.getSubReport( 1 ) ); rh.removeSubreport( rh.getSubReport( 1 ) ); DebugReportRunner.execGraphics2D( report ); }
Example 4
Source File: Prd4760IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testReport() throws ReportProcessingException, ContentProcessingException { Band b = new Band(); b.setLayout( BandStyleKeys.LAYOUT_ROW ); b.addElement( TableTestUtil.createDataItem( "Test" ) ); b.setVisible( false ); MasterReport report = new MasterReport(); report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY, "false" ); ReportHeader reportHeader = report.getReportHeader(); reportHeader.setLayout( BandStyleKeys.LAYOUT_ROW ); reportHeader.addElement( b ); reportHeader.getStyle().setStyleProperty( ElementStyleKeys.INVISIBLE_CONSUMES_SPACE, false ); LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, reportHeader ); RenderNode[] elementsByNodeType = MatchFactory.findElementsByNodeType( logicalPageBox, LayoutNodeTypes.TYPE_NODE_TEXT ); Assert.assertEquals( 0, elementsByNodeType.length ); }
Example 5
Source File: Pre422IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testSubReportDoesNotCrash() throws Exception { final URL target = Pre422IT.class.getResource( "Pre-422.xml" ); final ResourceManager rm = new ResourceManager(); rm.registerDefaults(); final Resource directly = rm.createDirectly( target, MasterReport.class ); final MasterReport report = (MasterReport) directly.getResource(); final MasterReport basereport = new MasterReport(); basereport.setCompatibilityLevel( null ); basereport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY, "false" ); basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) ); final Band band = report.getReportHeader(); band.setName( "ReportHeader1" ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), false, true ); // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000 // and that only two lines exist for each new ValidateRunner().startValidation( logicalPageBox ); }
Example 6
Source File: Prd4760IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testSimpleReport2() throws ReportProcessingException, ContentProcessingException { Element test = TableTestUtil.createDataItem( "Test" ); test.setVisible( false ); MasterReport report = new MasterReport(); report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY, "false" ); ReportHeader reportHeader = report.getReportHeader(); reportHeader.setLayout( BandStyleKeys.LAYOUT_ROW ); reportHeader.addElement( test ); reportHeader.getStyle().setStyleProperty( ElementStyleKeys.INVISIBLE_CONSUMES_SPACE, false ); reportHeader.setVisible( false ); LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, reportHeader ); RenderNode[] elementsByNodeType = MatchFactory.findElementsByNodeType( logicalPageBox, LayoutNodeTypes.TYPE_NODE_TEXT ); Assert.assertEquals( 0, elementsByNodeType.length ); }
Example 7
Source File: Prd3479IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testEmptyCanvasBoxInCanvas() throws ReportProcessingException, ContentProcessingException { final Band canvasBand = new Band(); canvasBand.setName( "CanvasBand" ); canvasBand.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, "canvas" ); canvasBand.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 1f ); final Band rowBand = new Band(); rowBand.setName( "RowBand" ); rowBand.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, "canvas" ); rowBand.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 1f ); rowBand.addElement( canvasBand ); final MasterReport report = new MasterReport(); final ReportHeader band = report.getReportHeader(); band.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 2f ); band.setLayout( "block" ); band.addElement( rowBand ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, band ); final RenderNode canvasBandRenderBox = MatchFactory.findElementByName( logicalPageBox, "CanvasBand" ); assertEquals( 0, canvasBandRenderBox.getWidth() ); }
Example 8
Source File: Prd3479IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testCanvasLayout() throws ReportProcessingException, ContentProcessingException { final MasterReport report = new MasterReport(); final ReportHeader reportHeader = report.getReportHeader(); reportHeader.addElement( createBand( "large", 0, 100 ) ); reportHeader.addElement( createBand( "rel", -25, -50 ) ); // Each character (regarless of font or font-size) will be 8pt high and 4pt wide. // this makes this test independent of the fonts installed on the system we run on. final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, reportHeader ); // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000 // and that only two lines exist for each // ModelPrinter.print(logicalPageBox); new ValidateRunner().startValidation( logicalPageBox ); }
Example 9
Source File: TableIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * This test should create auto-table elements to have a fully functional table. * * @throws ReportProcessingException * @throws ContentProcessingException */ public void testBrokenTableRow() throws ReportProcessingException, ContentProcessingException { final Element label = TableTestUtil.createDataItem( "Cell" ); final Band tableCell = new Band(); tableCell.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_CELL ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); tableCell.addElement( label ); final Band tableRow = TableTestUtil.createRow(); tableRow.addElement( tableCell ); final MasterReport report = new MasterReport(); final ReportHeader band = report.getReportHeader(); band.addElement( tableRow ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, band, false, false ); // ModelPrinter.print(logicalPageBox); final NodeMatcher matcher = new ChildMatcher( new ElementMatcher( "TableCellRenderBox" ) ); final RenderNode[] all = MatchFactory.matchAll( logicalPageBox, matcher ); assertEquals( 1, all.length ); for ( final RenderNode renderNode : all ) { assertEquals( 0l, renderNode.getX() ); assertEquals( 10000000l, renderNode.getWidth() ); assertEquals( 20000000l, renderNode.getHeight() ); assertEquals( 0l, renderNode.getY() ); } }
Example 10
Source File: TableIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * This test should create auto-table elements to have a fully functional table. * * @throws ReportProcessingException * @throws ContentProcessingException */ public void testBrokenTableBody() throws ReportProcessingException, ContentProcessingException, IOException { final Element label = TableTestUtil.createDataItem( "Cell" ); final Band tableCell = new Band(); tableCell.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_CELL ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); tableCell.addElement( label ); final Band tableRow = TableTestUtil.createRow(); tableRow.addElement( tableCell ); final Band tableBody = new Band(); tableBody.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_BODY ); tableBody.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); tableBody.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); tableBody.addElement( tableRow ); final MasterReport report = new MasterReport(); final ReportHeader band = report.getReportHeader(); band.addElement( tableBody ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, band, false, false ); // ModelPrinter.INSTANCE.print(logicalPageBox); final NodeMatcher matcher = new ChildMatcher( new ElementMatcher( "TableCellRenderBox" ) ); final RenderNode[] all = MatchFactory.matchAll( logicalPageBox, matcher ); assertEquals( 1, all.length ); for ( final RenderNode renderNode : all ) { assertEquals( 0l, renderNode.getX() ); assertEquals( 10000000l, renderNode.getWidth() ); assertEquals( 20000000l, renderNode.getHeight() ); assertEquals( 0l, renderNode.getY() ); } }
Example 11
Source File: LayoutIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void testLayout() throws ResourceException, ContentProcessingException, ReportProcessingException { final MasterReport basereport = new MasterReport(); basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) ); final URL target = LayoutIT.class.getResource( "layouting.xml" ); final ResourceManager rm = new ResourceManager(); rm.registerDefaults(); final Resource directly = rm.createDirectly( target, MasterReport.class ); final MasterReport report = (MasterReport) directly.getResource(); final Band band = report.getReportHeader(); band.setName( "ReportHeader1" ); DebugReportRunner.layoutSingleBand( report, report.getReportHeader(), false, true ); }
Example 12
Source File: AlignmentJustifiedIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void testAlignmentCenter() throws Exception { final MasterReport report = new MasterReport(); ReportHeader reportHeader = report.getReportHeader(); reportHeader.addElement( LabelElementFactory.createLabelElement( "CustomerLabel", new Rectangle2D.Double( 0, 0, 203, 157 ), Color.RED, ElementAlignment.JUSTIFY, null, longText ) ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, reportHeader ); // simple test, we assert that all paragraph-poolboxes are on either 485000 or 400000 // and that only two lines exist for each // ModelPrinter.print(logicalPageBox); new ValidateRunner().startValidation( logicalPageBox ); }
Example 13
Source File: TableIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * This test should create auto-table elements to have a fully functional table. * * @throws ReportProcessingException * @throws ContentProcessingException */ public void testBrokenTableBody2() throws ReportProcessingException, ContentProcessingException, IOException { final Element label = TableTestUtil.createDataItem( "Cell" ); final Band tableCell = new Band(); tableCell.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_CELL ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); tableCell.addElement( label ); final Band tableRow = TableTestUtil.createRow(); tableRow.addElement( tableCell ); final Band tableBody = new Band(); tableBody.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_BODY ); tableBody.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -50f ); tableBody.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); tableBody.addElement( tableRow ); final MasterReport report = new MasterReport(); final ReportHeader band = report.getReportHeader(); band.addElement( tableBody ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, band, false, false ); // ModelPrinter.INSTANCE.print(logicalPageBox); final NodeMatcher matcher = new ChildMatcher( new ElementMatcher( "TableCellRenderBox" ) ); final RenderNode[] all = MatchFactory.matchAll( logicalPageBox, matcher ); assertEquals( 1, all.length ); for ( final RenderNode renderNode : all ) { assertEquals( 0l, renderNode.getX() ); assertEquals( 10000000l, renderNode.getWidth() ); assertEquals( 20000000l, renderNode.getHeight() ); assertEquals( 0l, renderNode.getY() ); } }
Example 14
Source File: TableIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * This test should create auto-table elements to have a fully functional table. * * @throws ReportProcessingException * @throws ContentProcessingException */ public void testBrokenTableCell() throws ReportProcessingException, ContentProcessingException { final Element label = TableTestUtil.createDataItem( "Cell" ); final Band tableCell = new Band(); tableCell.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_CELL ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); tableCell.addElement( label ); final MasterReport report = new MasterReport(); final ReportHeader band = report.getReportHeader(); band.addElement( tableCell ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, band, false, false ); // ModelPrinter.print(logicalPageBox); final NodeMatcher matcher = new ChildMatcher( new ElementMatcher( "TableCellRenderBox" ) ); final RenderNode[] all = MatchFactory.matchAll( logicalPageBox, matcher ); assertEquals( 1, all.length ); for ( final RenderNode renderNode : all ) { assertEquals( 0l, renderNode.getX() ); assertEquals( 10000000l, renderNode.getWidth() ); assertEquals( 20000000l, renderNode.getHeight() ); assertEquals( 0l, renderNode.getY() ); } }
Example 15
Source File: WeavingTableIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testSimpleTable() throws ReportProcessingException, ContentProcessingException { System.out.println( ObjectUtilities.getResource( "simplelog.properties", getClass() ) ); final Element label = TableTestUtil.createDataItem( "Cell" ); final Band tableCell = new Band(); tableCell.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_CELL ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); tableCell.addElement( label ); final Band autoRow = TableTestUtil.createAutoBox( tableCell ); autoRow.setName( "AutoRow" ); final Band tableRow = TableTestUtil.createRow( autoRow ); final Band tableBody = new Band(); tableBody.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_BODY ); tableBody.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); tableBody.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); final Band autoBody = TableTestUtil.createAutoBox( tableRow ); autoBody.setName( "AutoBody" ); tableBody.addElement( autoBody ); final Band table = new Band(); table.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE ); table.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); table.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); final Band autoTable = TableTestUtil.createAutoBox( tableBody ); autoTable.setName( "AutoTable" ); table.addElement( autoTable ); final MasterReport report = new MasterReport(); report.setStrictLegacyMode( false ); final ReportHeader band = report.getReportHeader(); band.addElement( table ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, band, false, false ); // ModelPrinter.INSTANCE.print(logicalPageBox); final NodeMatcher matcher = new ChildMatcher( new ElementMatcher( "TableCellRenderBox" ) ); final RenderNode[] all = MatchFactory.matchAll( logicalPageBox, matcher ); // assert that the direct childs of a table-cell-render-box have the same width as the table-cell render box assertEquals( 1, all.length ); for ( final RenderNode renderNode : all ) { assertEquals( 0l, renderNode.getX() ); assertEquals( 46800000l, renderNode.getWidth() ); assertEquals( 20000000l, renderNode.getHeight() ); assertEquals( 0l, renderNode.getY() ); } }
Example 16
Source File: TableIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testSimpleTable() throws ReportProcessingException, ContentProcessingException { final Element label = TableTestUtil.createDataItem( "Cell" ); final Band tableCell = new Band(); tableCell.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_CELL ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); tableCell.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); tableCell.addElement( label ); final Band tableRow = TableTestUtil.createRow(); tableRow.addElement( tableCell ); final Band tableBody = new Band(); tableBody.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_BODY ); tableBody.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); tableBody.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); tableBody.addElement( tableRow ); final Band table = new Band(); table.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE ); table.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); table.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); table.addElement( tableBody ); final MasterReport report = new MasterReport(); final ReportHeader band = report.getReportHeader(); band.addElement( table ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, band, false, false ); // ModelPrinter.print(logicalPageBox); final NodeMatcher matcher = new ChildMatcher( new ElementMatcher( "TableCellRenderBox" ) ); final RenderNode[] all = MatchFactory.matchAll( logicalPageBox, matcher ); assertEquals( 1, all.length ); for ( final RenderNode renderNode : all ) { assertEquals( 0l, renderNode.getX() ); assertEquals( 46800000l, renderNode.getWidth() ); assertEquals( 20000000l, renderNode.getHeight() ); assertEquals( 0l, renderNode.getY() ); } }
Example 17
Source File: WidowOrphanIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testKeepTogetherEffectPagebreakLarger() throws Exception { final MasterReport report = new MasterReport(); report.setPageDefinition( new SimplePageDefinition( new PageSize( 500, 100 ) ) ); final Band detailBody = new Band(); detailBody.setLayout( BandStyleKeys.LAYOUT_BLOCK ); detailBody.setName( "detail-body" ); detailBody.getStyle().setStyleProperty( ElementStyleKeys.AVOID_PAGEBREAK_INSIDE, true ); detailBody.addElement( createBand( "ib1" ) ); detailBody.addElement( createBand( "ib2" ) ); detailBody.addElement( createBand( "ib3" ) ); detailBody.addElement( createBand( "ib4" ) ); detailBody.addElement( createBand( "ib5" ) ); detailBody.addElement( createBand( "ib6" ) ); detailBody.addElement( createBand( "ib7" ) ); final Band insideGroup = new Band(); insideGroup.getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 2 ); insideGroup.getStyle().setStyleProperty( ElementStyleKeys.WIDOWS, 2 ); insideGroup.setLayout( BandStyleKeys.LAYOUT_BLOCK ); insideGroup.setName( "group-inside" ); insideGroup.addElement( createBand( "group-header-inside" ) ); insideGroup.addElement( detailBody ); insideGroup.addElement( createBand( "group-footer-inside" ) ); final Band outsideBody = new Band(); outsideBody.setLayout( BandStyleKeys.LAYOUT_BLOCK ); outsideBody.setName( "group-body-outside" ); outsideBody.addElement( insideGroup ); final ReportHeader band = report.getReportHeader(); band.getStyle().setStyleProperty( ElementStyleKeys.AVOID_PAGEBREAK_INSIDE, false ); band.getStyle().setStyleProperty( ElementStyleKeys.WIDOW_ORPHAN_OPT_OUT, true ); band.setLayout( BandStyleKeys.LAYOUT_BLOCK ); band.setName( "group-outside" ); band.getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 2 ); band.getStyle().setStyleProperty( ElementStyleKeys.WIDOWS, 2 ); band.addElement( createBand( "group-header-outside" ) ); band.addElement( outsideBody ); band.addElement( createBand( "group-footer-outside" ) ); List<LogicalPageBox> pages = DebugReportRunner.layoutPages( report, 0, 1, 2 ); final LogicalPageBox logicalPageBox1 = pages.get( 0 ); ModelPrinter.INSTANCE.print( logicalPageBox1 ); final RenderNode grHOut2 = MatchFactory.findElementByName( logicalPageBox1, "group-header-outside" ); assertNotNull( grHOut2 ); final RenderNode grOut2 = MatchFactory.findElementByName( logicalPageBox1, "group-outside" ); assertNotNull( grOut2 ); final RenderNode ib1 = MatchFactory.findElementByName( logicalPageBox1, "ib1" ); assertNotNull( ib1 ); final RenderNode ib2 = MatchFactory.findElementByName( logicalPageBox1, "ib2" ); assertNotNull( ib2 ); final RenderNode ib3miss = MatchFactory.findElementByName( logicalPageBox1, "ib3" ); assertNotNull( ib3miss ); final LogicalPageBox logicalPageBox2 = pages.get( 1 ); ModelPrinter.INSTANCE.print( logicalPageBox2 ); final RenderNode ib3 = MatchFactory.findElementByName( logicalPageBox2, "ib3" ); assertNull( ib3 ); final RenderNode ib6 = MatchFactory.findElementByName( logicalPageBox2, "ib6" ); assertNotNull( ib6 ); final RenderNode ib7miss = MatchFactory.findElementByName( logicalPageBox2, "ib7" ); assertNull( ib7miss ); final LogicalPageBox logicalPageBox3 = pages.get( 2 ); final RenderNode ib7 = MatchFactory.findElementByName( logicalPageBox3, "ib7" ); assertNotNull( ib7 ); }
Example 18
Source File: OrphanIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testStandardLayout() throws ReportProcessingException, ContentProcessingException { final MasterReport report = new MasterReport(); report.setPageDefinition( new SimplePageDefinition( new PageSize( 500, 100 ) ) ); final Band detailBody = new Band(); detailBody.setLayout( BandStyleKeys.LAYOUT_BLOCK ); detailBody.setName( "detail-body-1" ); detailBody.addElement( createBand( "ib1" ) ); detailBody.addElement( createBand( "ib2" ) ); detailBody.addElement( createBand( "ib3" ) ); final Band insideGroup = new Band(); insideGroup.getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 2 ); insideGroup.setLayout( BandStyleKeys.LAYOUT_BLOCK ); insideGroup.setName( "group-inside" ); insideGroup.addElement( createBand( "group-header-inside" ) ); insideGroup.addElement( detailBody ); insideGroup.addElement( createBand( "group-footer-inside" ) ); final Band detailBody2 = new Band(); detailBody2.setLayout( BandStyleKeys.LAYOUT_BLOCK ); detailBody2.setName( "detail-body-2" ); detailBody2.addElement( createBand( "ib1" ) ); detailBody2.addElement( createBand( "ib2" ) ); detailBody2.addElement( createBand( "ib3" ) ); final Band insideGroup2 = new Band(); insideGroup2.getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 2 ); insideGroup2.setLayout( BandStyleKeys.LAYOUT_BLOCK ); insideGroup2.setName( "group-inside" ); insideGroup2.addElement( createBand( "group-header-inside" ) ); insideGroup2.addElement( detailBody2 ); insideGroup2.addElement( createBand( "group-footer-inside" ) ); final Band outsideBody = new Band(); outsideBody.setLayout( BandStyleKeys.LAYOUT_BLOCK ); outsideBody.setName( "group-body-outside" ); outsideBody.addElement( insideGroup ); outsideBody.addElement( insideGroup2 ); final ReportHeader band = report.getReportHeader(); band.getStyle().setStyleProperty( ElementStyleKeys.AVOID_PAGEBREAK_INSIDE, false ); band.setLayout( BandStyleKeys.LAYOUT_BLOCK ); band.setName( "group-outside" ); band.getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 2 ); band.addElement( createBand( "group-header-outside" ) ); band.addElement( outsideBody ); band.addElement( createBand( "group-footer-outside" ) ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, band, false, false ); final RenderNode grOut = MatchFactory.findElementByName( logicalPageBox, "group-outside" ); assertTrue( grOut instanceof RenderBox ); final RenderBox grOutBox = (RenderBox) grOut; assertEquals( StrictGeomUtility.toInternalValue( 60 ), grOutBox.getOrphanConstraintSize() ); final RenderNode grIn = MatchFactory.findElementByName( logicalPageBox, "group-inside" ); assertTrue( grIn instanceof RenderBox ); final RenderBox grInBox = (RenderBox) grIn; assertEquals( StrictGeomUtility.toInternalValue( 40 ), grInBox.getOrphanConstraintSize() ); // ModelPrinter.INSTANCE.print(logicalPageBox); }
Example 19
Source File: WidowIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testStandardLayout() throws ReportProcessingException, ContentProcessingException { final MasterReport report = new MasterReport(); report.setPageDefinition( new SimplePageDefinition( new PageSize( 500, 100 ) ) ); final Band detailBody = new Band(); detailBody.setLayout( BandStyleKeys.LAYOUT_BLOCK ); detailBody.setName( "detail-body-1" ); detailBody.addElement( createBand( "ib1" ) ); detailBody.addElement( createBand( "ib2" ) ); detailBody.addElement( createBand( "ib3" ) ); final Band insideGroup = new Band(); insideGroup.getStyle().setStyleProperty( ElementStyleKeys.WIDOWS, 2 ); insideGroup.setLayout( BandStyleKeys.LAYOUT_BLOCK ); insideGroup.setName( "group-inside" ); insideGroup.addElement( createBand( "group-header-inside" ) ); insideGroup.addElement( detailBody ); insideGroup.addElement( createBand( "group-footer-inside" ) ); final Band detailBody2 = new Band(); detailBody2.setLayout( BandStyleKeys.LAYOUT_BLOCK ); detailBody2.setName( "detail-body-1" ); detailBody2.addElement( createBand( "ib1" ) ); detailBody2.addElement( createBand( "ib2" ) ); detailBody2.addElement( createBand( "ib3" ) ); final Band insideGroup2 = new Band(); insideGroup2.getStyle().setStyleProperty( ElementStyleKeys.WIDOWS, 2 ); insideGroup2.setLayout( BandStyleKeys.LAYOUT_BLOCK ); insideGroup2.setName( "group-inside" ); insideGroup2.addElement( createBand( "group-header-inside" ) ); insideGroup2.addElement( detailBody2 ); insideGroup2.addElement( createBand( "group-footer-inside" ) ); final Band outsideBody = new Band(); outsideBody.setLayout( BandStyleKeys.LAYOUT_BLOCK ); outsideBody.setName( "group-body-outside" ); outsideBody.addElement( insideGroup ); outsideBody.addElement( insideGroup2 ); final ReportHeader band = report.getReportHeader(); band.getStyle().setStyleProperty( ElementStyleKeys.AVOID_PAGEBREAK_INSIDE, false ); band.setLayout( BandStyleKeys.LAYOUT_BLOCK ); band.setName( "group-outside" ); band.getStyle().setStyleProperty( ElementStyleKeys.WIDOWS, 2 ); band.addElement( createBand( "group-header-outside" ) ); band.addElement( outsideBody ); band.addElement( createBand( "group-footer-outside" ) ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, band, false, false ); final RenderNode grOut = MatchFactory.findElementByName( logicalPageBox, "group-outside" ); assertTrue( grOut instanceof RenderBox ); final RenderBox grOutBox = (RenderBox) grOut; assertEquals( StrictGeomUtility.toInternalValue( 60 ), grOutBox.getWidowConstraintSize() ); final RenderNode grIn = MatchFactory.findElementByName( logicalPageBox, "group-inside" ); assertTrue( grIn instanceof RenderBox ); final RenderBox grInBox = (RenderBox) grIn; assertEquals( StrictGeomUtility.toInternalValue( 40 ), grInBox.getWidowConstraintSize() ); // ModelPrinter.INSTANCE.print(logicalPageBox); }
Example 20
Source File: TableIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testSimpleTable2() throws ReportProcessingException, ContentProcessingException { final Band tableCellA1 = TableTestUtil.createCell( TableTestUtil.createDataItem( "Cell A1" ) ); final Band tableCellA2 = TableTestUtil.createCell( TableTestUtil.createDataItem( "Cell A2" ) ); final Band tableCellB1 = TableTestUtil.createCell( TableTestUtil.createDataItem( "Cell B1" ) ); final Band tableCellB2 = TableTestUtil.createCell( TableTestUtil.createDataItem( "Cell B2" ) ); final Band tableCellC1 = TableTestUtil.createCell( TableTestUtil.createDataItem( "Cell C1" ) ); final Band tableCellC2 = TableTestUtil.createCell( TableTestUtil.createDataItem( "Cell C2" ) ); final Band tableRowA = TableTestUtil.createRow( tableCellA1, tableCellA2 ); final Band tableRowB = TableTestUtil.createRow( tableCellB1, tableCellB2 ); final Band tableRowC = TableTestUtil.createRow( tableCellC1, tableCellC2 ); final Band tableBody = new Band(); tableBody.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_BODY ); tableBody.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); tableBody.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 150f ); tableBody.addElement( tableRowA ); tableBody.addElement( tableRowB ); tableBody.addElement( tableRowC ); final Band table = new Band(); table.getStyle().setStyleProperty( BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE ); table.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, -100f ); table.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, 200f ); table.addElement( tableBody ); final MasterReport report = new MasterReport(); final ReportHeader band = report.getReportHeader(); band.addElement( table ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( report, band, false, false ); // ModelPrinter.print(logicalPageBox); final NodeMatcher matcher = new ChildMatcher( new ElementMatcher( "TableCellRenderBox" ) ); final RenderNode[] all = MatchFactory.matchAll( logicalPageBox, matcher ); final NodeMatcher childMatcher = new AndMatcher( new ElementMatcher( "ParagraphRenderBox" ), new AttributeMatcher( "value" ) ); assertEquals( 6, all.length ); for ( final RenderNode renderNode : all ) { final RenderNode node = MatchFactory.match( renderNode, childMatcher ); assertNotNull( node ); final String name = (String) node.getAttributes().getFirstAttribute( "value" ); assertNotNull( name ); if ( name.endsWith( "1" ) ) { assertEquals( 0l, renderNode.getX() ); } else { assertEquals( 23400000l, renderNode.getX() ); } assertEquals( 23400000l, renderNode.getWidth() ); if ( name.startsWith( "Cell A" ) ) { assertEquals( 0l, renderNode.getY() ); } else if ( name.startsWith( "Cell B" ) ) { assertEquals( 20000000l, renderNode.getY() ); } else if ( name.startsWith( "Cell C" ) ) { assertEquals( 40000000l, renderNode.getY() ); } assertEquals( 20000000l, renderNode.getHeight() ); } }