org.apache.batik.bridge

Class UserAgentAdapter

public class UserAgentAdapter extends Object implements UserAgent

An abstract user agent adaptor implementation. It exists to simply the creation of UserAgent instances.
Field Summary
protected BridgeContextctx
The BridgeContext to use for error information.
protected Setextensions
protected SetFEATURES
Method Summary
voidaddStdFeatures()
Adds the standard SVG feature strings to the set of features supported by this user agent.
voidcheckLoadExternalResource(ParsedURL resourceURL, ParsedURL docURL)
This method throws a SecurityException if the resource found at url and referenced from docURL should not be loaded.
voidcheckLoadScript(String scriptType, ParsedURL scriptURL, ParsedURL docURL)
This method throws a SecurityException if the script of given type, found at url and referenced from docURL should not be loaded.
voiddeselectAll()
This user agent doesn't display text selections so nothing to clear.
voiddisplayError(String message)
Display the specified error message (forwards call to displayMessage).
voiddisplayError(Exception e)
Display the specified error (forwards call to displayError(String))
voiddisplayMessage(String message)
Display the specified message.
StringgetAlternateStyleSheet()
Returns this user agent's alternate style-sheet title.
floatgetBolderFontWeight(float f)
Returns a bolder font-weight.
SVGDocumentgetBrokenLinkDocument(Element e, String url, String message)
This Implementation simply throws a BridgeException.
PointgetClientAreaLocationOnScreen()
Unsupported operation.
StringgetDefaultFontFamily()
Returns the default font family.
EventDispatchergetEventDispatcher()
Unsupported operation.
ExternalResourceSecuritygetExternalResourceSecurity(ParsedURL resourceURL, ParsedURL docURL)
Returns the security settings for the given resource url and document url
StringgetLanguages()
Returns the user language "en" (english).
floatgetLighterFontWeight(float f)
Returns a lighter font-weight.
StringgetMedia()
Returns this user agent's CSS media.
floatgetMediumFontSize()
Returns the medium font size.
floatgetPixelToMM()
Returns the size of a px CSS unit in millimeters.
floatgetPixelUnitToMillimeter()
Returns the size of a px CSS unit in millimeters.
ScriptSecuritygetScriptSecurity(String scriptType, ParsedURL scriptURL, ParsedURL docURL)
Returns the security settings for the given script type, script url and document url
static floatgetStandardBolderFontWeight(float f)
Returns a bolder font-weight.
static floatgetStandardLighterFontWeight(float f)
Returns a lighter font-weight.
AffineTransformgetTransform()
Unsupported operation.
StringgetUserStyleSheetURI()
Returns the user stylesheet
Dimension2DgetViewportSize()
Returns the default size of this user agent (400x400).
StringgetXMLParserClassName()
Returns the XML parser to use
voidhandleElement(Element elt, Object data)
Notifies the UserAgent that the input element has been found in the document.
booleanhasFeature(String s)
Tells whether the given feature is supported by this user agent.
booleanisXMLParserValidating()
Returns false.
voidopenLink(SVGAElement elt)
Unsupported operation.
voidregisterExtension(BridgeExtension ext)
Lets the bridge tell the user agent that the following ex tension is supported by the bridge.
voidrunThread(Thread t)
Unsupported operation.
voidsetBridgeContext(BridgeContext ctx)
Sets the BridgeContext to be used for error information.
voidsetSVGCursor(Cursor cursor)
Unsupported operation.
voidsetTextSelection(Mark start, Mark end)
This user agent doesn't display text selections.
voidsetTransform(AffineTransform at)
Unsupported operation.
voidshowAlert(String message)
Shows an alert dialog box.
booleanshowConfirm(String message)
Shows a confirm dialog box.
StringshowPrompt(String message)
Shows a prompt dialog box.
StringshowPrompt(String message, String defaultValue)
Shows a prompt dialog box.
booleansupportExtension(String s)
Tells whether the given extension is supported by this user agent.

Field Detail

ctx

protected BridgeContext ctx
The BridgeContext to use for error information.

extensions

protected Set extensions

FEATURES

protected Set FEATURES

Method Detail

addStdFeatures

public void addStdFeatures()
Adds the standard SVG feature strings to the set of features supported by this user agent.

checkLoadExternalResource

public void checkLoadExternalResource(ParsedURL resourceURL, ParsedURL docURL)
This method throws a SecurityException if the resource found at url and referenced from docURL should not be loaded. This is a convenience method to call checkLoadExternalResource on the ExternalResourceSecurity strategy returned by getExternalResourceSecurity.

Parameters: resourceURL url for the resource, as defined in the resource's xlink:href attribute. If that attribute was empty, then this parameter should be null docURL url for the document into which the resource was found.

checkLoadScript

public void checkLoadScript(String scriptType, ParsedURL scriptURL, ParsedURL docURL)
This method throws a SecurityException if the script of given type, found at url and referenced from docURL should not be loaded. This is a convenience method to call checkLoadScript on the ScriptSecurity strategy returned by getScriptSecurity.

