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.jetbrains.annotations.NotNull;
17: import org.jfree.report.ElementAlignment;
18: import org.jfree.report.JFreeReport;
19: import org.jfree.report.JFreeReportBoot;
20: import org.jfree.report.TableDataFactory;
21: import org.jfree.report.TextElement;
22: import org.jfree.report.elementfactory.TextFieldElementFactory;
23: import org.jfree.report.function.strings.ToLowerCaseStringExpression;
24: import org.jfree.report.modules.gui.base.PreviewFrame;
25: import org.jfree.report.style.FontDefinition;
26: import org.pentaho.reportdesigner.crm.report.ReportDialogConstants;
27:
28: import javax.swing.table.DefaultTableModel;
29: import java.awt.*;
30: import java.awt.geom.Rectangle2D;
31:
32: /**
33: * User: Martin
34: * Date: 08.03.2006
35: * Time: 21:25:16
36: */
37: @SuppressWarnings({"ALL"})
38: public class LowerCaseTest {
39: public static void main(@NotNull
40: String[] args) {
41: Object[] columnNames = new Object[] { "ALIASES.NAME" };
42: DefaultTableModel reportTableModel = new DefaultTableModel(
43: new Object[][] { { "UPPERCASESTRING" },
44: { "MixedCaseString" }, { "lowercasestring" } },
45: columnNames);
46:
47: JFreeReport report = new JFreeReport();
48:
49: TextElement t2 = TextFieldElementFactory.createStringElement(
50: "ANAME", new Rectangle2D.Double(0, 0, -50, 10),
51: Color.black, ElementAlignment.LEFT,
52: ElementAlignment.TOP, new FontDefinition(new Font(
53: "Arial", Font.PLAIN, 8)), // font
54: "-", // null string
55: "toLowerCase");
56:
57: report.getItemBand().addElement(t2);
58:
59: ToLowerCaseStringExpression function = new ToLowerCaseStringExpression();
60: function.setField("ALIASES.NAME");
61: function.setName("toLowerCase");
62:
63: report.getExpressions().add(function);
64:
65: report.setDataFactory(new TableDataFactory(
66: ReportDialogConstants.DEFAULT_DATA_FACTORY,
67: reportTableModel));
68:
69: JFreeReportBoot.getInstance().start();
70:
71: PreviewFrame preview = new PreviewFrame(report);
72: preview.pack();
73: preview.setVisible(true);
74: }
75: }
|