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.legend.png;
06:
07: import org.vfny.geoserver.wms.GetLegendGraphicProducer;
08: import org.vfny.geoserver.wms.GetLegendGraphicProducerSpi;
09: import java.util.Map;
10: import java.util.Set;
11: import java.util.TreeSet;
12:
13: /**
14: * WMS GetLegendGraphic image producer for the formats supported by the
15: * available JAI library.
16: *
17: * @author Gabriel Roldan, Axios Engineering
18: * @version $Id: PNGLegendGraphicProducerFactory.java 6326 2007-03-15 18:36:40Z jdeolive $
19: */
20: public class PNGLegendGraphicProducerFactory implements
21: GetLegendGraphicProducerSpi {
22: /**
23: *
24: */
25: public PNGLegendGraphicProducerFactory() {
26: super ();
27: }
28:
29: /**
30: * @see org.vfny.geoserver.wms.responses.GetLegendGraphicProducerSpi#getName()
31: */
32: public String getName() {
33: return "Legend graphic producer factory for PNG format";
34: }
35:
36: /**
37: * @see org.vfny.geoserver.wms.responses.GetLegendGraphicProducerSpi#getSupportedFormats()
38: */
39: public Set getSupportedFormats() {
40: Set s = new TreeSet();
41: s.add("image/png");
42:
43: return s;
44: }
45:
46: /**
47: * @see org.vfny.geoserver.wms.responses.GetLegendGraphicProducerSpi#isAvailable()
48: */
49: public boolean isAvailable() {
50: return true;
51: }
52:
53: /**
54: * @see org.vfny.geoserver.wms.responses.GetLegendGraphicProducerSpi#canProduce(java.lang.String)
55: */
56: public boolean canProduce(String mimeType) {
57: return mimeType.equalsIgnoreCase("image/png");
58: }
59:
60: /**
61: * @see org.vfny.geoserver.wms.responses.GetLegendGraphicProducerSpi#createLegendProducer(java.lang.String)
62: */
63: public GetLegendGraphicProducer createLegendProducer(String format)
64: throws IllegalArgumentException {
65: if (!canProduce(format)) {
66: throw new IllegalArgumentException(format
67: + " not supported by this legend producer");
68: }
69:
70: return new PNGLegendGraphicProducer();
71: }
72:
73: /* (non-Javadoc)
74: * @see org.geotools.factory.Factory#getImplementationHints()
75: * This just returns java.util.Collections.EMPTY_MAP
76: */
77: public Map getImplementationHints() {
78: return java.util.Collections.EMPTY_MAP;
79: }
80: }
|