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.gif;
06:
07: import org.vfny.geoserver.wms.GetLegendGraphicProducer;
08: import org.vfny.geoserver.wms.GetLegendGraphicProducerSpi;
09: import org.vfny.geoserver.wms.responses.helpers.JAISupport;
10: import java.util.Collections;
11: import java.util.Map;
12: import java.util.Set;
13:
14: /**
15: * Factory of legend graphic producers for the <code>"image/gif"</code> format.
16: *
17: * @author Gabriel Roldan, Axios Engineering
18: * @version $Id: GIFLegendGraphicProducerFactory.java 6326 2007-03-15 18:36:40Z jdeolive $
19: */
20: public class GIFLegendGraphicProducerFactory implements
21: GetLegendGraphicProducerSpi {
22: /**
23: * Empty constructor, as required by the factory strategy.
24: */
25: public GIFLegendGraphicProducerFactory() {
26: super ();
27: }
28:
29: /**
30: * @see org.vfny.geoserver.wms.responses.GetLegendGraphicProducerSpi#getName()
31: */
32: public String getName() {
33: return "Graphics Interchange Format (GIF) legend graphics producer";
34: }
35:
36: /**
37: * DOCUMENT ME!
38: *
39: * @return a singleton Set with the supported mime type.
40: *
41: * @see org.vfny.geoserver.wms.responses.GetLegendGraphicProducerSpi#getSupportedFormats()
42: */
43: public Set getSupportedFormats() {
44: return Collections
45: .singleton(GifLegendGraphicProducer.MIME_TYPE);
46: }
47:
48: /**
49: * Returns wether the gif legend producer is available to be used.
50: *
51: * @return <code>true</code> iif JAI is available, since the actual image generation
52: * depends on JAI availability.
53: *
54: * @see org.vfny.geoserver.wms.responses.GetLegendGraphicProducerSpi#isAvailable()
55: */
56: public boolean isAvailable() {
57: return JAISupport.isJaiAvailable();
58: }
59:
60: /**
61: * Evaluates if the prioducer this factory serves can create images in
62: * <code>mimeType</code> format.
63: *
64: * @param mimeType DOCUMENT ME!
65: *
66: * @return true iif <code>mimeType == "image/gif"</code>
67: *
68: * @see org.vfny.geoserver.wms.responses.GetLegendGraphicProducerSpi#canProduce(java.lang.String)
69: */
70: public boolean canProduce(String mimeType) {
71: return GifLegendGraphicProducer.MIME_TYPE.equals(mimeType);
72: }
73:
74: /**
75: * Creates a legend graphics producer for the given format, which in this
76: * case must be <code>"image/gif"</code>
77: *
78: * @see org.vfny.geoserver.wms.responses.GetLegendGraphicProducerSpi#createLegendProducer(java.lang.String)
79: */
80: public GetLegendGraphicProducer createLegendProducer(String format)
81: throws IllegalArgumentException {
82: if (!canProduce(format)) {
83: throw new IllegalArgumentException(format
84: + " not supported by this legend producer");
85: }
86:
87: return new GifLegendGraphicProducer();
88: }
89:
90: /* (non-Javadoc)
91: * @see org.geotools.factory.Factory#getImplementationHints()
92: * This just returns java.util.Collections.EMPTY_MAP
93: */
94: public Map getImplementationHints() {
95: return java.util.Collections.EMPTY_MAP;
96: }
97: }
|