Skip to content

Commit 0a2a206

Browse files
committed
Add some documentation.
1 parent 0bc6c6e commit 0a2a206

File tree

6 files changed

+152
-0
lines changed

6 files changed

+152
-0
lines changed

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,30 @@ projects.
55

66
<br/>
77

8+
## Why the Web APIs project?
9+
10+
[EchoSVG](https://github.com/css4j/echosvg) is a fork of Apache Batik, an SVG
11+
toolkit in the Java language. Both projects require Java bindings based on old
12+
versions of the SVG and SMIL DOM APIs.
13+
14+
Apache Batik uses the `xml-apis-ext-1.3.04.jar` package, which is unsuitable for
15+
modular Java due to the fact that it also contains the SAC package which is found
16+
in other packages.
17+
18+
This project offers separate packages for SVGOM and SMIL which aren't the exact
19+
ones shipped by `xml-apis-ext-1.3.04` but are compatible with both EchoSVG and
20+
Batik.
21+
22+
The code is based on old Java bindings downloaded from the W3C, and several
23+
method signatures had to be modified so they matched the implementations in
24+
EchoSVG/Batik. Although it would have been easy to upgrade EchoSVG instead, that
25+
would have created problems in cases where both `xml-apis-ext-1.3.04.jar` and
26+
`svgom-api` or `smil-api` were found in the classpath or modulepath (which is
27+
conceivable if, for example, somebody is using EchoSVG and Apache FOP in the
28+
same project).
29+
30+
<br/>
31+
832
## Building from source
933

1034
### Requirements
@@ -13,6 +37,7 @@ To build `web-apis` you need the following software installed:
1337

1438
- The [Git version control system](https://git-scm.com/downloads) is required to
1539
obtain the sources. Any recent version should suffice.
40+
1641
- Java 11 or later. You can install it from your favourite package manager or by
1742
downloading from [Adoptium](https://adoptium.net/).
1843

@@ -34,7 +59,9 @@ or just `gradlew build` (without the `./`) on a Windows command prompt.
3459
### Deploying to a Maven repository
3560

3661
Use:
62+
3763
- `gradlew build publishToMavenLocal` to install in your local Maven repository.
64+
3865
- `gradlew publish` to deploy to a (generally remote) Maven repository.
3966

4067
Before deploying to a remote Maven repository, please read the
@@ -50,6 +77,7 @@ to learn which properties you need to set (like `mavenReleaseRepoUrl`or
5077

5178
If your Gradle project depends on any of the web-apis modules, you can use this
5279
project's own Maven repository in a `repositories` section of your build file:
80+
5381
```groovy
5482
repositories {
5583
maven {

smil-api/src/main/java/module-info.java

+13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@
1212
* Later modifications:
1313
* Copyright (c) 2020-2021 Carlos Amengual
1414
*/
15+
16+
/**
17+
* Synchronized Multimedia Integration Language (SMIL) Java binding.
18+
* <p>
19+
* This module contains the Java binding for a subset of an
20+
* <a href="https://www.w3.org/TR/smil-boston-dom/java-binding.zip">old SMIL
21+
* version</a>. It has been adapted for compatibility with the subset of SMIL
22+
* that Apache Batik (and hence EchoSVG) uses (it uses the SMIL packages at the
23+
* <a href=
24+
* "http://archive.apache.org/dist/xml/commons/xml-commons-external-1.3.04-src.zip">{@code xml-apis-ext-1.3.04}</a>
25+
* package).
26+
* </p>
27+
*/
1528
module org.w3c.dom.smil {
1629
exports org.w3c.dom.smil;
1730

smil-api/src/main/java/org/w3c/dom/smil/ElementTimeControl.java

+42
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,54 @@
1212

1313
package org.w3c.dom.smil;
1414

15+
/**
16+
* Control the behavior of an animated element.
17+
*/
1518
public interface ElementTimeControl {
19+
20+
/**
21+
* Creates a begin instance time for the current time which is added to the list
22+
* of begin instance times.
23+
* <p>
24+
* Note: modern versions of this method do not return any value.
25+
* </p>
26+
*
27+
* @return {@code true}. The return value should be ignored.
28+
*/
1629
boolean beginElement();
1730

31+
/**
32+
* Creates a begin instance time for the current time plus or minus the passed
33+
* offset which is added to the list of begin instance times.
34+
* <p>
35+
* Note: modern versions of this method do not return any value.
36+
* </p>
37+
*
38+
* @param offset the offset in seconds at which to begin the element.
39+
* @return {@code true}. The return value should be ignored.
40+
*/
1841
boolean beginElementAt(float offset);
1942

43+
/**
44+
* Creates an end instance time for the current time which is added to the list
45+
* of end instance times.
46+
* <p>
47+
* Note: modern versions of this method do not return any value.
48+
* </p>
49+
*
50+
* @return {@code true}. The return value should be ignored.
51+
*/
2052
boolean endElement();
2153

54+
/**
55+
* Creates an end instance time for the current time plus or minus the passed
56+
* offset which is added to the list of end instance times.
57+
* <p>
58+
* Note: modern versions of this method do not return any value.
59+
* </p>
60+
*
61+
* @param offset
62+
* @return {@code true}. The return value should be ignored.
63+
*/
2264
boolean endElementAt(float offset);
2365
}

smil-api/src/main/java/org/w3c/dom/smil/TimeEvent.java

+26
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,36 @@
1515
import org.w3c.dom.events.Event;
1616
import org.w3c.dom.views.AbstractView;
1717

18+
/**
19+
* Provides specific contextual information associated with Time events.
20+
*/
1821
public interface TimeEvent extends Event {
22+
23+
/**
24+
* Get the {@code AbstractView} from which this event was initialized.
25+
*/
1926
AbstractView getView();
2027

28+
/**
29+
* Get some detail information about the {@code Event}, depending on the type of
30+
* event.
31+
*
32+
* @return a detail information about this event.
33+
*/
2134
int getDetail();
2235

36+
/**
37+
* Initialize this event.
38+
* <p>
39+
* This method may only be called before this event has been dispatched via the
40+
* {@code dispatchEvent} method, though it may be called multiple times during
41+
* that phase if necessary. If called multiple times, the final invocation takes
42+
* precedence.
43+
* </p>
44+
*
45+
* @param typeArg the event type.
46+
* @param viewArg the event AbstractView.
47+
* @param detailArg the event's detail.
48+
*/
2349
void initTimeEvent(String typeArg, AbstractView viewArg, int detailArg);
2450
}

svgom-api/src/main/java/module-info.java

+19
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@
1212
* Later modifications:
1313
* Copyright (c) 2020-2021 Carlos Amengual
1414
*/
15+
16+
/**
17+
* Scalable Vector Graphics (SVG) Java binding.
18+
* <p>
19+
* This is a Java binding for an old version of the SVG DOM API (SVGOM). It is
20+
* compatible with the SVGOM API used by Apache Batik (which uses the SVGOM
21+
* packages at the <a href=
22+
* "http://archive.apache.org/dist/xml/commons/xml-commons-external-1.3.04-src.zip">{@code xml-apis-ext-1.3.04}</a>
23+
* package), that seem to be a mixture of the
24+
* <a href="http://www.w3.org/TR/2000/CR-SVG-20000802/java-binding.zip">SVG
25+
* 1.0</a> and
26+
* <a href="http://www.w3.org/TR/2011/REC-SVG11-20110816/java-binding.zip">SVG
27+
* 1.1</a> bindings.
28+
* </p>
29+
* <p>
30+
* Some method signatures were modified so they match the implementations in
31+
* Apache Batik/EchoSVG.
32+
* </p>
33+
*/
1534
module org.w3c.dom.svg {
1635
exports org.w3c.dom.svg;
1736

svgom-api/src/main/java/org/w3c/dom/svg/SVGElement.java

+24
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,39 @@
1616
import org.w3c.dom.Element;
1717

1818
public interface SVGElement extends Element {
19+
20+
/**
21+
* Gets the {@code id} content attribute.
22+
*
23+
* @return the value of the {@code id} attribute, or the empty string if none.
24+
*/
1925
public String getId();
2026

27+
/**
28+
* Sets the {@code id} content attribute.
29+
*
30+
* @param id the value of the {@code id} attribute.
31+
* @throws DOMException
32+
*/
2133
public void setId(String id) throws DOMException;
2234

2335
public String getXMLbase();
2436

2537
public void setXMLbase(String xmlbase) throws DOMException;
2638

39+
/**
40+
* Gets the nearest ancestor {@code svg} element.
41+
*
42+
* @return the nearest ancestor {@code svg} element, or {@code null} if the
43+
* current element is the outermost {@code svg} element.
44+
*/
2745
public SVGSVGElement getOwnerSVGElement();
2846

47+
/**
48+
* Get the element that provides the SVG viewport for this element.
49+
*
50+
* @return the nearest ancestor element that establishes an SVG viewport, or
51+
* {@code null} if the current element is the outermost svg element.
52+
*/
2953
public SVGElement getViewportElement();
3054
}

0 commit comments

Comments
 (0)