Coverage Report - ar.com.fdvs.dj.domain.AutoText
 
Classes in this File Line Coverage Branch Coverage Complexity
AutoText
62%
50/80
N/A
1
 
 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  
 /**
 31  
  *
 32  
  */
 33  
 package ar.com.fdvs.dj.domain;
 34  
 
 35  
 import ar.com.fdvs.dj.core.layout.HorizontalBandAlignment;
 36  
 import ar.com.fdvs.dj.domain.entities.Entity;
 37  
 
 38  
 /**
 39  
  * @author msimone
 40  
  *
 41  
  */
 42  
 public class AutoText extends DJBaseElement {
 43  
 
 44  
         private static final long serialVersionUID = Entity.SERIAL_VERSION_UID;
 45  
         
 46  1
         public static final Integer WIDTH_NOT_SET = new Integer(Integer.MIN_VALUE);
 47  1
         public static final Integer DEFAULT_WIDTH = new Integer(80);
 48  1
         public static final Integer DEFAULT_WIDTH2 = new Integer(30);
 49  
         public static final byte POSITION_FOOTER = 0;
 50  
         public static final byte POSITION_HEADER = 1;
 51  
 
 52  
         public static final byte AUTOTEXT_PAGE_X_OF_Y = 0;
 53  
         public static final byte AUTOTEXT_PAGE_X_SLASH_Y = 1;
 54  
         public static final byte AUTOTEXT_PAGE_X = 2;
 55  
         public static final byte AUTOTEXT_CREATED_ON = 3;
 56  
         public static final byte AUTOTEXT_CUSTOM_MESSAGE = 4;
 57  
 
 58  
         /**
 59  
          *@Deprecated due to miss spell
 60  
          *use ALIGNMENT_LEFT 
 61  
          */
 62  
         public static final byte ALIGMENT_LEFT = 1;
 63  
         /**
 64  
          *@Deprecated due to miss spell
 65  
          *use ALIGNMENT_CENTER
 66  
          */
 67  
         public static final byte ALIGMENT_CENTER = 2;
 68  
         /**
 69  
          *@Deprecated due to miss spell
 70  
          *use ALIGNMENT_RIGHT
 71  
          */
 72  
         public static final byte ALIGMENT_RIGHT = 3;
 73  
 
 74  
         public static final byte ALIGNMENT_LEFT = 1;
 75  
         public static final byte ALIGNMENT_CENTER = 2;
 76  
         public static final byte ALIGNMENT_RIGHT = 3;
 77  
         
 78  
         public static final byte PATTERN_DATE_DATE_ONLY = 1;
 79  
         public static final byte PATTERN_DATE_TIME_ONLY = 2;
 80  
         public static final byte PATTERN_DATE_DATE_TIME = 3;
 81  
 
 82  
         private HorizontalBandAlignment alignment;
 83  
 
 84  
         private byte type;
 85  
 
 86  
         private byte position;
 87  
 
 88  
         private String messageKey;
 89  
 
 90  
         private byte pattern; //Applies for CREATED_ON, its the pattern used for dates
 91  
 
 92  24
         private Integer height = new Integer(15);
 93  
 
 94  24
         private Style style = null;
 95  
 
 96  
         /**
 97  
          * 
 98  
          */
 99  24
         private Integer width = WIDTH_NOT_SET;
 100  
         
 101  
         /**
 102  
          * For autotexts that consists in two parts (like: "page x of y" and "x / y"). <br>
 103  
          * These autotext are compound by 2 text-fields with different render time (one is immediate, the other generally "time-report")<br> 
 104  
          * The first part is the "immediate" second part is the "y" (time-report)<br>
 105  
          * width2 defines how width is the second part. This is for fine tuning of the layout. depending on the size of report
 106  
          * the total pages can be a small or big number, making this width wide enough should prevent the text to
 107  
          * override the space given 
 108  
          */
 109  24
         private Integer width2 = WIDTH_NOT_SET;
 110  
         
 111  
 
 112  
         /**
 113  
          * tells if the API can modify the with if needed
 114  
          */
 115  24
         private boolean fixedWith = true;
 116  
         private BooleanExpression printWhenExpression;
 117  
         
 118  
         public boolean isFixedWith() {
 119  0
                 return fixedWith;
 120  
         }
 121  
         public void setFixedWith(boolean fixedWith) {
 122  0
                 this.fixedWith = fixedWith;
 123  0
         }
 124  
         /**
 125  
          * returns the style
 126  
          * @return can be null if no style has been set
 127  
          */
 128  
         public Style getStyle() {
 129  38
                 return style;
 130  
         }
 131  
         public AutoText setStyle(Style newStyle) {
 132  10
                 style = newStyle;
 133  10
                 return this;
 134  
         }
 135  
         public Integer getWidth() {
 136  68
                 return width;
 137  
         }
 138  
         public void setWidth(Integer width) {
 139  20
                 this.width = width;
 140  20
         }
 141  
         public Integer getWidth2() {
 142  28
                 return width2;
 143  
         }
 144  
         public void setWidth2(Integer width2) {
 145  30
                 this.width2 = width2;
 146  30
         }
 147  
         public Integer getHeight() {
 148  75
                 return height;
 149  
         }
 150  
         public void setHeight(Integer height) {
 151  0
                 this.height = height;
 152  0
         }
 153  9
         public AutoText(byte type, byte position, HorizontalBandAlignment alignment){
 154  9
                 this.type = type;
 155  9
                 this.position = position;
 156  9
                 this.alignment = alignment;
 157  9
         }
 158  3
         public AutoText(byte type, byte position, HorizontalBandAlignment alignment,byte pattern){
 159  3
                 this.type = type;
 160  3
                 this.position = position;
 161  3
                 this.alignment = alignment;
 162  3
                 this.pattern = pattern;
 163  3
         }
 164  0
         public AutoText(byte type, byte position, HorizontalBandAlignment alignment,byte pattern, int width){
 165  0
                 this.type = type;
 166  0
                 this.position = position;
 167  0
                 this.alignment = alignment;
 168  0
                 this.pattern = pattern;
 169  0
                 this.width = new Integer(width);
 170  0
         }
 171  0
         public AutoText(byte type, byte position, HorizontalBandAlignment alignment,byte pattern, int width, int width2){
 172  0
                 this.type = type;
 173  0
                 this.position = position;
 174  0
                 this.alignment = alignment;
 175  0
                 this.pattern = pattern;
 176  0
                 this.width = new Integer(width);
 177  0
                 this.width2 = new Integer(width2);
 178  0
         }
 179  
 
 180  1
         public AutoText(String message, byte position, HorizontalBandAlignment alignment) {
 181  1
                 this.type = AUTOTEXT_CUSTOM_MESSAGE;
 182  1
                 this.position = position;
 183  1
                 this.alignment = alignment;
 184  1
                 this.messageKey = message;
 185  1
                 this.fixedWith = false;
 186  1
         }
 187  
 
 188  11
         public AutoText(String message, byte position, HorizontalBandAlignment alignment, Integer with) {
 189  11
                 this.type = AUTOTEXT_CUSTOM_MESSAGE;
 190  11
                 this.position = position;
 191  11
                 this.alignment = alignment;
 192  11
                 this.messageKey = message;
 193  11
                 this.width = with;
 194  11
                 this.fixedWith = false;
 195  11
         }
 196  
 
 197  
         public HorizontalBandAlignment getAlignment() {
 198  156
                 return alignment;
 199  
         }
 200  
 
 201  
         public void setAlignment(HorizontalBandAlignment alignment) {
 202  0
                 this.alignment = alignment;
 203  0
         }
 204  
 
 205  
         public byte getPosition() {
 206  216
                 return position;
 207  
         }
 208  
 
 209  
         public void setPosition(byte position) {
 210  0
                 this.position = position;
 211  0
         }
 212  
 
 213  
         public byte getType() {
 214  24
                 return type;
 215  
         }
 216  
 
 217  
         public void setType(byte type) {
 218  0
                 this.type = type;
 219  0
         }
 220  
 
 221  
         public String getMessageKey() {
 222  12
                 return messageKey;
 223  
         }
 224  
 
 225  
         public void setMessageKey(String message) {
 226  0
                 this.messageKey = message;
 227  0
         }
 228  
 
 229  
         public byte getPattern() {
 230  3
                 return pattern;
 231  
         }
 232  
         
 233  
         public void setPrintWhenExpression(BooleanExpression printWhenExpression) {
 234  0
                 this.printWhenExpression = printWhenExpression;
 235  0
         }
 236  
 
 237  
         public BooleanExpression getPrintWhenExpression() {
 238  24
                 return printWhenExpression;
 239  
         }
 240  
 }