Coverage Report - ar.com.fdvs.dj.domain.DynamicReportOptions
 
Classes in this File Line Coverage Branch Coverage Complexity
DynamicReportOptions
78%
101/128
12%
1/8
1.071
 
 1  
 /*
 2  
  * DynamicJasper: A library for creating reports dynamically by specifying
 3  
  * columns, groups, styles, etc. at runtime. It also saves a lot of development
 4  
  * time in many cases! (http://sourceforge.net/projects/dynamicjasper)
 5  
  *
 6  
  * Copyright (C) 2008  FDV Solutions (http://www.fdvsolutions.com)
 7  
  *
 8  
  * This library is free software; you can redistribute it and/or
 9  
  * modify it under the terms of the GNU Lesser General Public
 10  
  *
 11  
  * License as published by the Free Software Foundation; either
 12  
  *
 13  
  * version 2.1 of the License, or (at your option) any later version.
 14  
  *
 15  
  * This library is distributed in the hope that it will be useful,
 16  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17  
  *
 18  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 19  
  *
 20  
  * Lesser General Public License for more details.
 21  
  *
 22  
  * You should have received a copy of the GNU Lesser General Public
 23  
  * License along with this library; if not, write to the Free Software
 24  
  *
 25  
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 26  
  *
 27  
  *
 28  
  */
 29  
 
 30  
 package ar.com.fdvs.dj.domain;
 31  
 
 32  
 import java.awt.Color;
 33  
 import java.util.HashMap;
 34  
 
 35  
 import ar.com.fdvs.dj.domain.builders.StyleBuilder;
 36  
 import ar.com.fdvs.dj.domain.constants.Page;
 37  
 import ar.com.fdvs.dj.domain.entities.Entity;
 38  
 
 39  
 /**
 40  
  * Class that defines the report configuration.
 41  
  */
 42  165
 public class DynamicReportOptions extends DJBaseElement {
 43  
 
 44  
         private static final long serialVersionUID = Entity.SERIAL_VERSION_UID;
 45  
         
 46  1
         public static final Integer DEFAULT_HEADER_HEIGHT                         = new Integer(30);
 47  1
         public static final Integer DEFAULT_HEADER_VARIABLES_HEIGHT        = new Integer(20);
 48  1
         public static final Integer DEFAULT_FOOTER_VARIABLES_HEIGHT        = new Integer(20);
 49  1
         public static final Integer DEFAULT_DETAIL_HEIGHT                         = new Integer(15);
 50  
         
 51  1
         public static final Integer DEFAULT_MARGIN_TOP                 = new Integer(20);
 52  1
         public static final Integer DEFAULT_MARGIN_BOTTOM         = new Integer(10);
 53  1
         public static final Integer DEFAULT_MARGIN_LEFT         = new Integer(30);
 54  1
         public static final Integer DEFAULT_MARGIN_RIGTH         = new Integer(10);
 55  
         
 56  165
         private Integer headerHeight                         = DEFAULT_HEADER_HEIGHT;
 57  165
         private Integer headerVariablesHeight         = DEFAULT_HEADER_HEIGHT;
 58  165
         private Integer footerVariablesHeight         = DEFAULT_FOOTER_VARIABLES_HEIGHT;
 59  165
         private Integer detailHeight                         = DEFAULT_DETAIL_HEIGHT;
 60  
 
 61  165
         private Integer leftMargin                 = DEFAULT_MARGIN_LEFT;
 62  165
         private Integer rightMargin         = DEFAULT_MARGIN_RIGTH;
 63  165
         private Integer topMargin                 = DEFAULT_MARGIN_TOP;
 64  165
         private Integer bottomMargin        = DEFAULT_MARGIN_BOTTOM;
 65  
 
 66  165
         private Integer columnsPerPage = new Integer(1);
 67  165
         private Integer columnSpace = new Integer(0);
 68  
 
 69  165
         private boolean useFullPageWidth = false;
 70  
 
 71  165
         private Page page = Page.Page_A4_Portrait();
 72  
 
 73  165
         private boolean printBackgroundOnOddRows = false;
 74  165
         private Style oddRowBackgroundStyle = new StyleBuilder(false,"defaultOddRowStyle")
 75  
                                                                                                 .setBackgroundColor(new Color(200,200,200))
 76  
                                                                                                 .build();
 77  165
         private Integer titleHeight =  DEFAULT_HEADER_HEIGHT;
 78  165
         private boolean titleNewPage =  false;
 79  165
         private boolean summaryNewPage =  false;
 80  165
         private Integer subtitleHeight = DEFAULT_DETAIL_HEIGHT;
 81  165
         private boolean showDetailBand = true;
 82  
 
 83  
         /**
 84  
          * When false, no main column names (usefull for excel)
 85  
          */
 86  165
         private boolean printColumnNames =  true;
 87  
 
 88  
         /**
 89  
          * When true, no page break at all
 90  
          */
 91  165
         private boolean ignorePagination =  false;
 92  
 
 93  165
         private Style defaultHeaderStyle = new Style("defaultHeaderStyle");
 94  165
         private Style defaultDetailStyle = new Style("defaultDetailStyle");
 95  165
         private Style defaultFooterStyle = new Style("defaultFooterStyle");
 96  165
         private Style defaultGroupHeaderStyle = new Style("defaultGroupHeaderStyle");
 97  165
         private Style defaultGroupFooterStyle = new Style("defaultGroupFooterStyle");
 98  
 
 99  
         /**
 100  
          * Key: Byte (ImageBanner.ALIGN_RIGHT, ImageBanner.ALIGN_LEFT, ImageBanner.ALIGN_CENTER)<br/>
 101  
          * value: ImageBanner
 102  
          */
 103  165
         private HashMap imageBanners = new HashMap();
 104  
 
 105  
         /**
 106  
          * Key: Byte (ImageBanner.ALIGN_RIGHT, ImageBanner.ALIGN_LEFT, ImageBanner.ALIGN_CENTER)<br/>
 107  
          * value: ImageBanner
 108  
          */
 109  165
         private HashMap firstPageImageBanners = new HashMap();
 110  
 
 111  
         public HashMap getImageBanners() {
 112  126
                 return imageBanners;
 113  
         }
 114  
 
 115  
         public Integer getFooterVariablesHeight() {
 116  0
                 return footerVariablesHeight;
 117  
         }
 118  
 
 119  
         public void setFooterVariablesHeight(Integer footerHeight) {
 120  0
                 if (footerHeight == null)
 121  0
                         footerHeight = DEFAULT_FOOTER_VARIABLES_HEIGHT;
 122  0
                 this.footerVariablesHeight = footerHeight;
 123  0
         }
 124  
 
 125  
         public Integer getHeaderHeight() {
 126  99
                 return headerHeight;
 127  
         }
 128  
 
 129  
         public void setHeaderHeight(Integer headerHeight) {
 130  0
                 if (headerHeight ==  null)
 131  0
                         headerHeight = DEFAULT_HEADER_HEIGHT;
 132  0
                 this.headerHeight = headerHeight;
 133  0
         }
 134  
 
 135  
         public Integer getDetailHeight() {
 136  912
                 return detailHeight;
 137  
         }
 138  
 
 139  
         public void setDetailHeight(Integer detailHeight) {
 140  29
                 if (detailHeight == null)
 141  0
                         detailHeight = DEFAULT_DETAIL_HEIGHT;
 142  29
                 this.detailHeight = detailHeight;
 143  29
         }
 144  
 
 145  
         public Integer getLeftMargin() {
 146  385
                 return leftMargin;
 147  
         }
 148  
 
 149  
         public void setLeftMargin(Integer leftMargin) {
 150  83
                 this.leftMargin = leftMargin;
 151  83
         }
 152  
 
 153  
         public boolean isUseFullPageWidth() {
 154  116
                 return useFullPageWidth;
 155  
         }
 156  
 
 157  
         public void setUseFullPageWidth(boolean useFullPageWidth) {
 158  171
                 this.useFullPageWidth = useFullPageWidth;
 159  171
         }
 160  
 
 161  
         public Integer getBottomMargin() {
 162  108
                 return bottomMargin;
 163  
         }
 164  
 
 165  
         public void setBottomMargin(Integer bottomMargin) {
 166  58
                 this.bottomMargin = bottomMargin;
 167  58
         }
 168  
 
 169  
         public Integer getRightMargin() {
 170  364
                 return rightMargin;
 171  
         }
 172  
 
 173  
         public void setRightMargin(Integer rightMargin) {
 174  79
                 this.rightMargin = rightMargin;
 175  79
         }
 176  
 
 177  
         public Integer getTopMargin() {
 178  108
                 return topMargin;
 179  
         }
 180  
 
 181  
         public void setTopMargin(Integer topMargin) {
 182  58
                 this.topMargin = topMargin;
 183  58
         }
 184  
 
 185  
         public Integer getColumnsPerPage() {
 186  566
                 return columnsPerPage;
 187  
         }
 188  
 
 189  
         public void setColumnsPerPage(Integer columnsPerPage) {
 190  24
                 this.columnsPerPage = columnsPerPage;
 191  24
         }
 192  
 
 193  
         public Integer getColumnSpace() {
 194  333
                 return columnSpace;
 195  
         }
 196  
 
 197  
         public void setColumnSpace(Integer columnSpace) {
 198  20
                 this.columnSpace = columnSpace;
 199  20
         }
 200  
 
 201  
         public Page getPage() {
 202  160
                 return page;
 203  
         }
 204  
 
 205  
         public void setPage(Page page) {
 206  38
                 this.page = page;
 207  38
         }
 208  
 
 209  
         /**
 210  
          * Gives the printableWidth between the page margins. </br>
 211  
          * pageTotalWidth - leftMargin - rightMargin
 212  
          * @return int
 213  
          */
 214  
         public int getPrintableWidth(){
 215  255
                 return page.getWidth() - leftMargin.intValue() - rightMargin.intValue();
 216  
         }
 217  
 
 218  
         /**
 219  
          * Gives the printableWidth between the page margins that also considers the </br>
 220  
          * number of columns per page and the space between them.</br>
 221  
          * @return int
 222  
          */
 223  
         public int getColumnWidth(){
 224  225
                 int usableWidth = page.getWidth()-getLeftMargin().intValue()-getRightMargin().intValue()-((getColumnsPerPage().intValue()-1)*getColumnSpace().intValue());
 225  225
                 return usableWidth / getColumnsPerPage().intValue();
 226  
         }
 227  
 
 228  
         public Style getOddRowBackgroundStyle() {
 229  133
                 return oddRowBackgroundStyle;
 230  
         }
 231  
 
 232  
         public void setOddRowBackgroundStyle(Style oddRowBackgroundStyle) {
 233  18
                 this.oddRowBackgroundStyle = oddRowBackgroundStyle;
 234  18
         }
 235  
 
 236  
         public boolean isPrintBackgroundOnOddRows() {
 237  556
                 return printBackgroundOnOddRows;
 238  
         }
 239  
 
 240  
         public void setPrintBackgroundOnOddRows(boolean printBackgroundOnOddRows) {
 241  21
                 this.printBackgroundOnOddRows = printBackgroundOnOddRows;
 242  21
         }
 243  
 
 244  
         public Integer getTitleHeight() {
 245  93
                 return this.titleHeight;
 246  
         }
 247  
 
 248  
         public Integer getSubtitleHeight() {
 249  67
                 return this.subtitleHeight;
 250  
         }
 251  
 
 252  
         public void setSubtitleHeight(Integer subtitleHeight) {
 253  8
                 this.subtitleHeight = subtitleHeight;
 254  8
         }
 255  
 
 256  
         public void setTitleHeight(Integer titleHeight) {
 257  7
                 this.titleHeight = titleHeight;
 258  7
         }
 259  
 
 260  
         public HashMap getFirstPageImageBanners() {
 261  345
                 return firstPageImageBanners;
 262  
         }
 263  
 
 264  
         public Style getDefaultDetailStyle() {
 265  119
                 return defaultDetailStyle;
 266  
         }
 267  
 
 268  
         /**
 269  
          * Should not be null
 270  
          * @param defaultDetailStyle
 271  
          */
 272  
         public void setDefaultDetailStyle(Style defaultDetailStyle) {
 273  7
                 this.defaultDetailStyle = defaultDetailStyle;
 274  7
         }
 275  
 
 276  
         public Style getDefaultFooterStyle() {
 277  0
                 return defaultFooterStyle;
 278  
         }
 279  
 
 280  
         /**
 281  
          * Should not be null
 282  
          * @param defaultFooterStyle
 283  
          */
 284  
         public void setDefaultFooterStyle(Style defaultFooterStyle) {
 285  0
                 this.defaultFooterStyle = defaultFooterStyle;
 286  0
         }
 287  
 
 288  
         public Style getDefaultHeaderStyle() {
 289  190
                 return defaultHeaderStyle;
 290  
         }
 291  
 
 292  
         /***
 293  
          * Should not be null
 294  
          * @param defaultHeaderStyle
 295  
          */
 296  
         public void setDefaultHeaderStyle(Style defaultHeaderStyle) {
 297  77
                 this.defaultHeaderStyle = defaultHeaderStyle;
 298  77
         }
 299  
 
 300  
         public Style getDefaultGroupHeaderStyle() {
 301  0
                 return defaultGroupHeaderStyle;
 302  
         }
 303  
 
 304  
         /**
 305  
          * Should not be null
 306  
          * @param defaultGroupHeaderStyle
 307  
          */
 308  
         public void setDefaultGroupHeaderStyle(Style defaultGroupHeaderStyle) {
 309  0
                 this.defaultGroupHeaderStyle = defaultGroupHeaderStyle;
 310  0
         }
 311  
 
 312  
         public Style getDefaultGroupFooterStyle() {
 313  0
                 return defaultGroupFooterStyle;
 314  
         }
 315  
 
 316  
         /**
 317  
          * Should not be null
 318  
          * @param defaultGroupFooterStyle
 319  
          */
 320  
         public void setDefaultGroupFooterStyle(Style defaultGroupFooterStyle) {
 321  0
                 this.defaultGroupFooterStyle = defaultGroupFooterStyle;
 322  0
         }
 323  
 
 324  
         public boolean isTitleNewPage() {
 325  116
                 return titleNewPage;
 326  
         }
 327  
 
 328  
         public void setTitleNewPage(boolean titleNewPage) {
 329  0
                 this.titleNewPage = titleNewPage;
 330  0
         }
 331  
 
 332  
         public boolean isPrintColumnNames() {
 333  116
                 return printColumnNames;
 334  
         }
 335  
 
 336  
         public void setPrintColumnNames(boolean printColumnNames) {
 337  21
                 this.printColumnNames = printColumnNames;
 338  21
         }
 339  
 
 340  
         public boolean isIgnorePagination() {
 341  117
                 return ignorePagination;
 342  
         }
 343  
 
 344  
         public void setIgnorePagination(boolean ignorePagination) {
 345  2
                 this.ignorePagination = ignorePagination;
 346  2
         }
 347  
 
 348  
         public Integer getHeaderVariablesHeight() {
 349  89
                 return headerVariablesHeight;
 350  
         }
 351  
 
 352  
         public void setHeaderVariablesHeight(Integer headerVariablesHeight) {
 353  0
                 if (headerVariablesHeight==null)
 354  0
                         headerVariablesHeight = DEFAULT_HEADER_VARIABLES_HEIGHT;
 355  0
                 this.headerVariablesHeight = headerVariablesHeight;
 356  0
         }
 357  
 
 358  
         public boolean isShowDetailBand() {
 359  558
                 return showDetailBand;
 360  
         }
 361  
 
 362  
         public void setShowDetailBand(boolean showDetailBand) {
 363  5
                 this.showDetailBand = showDetailBand;
 364  5
         }
 365  
 
 366  
         /**
 367  
          * When TRUE, the summary section will start in a new page
 368  
          * @return
 369  
          */
 370  
         public boolean isSummaryNewPage() {
 371  116
                 return summaryNewPage;
 372  
         }
 373  
 
 374  
         public void setSummaryNewPage(boolean summaryNewPage) {
 375  0
                 this.summaryNewPage = summaryNewPage;
 376  0
         }
 377  
 
 378  
 }