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.ext.awt.image.spi;
20:
21: import java.awt.Image;
22:
23: import org.apache.batik.ext.awt.image.renderable.Filter;
24:
25: /**
26: * This interface is to be used to provide alternate ways of
27: * generating a placeholder image when the ImageTagRegistry
28: * fails to handle a given reference.
29: *
30: * @version $Id: BrokenLinkProvider.java 498740 2007-01-22 18:35:57Z dvholten $
31: */
32: public abstract class BrokenLinkProvider {
33:
34: /**
35: * The image returned by getBrokenLinkImage should always
36: * return some value when queried for the BROKEN_LINK_PROPERTY.
37: * This allows code the determine if the image is the 'real'
38: * image or the broken link image, which may be important for
39: * the application of profiles etc.
40: */
41: public static final String BROKEN_LINK_PROPERTY = "org.apache.batik.BrokenLinkImage";
42:
43: /**
44: * This method is responsbile 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 base The object to use for Message decoding.
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: */
58: public abstract Filter getBrokenLinkImage(Object base, String code,
59: Object[] params);
60:
61: public static boolean hasBrokenLinkProperty(Filter f) {
62: Object o = f.getProperty(BROKEN_LINK_PROPERTY);
63: if (o == null)
64: return false;
65: if (o == Image.UndefinedProperty)
66: return false;
67: return true;
68: }
69:
70: }
|