1
|
1 /* DocuImage -- General image interface class implementation
|
|
2
|
|
3 Digital Image Library servlet components
|
|
4
|
|
5 Copyright (C) 2001, 2002 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
|
73
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1
|
18
|
|
19 */
|
|
20
|
|
21 package digilib.image;
|
|
22
|
|
23 import java.io.*;
|
|
24 import javax.servlet.ServletResponse;
|
|
25
|
|
26 import digilib.*;
|
|
27 import digilib.io.*;
|
|
28
|
73
|
29 /** Simple abstract implementation of the <code>DocuImage</code> interface.
|
|
30 *
|
|
31 * This implementation provides basic functionality for the utility methods like
|
|
32 * <code>SetUtils</code>, and <code>getKnownFileTypes</code>. Image methods like
|
|
33 * <code>loadImage</code>, <code>writeImage</code>, <code>getWidth</code>,
|
|
34 * <code>getHeight</code> and <code>cropAndScale</code> must be implemented by
|
|
35 * derived classes.
|
|
36 */
|
1
|
37 public abstract class DocuImageImpl implements DocuImage {
|
|
38
|
73
|
39 /** Internal utils object. */
|
1
|
40 protected Utils util = null;
|
|
41
|
73
|
42 /** Default constructor. */
|
1
|
43 public DocuImageImpl() {
|
|
44 util = new Utils();
|
|
45 }
|
|
46
|
73
|
47 /** Contructor taking an utils object.
|
|
48 *
|
|
49 * @param u Utils object.
|
|
50 */
|
1
|
51 public DocuImageImpl(Utils u) {
|
|
52 util = u;
|
|
53 }
|
|
54
|
73
|
55 /** Set local Utils object.
|
|
56 *
|
|
57 * @param u Utils object.
|
|
58 */
|
1
|
59 public void setUtils(Utils u) {
|
|
60 util = u;
|
|
61 }
|
|
62
|
73
|
63 /** Internal knownFileTypes. */
|
1
|
64 protected String[] knownFileTypes = {"jpg", "png", "gif", "tiff"};
|
|
65
|
73
|
66 /** Returns the list of image file types known to the DocuImage implementation.
|
|
67 *
|
|
68 * @return List of image file types. Strings are standard file extensions.
|
|
69 */
|
1
|
70 public String[] getKnownFileTypes() {
|
|
71 return knownFileTypes;
|
|
72 }
|
|
73
|
|
74
|
|
75 public abstract void loadImage(File f) throws FileOpException;
|
|
76 public abstract void writeImage(String mt, ServletResponse res) throws FileOpException;
|
|
77 public abstract int getWidth();
|
|
78 public abstract int getHeight();
|
|
79 public abstract void cropAndScale(int x_off, int y_off, int width, int height, float scale, int qual) throws ImageOpException;
|
|
80 }
|