1 28 package net.sf.jasperreports.engine.fill; 29 30 import java.util.HashMap ; 31 import java.util.Locale ; 32 import java.util.Map ; 33 import java.util.TimeZone ; 34 35 import net.sf.jasperreports.engine.JRException; 36 import net.sf.jasperreports.engine.JRPrintImage; 37 import net.sf.jasperreports.engine.JRPrintPage; 38 import net.sf.jasperreports.engine.query.JRQueryExecuter; 39 import net.sf.jasperreports.engine.util.FormatFactory; 40 41 50 public class JRFillContext 51 { 52 private Map loadedImages; 53 private boolean usingVirtualizer = false; 54 private boolean perPageBoundElements = false; 55 private JRPrintPage printPage = null; 56 private boolean ignorePagination = false; 57 private JRQueryExecuter queryExecuter; 58 59 private JRVirtualizationContext virtualizationContext; 60 61 private FormatFactory masterFormatFactory; 62 private Locale masterLocale; 63 private TimeZone masterTimeZone; 64 65 66 69 public JRFillContext() 70 { 71 loadedImages = new HashMap (); 72 } 73 74 75 83 public boolean hasLoadedImage(Object source) 84 { 85 return loadedImages.containsKey(source); 86 } 87 88 89 96 public JRPrintImage getLoadedImage(Object source) 97 { 98 return (JRPrintImage) loadedImages.get(source); 99 } 100 101 102 111 public void registerLoadedImage(Object source, JRPrintImage image) 112 { 113 loadedImages.put(source, image); 114 if (usingVirtualizer) 115 { 116 virtualizationContext.cacheRenderer(image); 117 } 118 } 119 120 121 127 public void setUsingVirtualizer(boolean usingVirtualizer) 128 { 129 this.usingVirtualizer = usingVirtualizer; 130 if (usingVirtualizer && virtualizationContext == null) 131 { 132 virtualizationContext = new JRVirtualizationContext(); 133 } 134 } 135 136 137 144 public boolean isUsingVirtualizer() 145 { 146 return usingVirtualizer; 147 } 148 149 150 157 public void setPerPageBoundElements(boolean perPageBoundElements) 158 { 159 this.perPageBoundElements = perPageBoundElements; 160 } 161 162 163 169 public boolean isPerPageBoundElements() 170 { 171 return perPageBoundElements; 172 } 173 174 175 181 public void setPrintPage(JRPrintPage page) 182 { 183 printPage = page; 184 } 185 186 187 193 public JRPrintPage getPrintPage() 194 { 195 return printPage; 196 } 197 198 199 205 public void setIgnorePagination(boolean ignorePagination) 206 { 207 this.ignorePagination = ignorePagination; 208 } 209 210 211 218 public boolean isIgnorePagination() 219 { 220 return ignorePagination; 221 } 222 223 224 231 public synchronized void setRunningQueryExecuter(JRQueryExecuter queryExecuter) 232 { 233 this.queryExecuter = queryExecuter; 234 } 235 236 237 243 public synchronized void clearRunningQueryExecuter() 244 { 245 this.queryExecuter = null; 246 } 247 248 249 255 public synchronized boolean cancelRunningQuery() throws JRException 256 { 257 if (queryExecuter != null) 258 { 259 return queryExecuter.cancelQuery(); 260 } 261 262 return false; 263 } 264 265 266 269 public void ensureMasterPageAvailable() 270 { 271 if (usingVirtualizer) 272 { 273 printPage.getElements(); 274 } 275 } 276 277 278 283 public JRVirtualizationContext getVirtualizationContext() 284 { 285 return virtualizationContext; 286 } 287 288 289 public FormatFactory getMasterFormatFactory() 290 { 291 return masterFormatFactory; 292 } 293 294 295 public void setMasterFormatFactory(FormatFactory masterFormatFactory) 296 { 297 this.masterFormatFactory = masterFormatFactory; 298 } 299 300 301 public Locale getMasterLocale() 302 { 303 return masterLocale; 304 } 305 306 307 public void setMasterLocale(Locale masterLocale) 308 { 309 this.masterLocale = masterLocale; 310 } 311 312 313 public TimeZone getMasterTimeZone() 314 { 315 return masterTimeZone; 316 } 317 318 319 public void setMasterTimeZone(TimeZone masterTimeZone) 320 { 321 this.masterTimeZone = masterTimeZone; 322 } 323 } 324 | Popular Tags |