예제 #1
0
 private ResourceManager locateResourceManager() {
   final ReportDefinition report = getMasterReport();
   if (report instanceof MasterReport) {
     MasterReport mr = (MasterReport) report;
     return mr.getResourceManager();
   }
   return new ResourceManager();
 }
  public void testAddToReport() {
    MasterReport report = new MasterReport();
    report.getItemBand().setName("ItemBand!");
    report.addGroup(new RelationalGroup());
    report.addGroup(createGroup("second", new String[] {"field"}));
    report.addGroup(createGroup("third", new String[] {"field", "field2"}));

    assertEquals(4, report.getGroupCount());
    assertEquals("ItemBand!", report.getItemBand().getName());
  }
 public void testFailure() throws Exception {
   final MasterReport report = new MasterReport();
   report.setDataFactory(new TableDataFactory("default", new DefaultTableModel(1, 1)));
   DebugReportRunner.executeAll(report);
 }
  public static void testBorder() throws IOException, ReportWriterException {
    Object[] columnNames = new Object[] {"Customer", "City", "Number"};

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

    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"));

    Element element =
        TextFieldElementFactory.createStringElement(
            "CustomerField",
            new Rectangle2D.Double(210, 0, 150, 30),
            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(1));
    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(1));
    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));
    element.getStyle().setStyleProperty(ElementStyleKeys.OVERFLOW_X, Boolean.TRUE);

    report.getItemBand().addElement(element);
    report.setQuery("default");
    report.setDataFactory(new TableDataFactory("default", reportTableModel));

    DebugReportRunner.execGraphics2D(report);
  }
  public void testRun() throws Exception {
    MasterReport report = new MasterReport();
    report.getRelationalGroup(0).getHeader().addElement(new SubReport());

    DebugReportRunner.executeAll(report);
  }