Coverage Report - ar.com.fdvs.dj.domain.DJCrosstab
 
Classes in this File Line Coverage Branch Coverage Complexity
DJCrosstab
79%
73/92
83%
5/6
1.06
 
 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.util.ArrayList;
 33  
 import java.util.Collections;
 34  
 import java.util.List;
 35  
 
 36  
 import ar.com.fdvs.dj.core.layout.CrossTabColorShema;
 37  
 import ar.com.fdvs.dj.domain.constants.Border;
 38  
 import ar.com.fdvs.dj.domain.entities.Entity;
 39  
 import org.apache.commons.collections.CollectionUtils;
 40  
 import org.apache.commons.collections.Predicate;
 41  
 
 42  9
 public class DJCrosstab extends DJBaseElement {
 43  
 
 44  
         private static final long serialVersionUID = Entity.SERIAL_VERSION_UID;
 45  
 
 46  9
         private List rows = new ArrayList();
 47  9
         private List columns = new ArrayList();
 48  9
         private List measures = new ArrayList();
 49  
 
 50  
         private DJLabel caption;
 51  
         
 52  
         private int height;
 53  
         private int width;
 54  
 
 55  9
         private int bottomSpace = 10; //blank space AFTER the crosstab
 56  9
         private int topSpace = 10; //blank space BEFORE the crosstab
 57  
 
 58  
         /**
 59  
          * if true, the width will be the page width - margins
 60  
          */
 61  9
         private boolean useFullWidth = true;
 62  
 
 63  
         private DJDataSource datasource;
 64  
 
 65  9
         private String mainHeaderTitle = "";
 66  
 
 67  9
         private boolean automaticTitle = false;
 68  
 
 69  
 
 70  
         /**
 71  
          * Default styles, can be overwritten by the column and row objects
 72  
          */
 73  
         private Style headerStyle;
 74  
         
 75  
         
 76  
         private Style columnHeaderStyle;
 77  
         private Style columnTotalheaderStyle;
 78  
         private Style columnTotalStyle;
 79  
 
 80  
         private Style rowHeaderStyle;
 81  
         private Style rowTotalheaderStyle;
 82  
         private Style rowTotalStyle;
 83  
         
 84  
         private Style measureStyle;
 85  
 
 86  9
         private int colorScheme = 0;
 87  
 
 88  9
         private CrossTabColorShema ctColorScheme = null;
 89  
 
 90  
         /**
 91  
          * If not null or NO_BORDER, all cells will have this border
 92  
          */
 93  
         private Border cellBorder;
 94  
 
 95  
         /**
 96  
          * From here on, pass-throug properties
 97  
          */
 98  9
         private int columnBreakOffset = 10;
 99  
 
 100  
         public int getColumnBreakOffset() {
 101  8
                 return columnBreakOffset;
 102  
         }
 103  
         public void setColumnBreakOffset(int columnBreakOffset) {
 104  0
                 this.columnBreakOffset = columnBreakOffset;
 105  0
         }
 106  
         public Style getHeaderStyle() {
 107  16
                 return headerStyle;
 108  
         }
 109  
         public void setHeaderStyle(Style headerStyle) {
 110  8
                 this.headerStyle = headerStyle;
 111  8
         }
 112  
         public List getRows() {
 113  111
                 return rows;
 114  
         }
 115  
         public void setRows(List rows) {
 116  0
                 this.rows = rows;
 117  0
         }
 118  
         public List getColumns() {
 119  111
                 return columns;
 120  
         }
 121  
         public void setColumns(List columns) {
 122  0
                 this.columns = columns;
 123  0
         }
 124  
         public int getHeight() {
 125  8
                 return height;
 126  
         }
 127  
         public void setHeight(int height) {
 128  8
                 this.height = height;
 129  8
         }
 130  
         public int getWidth() {
 131  0
                 return width;
 132  
         }
 133  
         public void setWidth(int width) {
 134  8
                 this.width = width;
 135  8
         }
 136  
         public List getMeasures() {
 137  206
                 return measures;
 138  
         }
 139  
         
 140  
         public void setMeasures(List measures) {
 141  3
                 this.measures = measures;
 142  3
         }
 143  
 
 144  
         public DJCrosstabMeasure getMeasure(int index) {
 145  1
                 return (DJCrosstabMeasure) measures.get(index);
 146  
         }
 147  
         public boolean isUseFullWidth() {
 148  8
                 return useFullWidth;
 149  
         }
 150  
         public void setUseFullWidth(boolean useFullWidth) {
 151  8
                 this.useFullWidth = useFullWidth;
 152  8
         }
 153  
         public DJDataSource getDatasource() {
 154  16
                 return datasource;
 155  
         }
 156  
         public void setDatasource(DJDataSource datasource) {
 157  9
                 this.datasource = datasource;
 158  9
         }
 159  
         public Border getCellBorder() {
 160  118
                 return cellBorder;
 161  
         }
 162  
         public void setCellBorder(Border cellBorder) {
 163  8
                 this.cellBorder = cellBorder;
 164  8
         }
 165  
         public int getColorScheme() {
 166  7
                 return colorScheme;
 167  
         }
 168  
         public void setColorScheme(int colorScheme) {
 169  7
                 this.colorScheme = colorScheme;
 170  7
         }
 171  
         public String getMainHeaderTitle() {
 172  0
                 return mainHeaderTitle;
 173  
         }
 174  
         public void setMainHeaderTitle(String mainHeaderTitle) {
 175  0
                 this.mainHeaderTitle = mainHeaderTitle;
 176  0
         }
 177  
         public boolean isAutomaticTitle() {
 178  8
                 return automaticTitle;
 179  
         }
 180  
         public void setAutomaticTitle(boolean automaticTitle) {
 181  8
                 this.automaticTitle = automaticTitle;
 182  8
         }
 183  
         public int getBottomSpace() {
 184  24
                 return bottomSpace;
 185  
         }
 186  
         public void setBottomSpace(int bottomSpace) {
 187  0
                 this.bottomSpace = bottomSpace;
 188  0
         }
 189  
         public int getTopSpace() {
 190  16
                 return topSpace;
 191  
         }
 192  
         public void setTopSpace(int topSpace) {
 193  0
                 this.topSpace = topSpace;
 194  0
         }
 195  
         public CrossTabColorShema getCtColorScheme() {
 196  8
                 return ctColorScheme;
 197  
         }
 198  
         public void setCtColorScheme(CrossTabColorShema ctColorScheme) {
 199  1
                 this.ctColorScheme = ctColorScheme;
 200  1
         }
 201  
         public Style getRowTotalheaderStyle() {
 202  9
                 return rowTotalheaderStyle;
 203  
         }
 204  
         
 205  
         /**
 206  
          * Default style. Can be overwritten by the row 
 207  
          * @param rowTotalheaderStyle
 208  
          */
 209  
         public void setRowTotalheaderStyle(Style rowTotalheaderStyle) {
 210  7
                 this.rowTotalheaderStyle = rowTotalheaderStyle;
 211  7
         }
 212  
         public Style getColumnTotalheaderStyle() {
 213  9
                 return columnTotalheaderStyle;
 214  
         }
 215  
         
 216  
         /**
 217  
          * Default style. Can be overwritten by the column
 218  
          * @param columnTotalheaderStyle
 219  
          */
 220  
         public void setColumnTotalheaderStyle(Style columnTotalheaderStyle) {
 221  7
                 this.columnTotalheaderStyle = columnTotalheaderStyle;
 222  7
         }
 223  
         public Style getRowHeaderStyle() {
 224  12
                 return rowHeaderStyle;
 225  
         }
 226  
         
 227  
         /**
 228  
          * Default style. Can be overwritten by the row
 229  
          * @param rowHeaderStyle
 230  
          */
 231  
         public void setRowHeaderStyle(Style rowHeaderStyle) {
 232  7
                 this.rowHeaderStyle = rowHeaderStyle;
 233  7
         }
 234  
         public Style getColumnHeaderStyle() {
 235  12
                 return columnHeaderStyle;
 236  
         }
 237  
         
 238  
         /**
 239  
          * Default style. Can be overwritten by the column
 240  
          * @param columnHeaderStyle
 241  
          */
 242  
         public void setColumnHeaderStyle(Style columnHeaderStyle) {
 243  7
                 this.columnHeaderStyle = columnHeaderStyle;
 244  7
         }
 245  
         public Style getMeasureStyle() {
 246  0
                 return measureStyle;
 247  
         }
 248  
         public void setMeasureStyle(Style measureStyle) {
 249  0
                 this.measureStyle = measureStyle;
 250  0
         }
 251  
         public Style getColumnTotalStyle() {
 252  18
                 return columnTotalStyle;
 253  
         }
 254  
         public void setColumnTotalStyle(Style columnTotalStyle) {
 255  7
                 this.columnTotalStyle = columnTotalStyle;
 256  7
         }
 257  
         public Style getRowTotalStyle() {
 258  44
                 return rowTotalStyle;
 259  
         }
 260  
         public void setRowTotalStyle(Style rowTotalStyle) {
 261  7
                 this.rowTotalStyle = rowTotalStyle;
 262  7
         }
 263  
         public DJLabel getCaption() {
 264  8
                 return caption;
 265  
         }
 266  
         public void setCaption(DJLabel caption) {
 267  0
                 this.caption = caption;
 268  0
         }
 269  
 
 270  
     public List<DJCrosstabMeasure> getVisibleMeasures() {
 271  68
         List<DJCrosstabMeasure> visibleMeasures = new ArrayList<DJCrosstabMeasure>();
 272  
 
 273  68
         for (Object measureObject : this.getMeasures()) {
 274  101
             DJCrosstabMeasure measure = DJCrosstabMeasure.class.cast(measureObject);
 275  101
             if (measure.getVisible() != null && measure.getVisible().equals(Boolean.TRUE)) {
 276  93
                 visibleMeasures.add(measure);
 277  
             }
 278  101
         }
 279  
 
 280  68
         return Collections.unmodifiableList(visibleMeasures);
 281  
     }
 282  
 }