Java Code Examples for org.pentaho.reporting.engine.classic.core.MasterReport#setName()

The following examples show how to use org.pentaho.reporting.engine.classic.core.MasterReport#setName() . 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: PeopleReportDefinition.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public PeopleReportDefinition()
{
  report = new MasterReport();
  report.setName("People Report (API)");
  configurePeopleGroup();
  configureRecordGroup();

  // now the groups ... configured by an external class (as if it would be included)
  final ActivityReportDefinition activityDef = new ActivityReportDefinition(report);
  activityDef.configure();

  final LunchReportDefinition lunchDef = new LunchReportDefinition(report);
  lunchDef.configure();

  final OfficeReportDefinition officeDef = new OfficeReportDefinition(report);
  officeDef.configure();

  configurePageHeader();
  configurePageFooter();
  configureFunctions();
}
 
Example 2
Source File: AlignmentRightApiIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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 3
Source File: StackedLayoutAPIDemoHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates a report definition.
 *
 * @return a report definition.
 */
public MasterReport createReport() throws ReportDefinitionException
{

  final MasterReport report = new MasterReport();
  final ReportHeader reportHeader = report.getReportHeader();
  report.setName(getDemoName());

  final TextFieldElementFactory factory = new TextFieldElementFactory();
  factory.setName("T1");
  factory.setAbsolutePosition(new Point2D.Float(0, 0));
  factory.setMinimumSize(new FloatDimension(150, 12));
  factory.setColor(Color.black);
  factory.setHorizontalAlignment(ElementAlignment.RIGHT);
  factory.setVerticalAlignment(ElementAlignment.MIDDLE);
  factory.setNullString("-");
  factory.setFieldname(DemoReportController.MESSAGE_ONE_FIELDNAME);
  factory.setDynamicHeight(Boolean.TRUE);
  reportHeader.addElement(factory.createElement());

  factory.setName("T2");
  factory.setAbsolutePosition(new Point2D.Float(200, 0));
  factory.setHorizontalAlignment(ElementAlignment.LEFT);
  factory.setFieldname(DemoReportController.MESSAGE_TWO_FIELDNAME);
  reportHeader.addElement(factory.createElement());

  final DefaultParameterDefinition paramDef = new DefaultParameterDefinition();
  paramDef.addParameterDefinition(new PlainParameter("Message1", String.class));
  paramDef.addParameterDefinition(new PlainParameter("Message2", String.class));
  report.getParameterValues().put("Message1", inputPanel.getMessageOne());
  report.getParameterValues().put("Message2", inputPanel.getMessageTwo());
  return report;

}
 
Example 4
Source File: SurveyScaleAPIDemoHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 5
Source File: WizardProcessorUtil.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static MasterReport materialize( final MasterReport report,
                                        final WizardProcessor processor ) throws ReportProcessingException {
  final PerformanceMonitorContext performanceMonitorContext =
    ClassicEngineBoot.getInstance().getObjectFactory().get( PerformanceMonitorContext.class );
  try {
    final DefaultProcessingContext processingContext = new DefaultProcessingContext( report );
    final DataSchemaDefinition definition = report.getDataSchemaDefinition();
    final DefaultFlowController flowController = new DefaultFlowController( processingContext,
      definition, StateUtilities.computeParameterValueSet( report ), performanceMonitorContext );
    final CachingDataFactory dataFactory =
      new CachingDataFactory( report.getDataFactory(), isCacheEnabled( report ) );
    dataFactory.initialize( new ProcessingDataFactoryContext( processingContext, dataFactory ) );

    try {
      final DefaultFlowController postQueryFlowController = flowController.performDesignTimeQuery
        ( dataFactory, report.getQuery(), report.getQueryLimit(),
          report.getQueryTimeout(), flowController.getMasterRow().getResourceBundleFactory() );

      final Object originalEnable =
        report.getAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE );
      report.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE, Boolean.TRUE );
      final MasterReport masterReport = processor.performPreProcessing( report, postQueryFlowController );
      masterReport.setAttribute( AttributeNames.Wizard.NAMESPACE, AttributeNames.Wizard.ENABLE, originalEnable );

      masterReport.setName( null );
      DesignTimeUtil.resetDocumentMetaData( masterReport );
      return masterReport;
    } finally {
      dataFactory.close();
    }
  } finally {
    performanceMonitorContext.close();
  }
}
 
