001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.bridge;
020:
021: import java.awt.Cursor;
022: import java.awt.Point;
023: import java.awt.geom.AffineTransform;
024: import java.awt.geom.Dimension2D;
025:
026: import org.apache.batik.gvt.event.EventDispatcher;
027: import org.apache.batik.gvt.text.Mark;
028: import org.apache.batik.util.ParsedURL;
029: import org.w3c.dom.Element;
030: import org.w3c.dom.svg.SVGAElement;
031: import org.w3c.dom.svg.SVGDocument;
032:
033: /**
034: * An interface that provides access to the User Agent informations
035: * needed by the bridge.
036: *
037: * @author <a href="mailto:cjolif@ilog.fr">Christophe Jolif</a>
038: * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
039: * @version $Id: UserAgent.java 475477 2006-11-15 22:44:28Z cam $
040: */
041: public interface UserAgent {
042:
043: // <!> FIXME: TO BE REMOVED
044: /**
045: * Returns the event dispatcher to use.
046: */
047: EventDispatcher getEventDispatcher();
048:
049: /**
050: * Returns the default size of the viewport.
051: */
052: Dimension2D getViewportSize();
053:
054: /**
055: * Displays an error resulting from the specified Exception.
056: */
057: void displayError(Exception ex);
058:
059: /**
060: * Displays a message in the User Agent interface.
061: */
062: void displayMessage(String message);
063:
064: /**
065: * Shows an alert dialog box.
066: */
067: void showAlert(String message);
068:
069: /**
070: * Shows a prompt dialog box.
071: */
072: String showPrompt(String message);
073:
074: /**
075: * Shows a prompt dialog box.
076: */
077: String showPrompt(String message, String defaultValue);
078:
079: /**
080: * Shows a confirm dialog box.
081: */
082: boolean showConfirm(String message);
083:
084: /**
085: * Returns the size of a px CSS unit in millimeters.
086: */
087: float getPixelUnitToMillimeter();
088:
089: /**
090: * Returns the size of a px CSS unit in millimeters.
091: * This will be removed after next release.
092: * @see #getPixelUnitToMillimeter()
093: */
094: float getPixelToMM();
095:
096: /**
097: * Returns the medium font size.
098: */
099: float getMediumFontSize();
100:
101: /**
102: * Returns a lighter font-weight.
103: */
104: float getLighterFontWeight(float f);
105:
106: /**
107: * Returns a bolder font-weight.
108: */
109: float getBolderFontWeight(float f);
110:
111: /**
112: * Returns the default font family.
113: */
114: String getDefaultFontFamily();
115:
116: /**
117: * Returns the language settings.
118: */
119: String getLanguages();
120:
121: /**
122: * Returns the user stylesheet uri.
123: * @return null if no user style sheet was specified.
124: */
125: String getUserStyleSheetURI();
126:
127: /**
128: * Opens a link.
129: * @param elt The activated link element.
130: */
131: void openLink(SVGAElement elt);
132:
133: /**
134: * Informs the user agent to change the cursor.
135: * @param cursor the new cursor
136: */
137: void setSVGCursor(Cursor cursor);
138:
139: /**
140: * Informs the user agent that the text selection has changed.
141: * @param start The Mark for the start of the selection.
142: * @param end The Mark for the end of the selection.
143: */
144: void setTextSelection(Mark start, Mark end);
145:
146: /**
147: * Informs the user agent that the text selection should be cleared.
148: */
149: void deselectAll();
150:
151: /**
152: * Returns the class name of the XML parser.
153: */
154: String getXMLParserClassName();
155:
156: /**
157: * Returns true if the XML parser must be in validation mode, false
158: * otherwise.
159: */
160: boolean isXMLParserValidating();
161:
162: /**
163: * Returns the <code>AffineTransform</code> currently
164: * applied to the drawing by the UserAgent.
165: */
166: AffineTransform getTransform();
167:
168: /**
169: * Sets the <code>AffineTransform</code> currently
170: * applied to the drawing by the UserAgent.
171: */
172: void setTransform(AffineTransform at);
173:
174: /**
175: * Returns this user agent's CSS media.
176: */
177: String getMedia();
178:
179: /**
180: * Returns this user agent's alternate style-sheet title.
181: */
182: String getAlternateStyleSheet();
183:
184: /**
185: * Returns the location on the screen of the
186: * client area in the UserAgent.
187: */
188: Point getClientAreaLocationOnScreen();
189:
190: /**
191: * Tells whether the given feature is supported by this
192: * user agent.
193: */
194: boolean hasFeature(String s);
195:
196: /**
197: * Tells whether the given extension is supported by this
198: * user agent.
199: */
200: boolean supportExtension(String s);
201:
202: /**
203: * Lets the bridge tell the user agent that the following
204: * extension is supported by the bridge.
205: */
206: void registerExtension(BridgeExtension ext);
207:
208: /**
209: * Notifies the UserAgent that the input element
210: * has been found in the document. This is sometimes
211: * called, for example, to handle <a> or
212: * <title> elements in a UserAgent-dependant
213: * way.
214: */
215: void handleElement(Element elt, Object data);
216:
217: /**
218: * Returns the security settings for the given script
219: * type, script url and document url
220: *
221: * @param scriptType type of script, as found in the
222: * type attribute of the <script> element.
223: * @param scriptURL url for the script, as defined in
224: * the script's xlink:href attribute. If that
225: * attribute was empty, then this parameter should
226: * be null
227: * @param docURL url for the document into which the
228: * script was found.
229: */
230: ScriptSecurity getScriptSecurity(String scriptType,
231: ParsedURL scriptURL, ParsedURL docURL);
232:
233: /**
234: * This method throws a SecurityException if the script
235: * of given type, found at url and referenced from docURL
236: * should not be loaded.
237: *
238: * This is a convenience method to call checkLoadScript
239: * on the ScriptSecurity strategy returned by
240: * getScriptSecurity.
241: *
242: * @param scriptType type of script, as found in the
243: * type attribute of the <script> element.
244: * @param scriptURL url for the script, as defined in
245: * the script's xlink:href attribute. If that
246: * attribute was empty, then this parameter should
247: * be null
248: * @param docURL url for the document into which the
249: * script was found.
250: */
251: void checkLoadScript(String scriptType, ParsedURL scriptURL,
252: ParsedURL docURL) throws SecurityException;
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 getExternalResourceSecurity(
266: ParsedURL resourceURL, ParsedURL docURL);
267:
268: /**
269: * This method throws a SecurityException if the resource
270: * found at url and referenced from docURL
271: * should not be loaded.
272: *
273: * This is a convenience method to call checkLoadExternalResource
274: * on the ExternalResourceSecurity strategy returned by
275: * getExternalResourceSecurity.
276: *
277: * @param resourceURL url for the resource, as defined in
278: * the resource's xlink:href attribute. If that
279: * attribute was empty, then this parameter should
280: * be null
281: * @param docURL url for the document into which the
282: * resource was found.
283: */
284: void checkLoadExternalResource(ParsedURL resourceURL,
285: ParsedURL docURL) throws SecurityException;
286:
287: /**
288: * This method should return an image to be displayed when an image
289: * can't be loaded. If it returns 'null' then a BridgeException will
290: * be thrown.
291: *
292: * @param e The <image> element that can't be loaded.
293: * @param url The resolved url that can't be loaded.
294: * @param message As best as can be determined the reason it can't be
295: * loaded (not available, corrupt, unknown format, ...).
296: */
297: SVGDocument getBrokenLinkDocument(Element e, String url,
298: String message);
299: }
|