KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > bridge > UserAgent


1 /*
2
3    Copyright 2000-2004 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.bridge;
19
20 import java.awt.Cursor JavaDoc;
21 import java.awt.Point JavaDoc;
22 import java.awt.geom.AffineTransform JavaDoc;
23 import java.awt.geom.Dimension2D JavaDoc;
24
25 import org.apache.batik.gvt.event.EventDispatcher;
26 import org.apache.batik.gvt.text.Mark;
27 import org.apache.batik.util.ParsedURL;
28 import org.w3c.dom.Element JavaDoc;
29 import org.w3c.dom.svg.SVGAElement;
30
31 /**
32  * An interface that provides access to the User Agent informations
33  * needed by the bridge.
34  *
35  * @author <a HREF="mailto:cjolif@ilog.fr">Christophe Jolif</a>
36  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
37  * @version $Id: UserAgent.java,v 1.32 2005/03/27 08:58:30 cam Exp $
38  */

39 public interface UserAgent {
40
41     // <!> FIXME: TO BE REMOVED
42
/**
43      * Returns the event dispatcher to use.
44      */

45     EventDispatcher getEventDispatcher();
46
47     /**
48      * Returns the default size of the viewport.
49      */

50     Dimension2D JavaDoc getViewportSize();
51
52     /**
53      * Displays an error resulting from the specified Exception.
54      */

55     void displayError(Exception JavaDoc ex);
56
57     /**
58      * Displays a message in the User Agent interface.
59      */

60     void displayMessage(String JavaDoc message);
61
62     /**
63      * Shows an alert dialog box.
64      */

65     void showAlert(String JavaDoc message);
66
67     /**
68      * Shows a prompt dialog box.
69      */

70     String JavaDoc showPrompt(String JavaDoc message);
71
72     /**
73      * Shows a prompt dialog box.
74      */

75     String JavaDoc showPrompt(String JavaDoc message, String JavaDoc defaultValue);
76
77     /**
78      * Shows a confirm dialog box.
79      */

80     boolean showConfirm(String JavaDoc message);
81
82     /**
83      * Returns the size of a px CSS unit in millimeters.
84      */

85     float getPixelUnitToMillimeter();
86
87     /**
88      * Returns the size of a px CSS unit in millimeters.
89      * This will be removed after next release.
90      * @see #getPixelUnitToMillimeter()
91      */

92     float getPixelToMM();
93
94     /**
95      * Returns the medium font size.
96      */

97     float getMediumFontSize();
98
99     /**
100      * Returns a lighter font-weight.
101      */

102     float getLighterFontWeight(float f);
103
104     /**
105      * Returns a bolder font-weight.
106      */

107     float getBolderFontWeight(float f);
108
109     /**
110      * Returns the default font family.
111      */

112     String JavaDoc getDefaultFontFamily();
113
114     /**
115      * Returns the language settings.
116      */

117     String JavaDoc getLanguages();
118
119     /**
120      * Returns the user stylesheet uri.
121      * @return null if no user style sheet was specified.
122      */

123     String JavaDoc getUserStyleSheetURI();
124
125     /**
126      * Opens a link.
127      * @param elt The activated link element.
128      */

129     void openLink(SVGAElement elt);
130
131     /**
132      * Informs the user agent to change the cursor.
133      * @param cursor the new cursor
134      */

135     void setSVGCursor(Cursor JavaDoc cursor);
136
137     /**
138      * Informs the user agent that the text selection has changed.
139      * @param start The Mark for the start of the selection.
140      * @param end The Mark for the end of the selection.
141      */

142     void setTextSelection(Mark start, Mark end);
143
144     /**
145      * Informs the user agent that the text selection should be cleared.
146      */

147     void deselectAll();
148
149     /**
150      * Returns the class name of the XML parser.
151      */

152     String JavaDoc getXMLParserClassName();
153
154     /**
155      * Returns true if the XML parser must be in validation mode, false
156      * otherwise.
157      */

158     boolean isXMLParserValidating();
159
160     /**
161      * Returns the <code>AffineTransform</code> currently
162      * applied to the drawing by the UserAgent.
163      */

164     AffineTransform JavaDoc getTransform();
165
166     /**
167      * Sets the <code>AffineTransform</code> currently
168      * applied to the drawing by the UserAgent.
169      */

170     void setTransform(AffineTransform JavaDoc at);
171
172     /**
173      * Returns this user agent's CSS media.
174      */

175     String JavaDoc getMedia();
176
177     /**
178      * Returns this user agent's alternate style-sheet title.
179      */

180     String JavaDoc getAlternateStyleSheet();
181
182     /**
183      * Returns the location on the screen of the
184      * client area in the UserAgent.
185      */

186     Point JavaDoc getClientAreaLocationOnScreen();
187
188     /**
189      * Tells whether the given feature is supported by this
190      * user agent.
191      */

192     boolean hasFeature(String JavaDoc s);
193
194     /**
195      * Tells whether the given extension is supported by this
196      * user agent.
197      */

198     boolean supportExtension(String JavaDoc s);
199
200     /**
201      * Lets the bridge tell the user agent that the following
202      * extension is supported by the bridge.
203      */

204     void registerExtension(BridgeExtension ext);
205
206     /**
207      * Notifies the UserAgent that the input element
208      * has been found in the document. This is sometimes
209      * called, for example, to handle &lt;a&gt; or
210      * &lt;title&gt; elements in a UserAgent-dependant
211      * way.
212      */

213     void handleElement(Element JavaDoc elt, Object JavaDoc data);
214
215     /**
216      * Returns the security settings for the given script
217      * type, script url and document url
218      *
219      * @param scriptType type of script, as found in the
220      * type attribute of the &lt;script&gt; element.
221      * @param scriptURL url for the script, as defined in
222      * the script's xlink:href attribute. If that
223      * attribute was empty, then this parameter should
224      * be null
225      * @param docURL url for the document into which the
226      * script was found.
227      */

228     ScriptSecurity getScriptSecurity(String JavaDoc scriptType,
229                                      ParsedURL scriptURL,
230                                      ParsedURL docURL);
231     
232     /**
233      * This method throws a SecurityException if the script
234      * of given type, found at url and referenced from docURL
235      * should not be loaded.
236      *
237      * This is a convenience method to call checkLoadScript
238      * on the ScriptSecurity strategy returned by
239      * getScriptSecurity.
240      *
241      * @param scriptType type of script, as found in the
242      * type attribute of the &lt;script&gt; element.
243      * @param scriptURL url for the script, as defined in
244      * the script's xlink:href attribute. If that
245      * attribute was empty, then this parameter should
246      * be null
247      * @param docURL url for the document into which the
248      * script was found.
249      */

250     void checkLoadScript(String JavaDoc scriptType,
251                          ParsedURL scriptURL,
252                          ParsedURL docURL) throws SecurityException JavaDoc;
253
254     /**
255      * Returns the security settings for the given resource
256      * url and document url
257      *
258      * @param resourceURL url for the resource, as defined in
259      * the resource's xlink:href attribute. If that
260      * attribute was empty, then this parameter should
261      * be null
262      * @param docURL url for the document into which the
263      * resource was found.
264      */

265     ExternalResourceSecurity
266         getExternalResourceSecurity(ParsedURL resourceURL,
267                                     ParsedURL docURL);
268     
269     /**
270      * This method throws a SecurityException if the resource
271      * found at url and referenced from docURL
272      * should not be loaded.
273      *
274      * This is a convenience method to call checkLoadExternalResource
275      * on the ExternalResourceSecurity strategy returned by
276      * getExternalResourceSecurity.
277      *
278      * @param resourceURL url for the resource, as defined in
279      * the resource's xlink:href attribute. If that
280      * attribute was empty, then this parameter should
281      * be null
282      * @param docURL url for the document into which the
283      * resource was found.
284      */

285     void checkLoadExternalResource(ParsedURL resourceURL,
286                                    ParsedURL docURL) throws SecurityException JavaDoc;
287
288 }
289
Popular Tags