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.ecw;
19:
20: import it.geosolutions.imageio.plugins.ecw.ECWImageReaderSpi;
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 ECW
32: * files.
33: *
34: * @author Daniele Romagnoli, GeoSolutions
35: * @author Simone Giannecchini, GeoSolutions
36: */
37: public final class ECWFormatFactory implements GridFormatFactorySpi {
38: /** Logger. */
39: private final static Logger LOGGER = org.geotools.util.logging.Logging
40: .getLogger("org.geotools.gce.ecw");
41:
42: /**
43: * Tells me if the coverage plugin to access ECW is availaible or not.
44: *
45: * @return <code>true</code> if the plugin is availaible, <code>false</code> otherwise.
46: */
47: public boolean isAvailable() {
48: boolean available = true;
49:
50: // if these classes are here, then the runtime environment has
51: // access to JAI and the JAI ImageI/O toolbox.
52: try {
53:
54: Class.forName("javax.media.jai.JAI");
55: Class
56: .forName("com.sun.media.jai.operator.ImageReadDescriptor");
57:
58: Class
59: .forName("it.geosolutions.imageio.plugins.ecw.ECWImageReaderSpi");
60: available = ECWImageReaderSpi.isAvailable();
61: ECWImageReaderSpi spi = new ECWImageReaderSpi();
62: available = available && spi.isDriverAvailable();
63: if (LOGGER.isLoggable(Level.FINE))
64: LOGGER.fine("ECWFormatFactory is availaible.");
65: } catch (ClassNotFoundException cnf) {
66: if (LOGGER.isLoggable(Level.FINE))
67: LOGGER.fine("ECWFormatFactory is not availaible.");
68: available = false;
69: }
70:
71: return available;
72: }
73:
74: /**
75: * Creating a {@link ECWFormat}
76: *
77: * @return A {@link ECWFormat}
78: */
79: public Format createFormat() {
80: return new ECWFormat();
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: }
|