1 /*
2
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
9
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 1733416 2016-03-03 07:07:13Z gadams $
36 */
37 public class SVGBrokenLinkProvider
38 extends DefaultBrokenLinkProvider
39 implements ErrorConstants {
40
41 public SVGBrokenLinkProvider() {
42 }
43
44 /**
45 * This method is responsible for constructing an image that will
46 * represent the missing image in the document. This method
47 * recives information about the reason a broken link image is
48 * being requested in the <code>code</code> and <code>params</code>
49 * parameters. These parameters may be used to generate nicely
50 * localized messages for insertion into the broken link image, or
51 * for selecting the broken link image returned.
52 *
53 * @param code This is the reason the image is unavailable should
54 * be taken from ErrorConstants.
55 * @param params This is more detailed information about
56 * the circumstances of the failure. */
57 public Filter getBrokenLinkImage(Object base, String code,
58 Object[] params) {
59 String message = formatMessage(base, code, params);
60 Map props = new HashMap();
61 props.put(BROKEN_LINK_PROPERTY, message);
62
63 CompositeGraphicsNode cgn = new CompositeGraphicsNode();
64 return new GraphicsNodeRable8Bit(cgn, props);
65 }
66 }
67