Java Code Examples for org.pentaho.reporting.engine.classic.core.MasterReport#setPageDefinition()
The following examples show how to use
org.pentaho.reporting.engine.classic.core.MasterReport#setPageDefinition() .
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: Pre448IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testBlockLayoutBox() throws Exception { final URL target = Pre448IT.class.getResource( "Pre-448.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.setPageDefinition( new SimplePageDefinition( new PageFormat() ) ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( basereport, (Band) report.getReportHeader().getElement( 3 ), 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 2
Source File: MinChunkWidthIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testMinChunkWidth() throws Exception { if ( DebugReportRunner.isSafeToTestComplexText() == false ) { return; } final MasterReport basereport = new MasterReport(); basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) ); basereport.setCompatibilityLevel( null ); basereport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY, "true" ); final URL target = LayoutIT.class.getResource( "min-chunkwidth.xml" ); final ResourceManager rm = new ResourceManager(); rm.registerDefaults(); final Resource directly = rm.createDirectly( target, MasterReport.class ); final MasterReport report = (MasterReport) directly.getResource(); report.getStyle().setStyleProperty( TextStyleKeys.WORDBREAK, true ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), true, false ); // simple test, we assert that all paragraph-poolboxes are on either 485 or 400 // and that only two lines exist for each ModelPrinter.INSTANCE.print( logicalPageBox ); new ValidateRunner( false, true ).startValidation( logicalPageBox ); }
Example 3
Source File: MinChunkWidthIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testMinChunkWidthLegacyMode() throws Exception { final MasterReport basereport = new MasterReport(); basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) ); basereport.setCompatibilityLevel( ClassicEngineBoot.computeVersionId( 3, 8, 0 ) ); basereport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY, "false" ); final URL target = LayoutIT.class.getResource( "min-chunkwidth.xml" ); final ResourceManager rm = new ResourceManager(); rm.registerDefaults(); final Resource directly = rm.createDirectly( target, MasterReport.class ); final MasterReport report = (MasterReport) directly.getResource(); // PRD-2736 note: word breaks are implemented now, // need to set WORDBREAK to false to keep the previous behaviour report.getStyle().setStyleProperty( TextStyleKeys.WORDBREAK, false ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), 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 ValidateRunner( true, false ).startValidation( logicalPageBox ); }
Example 4
Source File: ExpressionTestBase.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected MasterReport createCrosstabReport( final TableModel tableModel ) { Expression dummy = create( "dummy", null, null ); if ( dummy instanceof AggregationFunction == false ) { return null; } AggregationFunction function = (AggregationFunction) dummy; final MasterReport report = new MasterReport(); report.setPageDefinition( new SimplePageDefinition( PageSize.A3, PageFormat.LANDSCAPE, new Insets( 0, 0, 0, 0 ) ) ); report.setDataFactory( new TableDataFactory( "query", tableModel ) ); report.setQuery( "query" ); final ContextAwareDataSchemaModel dataSchemaModel = new DesignTimeDataSchemaModel( report ); final CrosstabBuilder builder = new CrosstabBuilder( dataSchemaModel ); builder.addRowDimension( ROW_DIMENSION_A ); builder.addRowDimension( ROW_DIMENSION_B ); builder.addColumnDimension( COLUMN_DIMENSION_A ); builder.addColumnDimension( COLUMN_DIMENSION_B ); builder.addDetails( VALUE, function.getClass() ); report.setRootGroup( builder.create() ); return report; }
Example 5
Source File: AlignmentRightApiIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates a report format by calling API methods directly. * * @return A report. */ public MasterReport createReport() { final MasterReport report = new MasterReport(); report.setName( "Survey Scale Demo Report" ); // use A4... final PageFormatFactory pff = PageFormatFactory.getInstance(); final Paper paper = pff.createPaper( PageSize.A4 ); pff.setBorders( paper, PAGE_MARGIN_TOP, PAGE_MARGIN_LEFT, PAGE_MARGIN_BOTTOM, PAGE_MARGIN_RIGHT ); final PageFormat format = pff.createPageFormat( paper, PageFormat.PORTRAIT ); report.setPageDefinition( new SimplePageDefinition( format ) ); setupWatermark( report ); setupPageHeader( report ); // // REPORT GROUP ///////////////////////////////////////////////////////////////////////// setupGroup( report ); // // ITEM BAND //////////////////////////////////////////////////////////////////////////// setupItemBand( report ); // // PAGE FOOTER ////////////////////////////////////////////////////////////////////////// setupPageFooter( report ); report.getParameterValues().put( "RESPONDENT_NAME", "Dave" ); report.setDataFactory( new TableDataFactory( "default", new SurveyScaleDemoTableModel() ) ); return report; }
Example 6
Source File: Pre434IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testCenterAlignment() throws Exception { final MasterReport report = new MasterReport(); // enforce letter-size pages; usable width = 468, usable height = 648 report.setPageDefinition( new SimplePageDefinition( new PageFormat() ) ); final LabelElementFactory labelFactory = new LabelElementFactory(); labelFactory.setText( "Free / Open Source Software Survey" ); labelFactory.setFontName( "SansSerif" ); labelFactory.setFontSize( new Integer( 18 ) ); labelFactory.setBold( Boolean.TRUE ); labelFactory.setAbsolutePosition( new Point2D.Double( 300, 10.0 ) ); labelFactory.setMinimumSize( new FloatDimension( 300, 24 ) ); labelFactory.setHorizontalAlignment( ElementAlignment.CENTER ); // watermark has a implicit rule that limits the height of the band to the size of the usable page-area. report.getReportHeader().addElement( labelFactory.createElement() ); validate( report ); }
Example 7
Source File: TotalPageFunctionsIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private MasterReport createRelationalReport( final TableModel tableModel, final Class aggFun ) { final MasterReport report = new MasterReport(); report.setPageDefinition( new SimplePageDefinition( new PageSize( 800, 300 ) ) ); report.setDataFactory( new TableDataFactory( "query", tableModel ) ); report.setQuery( "query" ); final DesignTimeDataSchemaModel dataSchemaModel = new DesignTimeDataSchemaModel( report ); final RelationalReportBuilder builder = new RelationalReportBuilder( dataSchemaModel ); builder.addGroup( ROW_DIMENSION_A ); builder.addGroup( ROW_DIMENSION_B ); builder.addDetails( VALUE, aggFun, VALUE_BACKGROUND ); builder.addDetails( "row-a-sum", null, ROWA_BACKGROUND ); builder.addDetails( "#row-a-sum", null, ROWA_VALIDATE_BACKGROUND ); builder.addDetails( "row-b-sum", null, ROWB_BACKGROUND ); builder.addDetails( "#row-b-sum", null, ROWB_VALIDATE_BACKGROUND ); builder.addDetails( "no-group", null, ROWC_BACKGROUND ); builder.addDetails( "#no-group", null, ROWC_VALIDATE_BACKGROUND ); report.setRootGroup( builder.create() ); return report; }
Example 8
Source File: Prd4069IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private MasterReport createTestReport() { final PerformanceTestSequence sequence = new PerformanceTestSequence(); sequence.setParameter( "seed", 999L ); sequence.setParameter( "limit", 20000 ); final SequenceDataFactory sdf = new SequenceDataFactory(); sdf.addSequence( "query", sequence ); // use HTML export for test final MasterReport report = new MasterReport(); report.setPageDefinition( new SimplePageDefinition( new PageSize( 800, 300 ) ) ); report.setDataFactory( sdf ); report.setQuery( "query" ); final DesignTimeDataSchemaModel dataSchemaModel = new DesignTimeDataSchemaModel( report ); final RelationalReportBuilder builder = new RelationalReportBuilder( dataSchemaModel ); builder.addDetails( "text", null, null ); report.setRootGroup( builder.create() ); return report; }
Example 9
Source File: HeightComputationIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void testNestedRowsComplex() throws Exception { final MasterReport basereport = new MasterReport(); basereport.setPageDefinition( new SimplePageDefinition( new PageFormat() ) ); basereport.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY, "true" ); final URL target = LayoutIT.class.getResource( "layout-matrix.xml" ); final ResourceManager rm = new ResourceManager(); rm.registerDefaults(); final Resource directly = rm.createDirectly( target, MasterReport.class ); final MasterReport report = (MasterReport) directly.getResource(); report.getStyle().setStyleProperty( TextStyleKeys.WORDBREAK, true ); final LogicalPageBox logicalPageBox = DebugReportRunner.layoutSingleBand( basereport, report.getReportHeader(), true, false ); // 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 10
Source File: ExpressionTestBase.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
protected MasterReport createRelationalReport( final TableModel tableModel, final String... additionalFields ) { final MasterReport report = new MasterReport(); report.setPageDefinition( new SimplePageDefinition( PageSize.A3, PageFormat.LANDSCAPE, new Insets( 0, 0, 0, 0 ) ) ); report.setDataFactory( new TableDataFactory( "query", tableModel ) ); report.setQuery( "query" ); final DesignTimeDataSchemaModel dataSchemaModel = new DesignTimeDataSchemaModel( report ); final RelationalReportBuilder builder = new RelationalReportBuilder( dataSchemaModel ); builder.addGroup( ROW_DIMENSION_A ); builder.addGroup( ROW_DIMENSION_B ); builder.addGroup( COLUMN_DIMENSION_A ); builder.addGroup( COLUMN_DIMENSION_B ); builder.addDetails( VALUE, null, Color.lightGray ); builder.addDetails( "relational", null, Color.yellow ); for ( int i = 0; i < additionalFields.length; i++ ) { String additionalField = additionalFields[i]; builder.addDetails( additionalField, null, null ); } report.setRootGroup( builder.create() ); return report; }
Example 11
Source File: SurveyScaleAPIDemoHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates a report format by calling API methods directly. * * @return A report. */ public MasterReport createReport() { final MasterReport report = new MasterReport(); report.setName("Survey Scale Demo Report"); // use A4... final PageFormatFactory pff = PageFormatFactory.getInstance(); final Paper paper = pff.createPaper(PageSize.A4); pff.setBorders(paper, PAGE_MARGIN_TOP, PAGE_MARGIN_LEFT, PAGE_MARGIN_BOTTOM, PAGE_MARGIN_RIGHT); final PageFormat format = pff.createPageFormat(paper, PageFormat.PORTRAIT); report.setPageDefinition(new SimplePageDefinition(format)); setupWatermark(report); setupPageHeader(report); //// REPORT GROUP ///////////////////////////////////////////////////////////////////////// setupGroup(report); //// ITEM BAND //////////////////////////////////////////////////////////////////////////// setupItemBand(report); //// PAGE FOOTER ////////////////////////////////////////////////////////////////////////// setupPageFooter(report); report.getParameterValues().put("RESPONDENT_NAME", "Dave"); report.setDataFactory(new TableDataFactory ("default", data)); return report; }
Example 12
Source File: TableCellSizingIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void testCellSize() throws Exception { final PageFormatFactory pff = PageFormatFactory.getInstance(); final Paper format = pff.createPaper( 200, 200 ); pff.setBorders( format, 0, 0, 0, 0 ); final SimplePageDefinition p = new SimplePageDefinition( pff.createPageFormat( format, PageFormat.PORTRAIT ) ); final MasterReport report = new MasterReport(); report.setPageDefinition( p ); final Band table = TableTestUtil.createTable( 2, 1, 1, new ElementCreator() ); table.setName( "table" ); report.getReportHeader().addElement( table ); final LogicalPageBox pageBox = DebugReportRunner.layoutPage( report, 0 ); final RenderNode[] elementsByNodeType = MatchFactory.findElementsByNodeType( pageBox, LayoutNodeTypes.TYPE_BOX_TABLE_CELL ); assertEquals( 4, elementsByNodeType.length ); for ( int i = 0; i < elementsByNodeType.length; i++ ) { final RenderNode renderNode = elementsByNodeType[i]; final RenderNode prev = renderNode.getPrev(); if ( prev != null ) { assertEquals( renderNode.getX(), prev.getX() + prev.getWidth() ); assertEquals( renderNode.getX(), renderNode.getMinimumChunkWidth() ); } assertEquals( renderNode.getWidth(), renderNode.getMinimumChunkWidth() ); } }
Example 13
Source File: Prd3425IT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public void testReverseLandscapeLoadSave() throws Exception { final PageFormatFactory pff = PageFormatFactory.getInstance(); final Paper format = pff.createPaper( PageSize.LETTER ); pff.setBorders( format, 10, 20, 30, 40 ); final MasterReport orgReport = new MasterReport(); orgReport .setPageDefinition( new SimplePageDefinition( pff.createPageFormat( format, PageFormat.REVERSE_LANDSCAPE ) ) ); final MasterReport savedReport = postProcess( orgReport ); assertEquals( orgReport.getPageDefinition(), savedReport.getPageDefinition() ); }
Example 14
Source File: WidowOrphanIT.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" ); detailBody.addElement( createBand( "ib1" ) ); detailBody.addElement( createBand( "ib2" ) ); detailBody.addElement( createBand( "ib3" ) ); 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.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" ) ); 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() ); 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.getOrphanConstraintSize() ); assertEquals( StrictGeomUtility.toInternalValue( 40 ), grInBox.getWidowConstraintSize() ); // ModelPrinter.INSTANCE.print(logicalPageBox); }
Example 15
Source File: WidowIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testReport() throws ReportProcessingException, IOException, ContentIOException, BundleWriterException { final TypedTableModel model = new TypedTableModel(); model.addColumn( "g0", String.class ); model.addColumn( "g1", String.class ); model.addColumn( "value", String.class ); model.addRow( "a", "1", "row-0" ); model.addRow( "a", "2", "row-1" ); model.addRow( "b", "1", "row-2" ); model.addRow( "b", "2", "row-3" ); model.addRow( "b", "2", "row-4" ); model.addRow( "b", "2", "row-5" ); model.addRow( "b", "3", "row-6" ); model.addRow( "a", "1", "row-7" ); model.addRow( "b", "1", "row-8" ); model.addRow( "b", "2", "row-9" ); final MasterReport report = new MasterReport(); report.setPageDefinition( new SimplePageDefinition( new PageSize( 500, 100 ) ) ); report.addGroup( new RelationalGroup() ); report.setDataFactory( new TableDataFactory( "query", model ) ); report.setQuery( "query" ); final RelationalGroup group0 = (RelationalGroup) report.getGroup( 0 ); group0.setName( "outer-group" ); group0.addField( "g0" ); group0.getHeader().addElement( TableTestUtil.createDataItem( "outer-header-field", 100, 20 ) ); group0.getFooter().addElement( TableTestUtil.createDataItem( "outer-footer-field", 100, 20 ) ); group0.getStyle().setStyleProperty( ElementStyleKeys.WIDOWS, 2 ); final RelationalGroup group1 = (RelationalGroup) report.getGroup( 1 ); group1.setName( "inner-group" ); group1.addField( "g1" ); group1.getHeader().addElement( TableTestUtil.createDataItem( "inner-header-field", 100, 20 ) ); group1.getFooter().addElement( TableTestUtil.createDataItem( "inner-footer-field", 100, 20 ) ); group1.getStyle().setStyleProperty( ElementStyleKeys.WIDOWS, 2 ); report.getItemBand().addElement( TableTestUtil.createDataItem( "detail-field", 100, 20 ) ); report.getItemBand().getParentSection().getStyle().setStyleProperty( ElementStyleKeys.WIDOWS, 2 ); // BundleWriter.writeReportToZipFile(report, "/tmp/Prd-2087-Widow-1.prpt"); // PdfReportUtil.createPDF(report, "/tmp/WidowTest.pdf"); }
Example 16
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 17
Source File: OrphanIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testInvalidSubReport2() throws Exception { final TypedTableModel model = new TypedTableModel(); model.addColumn( "g0", String.class ); model.addColumn( "g1", String.class ); model.addColumn( "value", String.class ); model.addRow( "a", "1", "row-0" ); model.addRow( "a", "1", "row-1" ); model.addRow( "a", "1", "row-2" ); model.addRow( "a", "2", "row-3" ); model.addRow( "b", "1", "row-4" ); model.addRow( "b", "2", "row-5" ); model.addRow( "b", "2", "row-6" ); model.addRow( "b", "2", "row-7" ); model.addRow( "b", "3", "row-8" ); model.addRow( "b", "3", "row-9" ); model.addRow( "b", "3", "row-10" ); model.addRow( "b", "3", "row-11" ); model.addRow( "b", "3", "row-12" ); model.addRow( "a", "1", "row-13" ); model.addRow( "b", "1", "row-14" ); model.addRow( "b", "2", "row-15" ); final SubReport report = new SubReport(); report.getStyle().setStyleProperty( ElementStyleKeys.MIN_WIDTH, 200f ); report.getStyle().setStyleProperty( ElementStyleKeys.POS_X, 100f ); report.getStyle().setStyleProperty( ElementStyleKeys.POS_Y, 20f ); report.addGroup( new RelationalGroup() ); report.setDataFactory( new TableDataFactory( "query", model ) ); report.setQuery( "query" ); final RelationalGroup group0 = (RelationalGroup) report.getGroup( 0 ); group0.setName( "outer-group" ); group0.addField( "g0" ); group0.getHeader().addElement( createDataItem( "outer-header-field", 100, 20 ) ); group0.getFooter().addElement( createDataItem( "outer-footer-field", 100, 20 ) ); group0.getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 2 ); final RelationalGroup group1 = (RelationalGroup) report.getGroup( 1 ); group1.setName( "inner-group" ); group1.addField( "g1" ); group1.getHeader().addElement( createDataItem( "inner-header-field", 100, 20 ) ); group1.getFooter().addElement( createDataItem( "inner-footer-field", 100, 20 ) ); report.getItemBand().addElement( createFieldItem( "detail-field", 100, 20 ) ); report.getItemBand().getParentSection().getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 200 ); group1.getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 2 ); final MasterReport master = new MasterReport(); master.setPageDefinition( new SimplePageDefinition( new PageSize( 500, 100 ) ) ); master.getReportHeader().addElement( report ); // BundleWriter.writeReportToZipFile(master, "/tmp/Prd-2087-Orphan-5.prpt"); // PdfReportUtil.createPDF(master, "/tmp/OrphanTest5.pdf"); DebugReportRunner.createPDF( master ); }
Example 18
Source File: PageSetupPlugin.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public boolean configure( final PreviewPane pane ) { final MasterReport report = pane.getReportJob(); if ( "true".equals( ClassicEngineBoot.getInstance().getGlobalConfig().getConfigProperty( "org.pentaho.reporting.engine.classic.core.modules.gui.print.UseAlternatePageSetupDialog" ) ) ) { final PageSetupDialog dialog; final Window proxy = getContext().getWindow(); if ( proxy instanceof Frame ) { dialog = new PageSetupDialog( getContext(), (Frame) proxy ); } else if ( proxy instanceof Dialog ) { dialog = new PageSetupDialog( getContext(), (Dialog) proxy ); } else { dialog = new PageSetupDialog( getContext() ); } dialog.pack(); LibSwingUtil.centerDialogInParent( dialog ); final PageDefinition definition = dialog.performSetup( report.getPageDefinition() ); if ( dialog.isConfirmed() == false ) { return false; } report.setPageDefinition( definition ); pane.setReportJob( report ); return true; } else { final PrinterJob pj = PrinterJob.getPrinterJob(); final PageFormat original = report.getPageDefinition().getPageFormat( 0 ); final PageFormat pf = pj.validatePage( pj.pageDialog( original ) ); if ( PageFormatFactory.isEqual( pf, original ) ) { return false; } final PageDefinition pageDefinition = report.getPageDefinition(); if ( pageDefinition instanceof SimplePageDefinition ) { final SimplePageDefinition spd = (SimplePageDefinition) pageDefinition; report.setPageDefinition( new SimplePageDefinition( pf, spd.getPageCountHorizontal(), spd .getPageCountVertical() ) ); } else { report.setPageDefinition( new SimplePageDefinition( pf ) ); } pane.setReportJob( report ); return true; } }
Example 19
Source File: OrphanIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testStandardLayoutKT() throws ReportProcessingException, ContentProcessingException { final MasterReport report = new MasterReport(); report.setPageDefinition( new SimplePageDefinition( new PageSize( 500, 100 ) ) ); final Band detailBody = new Band(); detailBody.getStyle().setStyleProperty( ElementStyleKeys.AVOID_PAGEBREAK_INSIDE, true ); 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.getStyle().setStyleProperty( ElementStyleKeys.AVOID_PAGEBREAK_INSIDE, true ); 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( 100 ), grOutBox.getOrphanConstraintSize() ); final RenderNode grIn = MatchFactory.findElementByName( logicalPageBox, "group-inside" ); assertTrue( grIn instanceof RenderBox ); final RenderBox grInBox = (RenderBox) grIn; assertEquals( StrictGeomUtility.toInternalValue( 80 ), grInBox.getOrphanConstraintSize() ); // ModelPrinter.INSTANCE.print(logicalPageBox); }
Example 20
Source File: OrphanIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testInvalidReport2() throws Exception { final TypedTableModel model = new TypedTableModel(); model.addColumn( "g0", String.class ); model.addColumn( "g1", String.class ); model.addColumn( "value", String.class ); model.addRow( "a", "1", "row-0" ); model.addRow( "a", "1", "row-1" ); model.addRow( "a", "1", "row-2" ); model.addRow( "a", "2", "row-3" ); model.addRow( "b", "1", "row-4" ); model.addRow( "b", "2", "row-5" ); model.addRow( "b", "2", "row-6" ); model.addRow( "b", "2", "row-7" ); model.addRow( "b", "3", "row-8" ); model.addRow( "b", "3", "row-9" ); model.addRow( "b", "3", "row-10" ); model.addRow( "b", "3", "row-11" ); model.addRow( "b", "3", "row-12" ); model.addRow( "a", "1", "row-13" ); model.addRow( "b", "1", "row-14" ); model.addRow( "b", "2", "row-15" ); final MasterReport report = new MasterReport(); report.setPageDefinition( new SimplePageDefinition( new PageSize( 500, 100 ) ) ); report.addGroup( new RelationalGroup() ); report.setDataFactory( new TableDataFactory( "query", model ) ); report.setQuery( "query" ); final RelationalGroup group0 = (RelationalGroup) report.getGroup( 0 ); group0.setName( "outer-group" ); group0.addField( "g0" ); group0.getHeader().addElement( createDataItem( "outer-header-field", 100, 20 ) ); group0.getFooter().addElement( createDataItem( "outer-footer-field", 100, 20 ) ); group0.getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 2 ); final RelationalGroup group1 = (RelationalGroup) report.getGroup( 1 ); group1.setName( "inner-group" ); group1.addField( "g1" ); group1.getHeader().addElement( createDataItem( "inner-header-field", 100, 20 ) ); group1.getFooter().addElement( createDataItem( "inner-footer-field", 100, 20 ) ); report.getItemBand().addElement( createFieldItem( "detail-field", 100, 20 ) ); report.getItemBand().getParentSection().getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 200 ); group1.getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 2 ); // PdfReportUtil.createPDF(report, "/tmp/OrphanTest2.pdf"); // BundleWriter.writeReportToZipFile(report, "/tmp/Prd-2087-Orphan-2.prpt"); DebugReportRunner.createPDF( report ); // ModelPrinter.INSTANCE.print(DebugReportRunner.layoutPage(report, 4)); // ModelPrinter.INSTANCE.print(DebugReportRunner.layoutPage(report, 5)); }