Example 6
Source File: PaddingIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private MasterReport createReport() {
  MasterReport report = new MasterReport();

  report.setName( "BorderTest" );

  Element label1 =
      LabelElementFactory.createLabelElement( "Label1", new Rectangle2D.Double( 0, 0, 200, 100 ), Color.RED,
          ElementAlignment.LEFT, new FontDefinition( "Arial", 12 ), "Label1" );

  report.getReportHeader().addElement( label1 );

  label1.getStyle().setStyleProperty( ElementStyleKeys.BACKGROUND_COLOR, new Color( 255, 127, 127, 120 ) );

  Element label2 =
      LabelElementFactory.createLabelElement( "Label2", new Rectangle2D.Double( 0, 110, 200, 100 ), Color.RED,
          ElementAlignment.LEFT, new FontDefinition( "Arial", 12 ), "Label2" );

  report.getReportHeader().addElement( label2 );

  label2.getStyle().setStyleProperty( ElementStyleKeys.BACKGROUND_COLOR, new Color( 255, 127, 127, 120 ) );
  label2.getStyle().setStyleProperty( ElementStyleKeys.PADDING_TOP, new Float( 10 ) );
  label2.getStyle().setStyleProperty( ElementStyleKeys.PADDING_LEFT, new Float( 10 ) );
  label2.getStyle().setStyleProperty( ElementStyleKeys.PADDING_RIGHT, new Float( 10 ) );
  label2.getStyle().setStyleProperty( ElementStyleKeys.PADDING_BOTTOM, new Float( 10 ) );

  Element label3 =
      LabelElementFactory.createLabelElement( "Label3", new Rectangle2D.Double( 210, 0, 200, 100 ), Color.RED,
          ElementAlignment.LEFT, new FontDefinition( "Arial", 12 ), "Label3" );

  report.getReportHeader().addElement( label3 );

  label3.getStyle().setStyleProperty( ElementStyleKeys.BACKGROUND_COLOR, new Color( 255, 127, 127, 120 ) );
  label3.getStyle().setStyleProperty( ElementStyleKeys.PADDING_TOP, new Float( 10 ) );
  label3.getStyle().setStyleProperty( ElementStyleKeys.PADDING_LEFT, new Float( 10 ) );
  label3.getStyle().setStyleProperty( ElementStyleKeys.PADDING_RIGHT, new Float( 10 ) );
  label3.getStyle().setStyleProperty( ElementStyleKeys.PADDING_BOTTOM, new Float( 10 ) );

  report.setDataFactory( new TableDataFactory( "default", new DefaultTableModel( 1, 1 ) ) );
  return report;
}
 
Example 7
Source File: SparklineAPIDemo.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Creates the report. For XML reports, this will most likely call the ReportGenerator, while API reports may use this
 * function to build and return a new, fully initialized report object.
 *
 * @return the fully initialized JFreeReport object.
 * @throws ReportDefinitionException if an error occured preventing the report definition.
 */
public MasterReport createReport() throws ReportDefinitionException
{
  final MasterReport report = new MasterReport();
  report.setName("Sparkline Demo");
  final DefaultParameterDefinition paramDef = new DefaultParameterDefinition();
  final PlainParameter plainParameter = new PlainParameter("sparkline-data", Number[].class);
  plainParameter.setDefaultValue(new Number[]
      {new Integer(10), new Integer(5),
          new Integer(6), new Integer(3),
          new Integer(1), new Integer(2),
          new Integer(7), new Integer(9)});
  paramDef.addParameterDefinition(plainParameter);

  report.setParameterDefinition(paramDef);

  // using the field sparkline-data
  final BarSparklineElementFactory elementFactory = new BarSparklineElementFactory();
  elementFactory.setFieldname("sparkline-data");
  elementFactory.setAbsolutePosition(new Point2D.Float(0, 0));
  elementFactory.setMinimumSize(new Dimension(100, 10));
  elementFactory.setColor(Color.black);
  elementFactory.setHighColor(Color.red);
  elementFactory.setLastColor(Color.blue);
  elementFactory.setBackgroundColor(Color.orange);

  final ReportFooter footer = report.getReportFooter();
  footer.addElement(elementFactory.createElement());

  // using a formula
  final BarSparklineElementFactory itemsSparkFactory = new BarSparklineElementFactory();
  itemsSparkFactory.setFormula
      ("={[January]|[February]|[March]|[April]|[May]|[June]|" +
          "[July]|[August]|[September]|[October]|[November]|[December]}");
  itemsSparkFactory.setAbsolutePosition(new Point2D.Float(0, 0));
  itemsSparkFactory.setMinimumSize(new Dimension(100, 10));
  itemsSparkFactory.setHighColor(Color.green);
  itemsSparkFactory.setLastColor(Color.blue);
  //itemsSparkFactory.setBackgroundColor(Color.yellow);
  final ItemBand itemBand = report.getItemBand();
  itemBand.addElement(itemsSparkFactory.createElement());

  itemBand.addElement(HorizontalLineElementFactory.createHorizontalLine
      (15, null, new BasicStroke(5)));

  report.setDataFactory(new TableDataFactory("default", data));
  return report;
}
 
Example 8
Source File: CountryReportAPIDemoHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * 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 9
Source File: BandInBandStackingDemoHandler.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Create a report with a single report header band. This band contains several sub bands.
 *
 * @return the created report.
 */