Parameters: scriptType type of script, as found in the type attribute of the <script> element. scriptURL url for the script, as defined in the script's xlink:href attribute. If that attribute was empty, then this parameter should be null docURL url for the document into which the script was found.

deselectAll

public void deselectAll()
This user agent doesn't display text selections so nothing to clear.

displayError

public void displayError(String message)
Display the specified error message (forwards call to displayMessage).

displayError

public void displayError(Exception e)
Display the specified error (forwards call to displayError(String))

displayMessage

public void displayMessage(String message)
Display the specified message.

getAlternateStyleSheet

public String getAlternateStyleSheet()
Returns this user agent's alternate style-sheet title.

getBolderFontWeight

public float getBolderFontWeight(float f)
Returns a bolder font-weight.

getBrokenLinkDocument

public SVGDocument getBrokenLinkDocument(Element e, String url, String message)
This Implementation simply throws a BridgeException.

Parameters: e The <image> element that can't be loaded. url The resolved url that can't be loaded. message As best as can be determined the reason it can't be loaded (not available, corrupt, unknown format,...).

getClientAreaLocationOnScreen

public Point getClientAreaLocationOnScreen()
Unsupported operation.

getDefaultFontFamily

public String getDefaultFontFamily()
Returns the default font family.

getEventDispatcher

public EventDispatcher getEventDispatcher()
Unsupported operation.

getExternalResourceSecurity

public ExternalResourceSecurity getExternalResourceSecurity(ParsedURL resourceURL, ParsedURL docURL)
Returns the security settings for the given resource url and document url

Parameters: resourceURL url for the resource, as defined in the resource's xlink:href attribute. If that attribute was empty, then this parameter should be null docURL url for the document into which the resource was found.

getLanguages

public String getLanguages()
Returns the user language "en" (english).

getLighterFontWeight

public float getLighterFontWeight(float f)
Returns a lighter font-weight.

getMedia

public String getMedia()
Returns this user agent's CSS media.

getMediumFontSize

public float getMediumFontSize()
Returns the medium font size.

getPixelToMM

public float getPixelToMM()
Returns the size of a px CSS unit in millimeters. This will be removed after next release.

See Also: getPixelUnitToMillimeter

getPixelUnitToMillimeter

public float getPixelUnitToMillimeter()
Returns the size of a px CSS unit in millimeters.

getScriptSecurity

public ScriptSecurity getScriptSecurity(String scriptType, ParsedURL scriptURL, ParsedURL docURL)
Returns the security settings for the given script type, script url and document url

Parameters: scriptType type of script, as found in the type attribute of the <script> element. scriptURL url for the script, as defined in the script's xlink:href attribute. If that attribute was empty, then this parameter should be null docURL url for the document into which the script was found.

getStandardBolderFontWeight

public static float getStandardBolderFontWeight(float f)
Returns a bolder font-weight.

getStandardLighterFontWeight

public static float getStandardLighterFontWeight(float f)
Returns a lighter font-weight.

getTransform

public AffineTransform getTransform()
Unsupported operation.

getUserStyleSheetURI

public String getUserStyleSheetURI()
Returns the user stylesheet

getViewportSize

public Dimension2D getViewportSize()
Returns the default size of this user agent (400x400).

getXMLParserClassName

public String getXMLParserClassName()
Returns the XML parser to use

handleElement

public void handleElement(Element elt, Object data)
Notifies the UserAgent that the input element has been found in the document. This is sometimes called, for example, to handle <a> or <title> elements in a UserAgent-dependant way.

hasFeature

public boolean hasFeature(String s)
Tells whether the given feature is supported by this user agent.

isXMLParserValidating

public boolean isXMLParserValidating()
Returns false. The XML parser is not in validation mode.

openLink

public void openLink(SVGAElement elt)
Unsupported operation.

registerExtension

public void registerExtension(BridgeExtension ext)
Lets the bridge tell the user agent that the following ex tension is supported by the bridge.

runThread

public void runThread(Thread t)
Unsupported operation.

setBridgeContext

public void setBridgeContext(BridgeContext ctx)
Sets the BridgeContext to be used for error information.

setSVGCursor

public void setSVGCursor(Cursor cursor)
Unsupported operation.

setTextSelection

public void setTextSelection(Mark start, Mark end)
This user agent doesn't display text selections.

setTransform

public void setTransform(AffineTransform at)
Unsupported operation.

showAlert

public void showAlert(String message)
Shows an alert dialog box.

showConfirm

public boolean showConfirm(String message)
Shows a confirm dialog box.

showPrompt

public String showPrompt(String message)
Shows a prompt dialog box.

showPrompt

public String showPrompt(String message, String defaultValue)
Shows a prompt dialog box.

supportExtension

public boolean supportExtension(String s)
Tells whether the given extension is supported by this user agent.
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.