01: /*
02: * Geotools2 - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2007, Geotools Project Managment Committee (PMC)
05: * (C) 2007, GeoSolutions S.A.S.
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation;
10: * version 2.1 of the License.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: */
18: package org.geotools.gce.mrsid;
19:
20: import it.geosolutions.imageio.plugins.mrsid.MrSIDImageReaderSpi;
21:
22: import java.util.Collections;
23: import java.util.Map;
24: import java.util.logging.Level;
25: import java.util.logging.Logger;
26:
27: import org.geotools.coverage.grid.io.GridFormatFactorySpi;
28: import org.opengis.coverage.grid.Format;
29:
30: /**
31: * Implementation of the {@link Format} service provider interface for MrSID
32: * files.
33: *
34: * @author Daniele Romagnoli, GeoSolutions
35: * @author Simone Giannecchini, GeoSolutions
36: */
37: public final class MrSIDFormatFactory implements GridFormatFactorySpi {
38: /** Logger. */
39: private final static Logger LOGGER = org.geotools.util.logging.Logging
40: .getLogger("org.geotools.gce.mrsid");
41:
42: /**
43: * Tells me if the coverage plugin to access MrSID is availaible or not.
44: *
45: * @return <code>true</code> if the plugin is availaible,
46: * <code>false</code> otherwise.
47: */
48: public boolean isAvailable() {
49: boolean available = true;
50:
51: // if these classes are here, then the runtime environment has
52: // access to JAI and the JAI ImageI/O toolbox.
53: try {
54:
55: Class.forName("javax.media.jai.JAI");
56: Class
57: .forName("com.sun.media.jai.operator.ImageReadDescriptor");
58:
59: Class
60: .forName("it.geosolutions.imageio.plugins.mrsid.MrSIDImageReaderSpi");
61: available = MrSIDImageReaderSpi.isAvailable();
62: MrSIDImageReaderSpi spi = new MrSIDImageReaderSpi();
63: available = available && spi.isDriverAvailable();
64: if (LOGGER.isLoggable(Level.FINE))
65: LOGGER.fine("MrSIDFormatFactory is availaible.");
66: } catch (ClassNotFoundException cnf) {
67: if (LOGGER.isLoggable(Level.FINE))
68: LOGGER.fine("MrSIDFormatFactory is not availaible.");
69: available = false;
70: }
71: return available;
72: }
73:
74: /**
75: * Creating a {@link MrSIDFormat}
76: *
77: * @return A {@link MrSIDFormat}
78: */
79: public Format createFormat() {
80: return new MrSIDFormat();
81: }
82:
83: /**
84: * Returns the implementation hints. The default implementation returns en
85: * empty map.
86: */
87: public Map getImplementationHints() {
88: return Collections.EMPTY_MAP;
89: }
90: }
|