文字
分享

SVG 1.1 (Second Edition) – 16 August 2011Top ⋅ Contents ⋅ Previous ⋅ Next ⋅ Elements ⋅ Attributes ⋅ Properties

Appendix D: Java Language Binding

Contents

  • D.1 The Java language binding
  • D.2 Using SVG with the Java language

This appendix is informative, not normative.

D.1 The Java language binding

The Java language binding for the SVG Document Object Model definitions is available at:

1

http://www.w3.org/TR/2011/REC-SVG11-20110816/java-binding.zip

Note that this language binding is not normative. The IDL Definitions are the normative parts of the SVG DOM.

D.2 Using SVG with the Java language

When scripting SVG with a language such as ECMAScript, it is possible to embed script code directly in the SVG content using the ‘script’ element and the event attributes (e.g., ‘onload’ or ‘onclick’). For programming languages with a binary delivery format, such as the Java language, it is not possible to embed the code into the ‘script’ element or within the event attributes. Therefore there is a need to specify how such languages can bind to and handle events in the SVG document. The following technique describes how this should be done when using the Java language and what is expected of the User Agent that supports dynamic SVG content through the Java language.

  • The ‘script’ element should reference a jar file containing the compiled code to handle the events fired by the document. For example:

    1

    <script type="application/java-archive" xlink:href="myJavaHandlers.jar"/>

  • The manifest in the referenced jar file contains an entry, SVG-Handler-Class, defining the class responsible for initializing the event listeners on the SVG document. The entry should be a fully qualified class name. For example:

    1

    2

    Manifest-Version: 1.1

    SVG-Handler-Class: org.example.svg.SVGHandler

  • The class referenced by SVG-Handler-Class implements the EventListenerInitializer interface defined as:

    1

    2

    3

    public interface EventListenerInitializer {

      void initializeEventListeners(SVGDocument doc);

    }

  • The method initializeEventListeners() will be called by the User Agent before the onload event is triggered.

The event binding of other binary programming languages is not specified.

SVG 1.1 (Second Edition) – 16 August 2011Top ⋅ Contents ⋅ Previous ⋅ Next ⋅ Elements ⋅ Attributes ⋅ Properties