01: /*
02:
03: Licensed to the Apache Software Foundation (ASF) under one or more
04: contributor license agreements. See the NOTICE file distributed with
05: this work for additional information regarding copyright ownership.
06: The ASF licenses this file to You under the Apache License, Version 2.0
07: (the "License"); you may not use this file except in compliance with
08: the License. You may obtain a copy of the License at
09:
10: http://www.apache.org/licenses/LICENSE-2.0
11:
12: Unless required by applicable law or agreed to in writing, software
13: distributed under the License is distributed on an "AS IS" BASIS,
14: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: See the License for the specific language governing permissions and
16: limitations under the License.
17:
18: */
19: package org.apache.batik.bridge;
20:
21: import java.util.HashMap;
22: import java.util.Map;
23:
24: import org.apache.batik.ext.awt.image.renderable.Filter;
25: import org.apache.batik.ext.awt.image.spi.DefaultBrokenLinkProvider;
26: import org.apache.batik.gvt.CompositeGraphicsNode;
27: import org.apache.batik.gvt.filter.GraphicsNodeRable8Bit;
28:
29: /**
30: * This interface is to be used to provide alternate ways of
31: * generating a placeholder image when the ImageTagRegistry
32: * fails to handle a given reference.
33: *
34: * @author <a href="mailto:thomas.deweese@kodak.com">Thomas DeWeese</a>
35: * @version $Id: SVGBrokenLinkProvider.java 475477 2006-11-15 22:44:28Z cam $
36: */
37: public class SVGBrokenLinkProvider extends DefaultBrokenLinkProvider
38: implements ErrorConstants {
39:
40: public SVGBrokenLinkProvider() {
41: }
42:
43: /**
44: * This method is responsible for constructing an image that will
45: * represent the missing image in the document. This method
46: * recives information about the reason a broken link image is
47: * being requested in the <tt>code</tt> and <tt>params</tt>
48: * parameters. These parameters may be used to generate nicely
49: * localized messages for insertion into the broken link image, or
50: * for selecting the broken link image returned.
51: *
52: * @param code This is the reason the image is unavailable should
53: * be taken from ErrorConstants.
54: * @param params This is more detailed information about
55: * the circumstances of the failure. */
56: public Filter getBrokenLinkImage(Object base, String code,
57: Object[] params) {
58: String message = formatMessage(base, code, params);
59: Map props = new HashMap();
60: props.put(BROKEN_LINK_PROPERTY, message);
61:
62: CompositeGraphicsNode cgn = new CompositeGraphicsNode();
63: return new GraphicsNodeRable8Bit(cgn, props);
64: }
65: }
|