コード例 #1
0
  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);
  }