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;
06:
07: import org.vfny.geoserver.ServiceException;
08: import org.vfny.geoserver.wms.requests.GetLegendGraphicRequest;
09: import java.io.IOException;
10: import java.io.OutputStream;
11:
12: /**
13: * Provides the skeleton for producers of a legend image, as required by the
14: * GetLegendGraphic WMS request.
15: *
16: * <p>
17: * To incorporate a new producer specialized in one or many output formats,
18: * there must be a {@linkPlain
19: * org.vfny.geoserver.responses.wms.GetLegendGraphicProducerSpi} registered
20: * that can provide instances of that concrete implementation.
21: * </p>
22: *
23: * <p>
24: * The methods defined in this interface respects the general parse
25: * request/produce response/get mime type/write content workflow, so they
26: * should raise an exception if are called in the wrong order (which is
27: * produceLegendGraphic -> getContentType -> writeTo)
28: * </p>
29: *
30: * @author Gabriel Roldan, Axios Engineering
31: * @version $Id: GetLegendGraphicProducer.java 6326 2007-03-15 18:36:40Z jdeolive $
32: */
33: public interface GetLegendGraphicProducer {
34: /**
35: * Asks this legend graphic producer to create a graphic for the
36: * GetLegenGraphic request parameters held in <code>request</code>
37: *
38: * @param request the "parsed" request, where "parsed" means that it's
39: * properties are already validated so this method must not take
40: * care of verifying the requested layer exists and the like.
41: *
42: * @throws WmsException something goes wrong
43: */
44: void produceLegendGraphic(GetLegendGraphicRequest request)
45: throws WmsException;
46:
47: /**
48: * Writes the legend graphic created in produceLegendGraphic to the
49: * destination stream, though it could be used to encode the legend to the
50: * proper output format, provided that there are almost no risk that the
51: * encoding fails.
52: *
53: * @param out an open stream where to send the produced legend graphic to.
54: *
55: * @throws IOException if something goes wrong in the actual process of
56: * writing content to <code>out</code>.
57: * @throws ServiceException if something else goes wrong.
58: */
59: void writeTo(OutputStream out) throws IOException, ServiceException;
60:
61: /**
62: * Returns the MIME type of the content to be writen at
63: * <code>writeTo(OutputStream)</code>
64: *
65: * @return the output format
66: *
67: * @throws java.lang.IllegalStateException if this method is called before
68: * {@linkplain #produceLegendGraphic(GetLegendGraphicRequest)}.
69: */
70: String getContentType() throws java.lang.IllegalStateException;
71:
72: /**
73: * asks the legend graphic producer to stop processing since it will be no
74: * longer needed (for example, because the request was interrupted by the
75: * user)
76: */
77: void abort();
78: }
|