annotate servlet/src/digilib/image/ImageSize.java @ 486:a92f319aec1c

Servlet version 1.16.1 - now with absolute scaling: mo=ascale&scale=X - reworked scale factor and resolution selection so that absolute scale can use prescaled images (osize can do that too) ASSIGNED - # 23: display thumbnails with absolute scaling https://itgroup.mpiwg-berlin.mpg.de:8080/tracs/cdli/ticket/23
author robcast
date Sat, 12 May 2007 14:23:34 +0200
parents eec0d8c9c3c9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
1 /*
458
eec0d8c9c3c9 Servlet version 1.5.9h
robcast
parents: 293
diff changeset
2 * ImageSize.java -- digilib image size class.
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
3 * Digital Image Library servlet components
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
4 * Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de)
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
5 * This program is free software; you can redistribute it and/or modify it under the
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
6 * terms of the GNU General Public License as published by the Free Software
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
7 * Foundation; either version 2 of the License, or (at your option) any later
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
8 * version. Please read license.txt for the full details. A copy of the GPL may
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
9 * be found at http://www.gnu.org/copyleft/lgpl.html You should have received a
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
10 * copy of the GNU General Public License along with this program; if not,
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
11 * write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
12 * Boston, MA 02111-1307 USA Created on 26.08.2003
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
13 */
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
14
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
15 package digilib.image;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
16
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
17 /** Class for image size (width, height).
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
18 *
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
19 * A width or height of 0 is treated as a 'wildcard' that matches any size.
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
20 *
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
21 * @author casties
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
22 *
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
23 */
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
24 public class ImageSize {
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
25 public int width;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
26 public int height;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
27
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
28 public ImageSize() {
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
29 super();
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
30 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
31
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
32 public ImageSize(int width, int height) {
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
33 this.width = width;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
34 this.height = height;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
35 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
36
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
37 public ImageSize(ImageSize i) {
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
38 this.width = i.width;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
39 this.height = i.height;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
40 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
41
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
42 public void setSize(int width, int height) {
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
43 this.width = width;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
44 this.height = height;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
45 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
46
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
47 /**
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
48 * Returns if the size of this image is smaller in every dimension than the
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
49 * other image.
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
50 *
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
51 *
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
52 *
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
53 * @param is
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
54 * @return
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
55 */
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
56 public boolean isTotallySmallerThan(ImageSize is) {
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
57 if ((this.width == 0)||(is.width == 0)) {
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
58 // width wildcard
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
59 return (this.height <= is.height);
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
60 }
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
61 if ((this.height == 0)||(is.height == 0)) {
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
62 // height wildcard
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
63 return (this.width <= is.width);
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
64 }
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
65 return ((this.width <= is.width)&&(this.height <= is.height));
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
66 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
67
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
68 /**
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
69 * Returns if the size of this image is smaller in at least one dimension
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
70 * than the other image.
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
71 *
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
72 * @param is
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
73 * @return
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
74 */
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
75 public boolean isSmallerThan(ImageSize is) {
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
76 if ((this.width == 0)||(is.width == 0)) {
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
77 // width wildcard
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
78 return (this.height <= is.height);
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
79 }
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
80 if ((this.height == 0)||(is.height == 0)) {
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
81 // height wildcard
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
82 return (this.width <= is.width);
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
83 }
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
84 return ((this.width <= is.width) || (this.height <= is.height));
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
85 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
86
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
87 /**
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
88 * Returns if the size of this image is bigger in every dimension than the
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
89 * other image.
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
90 *
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
91 *
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
92 *
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
93 * @param is
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
94 * @return
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
95 */
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
96 public boolean isTotallyBiggerThan(ImageSize is) {
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
97 if ((this.width == 0)||(is.width == 0)) {
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
98 // width wildcard
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
99 return (this.height >= is.height);
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
100 }
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
101 if ((this.height == 0)||(is.height == 0)) {
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
102 // height wildcard
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
103 return (this.width >= is.width);
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
104 }
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
105 return ((this.width >= is.width) && (this.height >= is.height));
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
106 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
107
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
108 /**
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
109 * Returns if the size of this image is bigger in at least one dimension
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
110 * than the other image.
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
111 *
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
112 *
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
113 *
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
114 * @param is
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
115 * @return
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
116 */
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
117 public boolean isBiggerThan(ImageSize is) {
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
118 if ((this.width == 0)||(is.width == 0)) {
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
119 // width wildcard
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
120 return (this.height >= is.height);
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
121 }
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
122 if ((this.height == 0)||(is.height == 0)) {
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
123 // height wildcard
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
124 return (this.width >= is.width);
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
125 }
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
126 return ((this.width >= is.width) || (this.height >= is.height));
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
127 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
128
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
129 /**
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
130 * Returns if this image has the same size or height as the other image.
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
131 *
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
132 *
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
133 *
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
134 * @param is
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
135 * @return
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
136 */
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
137 public boolean fitsIn(ImageSize is) {
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
138 if ((this.width == 0)||(is.width == 0)) {
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
139 // width wildcard
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
140 return (this.height == is.height);
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
141 }
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
142 if ((this.height == 0)||(is.height == 0)) {
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
143 // height wildcard
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
144 return (this.width == is.width);
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
145 }
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
146 return (
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
147 (this.width == is.width)
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
148 && (this.height <= is.height)
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
149 || (this.width <= is.width)
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
150 && (this.height == is.height));
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
151 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
152
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
153 /**
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
154 * Returns if the size of this image is the same as the other image.
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
155 *
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
156 *
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
157 *
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
158 * @param is
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
159 * @return
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
160 */
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
161 public boolean equals(ImageSize is) {
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
162 if ((this.width == 0)||(is.width == 0)) {
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
163 // width wildcard
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
164 return (this.height == is.height);
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
165 }
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
166 if ((this.height == 0)||(is.height == 0)) {
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
167 // height wildcard
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
168 return (this.width == is.width);
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
169 }
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
170 return ((this.width == is.width) && (this.height == is.height));
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
171 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
172
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
173 /**
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
174 * @return
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
175 */
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
176 public int getHeight() {
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
177 return height;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
178 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
179
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
180 /**
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
181 * @param height
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
182 */
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
183 public void setHeight(int height) {
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
184 this.height = height;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
185 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
186
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
187 /**
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
188 * @return
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
189 */
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
190 public int getWidth() {
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
191 return width;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
192 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
193
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
194 /**
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
195 * @param width
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
196 */
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
197 public void setWidth(int width) {
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
198 this.width = width;
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
199 }
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
200
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
201 /**
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
202 * Returns the aspect ratio.
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
203 *
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
204 * Aspect ratio is (width/height). So it's <1 for portrait and >1 for
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
205 * landscape.
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
206 *
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
207 * @return
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
208 */
293
126684ac4a37 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents: 258
diff changeset
209 public float getAspect() {
126684ac4a37 Servlet version 1.5.0b -- the beginning of the next generation :-)
robcast
parents: 258
diff changeset
210 return (height > 0) ? ((float) width / (float) height) : 0;
170
d40922628e4a Servlet Version 1.16b2 with new DigilibParameter code.
robcast
parents: 159
diff changeset
211 }
258
7a89d105f526 nicer ImageSize.toString()
robcast
parents: 170
diff changeset
212
486
a92f319aec1c Servlet version 1.16.1
robcast
parents: 458
diff changeset
213 /**
a92f319aec1c Servlet version 1.16.1
robcast
parents: 458
diff changeset
214 * Returns a scaled copy of this image size.
a92f319aec1c Servlet version 1.16.1
robcast
parents: 458
diff changeset
215 *
a92f319aec1c Servlet version 1.16.1
robcast
parents: 458
diff changeset
216 * @param scale
a92f319aec1c Servlet version 1.16.1
robcast
parents: 458
diff changeset
217 * @return
a92f319aec1c Servlet version 1.16.1
robcast
parents: 458
diff changeset
218 */
a92f319aec1c Servlet version 1.16.1
robcast
parents: 458
diff changeset
219 public ImageSize getScaled(float scale) {
a92f319aec1c Servlet version 1.16.1
robcast
parents: 458
diff changeset
220 return new ImageSize((int) (width * scale), (int) (height * scale));
a92f319aec1c Servlet version 1.16.1
robcast
parents: 458
diff changeset
221 }
a92f319aec1c Servlet version 1.16.1
robcast
parents: 458
diff changeset
222
258
7a89d105f526 nicer ImageSize.toString()
robcast
parents: 170
diff changeset
223 /* (non-Javadoc)
7a89d105f526 nicer ImageSize.toString()
robcast
parents: 170
diff changeset
224 * @see java.lang.Object#toString()
7a89d105f526 nicer ImageSize.toString()
robcast
parents: 170
diff changeset
225 */
7a89d105f526 nicer ImageSize.toString()
robcast
parents: 170
diff changeset
226 public String toString() {
7a89d105f526 nicer ImageSize.toString()
robcast
parents: 170
diff changeset
227 String s = "[" + width + "x" + height + "]";
7a89d105f526 nicer ImageSize.toString()
robcast
parents: 170
diff changeset
228 return s;
7a89d105f526 nicer ImageSize.toString()
robcast
parents: 170
diff changeset
229 }
149
04ad64b2137a Servlet version 1.14b1
robcast
parents:
diff changeset
230 }