annotate common/src/main/java/digilib/io/ImageCacheStream.java @ 1158:2ee261676828 default tip

better out-of-the box experience: * digilib works without config files using sensible defaults * new sample images folder used by default * config files moved to templates
author robcast
date Tue, 19 Feb 2013 17:32:25 +0100
parents 28d007673346
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
590
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
1 /**
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
2 *
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
3 */
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
4 package digilib.io;
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
5
906
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
6 import java.io.IOException;
590
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
7 import java.io.InputStream;
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
8
906
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
9 import javax.imageio.ImageIO;
590
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
10 import javax.imageio.stream.ImageInputStream;
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
11
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
12 /**
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
13 * @author casties
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
14 *
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
15 */
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
16 public class ImageCacheStream extends ImageStream {
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
17
906
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
18 private ImageInputStream iis = null;
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
19
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
20 /** Create ImageCacheStream from InputStream and mime-type.
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
21 *
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
22 * @param stream
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
23 * @param mimeType
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
24 * @throws IOException
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
25 */
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
26 public ImageCacheStream(InputStream stream, String mimeType) throws IOException {
590
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
27 super(stream, mimeType);
906
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
28 /*
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
29 * Type of stream backing configured via ImageIO.setUseCache().
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
30 * [...] In general, it is preferable to
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
31 * use a FileCacheImageInputStream when reading from a regular
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
32 * InputStream. This class is provided for cases where it is not
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
33 * possible to create a writable temporary file.
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
34 */
28d007673346 really works with streams now.
robcast
parents: 903
diff changeset
35 iis = ImageIO.createImageInputStream(stream);
590
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
36 }
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
37
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
38 /*
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
39 * (non-Javadoc)
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
40 *
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
41 * @see digilib.io.ImageInput#hasImageInputStream()
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
42 */
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
43 @Override
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
44 public boolean hasImageInputStream() {
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
45 return true;
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
46 }
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
47
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
48 /*
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
49 * (non-Javadoc)
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
50 *
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
51 * @see digilib.io.ImageInput#getImageInputStream()
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
52 */
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
53 @Override
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
54 public ImageInputStream getImageInputStream() {
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
55 return iis;
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
56 }
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
57
69bc69381ac4 more work on stream input and more cleanup
robcast
parents:
diff changeset
58 }