001 /** 002 * ======================================== 003 * JFreeReport : a free Java report library 004 * ======================================== 005 * 006 * Project Info: http://reporting.pentaho.org/ 007 * 008 * (C) Copyright 2000-2007, by Object Refinery Limited, Pentaho Corporation and Contributors. 009 * 010 * This library is free software; you can redistribute it and/or modify it under the terms 011 * of the GNU Lesser General Public License as published by the Free Software Foundation; 012 * either version 2.1 of the License, or (at your option) any later version. 013 * 014 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 015 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 016 * See the GNU Lesser General Public License for more details. 017 * 018 * You should have received a copy of the GNU Lesser General Public License along with this 019 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 020 * Boston, MA 02111-1307, USA. 021 * 022 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 023 * in the United States and other countries.] 024 * 025 * ------------ 026 * $Id: LayoutController.java 2725 2007-04-01 18:49:29Z taqua $ 027 * ------------ 028 * (C) Copyright 2000-2005, by Object Refinery Limited. 029 * (C) Copyright 2005-2007, by Pentaho Corporation. 030 */ 031 package org.jfree.report.flow.layoutprocessor; 032 033 import org.jfree.report.DataSourceException; 034 import org.jfree.report.ReportDataFactoryException; 035 import org.jfree.report.ReportProcessingException; 036 import org.jfree.report.flow.FlowController; 037 import org.jfree.report.flow.ReportTarget; 038 039 /** 040 * The layout controller iterates over the report layout. It uses a flow 041 * controller to query the data. 042 * 043 * @author Thomas Morgner 044 */ 045 public interface LayoutController extends Cloneable 046 { 047 /** 048 * Retrieves the parent of this layout controller. This allows childs to query 049 * their context. 050 * 051 * @return the layout controller's parent to <code>null</code> if there is no 052 * parent. 053 */ 054 public LayoutController getParent(); 055 056 /** 057 * Initializes the layout controller. This method is called exactly once. It 058 * is the creators responsibility to call this method. 059 * <p/> 060 * Calling initialize after the first advance must result in a 061 * IllegalStateException. 062 * 063 * @param node the currently processed object or layout node. 064 * @param flowController the current flow controller. 065 * @param parent the parent layout controller that was responsible for 066 * instantiating this controller. 067 * @throws DataSourceException if there was a problem reading data from 068 * the datasource. 069 * @throws ReportProcessingException if there was a general problem during 070 * the report processing. 071 * @throws ReportDataFactoryException if a query failed. 072 */ 073 public void initialize(final Object node, 074 final FlowController flowController, 075 final LayoutController parent) 076 throws DataSourceException, ReportDataFactoryException, 077 ReportProcessingException; 078 079 /** 080 * Advances the processing position. 081 * 082 * @param target the report target that receives generated events. 083 * @return the new layout controller instance representing the new state. 084 * 085 * @throws DataSourceException if there was a problem reading data from 086 * the datasource. 087 * @throws ReportProcessingException if there was a general problem during 088 * the report processing. 089 * @throws ReportDataFactoryException if a query failed. 090 */ 091 public LayoutController advance(ReportTarget target) 092 throws DataSourceException, ReportDataFactoryException, 093 ReportProcessingException; 094 095 /** 096 * Checks, whether the layout controller would be advanceable. If this method 097 * returns true, it is generally safe to call the 'advance()' method. 098 * 099 * @return true, if the layout controller is advanceable, false otherwise. 100 */ 101 public boolean isAdvanceable(); 102 103 /** 104 * Joins with a delegated process flow. This is generally called from a child 105 * flow and should *not* (I mean it!) be called from outside. If you do, 106 * you'll suffer. 107 * 108 * @param flowController the flow controller of the parent. 109 * @return the joined layout controller that incorperates all changes from 110 * the delegate. 111 */ 112 public LayoutController join(FlowController flowController) 113 throws DataSourceException, ReportDataFactoryException, 114 ReportProcessingException; 115 116 /** 117 * Creates a copy of this layout controller. 118 * 119 * @return a copy. 120 */ 121 public Object clone(); 122 123 /** 124 * Derives a copy of this controller that is suitable to perform a 125 * precomputation. The returned layout controller must be independent from 126 * the it's anchestor controller. 127 * 128 * @param fc a new flow controller for the precomputation. 129 * @return a copy that is suitable for precomputation. 130 */ 131 public LayoutController createPrecomputeInstance(FlowController fc); 132 133 public FlowController getFlowController(); 134 public Object getNode(); 135 }