1:
31:
32: package ;
33:
34: import ;
35: import ;
36: import ;
37: import ;
38:
39: import ;
40: import ;
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50:
51:
68: public class JFreeReport extends ReportDefinition
69: implements ReportStructureRoot
70: {
71:
74: private ModifiableConfiguration reportConfiguration;
75:
76: private ArrayList styleSheets;
77: private StyleSheet pageFormatStyleSheet;
78: private CSSPageRule pageRule;
79:
80: private ReportParameters parameters;
81:
82: private ReportDataFactory dataFactory;
83:
84: private ResourceManager resourceManager;
85: private ResourceKey baseResource;
86:
87:
90: public JFreeReport()
91: {
92: setType("report");
93: this.reportConfiguration = new HierarchicalConfiguration
94: (JFreeReportBoot.getInstance().getGlobalConfig());
95:
96: this.styleSheets = new ArrayList();
97: this.parameters = new ReportParameters();
98: this.dataFactory = new EmptyReportDataFactory();
99:
100: this.pageFormatStyleSheet = new StyleSheet();
101: this.pageRule = new CSSPageRule(pageFormatStyleSheet, null, null, null);
102: this.pageFormatStyleSheet.addRule(pageRule);
103:
104: setQuery("default");
105: }
106:
107:
115: public Configuration getConfiguration()
116: {
117: return reportConfiguration;
118: }
119:
120: public void addStyleSheet(final StyleSheet s)
121: {
122: if (s == null)
123: {
124: throw new NullPointerException();
125: }
126: styleSheets.add(s);
127: }
128:
129: public void removeStyleSheet(final StyleSheet s)
130: {
131: styleSheets.remove(s);
132: }
133:
134: public StyleSheet getStyleSheet(final int i)
135: {
136: if (i == 0)
137: {
138: return pageFormatStyleSheet;
139: }
140: return (StyleSheet) styleSheets.get(i - 1);
141: }
142:
143: public int getStyleSheetCount()
144: {
145: return styleSheets.size() + 1;
146: }
147:
148: public JFreeReport getRootReport()
149: {
150: return this;
151: }
152:
153: public ReportParameters getInputParameters()
154: {
155: return parameters;
156: }
157:
158: public ReportDataFactory getDataFactory()
159: {
160: return dataFactory;
161: }
162:
163: public void setDataFactory(final ReportDataFactory dataFactory)
164: {
165: if (dataFactory == null)
166: {
167: throw new NullPointerException();
168: }
169:
170: this.dataFactory = dataFactory;
171: }
172:
173: public ResourceManager getResourceManager()
174: {
175: if (resourceManager == null)
176: {
177: resourceManager = new ResourceManager();
178: resourceManager.registerDefaults();
179: }
180: return resourceManager;
181: }
182:
183: public void setResourceManager(final ResourceManager resourceManager)
184: {
185: this.resourceManager = resourceManager;
186: }
187:
188: public ResourceKey getBaseResource()
189: {
190: return baseResource;
191: }
192:
193: public void setBaseResource(final ResourceKey baseResource)
194: {
195: this.baseResource = baseResource;
196: }
197:
198: public void setPageFormat(final PageFormat format)
199: {
200: pageRule.clear();
201: StyleSheetUtility.updateRuleForPage(pageRule, format);
202: }
203:
204: public PageFormat getPageFormat()
205: {
206: return StyleSheetUtility.getPageFormat(pageRule);
207: }
208:
209: public ModifiableConfiguration getEditableConfiguration()
210: {
211: return reportConfiguration;
212: }
213:
214: public Locale getLocale()
215: {
216: final Locale locale = super.getLocale();
217: if (locale == null)
218: {
219: return Locale.getDefault();
220: }
221: return locale;
222: }
223:
224:
225:
242: public Object clone()
243: throws CloneNotSupportedException
244: {
245: final JFreeReport report = (JFreeReport) super.clone();
246: report.dataFactory = dataFactory.derive();
247: report.parameters = (ReportParameters) parameters.clone();
248: report.pageRule = (CSSPageRule) pageRule.clone();
249: report.styleSheets = (ArrayList) styleSheets.clone();
250: report.pageFormatStyleSheet = pageFormatStyleSheet;
251: return report;
252: }
253: }