KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > crosstabs > JRCrosstab


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28 package net.sf.jasperreports.crosstabs;
29
30 import net.sf.jasperreports.engine.JRElement;
31 import net.sf.jasperreports.engine.JRExpression;
32 import net.sf.jasperreports.engine.JRVariable;
33
34 /**
35  * Crosstab element interface.
36  *
37  * @author Lucian Chirita (lucianc@users.sourceforge.net)
38  * @version $Id: JRCrosstab.java 1229 2006-04-19 13:27:35 +0300 (Wed, 19 Apr 2006) teodord $
39  */

40 public interface JRCrosstab extends JRElement
41 {
42     /**
43      * The default offset used for column breaks.
44      * @see #getColumnBreakOffset()
45      */

46     public static final int DEFAULT_COLUMN_BREAK_OFFSET = 10;
47     
48     /**
49      * Name of the built-in row count variable.
50      */

51     public static final String JavaDoc VARIABLE_ROW_COUNT = "ROW_COUNT";
52     
53     /**
54      * Name of the built-in column count variable.
55      */

56     public static final String JavaDoc VARIABLE_COLUMN_COUNT = "COLUMN_COUNT";
57     
58     /**
59      * Returns the ID of the crosstab.
60      * <p>
61      * The ID is generated when the report is compiled and is used internally.
62      *
63      * @return the ID of the crosstab
64      */

65     public int getId();
66     
67     /**
68      * Returns the input dataset of the crosstab.
69      *
70      * @return the input dataset of the crosstab
71      */

72     public JRCrosstabDataset getDataset();
73     
74     /**
75      * Returns the row groups of the crosstab.
76      *
77      * @return the row groups
78      */

79     public JRCrosstabRowGroup[] getRowGroups();
80         
81     /**
82      * Returns the column groups of the crosstab.
83      *
84      * @return the column groups
85      */

86     public JRCrosstabColumnGroup[] getColumnGroups();
87     
88     /**
89      * Returns the crosstab measures.
90      *
91      * @return the crosstab measures
92      */

93     public JRCrosstabMeasure[] getMeasures();
94
95     /**
96      * Returns the column break offset.
97      * <p>
98      * When the crosstab columns do not fit the width, the crosstab
99      * breaks the columns and prints the ones that don't fit after printing
100      * the first set of columns for all rows. This method returns the offset
101      * to be used when continuing the printing after a column break.
102      *
103      * @return the column break offset
104      */

105     public int getColumnBreakOffset();
106     
107     /**
108      * Returns whether to repeat the column headers after a row break.
109      *
110      * @return whether to repeat the column headers after a row break
111      */

112     public boolean isRepeatColumnHeaders();
113     
114     /**
115      * Returns whether to repeat the row headers after a column break.
116      *
117      * @return whether to repeat the row headers after a column break
118      */

119     public boolean isRepeatRowHeaders();
120     
121     /**
122      * Returns the data cell matrix.
123      * <p>
124      * A crosstab can have multiple data cells for row/groups totals.
125      * These cells are organized in a (rowGroupCount + 1) x (columnGroupCount + 1)
126      * matrix as following:
127      * <ul>
128      * <li>the row index of a cell is
129      * <ul>
130      * <li>the row group index, if the cell corresponds to a total row</li>
131      * <li>rowGroupCount, otherwise</li>
132      * </ul>
133      * </li>
134      * <li>the column index of a cell is
135      * <ul>
136      * <li>the column group index, if the cell corresponds to a total column</li>
137      * <li>columnGroupCount, otherwise</li>
138      * </ul>
139      * </li>
140      * </ul>
141      * <p>
142      * E.g. if the crosstab has Country and City (subgroup of Country) row groups and Year and Month column
143      * groups, the cells will be organized in the following matrix
144      * <table border="1">
145      * <tr>
146      * <td></td>
147      * <td>0/Years total</td>
148      * <td>1/Months total</td>
149      * <td>2/Base</td>
150      * </tr>
151      * <tr>
152      * <td>0/Countries total</td>
153      * <td>Total for all countries and all years</td>
154      * <td>Total for all countries and a year</td>
155      * <td>Total for all countries and a month</td>
156      * </tr>
157      * <tr>
158      * <td>1/Cities total</td>
159      * <td>Total for a country and all years</td>
160      * <td>Total for a country and a year</td>
161      * <td>Total for a country and a month</td>
162      * </tr>
163      * <tr>
164      * <td>2/Base</td>
165      * <td>Total for a city and all years</td>
166      * <td>Total for a city and a year</td>
167      * <td>Total for a city and a month</td>
168      * </tr>
169      * </table>
170      * <p>
171      * If the data cell for a total row/column is not specified, the cell will be inherited
172      * from lower levels, if possible. For example, if the "Total for all countries and a year"
173      * cell is not specified, the "Total for a country and a year" or "Total for a city and a year"
174      * cell will be used (in this order).
175      * <p>
176      * The data cell sizes are calculated from the base data cell sizes, i.e.
177      * the height of all data cells for a row will be the height of the base cell
178      * of that row. The base cell sizes are also inherited, e.g. if the height of a total
179      * row is not specified the height of the base row will be used.
180      *
181      * @return the data cell matrix
182      */

183     public JRCrosstabCell[][] getCells();
184     
185     /**
186      * Returns the crosstab parameters.
187      * <p>
188      * Crosstabs have separate expression evaluators and cannot access
189      * the parameters/fields/variables of the report.
190      * In order to use a value from the report inside a crosstab, it should be
191      * passed as parameter to the crosstab.
192      * <p>
193      * A crosstab parameters has a name and a value expression.
194      *
195      * @return the crosstab parameters
196      */

197     public JRCrosstabParameter[] getParameters();
198     
199     /**
200      * Returns the parameters map expression.
201      * <p>
202      * The set of values for crosstab parameters can be set using a map.
203      * If a parameter has also a value expression, it will overwrite the value
204      * from the map.
205      *
206      * @return the parameters map expression
207      */

208     public JRExpression getParametersMapExpression();
209     
210     /**
211      * Returns a cell which will be rendered when no data was fed to the crosstab.
212      * <p>
213      * If this cell is not specified for a crosstab, nothing will be rendered for an
214      * empty crosstab.
215      * <p>
216      * The cell sizes are the same as the crosstab element sizes.
217      *
218      * @return a cell which will be rendered when no data was fed to the crosstab
219      */

220     public JRCellContents getWhenNoDataCell();
221
222
223     /**
224      * Searches for an element inside all crosstab cells.
225      *
226      * @param key the element key
227      * @return the first element having the specified key
228      */

229     public JRElement getElementByKey(String JavaDoc key);
230
231     
232     /**
233      * Returns a cell which will be rendered at the upper-left corner of the crosstab.
234      * <p/>
235      * The cell size will be calculated based on the row/column header cell widths/heights.
236      *
237      * @return a cell which will be rendered at the upper-left corner of the crosstab
238      */

239     public JRCellContents getHeaderCell();
240     
241     
242     /**
243      * Returns the variables defined for the crosstab.
244      *
245      * @return variables defined for the crosstab
246      * @see JRCrosstabGroup#getVariable()
247      * @see JRCrosstabMeasure#getVariable()
248      * @see #VARIABLE_ROW_COUNT
249      * @see #VARIABLE_COLUMN_COUNT
250      */

251     public JRVariable[] getVariables();
252 }
253
Popular Tags