001: /*
002: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007: *
008: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
010: * the license for the specific language governing your rights and limitations.
011: *
012: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013: */
014: package org.pentaho.reportdesigner.crm.report.tests;
015:
016: import org.jetbrains.annotations.NonNls;
017: import org.jetbrains.annotations.NotNull;
018: import org.jfree.report.Band;
019: import org.jfree.report.ElementAlignment;
020: import org.jfree.report.ImageElement;
021: import org.jfree.report.JFreeReport;
022: import org.jfree.report.TableDataFactory;
023: import org.jfree.report.TextElement;
024: import org.jfree.report.elementfactory.ImageFieldElementFactory;
025: import org.jfree.report.elementfactory.TextFieldElementFactory;
026: import org.jfree.report.layout.StaticLayoutManager;
027: import org.jfree.report.modules.gui.base.PreviewFrame;
028: import org.pentaho.reportdesigner.crm.report.ReportDialogConstants;
029:
030: import javax.swing.table.AbstractTableModel;
031: import java.awt.*;
032: import java.awt.geom.Point2D;
033: import java.awt.geom.Rectangle2D;
034:
035: /**
036: * User: Martin
037: * Date: 06.10.2005
038: * Time: 15:54:54
039: */
040: @SuppressWarnings({"ALL"})
041: public class BugTest {
042: public static void main(@NotNull
043: String[] args) {
044: ReportTableModel reportTableModel = new ReportTableModel();
045:
046: JFreeReport report = new JFreeReport();
047:
048: report.setName("A Very Simple Report");
049:
050: ImageElement imageDataRowElement = ImageFieldElementFactory
051: .createImageDataRowElement("I1",
052: new Rectangle2D.Double(0.0, 0.0, 80, 80),
053: "mediumImage", true, true);
054: imageDataRowElement.setDynamicContent(false);
055:
056: report.getItemBand().addElement(imageDataRowElement);
057:
058: TextElement t2 = TextFieldElementFactory.createStringElement(
059: "T2", new Rectangle2D.Double(0, 0.0, -100, 30.0),
060: Color.black, ElementAlignment.LEFT,
061: ElementAlignment.TOP, null, // font
062: "-", // null string
063: "title");
064: t2.setFontSize(30);
065: t2.setDynamicContent(true);
066:
067: TextElement t3 = TextFieldElementFactory.createStringElement(
068: "T3", new Rectangle2D.Double(0, 0, -100, 50),
069: Color.black, ElementAlignment.LEFT,
070: ElementAlignment.TOP, null, // font
071: "-", // null string
072: "creators");
073: t3.setDynamicContent(true);
074: report.getItemBand().setDynamicContent(true);
075:
076: Band band = new Band();
077: //TODO fix 0.8.9
078: //band.setLayout(new StackedLayoutManager());
079: band.addElement(t2);
080: band.addElement(t3);
081: band.setDynamicContent(true);
082:
083: band.getStyle().setStyleProperty(
084: StaticLayoutManager.ABSOLUTE_POS,
085: new Point2D.Double(90, 0));
086:
087: report.getItemBand().addElement(band);
088:
089: report.setDataFactory(new TableDataFactory(
090: ReportDialogConstants.DEFAULT_DATA_FACTORY,
091: reportTableModel));
092:
093: PreviewFrame preview = new PreviewFrame(report);
094: preview.pack();
095: preview.setVisible(true);
096: }
097:
098: @NonNls
099: private static class ReportTableModel extends AbstractTableModel {
100: public ReportTableModel() {
101: }
102:
103: public int getRowCount() {
104: return 2;
105: }
106:
107: public int getColumnCount() {
108: return 4;
109: }
110:
111: public String getColumnName(int columnIndex) {
112: switch (columnIndex) {
113: case 0:
114: return "itemId";
115: case 1:
116: return "mediumImage";
117: case 2:
118: return "title";
119: case 3:
120: return "creators";
121: }
122:
123: return null;
124: }
125:
126: public Class<?> getColumnClass(int columnIndex) {
127:
128: return String.class;
129: }
130:
131: public Object getValueAt(int rowIndex, int columnIndex) {
132: switch (columnIndex) {
133: case 0:
134: return "a";
135: case 1:
136: return "b";
137: case 2:
138: return "Bend It Like Beckham UK IMPORT";
139: case 3:
140: return "test";
141: }
142:
143: return null;
144: }
145: }
146: }
|