Java Code Examples for org.pentaho.reporting.engine.classic.core.MasterReport#addGroup()
The following examples show how to use
org.pentaho.reporting.engine.classic.core.MasterReport#addGroup() .
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: SurveyScaleAPIDemoHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private void setupGroup(final MasterReport report) { final RelationalGroup group = new RelationalGroup(); group.setName("Category Group"); group.addField("Category"); final GroupHeader gh = group.getHeader(); gh.setRepeat(true); gh.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, new Float(26)); final TextFieldElementFactory factory1 = new TextFieldElementFactory(); factory1.setName("CategoryTextField"); factory1.setAbsolutePosition(new Point2D.Double(X1, 10.0)); factory1.setMinimumSize(new FloatDimension(C1_WIDTH + C2_WIDTH + C3_WIDTH, 16.0f)); factory1.setVerticalAlignment(ElementAlignment.TOP); factory1.setFieldname("Category"); factory1.setFontName("SansSerif"); factory1.setFontSize(new Integer(12)); factory1.setBold(Boolean.TRUE); factory1.setDynamicHeight(Boolean.TRUE); factory1.setTrimTextContent(Boolean.TRUE); gh.addElement(factory1.createElement()); factory1.setFieldname("Category Description"); factory1.setBold(Boolean.FALSE); factory1.setAbsolutePosition(new Point2D.Double(X1, 26)); factory1.setFontName("Serif"); factory1.setFontSize(new Integer(11)); gh.addElement(factory1.createElement()); report.addGroup(group); }
Example 2
Source File: AlignmentRightApiIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private void setupGroup( final MasterReport report ) { final RelationalGroup group = new RelationalGroup(); group.setName( "Category Group" ); group.addField( "Category" ); final GroupHeader gh = group.getHeader(); gh.setRepeat( true ); gh.getStyle().setStyleProperty( ElementStyleKeys.MIN_HEIGHT, new Float( 26 ) ); final TextFieldElementFactory factory1 = new TextFieldElementFactory(); factory1.setName( "CategoryTextField" ); factory1.setAbsolutePosition( new Point2D.Double( X1, 10.0 ) ); factory1.setMinimumSize( new FloatDimension( C1_WIDTH + C2_WIDTH + C3_WIDTH, 16.0f ) ); factory1.setVerticalAlignment( ElementAlignment.TOP ); factory1.setFieldname( "Category" ); factory1.setFontName( "SansSerif" ); factory1.setFontSize( new Integer( 12 ) ); factory1.setBold( Boolean.TRUE ); factory1.setDynamicHeight( Boolean.TRUE ); factory1.setTrimTextContent( Boolean.TRUE ); gh.addElement( factory1.createElement() ); factory1.setFieldname( "Category Description" ); factory1.setBold( Boolean.FALSE ); factory1.setAbsolutePosition( new Point2D.Double( X1, 26 ) ); factory1.setFontName( "Serif" ); factory1.setFontSize( new Integer( 11 ) ); gh.addElement( factory1.createElement() ); report.addGroup( group ); }
Example 3
Source File: CountryReportAPIDemoHandler.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
/** * Creates the report. * * @return the constructed report. */ public MasterReport createReport() { final MasterReport report = new MasterReport(); report.setName("Sample Report 1"); report.setReportFooter(createReportFooter()); report.setReportHeader(createReportHeader()); report.setPageFooter(createPageFooter()); report.setPageHeader(createPageHeader()); report.addGroup(createContinentGroup()); final GroupDataBody dataBody = (GroupDataBody) report.getChildElementByType(GroupDataBodyType.INSTANCE); dataBody.setItemBand(createItemBand()); report.setExpressions(createFunctions()); report.getReportConfiguration().setConfigProperty ("org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.Encoding", "Identity-H"); report.setDataFactory(new TableDataFactory ("default", data)); try { Watermark watermark = report.getWatermark(); watermark.setName("WaterMark"); final URL resource = getClass().getResource("earth.png"); final ContentElementFactory img1 = new ContentElementFactory(); img1.setContent(resource); img1.setMinimumSize(new FloatDimension(500, 500)); img1.setAbsolutePosition(new Point2D.Float(0, 0)); img1.setScale(Boolean.TRUE); watermark.addElement(img1.createElement()); } catch (Exception e) { e.printStackTrace(); } return report; }
Example 4
Source File: KeepTogetherIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testReport() 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", "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-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( createDataItem( "outer-header-field", 100, 20 ) ); group0.getFooter().addElement( createDataItem( "outer-footer-field", 100, 20 ) ); 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.AVOID_PAGEBREAK_INSIDE, Boolean.TRUE ); group1.getStyle().setStyleProperty( ElementStyleKeys.AVOID_PAGEBREAK_INSIDE, Boolean.TRUE ); // PdfReportUtil.createPDF(report, "/tmp/WidowTest.pdf"); List<LogicalPageBox> pages = DebugReportRunner.layoutPages( report, 0, 1, 2, 3, 4, 5, 6, 7 ); final LogicalPageBox page1 = pages.get( 0 ); assertElementExists( "outer-header-field", page1 ); assertElementExists( "inner-footer-field", page1 ); assertElementExists( "row-0", page1 ); assertElementExists( "inner-header-field", page1 ); final LogicalPageBox page2 = pages.get( 1 ); assertElementExists( "inner-header-field", page2 ); assertElementExists( "row-1", page2 ); assertElementExists( "inner-footer-field", page2 ); assertElementExists( "outer-footer-field", page2 ); assertElementExists( "outer-header-field", page2 ); final LogicalPageBox page3 = pages.get( 2 ); assertElementExists( "inner-header-field", page3 ); assertElementExists( "row-2", page3 ); assertElementExists( "inner-footer-field", page3 ); assertElementDoesNotExist( "row-3", page3 ); final LogicalPageBox page4 = pages.get( 3 ); assertElementExists( "inner-header-field", page4 ); assertElementExists( "row-5", page4 ); assertElementDoesNotExist( "row-6", page4 ); final LogicalPageBox page5 = pages.get( 4 ); assertElementExists( "inner-header-field", page5 ); assertElementExists( "row-6", page5 ); assertElementDoesNotExist( "row-7", page5 ); final LogicalPageBox page6 = pages.get( 5 ); assertElementExists( "inner-header-field", page6 ); assertElementExists( "row-7", page6 ); assertElementDoesNotExist( "row-8", page6 ); final LogicalPageBox page7 = pages.get( 6 ); assertElementExists( "inner-header-field", page7 ); assertElementExists( "row-8", page7 ); assertElementDoesNotExist( "row-9", page7 ); final LogicalPageBox page8 = pages.get( 7 ); assertElementExists( "inner-header-field", page8 ); assertElementExists( "row-9", page8 ); assertElementExists( "inner-footer-field", page8 ); assertElementExists( "outer-footer-field", page8 ); // BundleWriter.writeReportToZipFile(report, "/tmp/Prd-2087-Keep-Together-0.prpt"); }
Example 5
Source File: KeepTogetherIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testReport2() 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", "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-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( createDataItem( "outer-header-field", 100, 20 ) ); group0.getFooter().addElement( createDataItem( "outer-footer-field", 100, 20 ) ); 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.AVOID_PAGEBREAK_INSIDE, Boolean.TRUE ); group0.getStyle().setStyleProperty( ElementStyleKeys.AVOID_PAGEBREAK_INSIDE, Boolean.TRUE ); DebugReportRunner.createPDF( report ); // BundleWriter.writeReportToZipFile(report, "/tmp/Prd-2087-Keep-Together-1.prpt"); }
Example 6
Source File: OrphanIT.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( 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( createDataItem( "detail-field", 100, 20 ) ); report.getItemBand().getParentSection().getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 2 ); group1.getStyle().setStyleProperty( ElementStyleKeys.ORPHANS, 2 ); // BundleWriter.writeReportToZipFile(report, "/tmp/Prd-2087-Orphan-0.prpt"); DebugReportRunner.createPDF( report ); // PdfReportUtil.createPDF(report, "/tmp/OrphanTest.pdf"); }
Example 7
Source File: OrphanIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public void testInvalidReport() 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( "a", "1", "row-12" ); model.addRow( "b", "1", "row-13" ); model.addRow( "b", "2", "row-14" ); 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 ); // BundleWriter.writeReportToZipFile(report, "/tmp/Prd-2087-Orphan-1.prpt"); DebugReportRunner.createPDF( report ); // PdfReportUtil.createPDF(report, "/tmp/OrphanTest1.pdf"); // ModelPrinter.INSTANCE.print(DebugReportRunner.layoutPage(report, 1)); // ModelPrinter.INSTANCE.print(DebugReportRunner.layoutPage(report, 2)); }
Example 8
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)); }
Example 9
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"); }