01: /*
02: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
07: *
08: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
09: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
10: * the license for the specific language governing your rights and limitations.
11: *
12: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
13: */
14: package org.pentaho.reportdesigner.crm.report.tests;
15:
16: import org.jfree.report.ElementAlignment;
17: import org.jfree.report.JFreeReport;
18: import org.jfree.report.JFreeReportBoot;
19: import org.jfree.report.ShapeElement;
20: import org.jfree.report.TableDataFactory;
21: import org.jfree.report.elementfactory.StaticShapeElementFactory;
22: import org.jfree.report.elementfactory.TextFieldElementFactory;
23: import org.jfree.report.function.ElementVisibilitySwitchFunction;
24: import org.jfree.report.modules.gui.base.PreviewFrame;
25: import org.jfree.report.style.FontDefinition;
26:
27: import javax.swing.table.DefaultTableModel;
28: import java.awt.*;
29: import java.awt.geom.Rectangle2D;
30:
31: /**
32: * User: Martin
33: * Date: 06.10.2005
34: * Time: 15:55:11
35: */
36: @SuppressWarnings({"ALL"})
37: public class RowBandingTest {
38: public static void main(String[] args) {
39: JFreeReport report = new JFreeReport();
40: report.setName("RowBandingTest");
41: report.getItemBand().addElement(
42: TextFieldElementFactory
43: .createStringElement("tf1",
44: new Rectangle2D.Double(20, 0, 100, 18),
45: Color.BLACK,
46: ElementAlignment.LEFT,
47: ElementAlignment.MIDDLE,//change to ElementAlignment.TOP
48: new FontDefinition("dialog", 12), "-",
49: "column"));
50:
51: ShapeElement shapeElement = StaticShapeElementFactory
52: .createRectangleShapeElement("rect", new Color(255, 0,
53: 0, 128), new BasicStroke(1),
54: new Rectangle2D.Double(0, 0, -100, -100),
55: false, true);
56:
57: ElementVisibilitySwitchFunction switchFunction = new ElementVisibilitySwitchFunction();
58: switchFunction.setElement("rect");
59: switchFunction.setInitialState(true);
60: switchFunction.setNumberOfElements(1);
61: report.getExpressions().add(switchFunction);
62:
63: report.getItemBand().addElement(shapeElement);
64:
65: report
66: .getReportConfiguration()
67: .setConfigProperty(
68: "org.jfree.report.layout.fontrenderer.UseMaxCharBounds",
69: Boolean.TRUE.toString());
70:
71: DefaultTableModel tm1 = new DefaultTableModel(new Object[][] {
72: { "1" }, { "2" }, { "3" }, { "4" }, { "5" }, { "6" },
73: { "7" }, { "8" }, { "9" } }, new Object[] { "column" });
74:
75: TableDataFactory dataFactory = new TableDataFactory("default",
76: tm1);
77: report.setDataFactory(dataFactory);
78:
79: JFreeReportBoot.getInstance().start();
80:
81: PreviewFrame preview = new PreviewFrame(report);
82: preview.pack();
83: preview.setVisible(true);
84: }
85: }
|