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.engine.JRImage;
27 import net.sf.jasperreports.renderers.DimensionRenderable;
28
29
30 /**
31 * @author Sanda Zaharia (shertage@users.sourceforge.net)
32 */
33 public enum ScaleImageEnum implements JREnum
34 {
35 /**
36 * A constant value specifying that if the actual image is larger than the image element size, it will be cut off so
37 * that it keeps its original resolution, and only the region that fits the specified size will be displayed.
38 */
39 CLIP((byte)1, "Clip"),
40
41 /**
42 * A constant value specifying that if the dimensions of the actual image do not fit those specified for the
43 * image element that displays it, the image can be forced to obey them and stretch itself so that it fits
44 * in the designated output area.
45 */
46 FILL_FRAME((byte)2, "FillFrame"),
47
48 /**
49 * A constant value specifying that if the actual image does not fit into the image element, it can be adapted
50 * to those dimensions without needing to change its original proportions.
51 */
52 RETAIN_SHAPE((byte)3, "RetainShape"),
53
54 /**
55 * A scale image type that instructs the engine to stretch the image height
56 * to fit the actual height of the image.
57 *
58 * <p>
59 * Several restrictions apply to the image stretching mechanism:
60 * <ul>
61 * <li>It only works when the image renderer implements
62 * {@link DimensionRenderable}.</li>
63 * <li>If the actual image width exceeds the declared image element width,
64 * the image is proportionally stretched to fit the declared width.</li>
65 * <li>Images with delayed evaluation (see {@link JRImage#getEvaluationTimeValue()})
66 * do not stretch and is proportionally shrunk to fit the declared
67 * height/width.</li>
68 * <li>An image overflows (to the next page/column) only once, after this
69 * the image gets rendered on the available space by proportionally
70 * shrinking its size.</li>
71 * </ul>
72 * </p>
73 *
74 * @see #REAL_SIZE
75 */
76 REAL_HEIGHT((byte)4, "RealHeight"),
77
78 /**
79 * A scale image type that stretches the images height in the same way as
80 * {@link #REAL_HEIGHT}, and in addition it changes the image
81 * width to the actual with of the image.
82 *
83 * This can be useful when, for instance, a border has to be drawn around
84 * the image, respecting its actual size.
85 */
86 REAL_SIZE((byte)5, "RealSize");
87
88 /**
89 *
90 */
91 private final transient byte value;
92 private final transient String name;
93
94 private ScaleImageEnum(byte value, String name)
95 {
96 this.value = value;
97 this.name = name;
98 }
99
100 /**
101 * @deprecated Used only by deprecated serialized fields.
102 */
103 @Override
104 public Byte getValueByte()
105 {
106 return value;
107 }
108
109 /**
110 * @deprecated Used only by deprecated serialized fields.
111 */
112 @Override
113 public final byte getValue()
114 {
115 return value;
116 }
117
118 @Override
119 public String getName()
120 {
121 return name;
122 }
123
124 /**
125 *
126 */
127 public static ScaleImageEnum getByName(String name)
128 {
129 return EnumUtil.getEnumByName(values(), name);
130 }
131
132 /**
133 * @deprecated Used only by deprecated serialized fields.
134 */
135 public static ScaleImageEnum getByValue(Byte value)
136 {
137 return (ScaleImageEnum)EnumUtil.getByValue(values(), value);
138 }
139
140 /**
141 * @deprecated Used only by deprecated serialized fields.
142 */
143 public static ScaleImageEnum getByValue(byte value)
144 {
145 return getByValue((Byte)value);
146 }
147 }
148