1 /*
2 * JasperReports - Free Java Reporting Library.
3 * Copyright (C) 2001 - 2019 TIBCO Software Inc. All rights reserved.
4 * http://www.jaspersoft.com
5 *
6 * Unless you have purchased a commercial license agreement from Jaspersoft,
7 * the following license terms apply:
8 *
9 * This program is part of JasperReports.
10 *
11 * JasperReports is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * JasperReports is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
23 */
24 package net.sf.jasperreports.engine.type;
25
26 import net.sf.jasperreports.annotations.properties.Property;
27 import net.sf.jasperreports.annotations.properties.PropertyScope;
28 import net.sf.jasperreports.engine.JRPropertiesUtil;
29 import net.sf.jasperreports.properties.PropertyConstants;
30
31 /**
32 * There are two main reasons for an element to stretch.
33 * <p>
34 * First, there is the natural stretch of the element, which is caused by the element growing naturally in order to display its entire content.
35 * This is the case with text fields that have isStretchWithOverflow set to true and thus growing in height in order to display all the rows of text
36 * that the value of their text field expression provides at runtime.
37 * <p>
38 * Secondly, there is the forced stretch of an element, which in addition to its natural growth required by its own content, needs to further grow
39 * to match the growing height of some other element that it is put in relation with at report design time.
40 * <p>
41 * A forced stretch can be imposed to elements that are part of element groups (JRElementGroup) or element containers (bands, frames, table cells, list cells, etc.).
42 * The forced stretch also comes in two flavors.
43 * <br>
44 * There is element group stretch and container stretch.
45 * <br>
46 * Element group stretch is forced upon an element by the natural growth of the other elements in the same group.
47 * <br>
48 * The container stretch is forced upon an element by all types of growth that the container itself suffers,
49 * including forced container stretch imposed onto the container by its own parent container.
50 *
51 * @author Sanda Zaharia (shertage@users.sourceforge.net)
52 */
53 public enum StretchTypeEnum implements JREnum
54 {
55 /**
56 * A constant indicating that the element preserves its original specified height.
57 */
58 NO_STRETCH((byte)0, "NoStretch"),//FIXMEENUM check all 0 constants for initialization
59
60 /**
61 * @deprecated Replaced by {@link StretchTypeEnum#ELEMENT_GROUP_HEIGHT}.
62 */
63 @Deprecated
64 RELATIVE_TO_TALLEST_OBJECT((byte)1, "RelativeToTallestObject"),
65
66 /**
67 * @deprecated Replaced by {@link StretchTypeEnum#CONTAINER_HEIGHT}.
68 */
69 @Deprecated
70 RELATIVE_TO_BAND_HEIGHT((byte)2, "RelativeToBandHeight"),
71
72 /**
73 * Constant used for specifying that the element will adapt its height to match the changing
74 * height of the overall element group it is part of, but without taking into account the fact that the Y position of the
75 * element within the group has probably changed due to floating and/or
76 * collapsing white space above it. This position change is not compensated for, which might result in the element distance
77 * to the group's initial bottom edge increasing or diminishing.
78 * <br>
79 * Like all element group based types of stretch, the amount of stretch forced onto the element comes only from the natural
80 * stretch of the sibling elements in the same group.
81 */
82 ELEMENT_GROUP_HEIGHT((byte)3, "ElementGroupHeight"),
83
84 /**
85 * Constant used for specifying that the element will adapt its height to match the changing
86 * height of the overall element group it is part of, but also taking into account the fact that the Y position of the
87 * element within the group has probably changed due to floating and/or
88 * collapsing white space above it and should be compensated for, resulting in the element's distance to the group's initial
89 * bottom edge being preserved.
90 * <br>
91 * Like all element group based types of stretch, the amount of stretch forced onto the element comes only from the natural
92 * stretch of the sibling elements in the same group.
93 */
94 ELEMENT_GROUP_BOTTOM((byte)3, "ElementGroupBottom"),
95
96 /**
97 * Constant used for specifying that the element will adapt its height to match the new
98 * height of the container it is placed on, which has been affected by stretch, but without taking
99 * into account the fact that the Y position of the element within the container has probably changed due to floating and/or
100 * collapsing white space above it. This position change is not compensated for, which might result in the element distance
101 * to the container's bottom edge increasing or diminishing. It could even happen that the element bottom edge goes beyond
102 * container bottom edge and thus the element will no longer render at all.
103 * <br>
104 * Like all container based types of stretch, the amount of stretch forced onto the element can come from both the natural
105 * stretch of the sibling elements in the same container, or from the container's own forced stretch imposed onto it by its own parent container.
106 */
107 CONTAINER_HEIGHT((byte)3, "ContainerHeight"),
108
109 /**
110 * Constant used for specifying that the element will adapt its height to match the new
111 * height of the container it is placed on, which has been affected by stretch, but also taking
112 * into account the fact that the Y position of the element has probably changed and should be compensated for,
113 * resulting in the element's distance to container bottom being preserved.
114 * <br>
115 * Like all container based types of stretch, the amount of stretch forced onto the element can come from both the natural
116 * stretch of the sibling elements in the same container, or from the container's own forced stretch imposed onto it by its own parent container.
117 */
118 CONTAINER_BOTTOM((byte)4, "ContainerBottom");
119
120
121 /**
122 *
123 */
124 @Property(
125 category = PropertyConstants.CATEGORY_FILL,
126 defaultValue = PropertyConstants.BOOLEAN_FALSE,
127 scopes = {PropertyScope.CONTEXT},
128 sinceVersion = PropertyConstants.VERSION_6_2_2,
129 valueType = Boolean.class
130 )
131 public static final String PROPERTY_LEGACY_ELEMENT_STRETCH_ENABLED =
132 JRPropertiesUtil.PROPERTY_PREFIX + "legacy.element.stretch.enabled";
133
134 /**
135 *
136 */
137 private final transient byte value;
138 private final transient String name;
139
140 private StretchTypeEnum(byte value, String name)
141 {
142 this.value = value;
143 this.name = name;
144 }
145
146 /**
147 * @deprecated Used only by deprecated serialized fields.
148 */
149 @Override
150 public Byte getValueByte()
151 {
152 return value;
153 }
154
155 /**
156 * @deprecated Used only by deprecated serialized fields.
157 */
158 @Override
159 public final byte getValue()
160 {
161 return value;
162 }
163
164 @Override
165 public String getName()
166 {
167 return name;
168 }
169
170 /**
171 *
172 */
173 public static StretchTypeEnum getByName(String name)
174 {
175 return EnumUtil.getEnumByName(values(), name);
176 }
177
178 /**
179 * @deprecated Used only by deprecated serialized fields.
180 */
181 public static StretchTypeEnum getByValue(Byte value)
182 {
183 return (StretchTypeEnum)EnumUtil.getByValue(values(), value);
184 }
185
186 /**
187 * @deprecated Used only by deprecated serialized fields.
188 */
189 public static StretchTypeEnum getByValue(byte value)
190 {
191 return getByValue((Byte)value);
192 }
193 }
194