01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.vfny.geoserver.wms.responses.map.jpeg;
06:
07: import org.vfny.geoserver.global.WMS;
08: import org.vfny.geoserver.wms.GetMapProducer;
09: import org.vfny.geoserver.wms.GetMapProducerFactorySpi;
10: import java.util.Collections;
11: import java.util.Map;
12: import java.util.Set;
13:
14: /**
15: * Factory for a JPEG writer.
16: *
17: * @author Simone Giannecchini
18: * @since 1.4.x
19: */
20: public final class JPEGMapProducerFactory implements
21: GetMapProducerFactorySpi {
22: /** the only MIME type this map producer supports */
23: static final String MIME_TYPE = "image/jpeg";
24:
25: public boolean canProduce(String mapFormat) {
26: return MIME_TYPE.equalsIgnoreCase(mapFormat);
27: }
28:
29: public GetMapProducer createMapProducer(String mapFormat, WMS wms)
30: throws IllegalArgumentException {
31: if (!canProduce(mapFormat)) {
32: throw new IllegalArgumentException(new StringBuffer(
33: mapFormat).append(
34: " not supported by this map producer").toString());
35: }
36:
37: return new JPEGMapProducer(MIME_TYPE, wms);
38: }
39:
40: public JPEGMapProducerFactory() {
41: super ();
42: }
43:
44: public String getName() {
45: return "Joint Photographic Experts Group";
46: }
47:
48: public Set getSupportedFormats() {
49: return Collections.singleton(MIME_TYPE);
50: }
51:
52: public boolean isAvailable() {
53: try {
54: return (Class
55: .forName("com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageWriter") != null)
56: || (Class
57: .forName("com.sun.imageio.plugins.jpeg.JPEGImageWriter") != null);
58: } catch (ClassNotFoundException e) {
59: return false;
60: }
61: }
62:
63: /*
64: * (non-Javadoc)
65: *
66: * @see org.geotools.factory.Factory#getImplementationHints() This just
67: * returns java.util.Collections.EMPTY_MAP
68: */
69: public Map getImplementationHints() {
70: return java.util.Collections.EMPTY_MAP;
71: }
72: }
|