public MasterReport createReport()
{
  final Band levelA1 = createBand("A1", Color.magenta, 0, 0, 100, 100);
  levelA1.addElement(createBand("A1-B1", Color.blue, 0, 50, 50, 50));
  levelA1.addElement(createBand("A1-B2", Color.yellow, 50, 0, 150, 50));
  // x=55%, y=5%, width=40%, height=100%
  final Band levelA2 = createBand("A2", Color.green, -50, 0, -50, -100);
  // x=5%, y=55%, width=40%, height=40%
  levelA2.addElement(createBand("A2-B1", Color.red, 0, -50, -50, -50));
  // x=55%, y=5%, width=40%, height=40%
  levelA2.addElement(createBand("A2-B2", Color.darkGray, -55, -5, -40, -40));

  final ReportHeader header = new ReportHeader();
  header.setName("Report-Header");
  header.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, new Float(-100));
  header.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, new Float(100));
  header.getStyle().setStyleProperty(ElementStyleKeys.MAX_WIDTH, new Float(Short.MAX_VALUE));
  header.getStyle().setStyleProperty(ElementStyleKeys.MAX_HEIGHT, new Float(100));

  header.getStyle().setStyleProperty(ElementStyleKeys.BACKGROUND_COLOR, Color.ORANGE);

  header.addElement(levelA1);
  header.addElement(levelA2);

  final ContentFieldElementFactory cfef = new ContentFieldElementFactory();
  cfef.setFieldname("CreateComponent");
  cfef.setMinimumSize(new FloatDimension(400, 400));
  cfef.setAbsolutePosition(new Point2D.Float(0, 0));

  final ReportFooter footer = new ReportFooter();
  footer.addElement(cfef.createElement());

  final MasterReport report = new MasterReport();
  report.setReportHeader(header);
  report.setReportFooter(footer);
  report.setName("Band in Band stacking");

  report.addExpression(new ComplexComponentExpression("CreateComponent"));
  return report;
}
 
Example 10
Source File: BorderIT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void testFailure() throws Exception {
  final Object[] columnNames = new Object[] { "Customer", "City", "Number" };

  final DefaultTableModel reportTableModel =
      new DefaultTableModel( new Object[][] {
        { "Customer_ASDFSDFSDFSDFSaasdasdasdasweruzweurzwiezrwieuzriweuzriweu", "Bern", "123" },
        { "Hugo", "Z?rich", "2234" }, }, columnNames );

  final MasterReport report = new MasterReport();

  report.setName( "BorderTest" );

  report.getItemBand().addElement(
      LabelElementFactory.createLabelElement( "CustomerLabel", new Rectangle2D.Double( 0, 0, 200, 100 ), Color.RED,
          ElementAlignment.LEFT, new FontDefinition( "Arial", 12 ), "CustomerLabel" ) );

  final Element element =
      TextFieldElementFactory.createStringElement( "CustomerField", new Rectangle2D.Double( 110, 0, 250, 50 ),
          Color.black, ElementAlignment.LEFT, ElementAlignment.TOP, null, // font
          "-", // null string
          "Customer" );

  element.getStyle().setStyleProperty( ElementStyleKeys.BORDER_TOP_COLOR, Color.RED );
  element.getStyle().setStyleProperty( ElementStyleKeys.BORDER_TOP_WIDTH, new Float( 5 ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.BORDER_TOP_STYLE, BorderStyle.SOLID );

  element.getStyle().setStyleProperty( ElementStyleKeys.BORDER_LEFT_COLOR, Color.GREEN );
  element.getStyle().setStyleProperty( ElementStyleKeys.BORDER_LEFT_WIDTH, new Float( 5 ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.BORDER_LEFT_STYLE, BorderStyle.SOLID );

  element.getStyle().setStyleProperty( ElementStyleKeys.BORDER_RIGHT_COLOR, Color.YELLOW );
  element.getStyle().setStyleProperty( ElementStyleKeys.BORDER_RIGHT_WIDTH, new Float( 5 ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.BORDER_RIGHT_STYLE, BorderStyle.SOLID );

  element.getStyle().setStyleProperty( ElementStyleKeys.BORDER_BOTTOM_COLOR, Color.CYAN );
  element.getStyle().setStyleProperty( ElementStyleKeys.BORDER_BOTTOM_WIDTH, new Float( 5 ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.BORDER_BOTTOM_STYLE, BorderStyle.SOLID );
  element.getStyle().setStyleProperty( ElementStyleKeys.BACKGROUND_COLOR, new Color( 255, 127, 127, 120 ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.PADDING_LEFT, new Float( 5 ) );
  element.getStyle().setStyleProperty( ElementStyleKeys.PADDING_TOP, new Float( 5 ) );

  report.getItemBand().addElement( element );

  report.setDataFactory( new TableDataFactory( "default", reportTableModel ) );
  DebugReportRunner.executeAll( report );

}