comparison servlet/src/digilib/io/DocuFileset.java @ 139:11cfe4c89fdc

Servlet version 1.11b1 with improved original-size. - fixed lots of bugs in metadata handling.
author robcast
date Thu, 31 Jul 2003 20:56:51 +0200
parents c36944be0b58
children bdd6789d21e0
comparison
equal deleted inserted replaced
138:d18b0ff52b07 139:11cfe4c89fdc
42 // resolution (DPI) 42 // resolution (DPI)
43 private double resX = 0; 43 private double resX = 0;
44 private double resY = 0; 44 private double resY = 0;
45 // parent directory 45 // parent directory
46 private DocuDirectory parent = null; 46 private DocuDirectory parent = null;
47
48 47
49 /* 48 /*
50 * constructors 49 * constructors
51 */ 50 */
52 51
192 public void checkMeta() { 191 public void checkMeta() {
193 if (metaChecked) { 192 if (metaChecked) {
194 return; 193 return;
195 } 194 }
196 if (fileMeta == null) { 195 if (fileMeta == null) {
197 // try to read meta-data file 196 // try to read metadata file
198 readMeta(); 197 readMeta();
199 if (fileMeta == null) { 198 if (fileMeta == null) {
200 // there is no meta data 199 // try directory metadata
201 metaChecked = true; 200 if (parent.getDirMeta() != null) {
202 return; 201 fileMeta = parent.getDirMeta();
202 } else {
203 // no metadata available
204 metaChecked = true;
205 return;
206 }
203 } 207 }
204 } 208 }
205 metaChecked = true; 209 metaChecked = true;
210 String s;
206 double dpi = 0; 211 double dpi = 0;
207 double dpix = 0; 212 double dpix = 0;
208 double dpiy = 0; 213 double dpiy = 0;
209 double sizex = 0; 214 double sizex = 0;
210 double sizey = 0; 215 double sizey = 0;
211 double pixx = 0; 216 double pixx = 0;
212 double pixy = 0; 217 double pixy = 0;
213 // DPI is valid for X and Y 218 // DPI is valid for X and Y
214 try { 219 if (fileMeta.containsKey("original-dpi")) {
215 dpi = Double.parseDouble((String) fileMeta.get("dpi")); 220 try {
216 } catch (NumberFormatException e) { 221 dpi = Double.parseDouble((String) fileMeta.get("original-dpi"));
217 } 222 } catch (NumberFormatException e) {
218 if (dpi != 0) { 223 }
219 resX = dpi; 224 if (dpi != 0) {
220 resY = dpi; 225 resX = dpi;
221 return; 226 resY = dpi;
227 return;
228 }
222 } 229 }
223 // DPI-X and DPI-Y 230 // DPI-X and DPI-Y
224 try { 231 if (fileMeta.containsKey("original-dpi-x")
225 dpix = Double.parseDouble((String) fileMeta.get("dpi-x")); 232 && fileMeta.containsKey("original-dpi-y")) {
226 dpiy = Double.parseDouble((String) fileMeta.get("dpi-y")); 233 try {
227 } catch (NumberFormatException e) { 234 dpix =
228 } 235 Double.parseDouble((String) fileMeta.get("original-dpi-x"));
229 if ((dpix != 0) && (dpiy != 0)) { 236 dpiy =
230 resX = dpix; 237 Double.parseDouble((String) fileMeta.get("original-dpi-y"));
231 resY = dpiy; 238 } catch (NumberFormatException e) {
232 return; 239 }
240 if ((dpix != 0) && (dpiy != 0)) {
241 resX = dpix;
242 resY = dpiy;
243 return;
244 }
233 } 245 }
234 // SIZE-X and SIZE-Y and PIXEL-X and PIXEL-Y 246 // SIZE-X and SIZE-Y and PIXEL-X and PIXEL-Y
235 try { 247 if (fileMeta.containsKey("original-size-x")
236 sizex = 248 && fileMeta.containsKey("original-size-y")
237 Double.parseDouble((String) fileMeta.get("original-size-x")); 249 && fileMeta.containsKey("original-pixel-x")
238 sizey = 250 && fileMeta.containsKey("original-pixel-y")) {
239 Double.parseDouble((String) fileMeta.get("original-size-y")); 251 try {
240 pixx = 252 sizex =
241 Double.parseDouble((String) fileMeta.get("original-pixel-x")); 253 Double.parseDouble(
242 pixy = 254 (String) fileMeta.get("original-size-x"));
243 Double.parseDouble((String) fileMeta.get("original-pixel-y")); 255 sizey =
244 } catch (NumberFormatException e) { 256 Double.parseDouble(
245 } 257 (String) fileMeta.get("original-size-y"));
246 if ((sizex != 0) && (sizey != 0) && (pixx != 0) && (pixy != 0)) { 258 pixx =
247 resX = pixx / (sizex * 100 / 2.54); 259 Double.parseDouble(
248 resY = pixy / (sizey * 100 / 2.54); 260 (String) fileMeta.get("original-pixel-x"));
249 return; 261 pixy =
262 Double.parseDouble(
263 (String) fileMeta.get("original-pixel-y"));
264 } catch (NumberFormatException e) {
265 }
266 if ((sizex != 0) && (sizey != 0) && (pixx != 0) && (pixy != 0)) {
267 resX = pixx / (sizex * 100 / 2.54);
268 resY = pixy / (sizey * 100 / 2.54);
269 return;
270 }
250 } 271 }
251 } 272 }
252 273
253 /** The name of the (hires) image file. 274 /** The name of the (hires) image file.
254 * 275 *
297 * @return 318 * @return
298 */ 319 */
299 public boolean isMetaChecked() { 320 public boolean isMetaChecked() {
300 return metaChecked; 321 return metaChecked;
301 } 322 }
302 323
303 /** 324 /**
304 * @return 325 * @return
305 */ 326 */
306 public double getResX() { 327 public double getResX() {
307 return resX; 328 return resX;
311 * @return 332 * @return
312 */ 333 */
313 public double getResY() { 334 public double getResY() {
314 return resY; 335 return resY;
315 } 336 }
316 337
317 } 338 }