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.png;
006:
007: import java.util.HashSet;
008: import java.util.Map;
009: import java.util.Set;
010:
011: import org.vfny.geoserver.global.WMS;
012: import org.vfny.geoserver.wms.GetMapProducer;
013: import org.vfny.geoserver.wms.GetMapProducerFactorySpi;
014:
015: /**
016: * DOCUMENT ME!
017: *
018: * @author Didier Richard, IGN-F
019: * @author Simone Giannecchini
020: * @version $Id: PNGMapProducerFactory.java 7467 2007-08-28 22:29:03Z afabiani $
021: */
022: public class PNGMapProducerFactory implements GetMapProducerFactorySpi {
023: /** the only MIME type this map producer supports */
024: static final String MIME_TYPE = "image/png";
025:
026: /**
027: * convenient singleton Set to expose the output format this producer
028: * supports
029: */
030: private static final Set SUPPORTED_FORMATS;
031:
032: static {
033: SUPPORTED_FORMATS = new HashSet(2);
034: SUPPORTED_FORMATS.add(MIME_TYPE);
035: SUPPORTED_FORMATS.add(MIME_TYPE + "8");
036: }
037:
038: /**
039: * Creates a new PNGMapProducerFactory object.
040: */
041: public PNGMapProducerFactory() {
042: super ();
043: }
044:
045: /**
046: * DOCUMENT ME!
047: *
048: * @return DOCUMENT ME!
049: */
050: public String getName() {
051: return "Portable Network Graphics (PNG) map producer";
052: }
053:
054: /**
055: * Returns the Set of output format this producer supports
056: *
057: * @return Set of output format this producer supports (actually
058: * "image/png")
059: */
060: public Set getSupportedFormats() {
061: return SUPPORTED_FORMATS;
062: }
063:
064: /**
065: * <b>FIXME</b> JAI dependency ?
066: *
067: * @return <code>true</code>
068: */
069: public boolean isAvailable() {
070: return true;
071: }
072:
073: /**
074: * Returns wether the map producers created by this factory can create maps
075: * in the passed output format.
076: *
077: * @param mapFormat
078: * a MIME type string to check if this producer is able to
079: * handle.
080: *
081: * @return <code>true</code> if <code>mapFormat == "image/gif"</code>,
082: * <code>false</code> otherwise.
083: */
084: public boolean canProduce(String mapFormat) {
085: return SUPPORTED_FORMATS.contains(mapFormat);
086: }
087:
088: /**
089: * DOCUMENT ME!
090: *
091: * @param mapFormat
092: * DOCUMENT ME!
093: * @param wms
094: * DOCUMENT ME!
095: *
096: * @return DOCUMENT ME!
097: *
098: * @throws IllegalArgumentException
099: * DOCUMENT ME!
100: */
101: public GetMapProducer createMapProducer(String mapFormat, WMS wms)
102: throws IllegalArgumentException {
103: if (!canProduce(mapFormat)) {
104: throw new IllegalArgumentException(new StringBuffer(
105: mapFormat).append(
106: " not supported by this map producer").toString());
107: }
108:
109: return new PNGMapProducer(mapFormat, MIME_TYPE, wms);
110: }
111:
112: /*
113: * (non-Javadoc)
114: *
115: * @see org.geotools.factory.Factory#getImplementationHints() This just
116: * returns java.util.Collections.EMPTY_MAP
117: */
118: public Map getImplementationHints() {
119: return java.util.Collections.EMPTY_MAP;
120: }
121: }
|