comparison servlet/src/digilib/image/ImageSize.java @ 149:04ad64b2137a

Servlet version 1.14b1 - better performance with thumbnails (really, this time :-) - new DocuInfo class - new Directory class - DocuFile uses String and Directory as data members - parameter rearrangements
author robcast
date Tue, 26 Aug 2003 22:28:43 +0200
parents
children e743b853efca
comparison
equal deleted inserted replaced
148:837a633a0407 149:04ad64b2137a
1 /* DocuFile.java -- digilib image file class.
2
3 Digital Image Library servlet components
4
5 Copyright (C) 2003 Robert Casties (robcast@mail.berlios.de)
6
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
11
12 Please read license.txt for the full details. A copy of the GPL
13 may be found at http://www.gnu.org/copyleft/lgpl.html
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 * Created on 26.08.2003
20 */
21
22 package digilib.image;
23
24 /** Class for image size (width, height).
25 *
26 * @author casties
27 *
28 */
29 public class ImageSize {
30 public int width;
31 public int height;
32
33 public ImageSize() {
34 super();
35 }
36
37 public ImageSize(int width, int height) {
38 this.width = width;
39 this.height = height;
40 }
41
42 public ImageSize(ImageSize i) {
43 this.width = i.width;
44 this.height = i.height;
45 }
46
47 public void setSize(int width, int height) {
48 this.width = width;
49 this.height = height;
50 }
51
52 /** Returns if the size of this image is smaller in every dimension than the other image.
53 *
54 * @param is
55 * @return
56 */
57 public boolean isTotallySmallerThan(ImageSize is) {
58 return ((this.width <= is.width) && (this.height <= is.height));
59 }
60
61 /** Returns if the size of this image is smaller in at least one dimension than the other image.
62 *
63 * @param is
64 * @return
65 */
66 public boolean isSmallerThan(ImageSize is) {
67 return ((this.width <= is.width) || (this.height <= is.height));
68 }
69
70 /** Returns if the size of this image is bigger in every dimension than the other image.
71 *
72 * @param is
73 * @return
74 */
75 public boolean isTotallyBiggerThan(ImageSize is) {
76 return ((this.width >= is.width) && (this.height >= is.height));
77 }
78
79 /** Returns if the size of this image is bigger in at least one dimension than the other image.
80 *
81 * @param is
82 * @return
83 */
84 public boolean isBiggerThan(ImageSize is) {
85 return ((this.width >= is.width) || (this.height >= is.height));
86 }
87
88 /** Returns if this image has the same size or height as the other image.
89 *
90 * @param is
91 * @return
92 */
93 public boolean fitsIn(ImageSize is) {
94 return ((this.width == is.width)&&(this.height <= is.height)
95 ||(this.width <= is.width)&&(this.height == is.height));
96 }
97
98 /** Returns if the size of this image is the same as the other image.
99 *
100 * @param is
101 * @return
102 */
103 public boolean equals(ImageSize is) {
104 return ((this.width == is.width)&&(this.height == is.height));
105 }
106
107 /**
108 * @return
109 */
110 public int getHeight() {
111 return height;
112 }
113
114 /**
115 * @param height
116 */
117 public void setHeight(int height) {
118 this.height = height;
119 }
120
121 /**
122 * @return
123 */
124 public int getWidth() {
125 return width;
126 }
127
128 /**
129 * @param width
130 */
131 public void setWidth(int width) {
132 this.width = width;
133 }
134
135 }