Class UserAgentAdapter

java.lang.Object
org.apache.batik.bridge.UserAgentAdapter
All Implemented Interfaces:
UserAgent
Direct Known Subclasses:
SVGAbstractTranscoder.SVGAbstractTranscoderUserAgent

public class UserAgentAdapter extends Object implements UserAgent
An abstract user agent adaptor implementation. It exists to simply the creation of UserAgent instances.
  • Field Details

    • FEATURES

      protected Set FEATURES
    • extensions

      protected Set extensions
    • ctx

      protected BridgeContext ctx
      The BridgeContext to use for error information.
  • Constructor Details

    • UserAgentAdapter

      public UserAgentAdapter()
  • Method Details

    • setBridgeContext

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

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

      public Dimension2D getViewportSize()
      Returns the default size of this user agent (400x400).
      Specified by:
      getViewportSize in interface UserAgent
    • displayMessage

      public void displayMessage(String message)
      Display the specified message.
      Specified by:
      displayMessage in interface UserAgent
    • 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))
      Specified by:
      displayError in interface UserAgent
    • showAlert

      public void showAlert(String message)
      Shows an alert dialog box.
      Specified by:
      showAlert in interface UserAgent
    • showPrompt

      public String showPrompt(String message)
      Shows a prompt dialog box.
      Specified by:
      showPrompt in interface UserAgent
    • showPrompt

      public String showPrompt(String message, String defaultValue)
      Shows a prompt dialog box.
      Specified by:
      showPrompt in interface UserAgent
    • showConfirm

      public boolean showConfirm(String message)
      Shows a confirm dialog box.
      Specified by:
      showConfirm in interface UserAgent
    • getPixelUnitToMillimeter

      public float getPixelUnitToMillimeter()
      Returns the size of a px CSS unit in millimeters.
      Specified by:
      getPixelUnitToMillimeter in interface UserAgent
    • getPixelToMM

      public float getPixelToMM()
      Returns the size of a px CSS unit in millimeters. This will be removed after next release.
      Specified by:
      getPixelToMM in interface UserAgent
      See Also:
    • getDefaultFontFamily

      public String getDefaultFontFamily()
      Returns the default font family.
      Specified by:
      getDefaultFontFamily in interface UserAgent
    • getMediumFontSize

      public float getMediumFontSize()
      Returns the medium font size.
      Specified by:
      getMediumFontSize in interface UserAgent
    • getLighterFontWeight

      public float getLighterFontWeight(float f)
      Returns a lighter font-weight.
      Specified by:
      getLighterFontWeight in interface UserAgent
    • getBolderFontWeight

      public float getBolderFontWeight(float f)
      Returns a bolder font-weight.
      Specified by:
      getBolderFontWeight in interface UserAgent
    • getLanguages

      public String getLanguages()
      Returns the user language "en" (english).
      Specified by:
      getLanguages in interface UserAgent
    • getMedia

      public String getMedia()
      Returns this user agent's CSS media.
      Specified by:
      getMedia in interface UserAgent
    • getAlternateStyleSheet

      public String getAlternateStyleSheet()
      Returns this user agent's alternate style-sheet title.
      Specified by:
      getAlternateStyleSheet in interface UserAgent
    • getUserStyleSheetURI

      public String getUserStyleSheetURI()
      Returns the user stylesheet
      Specified by:
      getUserStyleSheetURI in interface UserAgent
      Returns:
      null if no user style sheet was specified.
    • getXMLParserClassName

      public String getXMLParserClassName()
      Returns the XML parser to use
      Specified by:
      getXMLParserClassName in interface UserAgent
    • isXMLParserValidating

      public boolean isXMLParserValidating()
      Returns false. The XML parser is not in validation mode.
      Specified by:
      isXMLParserValidating in interface UserAgent
    • getEventDispatcher

      public EventDispatcher getEventDispatcher()
      Unsupported operation.
      Specified by:
      getEventDispatcher in interface UserAgent
    • openLink

      public void openLink(org.w3c.dom.svg.SVGAElement elt)
      Unsupported operation.
      Specified by:
      openLink in interface UserAgent
      Parameters:
      elt - The activated link element.
    • setSVGCursor

      public void setSVGCursor(Cursor cursor)
      Unsupported operation.
      Specified by:
      setSVGCursor in interface UserAgent
      Parameters:
      cursor - the new cursor
    • setTextSelection

      public void setTextSelection(Mark start, Mark end)
      This user agent doesn't display text selections.
      Specified by:
      setTextSelection in interface UserAgent
      Parameters:
      start - The Mark for the start of the selection.
      end - The Mark for the end of the selection.
    • deselectAll

      public void deselectAll()
      This user agent doesn't display text selections so nothing to clear.
      Specified by:
      deselectAll in interface UserAgent
    • runThread

      public void runThread(Thread t)
      Unsupported operation.
    • getTransform

      public AffineTransform getTransform()
      Unsupported operation.
      Specified by:
      getTransform in interface UserAgent
    • setTransform

      public void setTransform(AffineTransform at)
      Unsupported operation.
      Specified by:
      setTransform in interface UserAgent
    • getClientAreaLocationOnScreen

      public Point getClientAreaLocationOnScreen()
      Unsupported operation.
      Specified by:
      getClientAreaLocationOnScreen in interface UserAgent
    • hasFeature

      public boolean hasFeature(String s)
      Tells whether the given feature is supported by this user agent.
      Specified by:
      hasFeature in interface UserAgent
    • supportExtension

      public boolean supportExtension(String s)
      Tells whether the given extension is supported by this user agent.
      Specified by:
      supportExtension in interface UserAgent
    • registerExtension

      public void registerExtension(BridgeExtension ext)
      Lets the bridge tell the user agent that the following ex tension is supported by the bridge.
      Specified by:
      registerExtension in interface UserAgent
    • 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.
      Specified by:
      handleElement in interface UserAgent
    • getScriptSecurity

      public ScriptSecurity getScriptSecurity(String scriptType, ParsedURL scriptURL, ParsedURL docURL)
      Returns the security settings for the given script type, script url and document url
      Specified by:
      getScriptSecurity in interface UserAgent
      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.
    • checkLoadScript

      public void checkLoadScript(String scriptType, ParsedURL scriptURL, ParsedURL docURL) throws SecurityException
      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.
      Specified by:
      checkLoadScript in interface UserAgent
      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.
      Throws:
      SecurityException
    • getExternalResourceSecurity

      public ExternalResourceSecurity getExternalResourceSecurity(ParsedURL resourceURL, ParsedURL docURL)
      Returns the security settings for the given resource url and document url
      Specified by:
      getExternalResourceSecurity in interface UserAgent
      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.
    • checkLoadExternalResource

      public void checkLoadExternalResource(ParsedURL resourceURL, ParsedURL docURL) throws SecurityException
      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.
      Specified by:
      checkLoadExternalResource in interface UserAgent
      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.
      Throws:
      SecurityException
    • getStandardLighterFontWeight

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

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

      public org.w3c.dom.svg.SVGDocument getBrokenLinkDocument(Element e, String url, String message)
      This Implementation simply throws a BridgeException.
      Specified by:
      getBrokenLinkDocument in interface UserAgent
      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,...).
    • loadDocument

      public void loadDocument(String url)
      This method should load a new document described by the supplied URL.
      Specified by:
      loadDocument in interface UserAgent
      Parameters:
      url - The url to be loaded as a string.
    • getFontFamilyResolver

      public FontFamilyResolver getFontFamilyResolver()
      Returns the Font Family Resolver
      Specified by:
      getFontFamilyResolver in interface UserAgent