001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.vfny.geoserver.wms.responses.map.tiff;
006:
007: import java.util.HashSet;
008: import java.util.Map;
009: import java.util.Set;
010: import java.util.logging.Logger;
011:
012: import org.vfny.geoserver.global.WMS;
013: import org.vfny.geoserver.wms.GetMapProducer;
014: import org.vfny.geoserver.wms.GetMapProducerFactorySpi;
015:
016: /**
017: * Factory for producing Tiff images.
018: *
019: * @author Simone Giannecchini
020: * @since .1.4.x
021: * @version $Id: TiffMapProducerFactory.java 7746 2007-11-13 15:38:35Z aaime $
022: */
023: public final class TiffMapProducerFactory implements
024: GetMapProducerFactorySpi {
025: /** the only MIME type this map producer supports */
026: static final String MIME_TYPE = "image/tiff";
027:
028: /**
029: * Convenient singleton Set to expose the output format this producer
030: * supports
031: */
032: private static final Set SUPPORTED_FORMATS;
033:
034: static {
035: SUPPORTED_FORMATS = new HashSet(2);
036: SUPPORTED_FORMATS.add(MIME_TYPE);
037: SUPPORTED_FORMATS.add("image/tiff8");
038: }
039:
040: /** Logger */
041: private static final Logger LOGGER = org.geotools.util.logging.Logging
042: .getLogger("org.vfny.geoserver.wms.responses.map.tiff");
043:
044: /**
045: * Default constructor.
046: */
047: public TiffMapProducerFactory() {
048: }
049:
050: /**
051: * DOCUMENT ME!
052: *
053: * @return DOCUMENT ME!
054: */
055: public String getName() {
056: return "Tiff backed raster maps producer";
057: }
058:
059: public Set getSupportedFormats() {
060: return SUPPORTED_FORMATS;
061: }
062:
063: public boolean isAvailable() {
064: try {
065: Class
066: .forName("com.sun.media.imageio.plugins.tiff.TIFFImageWriteParam");
067:
068: return true;
069: } catch (Exception e) {
070: }
071:
072: return false;
073: }
074:
075: public boolean canProduce(String mapFormat) {
076: return SUPPORTED_FORMATS.contains(mapFormat);
077: }
078:
079: /**
080: * DOCUMENT ME!
081: *
082: * @param mapFormat
083: * DOCUMENT ME!
084: * @param wms
085: * DOCUMENT ME!
086: *
087: * @return DOCUMENT ME!
088: *
089: * @throws IllegalArgumentException
090: * DOCUMENT ME!
091: */
092: public GetMapProducer createMapProducer(String mapFormat, WMS wms)
093: throws IllegalArgumentException {
094: if (!canProduce(mapFormat)) {
095: throw new IllegalArgumentException("Can't produce "
096: + mapFormat + " format");
097: }
098:
099: return new TiffMapProducer(mapFormat, MIME_TYPE, wms);
100: }
101:
102: /*
103: * (non-Javadoc)
104: *
105: * @see org.geotools.factory.Factory#getImplementationHints() This just
106: * returns java.util.Collections.EMPTY_MAP
107: */
108: public Map getImplementationHints() {
109: return java.util.Collections.EMPTY_MAP;
110: }
111: }
|