1
24 package net.sf.jasperreports.engine.fill;
25
26 import net.sf.jasperreports.engine.JRBand;
27 import net.sf.jasperreports.engine.JRGroup;
28 import net.sf.jasperreports.engine.JROrigin;
29 import net.sf.jasperreports.engine.JRPart;
30 import net.sf.jasperreports.engine.JRSection;
31
32
33
36 public class JRFillSection implements JRSection, JROriginProvider
37 {
38
39
42 protected JRBaseFiller filler;
43
44 protected JRFillBand[] bands;
45
46 protected JROrigin origin;
47
48 private boolean isEmpty = true;
49 private boolean areAllPrintWhenExprNull = true;
50
51
52
55 protected JRFillSection(
56 JRBaseFiller filler,
57 JRSection section,
58 JRFillObjectFactory factory
59 )
60 {
61 if (section != null)
62 {
63 factory.put(section, this);
64
65 isEmpty = true;
66 areAllPrintWhenExprNull = true;
67
68 JRBand[] jrBands = section.getBands();
69 if (jrBands != null && jrBands.length > 0)
70 {
71 bands = new JRFillBand[jrBands.length];
72 for (int i = 0; i < jrBands.length; i++)
73 {
74 bands[i] = factory.getBand(jrBands[i]);
75 isEmpty = isEmpty && bands[i].isEmpty();
76 areAllPrintWhenExprNull = areAllPrintWhenExprNull && bands[i].isPrintWhenExpressionNull();
77 }
78 }
79 else
80 {
81
82 bands = new JRFillBand[]{filler.missingFillBand};
83 }
84 }
85 else
86 {
87
88 bands = new JRFillBand[]{filler.missingFillBand};
89 }
90
91 this.filler = filler;
92 }
93
94
95 @Override
96 public JROrigin getOrigin()
97 {
98 return origin;
99 }
100
101
102
105 protected void setOrigin(JROrigin origin)
106 {
107 this.origin = origin;
108
109 if (bands.length > 0)
110 {
111 for (int i = 0; i < bands.length; i++)
112 {
113 bands[i].setOrigin(origin);
114 }
115 }
116
117 this.filler.getJasperPrint().addOrigin(origin);
118 }
119
120
121 public JRFillBand[] getFillBands()
122 {
123 return bands;
124 }
125
126 @Override
127 public JRBand[] getBands()
128 {
129 return bands;
130 }
131
132 @Override
133 public JRPart[] getParts()
134 {
135 return null;
136 }
137
138
139 @Override
140 public Object clone()
141 {
142 throw new UnsupportedOperationException();
143 }
144
145
146 protected boolean isEmpty()
147 {
148 return isEmpty;
149 }
150
151
152 protected boolean areAllPrintWhenExpressionsNull()
153 {
154 return areAllPrintWhenExprNull;
155 }
156
157
158 protected void setNewPageColumn(boolean isNew)
159 {
160 for(int i = 0; i < bands.length; i++)
161 {
162 bands[i].setNewPageColumn(isNew);
163 }
164 }
165
166
167 protected void setNewGroup(JRGroup group, boolean isNew)
168 {
169 for(int i = 0; i < bands.length; i++)
170 {
171 bands[i].setNewGroup(group, isNew);
172 }
173 }
174
175
176 protected void addNowEvaluationTime(JREvaluationTime evaluationTime)
177 {
178 for(int i = 0; i < bands.length; i++)
179 {
180 bands[i].addNowEvaluationTime(evaluationTime);
181 }
182 }
183
184 }
185