You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2005/07/12 04:06:00 UTC
svn commit: r215909 [8/13] - in /xmlgraphics/batik/branches/svg12: ./
contrib/charts/xml/ contrib/charts/xsl/ contrib/fonts/gladiator/svg/
contrib/jsvg/ contrib/tiledTranscoder/
resources/org/apache/batik/apps/svgbrowser/resources/ resources/org/apache...
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/FragmentIdentifierParser.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/FragmentIdentifierParser.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/FragmentIdentifierParser.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/FragmentIdentifierParser.java Mon Jul 11 19:05:44 2005
@@ -144,7 +144,7 @@
if (current != 'i') {
reportError("character.expected",
new Object[] { new Character('i'),
- new Integer(current) });
+ new Integer(current) });
break ident;
}
current = reader.read();
@@ -935,98 +935,98 @@
* Returns the content of the buffer.
*/
protected String getBufferContent() {
- return new String(buffer, 0, bufferSize);
+ return new String(buffer, 0, bufferSize);
}
/**
* Adds the current character to the buffer.
*/
protected void bufferize() {
- if (bufferSize >= buffer.length) {
- char[] t = new char[buffer.length * 2];
- for (int i = 0; i < bufferSize; i++) {
- t[i] = buffer[i];
- }
- buffer = t;
- }
- buffer[bufferSize++] = (char)current;
+ if (bufferSize >= buffer.length) {
+ char[] t = new char[buffer.length * 2];
+ for (int i = 0; i < bufferSize; i++) {
+ t[i] = buffer[i];
+ }
+ buffer = t;
+ }
+ buffer[bufferSize++] = (char)current;
}
/**
* Skips the whitespaces in the current reader.
*/
protected void skipSpaces() throws IOException {
- if (current == ',') {
+ if (current == ',') {
current = reader.read();
- }
+ }
}
/**
* Skips the whitespaces and an optional comma.
*/
protected void skipCommaSpaces() throws IOException {
- if (current == ',') {
+ if (current == ',') {
current = reader.read();
- }
+ }
}
/**
* Parses a matrix transform. 'm' is assumed to be the current character.
*/
protected void parseMatrix() throws ParseException, IOException {
- current = reader.read();
+ current = reader.read();
- // Parse 'atrix wsp? ( wsp?'
- if (current != 'a') {
- reportError("character.expected",
- new Object[] { new Character('a'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 't') {
- reportError("character.expected",
- new Object[] { new Character('t'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'r') {
- reportError("character.expected",
- new Object[] { new Character('r'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'i') {
- reportError("character.expected",
- new Object[] { new Character('i'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'x') {
- reportError("character.expected",
- new Object[] { new Character('x'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- skipSpaces();
- if (current != '(') {
- reportError("character.expected",
- new Object[] { new Character('('),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- skipSpaces();
+ // Parse 'atrix wsp? ( wsp?'
+ if (current != 'a') {
+ reportError("character.expected",
+ new Object[] { new Character('a'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 't') {
+ reportError("character.expected",
+ new Object[] { new Character('t'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'r') {
+ reportError("character.expected",
+ new Object[] { new Character('r'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'i') {
+ reportError("character.expected",
+ new Object[] { new Character('i'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'x') {
+ reportError("character.expected",
+ new Object[] { new Character('x'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ skipSpaces();
+ if (current != '(') {
+ reportError("character.expected",
+ new Object[] { new Character('('),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ skipSpaces();
float a = parseFloat();
skipCommaSpaces();
@@ -1039,7 +1039,7 @@
float e = parseFloat();
skipCommaSpaces();
float f = parseFloat();
-
+
skipSpaces();
if (current != ')') {
reportError("character.expected",
@@ -1054,63 +1054,62 @@
/**
* Parses a rotate transform. 'r' is assumed to be the current character.
- * @return the current character.
*/
protected void parseRotate() throws ParseException, IOException {
- current = reader.read();
+ current = reader.read();
+
+ // Parse 'otate wsp? ( wsp?'
+ if (current != 'o') {
+ reportError("character.expected",
+ new Object[] { new Character('o'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 't') {
+ reportError("character.expected",
+ new Object[] { new Character('t'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'a') {
+ reportError("character.expected",
+ new Object[] { new Character('a'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 't') {
+ reportError("character.expected",
+ new Object[] { new Character('t'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'e') {
+ reportError("character.expected",
+ new Object[] { new Character('e'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ skipSpaces();
- // Parse 'otate wsp? ( wsp?'
- if (current != 'o') {
- reportError("character.expected",
- new Object[] { new Character('o'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 't') {
- reportError("character.expected",
- new Object[] { new Character('t'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'a') {
- reportError("character.expected",
- new Object[] { new Character('a'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 't') {
- reportError("character.expected",
- new Object[] { new Character('t'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'e') {
- reportError("character.expected",
- new Object[] { new Character('e'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- skipSpaces();
-
- if (current != '(') {
- reportError("character.expected",
- new Object[] { new Character('('),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- skipSpaces();
+ if (current != '(') {
+ reportError("character.expected",
+ new Object[] { new Character('('),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ skipSpaces();
float theta = parseFloat();
skipSpaces();
@@ -1143,86 +1142,85 @@
/**
* Parses a translate transform. 't' is assumed to be
* the current character.
- * @return the current character.
*/
protected void parseTranslate() throws ParseException, IOException {
- current = reader.read();
+ current = reader.read();
- // Parse 'ranslate wsp? ( wsp?'
- if (current != 'r') {
- reportError("character.expected",
- new Object[] { new Character('r'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'a') {
- reportError("character.expected",
- new Object[] { new Character('a'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'n') {
- reportError("character.expected",
- new Object[] { new Character('n'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 's') {
- reportError("character.expected",
- new Object[] { new Character('s'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'l') {
- reportError("character.expected",
- new Object[] { new Character('l'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'a') {
- reportError("character.expected",
- new Object[] { new Character('a'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 't') {
- reportError("character.expected",
- new Object[] { new Character('t'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'e') {
- reportError("character.expected",
- new Object[] { new Character('e'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- skipSpaces();
- if (current != '(') {
- reportError("character.expected",
- new Object[] { new Character('('),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- skipSpaces();
+ // Parse 'ranslate wsp? ( wsp?'
+ if (current != 'r') {
+ reportError("character.expected",
+ new Object[] { new Character('r'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'a') {
+ reportError("character.expected",
+ new Object[] { new Character('a'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'n') {
+ reportError("character.expected",
+ new Object[] { new Character('n'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 's') {
+ reportError("character.expected",
+ new Object[] { new Character('s'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'l') {
+ reportError("character.expected",
+ new Object[] { new Character('l'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'a') {
+ reportError("character.expected",
+ new Object[] { new Character('a'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 't') {
+ reportError("character.expected",
+ new Object[] { new Character('t'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'e') {
+ reportError("character.expected",
+ new Object[] { new Character('e'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ skipSpaces();
+ if (current != '(') {
+ reportError("character.expected",
+ new Object[] { new Character('('),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ skipSpaces();
float tx = parseFloat();
skipSpaces();
@@ -1252,46 +1250,45 @@
/**
* Parses a scale transform. 'c' is assumed to be the current character.
- * @return the current character.
*/
protected void parseScale() throws ParseException, IOException {
- current = reader.read();
+ current = reader.read();
- // Parse 'ale wsp? ( wsp?'
- if (current != 'a') {
- reportError("character.expected",
- new Object[] { new Character('a'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'l') {
- reportError("character.expected",
- new Object[] { new Character('l'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'e') {
- reportError("character.expected",
- new Object[] { new Character('e'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- skipSpaces();
- if (current != '(') {
- reportError("character.expected",
- new Object[] { new Character('('),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- skipSpaces();
+ // Parse 'ale wsp? ( wsp?'
+ if (current != 'a') {
+ reportError("character.expected",
+ new Object[] { new Character('a'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'l') {
+ reportError("character.expected",
+ new Object[] { new Character('l'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'e') {
+ reportError("character.expected",
+ new Object[] { new Character('e'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ skipSpaces();
+ if (current != '(') {
+ reportError("character.expected",
+ new Object[] { new Character('('),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ skipSpaces();
float sx = parseFloat();
skipSpaces();
@@ -1321,53 +1318,52 @@
/**
* Parses a skew transform. 'e' is assumed to be the current character.
- * @return the current character.
*/
protected void parseSkew() throws ParseException, IOException {
- current = reader.read();
+ current = reader.read();
- // Parse 'ew[XY] wsp? ( wsp?'
- if (current != 'e') {
- reportError("character.expected",
- new Object[] { new Character('e'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- if (current != 'w') {
- reportError("character.expected",
- new Object[] { new Character('w'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
-
- boolean skewX = false;
- switch (current) {
- case 'X':
- skewX = true;
- case 'Y':
- break;
- default:
- reportError("character.expected",
- new Object[] { new Character('X'),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- skipSpaces();
- if (current != '(') {
- reportError("character.expected",
- new Object[] { new Character('('),
- new Integer(current) });
- skipTransform();
- return;
- }
- current = reader.read();
- skipSpaces();
+ // Parse 'ew[XY] wsp? ( wsp?'
+ if (current != 'e') {
+ reportError("character.expected",
+ new Object[] { new Character('e'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ if (current != 'w') {
+ reportError("character.expected",
+ new Object[] { new Character('w'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+
+ boolean skewX = false;
+ switch (current) {
+ case 'X':
+ skewX = true;
+ case 'Y':
+ break;
+ default:
+ reportError("character.expected",
+ new Object[] { new Character('X'),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ skipSpaces();
+ if (current != '(') {
+ reportError("character.expected",
+ new Object[] { new Character('('),
+ new Integer(current) });
+ skipTransform();
+ return;
+ }
+ current = reader.read();
+ skipSpaces();
float sk = parseFloat();
@@ -1389,20 +1385,19 @@
/**
* Skips characters in the given reader until a ')' is encountered.
- * @return the first character after the ')'.
*/
protected void skipTransform() throws IOException {
- loop: for (;;) {
- current = reader.read();
- switch (current) {
- case ')':
- break loop;
- default:
- if (current == -1) {
- break loop;
- }
- }
- }
+ loop: for (;;) {
+ current = reader.read();
+ switch (current) {
+ case ')':
+ break loop;
+ default:
+ if (current == -1) {
+ break loop;
+ }
+ }
+ }
}
/**
@@ -1410,37 +1405,37 @@
*/
protected void parsePreserveAspectRatio()
throws ParseException, IOException {
- fragmentIdentifierHandler.startPreserveAspectRatio();
+ fragmentIdentifierHandler.startPreserveAspectRatio();
align: switch (current) {
case 'n':
- current = reader.read();
- if (current != 'o') {
- reportError("character.expected",
- new Object[] { new Character('o'),
+ current = reader.read();
+ if (current != 'o') {
+ reportError("character.expected",
+ new Object[] { new Character('o'),
new Integer(current) });
- skipIdentifier();
- break align;
- }
- current = reader.read();
- if (current != 'n') {
- reportError("character.expected",
- new Object[] { new Character('n'),
- new Integer(current) });
- skipIdentifier();
- break align;
- }
- current = reader.read();
- if (current != 'e') {
- reportError("character.expected",
- new Object[] { new Character('e'),
- new Integer(current) });
- skipIdentifier();
- break align;
- }
- current = reader.read();
- skipSpaces();
- fragmentIdentifierHandler.none();
+ skipIdentifier();
+ break align;
+ }
+ current = reader.read();
+ if (current != 'n') {
+ reportError("character.expected",
+ new Object[] { new Character('n'),
+ new Integer(current) });
+ skipIdentifier();
+ break align;
+ }
+ current = reader.read();
+ if (current != 'e') {
+ reportError("character.expected",
+ new Object[] { new Character('e'),
+ new Integer(current) });
+ skipIdentifier();
+ break align;
+ }
+ current = reader.read();
+ skipSpaces();
+ fragmentIdentifierHandler.none();
break;
case 'x':
@@ -1448,7 +1443,7 @@
if (current != 'M') {
reportError("character.expected",
new Object[] { new Character('M'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break;
}
@@ -1459,7 +1454,7 @@
if (current != 'x') {
reportError("character.expected",
new Object[] { new Character('x'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break align;
}
@@ -1467,7 +1462,7 @@
if (current != 'Y') {
reportError("character.expected",
new Object[] { new Character('Y'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break align;
}
@@ -1475,7 +1470,7 @@
if (current != 'M') {
reportError("character.expected",
new Object[] { new Character('M'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break align;
}
@@ -1486,7 +1481,7 @@
if (current != 'x') {
reportError("character.expected",
new Object[] { new Character('x'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break align;
}
@@ -1520,7 +1515,7 @@
if (current != 'Y') {
reportError("character.expected",
new Object[] { new Character('Y'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break align;
}
@@ -1528,7 +1523,7 @@
if (current != 'M') {
reportError("character.expected",
new Object[] { new Character('M'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break align;
}
@@ -1541,8 +1536,8 @@
("character.expected",
new Object[] { new Character('x'),
new Integer(current) });
- skipIdentifier();
- break align;
+ skipIdentifier();
+ break align;
}
fragmentIdentifierHandler.xMidYMax();
current = reader.read();
@@ -1551,18 +1546,18 @@
current = reader.read();
switch (current) {
case 'd':
- fragmentIdentifierHandler.xMidYMid();
- current = reader.read();
- break;
+ fragmentIdentifierHandler.xMidYMid();
+ current = reader.read();
+ break;
case 'n':
fragmentIdentifierHandler.xMidYMin();
current = reader.read();
break;
- default:
- reportError("character.unexpected",
- new Object[] { new Integer(current) });
- skipIdentifier();
- break align;
+ default:
+ reportError("character.unexpected",
+ new Object[] { new Integer(current) });
+ skipIdentifier();
+ break align;
}
}
break;
@@ -1571,7 +1566,7 @@
if (current != 'Y') {
reportError("character.expected",
new Object[] { new Character('Y'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break align;
}
@@ -1579,7 +1574,7 @@
if (current != 'M') {
reportError("character.expected",
new Object[] { new Character('M'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break align;
}
@@ -1647,7 +1642,7 @@
if (current != 'e') {
reportError("character.expected",
new Object[] { new Character('e'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break;
}
@@ -1655,7 +1650,7 @@
if (current != 'e') {
reportError("character.expected",
new Object[] { new Character('e'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break;
}
@@ -1663,7 +1658,7 @@
if (current != 't') {
reportError("character.expected",
new Object[] { new Character('t'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break;
}
@@ -1675,7 +1670,7 @@
if (current != 'l') {
reportError("character.expected",
new Object[] { new Character('l'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break;
}
@@ -1683,7 +1678,7 @@
if (current != 'i') {
reportError("character.expected",
new Object[] { new Character('i'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break;
}
@@ -1691,7 +1686,7 @@
if (current != 'c') {
reportError("character.expected",
new Object[] { new Character('c'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break;
}
@@ -1699,7 +1694,7 @@
if (current != 'e') {
reportError("character.expected",
new Object[] { new Character('e'),
- new Integer(current) });
+ new Integer(current) });
skipIdentifier();
break;
}
@@ -1707,22 +1702,21 @@
current = reader.read();
}
- fragmentIdentifierHandler.endPreserveAspectRatio();
+ fragmentIdentifierHandler.endPreserveAspectRatio();
}
/**
* Skips characters in the given reader until a white space is encountered.
- * @return the first character after the space.
*/
protected void skipIdentifier() throws IOException {
- loop: for (;;) {
- current = reader.read();
- switch(current) {
- case 0xD: case 0xA: case 0x20: case 0x9:
- current = reader.read();
- case -1:
- break loop;
- }
- }
+ loop: for (;;) {
+ current = reader.read();
+ switch(current) {
+ case 0xD: case 0xA: case 0x20: case 0x9:
+ current = reader.read();
+ case -1:
+ break loop;
+ }
+ }
}
}
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/NumberListHandler.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/NumberListHandler.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/NumberListHandler.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/NumberListHandler.java Mon Jul 11 19:05:44 2005
@@ -14,11 +14,14 @@
See the License for the specific language governing permissions and
limitations under the License.
- */package org.apache.batik.parser;
+ */
+package org.apache.batik.parser;
/**
+ * An handler interface for parsing NumberLists.
*
* @author tonny@kiyut.com
+ * @version $Id$
*/
public interface NumberListHandler {
/**
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/NumberParser.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/NumberParser.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/NumberParser.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/NumberParser.java Mon Jul 11 19:05:44 2005
@@ -218,7 +218,7 @@
return 0f;
}
- if (exp > 128) {
+ if (exp >= 128) {
return (mant > 0)
? Float.POSITIVE_INFINITY
: Float.NEGATIVE_INFINITY;
@@ -228,7 +228,7 @@
return mant;
}
- if (mant >= 1 << 26) {
+ if (mant >= (1 << 26)) {
mant++; // round up trailing bits if they will be dropped.
}
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/PathHandler.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/PathHandler.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/PathHandler.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/PathHandler.java Mon Jul 11 19:05:44 2005
@@ -41,7 +41,8 @@
/**
* Invoked when a relative moveto command has been parsed.
* <p>Command : <b>m</b>
- * @param x, y the relative coordinates for the end point
+ * @param x the relative x coordinate for the end point
+ * @param y the relative y coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void movetoRel(float x, float y) throws ParseException;
@@ -49,7 +50,8 @@
/**
* Invoked when an absolute moveto command has been parsed.
* <p>Command : <b>M</b>
- * @param x, y the absolute coordinates for the end point
+ * @param x the absolute x coordinate for the end point
+ * @param y the absolute y coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void movetoAbs(float x, float y) throws ParseException;
@@ -64,7 +66,8 @@
/**
* Invoked when a relative line command has been parsed.
* <p>Command : <b>l</b>
- * @param x, y the relative coordinates for the end point
+ * @param x the relative x coordinates for the end point
+ * @param y the relative y coordinates for the end point
* @exception ParseException if an error occured while processing the path
*/
void linetoRel(float x, float y) throws ParseException;
@@ -72,7 +75,8 @@
/**
* Invoked when an absolute line command has been parsed.
* <p>Command : <b>L</b>
- * @param x, y the absolute coordinates for the end point
+ * @param x the absolute x coordinate for the end point
+ * @param y the absolute y coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void linetoAbs(float x, float y) throws ParseException;
@@ -112,9 +116,12 @@
/**
* Invoked when a relative cubic bezier curve command has been parsed.
* <p>Command : <b>c</b>
- * @param x1, y1 the relative coordinates for the first control point
- * @param x2, y2 the relative coordinates for the second control point
- * @param x, y the relative coordinates for the end point
+ * @param x1 the relative x coordinate for the first control point
+ * @param y1 the relative y coordinate for the first control point
+ * @param x2 the relative x coordinate for the second control point
+ * @param y2 the relative y coordinate for the second control point
+ * @param x the relative x coordinate for the end point
+ * @param y the relative y coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void curvetoCubicRel(float x1, float y1,
@@ -125,9 +132,12 @@
/**
* Invoked when an absolute cubic bezier curve command has been parsed.
* <p>Command : <b>C</b>
- * @param x1, y1 the absolute coordinates for the first control point
- * @param x2, y2 the absolute coordinates for the second control point
- * @param x, y the absolute coordinates for the end point
+ * @param x1 the absolute x coordinate for the first control point
+ * @param y1 the absolute y coordinate for the first control point
+ * @param x2 the absolute x coordinate for the second control point
+ * @param y2 the absolute y coordinate for the second control point
+ * @param x the absolute x coordinate for the end point
+ * @param y the absolute y coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void curvetoCubicAbs(float x1, float y1,
@@ -140,8 +150,10 @@
* reflection of the second control point on the previous command
* relative to the current point.
* <p>Command : <b>s</b>
- * @param x2, y2 the relative coordinates for the second control point
- * @param x, y the relative coordinates for the end point
+ * @param x2 the relative x coordinate for the second control point
+ * @param y2 the relative y coordinate for the second control point
+ * @param x the relative x coordinate for the end point
+ * @param y the relative y coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void curvetoCubicSmoothRel(float x2, float y2,
@@ -153,8 +165,10 @@
* reflection of the second control point on the previous command
* relative to the current point.
* <p>Command : <b>S</b>
- * @param x2, y2 the absolute coordinates for the second control point
- * @param x, y the absolute coordinates for the end point
+ * @param x2 the absolute x coordinate for the second control point
+ * @param y2 the absolute y coordinate for the second control point
+ * @param x the absolute x coordinate for the end point
+ * @param y the absolute y coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void curvetoCubicSmoothAbs(float x2, float y2,
@@ -163,8 +177,10 @@
/**
* Invoked when a relative quadratic bezier curve command has been parsed.
* <p>Command : <b>q</b>
- * @param x1, y1 the relative coordinates for the control point
- * @param x, y the relative coordinates for the end point
+ * @param x1 the relative x coordinate for the control point
+ * @param y1 the relative y coordinate for the control point
+ * @param x the relative x coordinate for the end point
+ * @param y the relative x coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void curvetoQuadraticRel(float x1, float y1,
@@ -173,8 +189,10 @@
/**
* Invoked when an absolute quadratic bezier curve command has been parsed.
* <p>Command : <b>Q</b>
- * @param x1, y1 the absolute coordinates for the control point
- * @param x, y the absolute coordinates for the end point
+ * @param x1 the absolute x coordinate for the control point
+ * @param y1 the absolute y coordinate for the control point
+ * @param x the absolute x coordinate for the end point
+ * @param y the absolute x coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void curvetoQuadraticAbs(float x1, float y1,
@@ -186,7 +204,8 @@
* reflection of the control point on the previous command
* relative to the current point.
* <p>Command : <b>t</b>
- * @param x, y the relative coordinates for the end point
+ * @param x the relative x coordinate for the end point
+ * @param y the relative y coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void curvetoQuadraticSmoothRel(float x, float y) throws ParseException;
@@ -197,7 +216,8 @@
* reflection of the control point on the previous command
* relative to the current point.
* <p>Command : <b>T</b>
- * @param x, y the absolute coordinates for the end point
+ * @param x the absolute x coordinate for the end point
+ * @param y the absolute y coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void curvetoQuadraticSmoothAbs(float x, float y) throws ParseException;
@@ -207,11 +227,12 @@
* <p>Command : <b>a</b>
* @param rx the X axis radius for the ellipse
* @param ry the Y axis radius for the ellipse
- * @param angle the rotation angle in degrees for the ellipse's X-axis
- * relative to the X-axis
+ * @param xAxisRotation the rotation angle in degrees for the ellipse's
+ * X-axis relative to the X-axis
* @param largeArcFlag the value of the large-arc-flag
* @param sweepFlag the value of the sweep-flag
- * @param x, y the relative coordinates for the end point
+ * @param x the relative x coordinate for the end point
+ * @param y the relative y coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void arcRel(float rx, float ry,
@@ -225,11 +246,12 @@
* <p>Command : <b>A</b>
* @param rx the X axis radius for the ellipse
* @param ry the Y axis radius for the ellipse
- * @param angle the rotation angle in degrees for the ellipse's X-axis
- * relative to the X-axis
+ * @param xAxisRotation the rotation angle in degrees for the ellipse's
+ * X-axis relative to the X-axis
* @param largeArcFlag the value of the large-arc-flag
* @param sweepFlag the value of the sweep-flag
- * @param x, y the absolute coordinates for the end point
+ * @param x the absolute x coordinate for the end point
+ * @param y the absolute y coordinate for the end point
* @exception ParseException if an error occured while processing the path
*/
void arcAbs(float rx, float ry,
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/PointsHandler.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/PointsHandler.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/PointsHandler.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/PointsHandler.java Mon Jul 11 19:05:44 2005
@@ -35,7 +35,8 @@
/**
* Invoked when a point has been parsed.
- * @param x, y the coordinates of the point
+ * @param x the x coordinate of the point
+ * @param y the y coordinate of the point
* @exception ParseException if an error occured while processing the
* points
*/
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/UnitProcessor.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/UnitProcessor.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/UnitProcessor.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/parser/UnitProcessor.java Mon Jul 11 19:05:44 2005
@@ -77,7 +77,7 @@
* Returns the specified value with the specified direction in
* objectBoundingBox units.
*
- * @param s the value
+ * @param value the value
* @param type the type of the value
* @param d the direction of the value
* @param ctx the context used to resolve relative value
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/InterpreterException.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/InterpreterException.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/InterpreterException.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/InterpreterException.java Mon Jul 11 19:05:44 2005
@@ -32,7 +32,7 @@
* Builds an instance of <code>InterpreterException</code>.
* @param message the <code>Exception</code> message.
* @param lineno the number of the line the error occurs.
- * @param columno the number of the column the error occurs.
+ * @param columnno the number of the column the error occurs.
*/
public InterpreterException(String message, int lineno, int columnno) {
super(message);
@@ -45,7 +45,7 @@
* @param exception the embedded exception.
* @param message the <code>Exception</code> message.
* @param lineno the number of the line the error occurs.
- * @param columno the number of the column the error occurs.
+ * @param columnno the number of the column the error occurs.
*/
public InterpreterException(Exception exception,
String message, int lineno, int columnno) {
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/InterpreterPool.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/InterpreterPool.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/InterpreterPool.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/InterpreterPool.java Mon Jul 11 19:05:44 2005
@@ -96,13 +96,14 @@
*/
public Interpreter createInterpreter(Document document, String language) {
InterpreterFactory factory = (InterpreterFactory)factories.get(language);
- Interpreter interpreter = null;
- if (factory != null)
- interpreter = factory.createInterpreter
+ if (factory == null) return null;
+
+ Interpreter interpreter = factory.createInterpreter
(((SVGOMDocument)document).getURLObject());
- if (document != null) {
+ if (interpreter == null) return null;
+
+ if (document != null)
interpreter.bindObject(BIND_NAME_DOCUMENT, document);
- }
return interpreter;
}
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/jpython/JPythonInterpreter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/jpython/JPythonInterpreter.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/jpython/JPythonInterpreter.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/jpython/JPythonInterpreter.java Mon Jul 11 19:05:44 2005
@@ -24,7 +24,6 @@
import org.apache.batik.script.InterpreterException;
import org.python.util.PythonInterpreter;
-;
/**
* A simple implementation of <code>Interpreter</code> interface to use
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/EventTargetWrapper.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/EventTargetWrapper.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/EventTargetWrapper.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/EventTargetWrapper.java Mon Jul 11 19:05:44 2005
@@ -55,8 +55,8 @@
* The Java function object calling the Rhino function.
*/
static class FunctionEventListener implements EventListener {
- private Function function;
- private RhinoInterpreter interpreter;
+ protected Function function;
+ protected RhinoInterpreter interpreter;
FunctionEventListener(Function f, RhinoInterpreter i) {
function = f;
interpreter = i;
@@ -75,11 +75,11 @@
}
static class HandleEventListener implements EventListener {
- private final static String HANDLE_EVENT = "handleEvent";
+ public final static String HANDLE_EVENT = "handleEvent";
- private Scriptable scriptable;
- private Object[] array = new Object[1];
- private RhinoInterpreter interpreter;
+ public Scriptable scriptable;
+ public Object[] array = new Object[1];
+ public RhinoInterpreter interpreter;
HandleEventListener(Scriptable s, RhinoInterpreter interpreter) {
scriptable = s;
@@ -190,11 +190,13 @@
* cases.
*/
static class FunctionAddProxy extends FunctionProxy {
- private Map listenerMap;
-
- FunctionAddProxy(Function delegate, Map listenerMap) {
+ protected Map listenerMap;
+ protected RhinoInterpreter interpreter;
+ FunctionAddProxy(RhinoInterpreter interpreter,
+ Function delegate, Map listenerMap) {
super(delegate);
this.listenerMap = listenerMap;
+ this.interpreter = interpreter;
}
public Object call(Context ctx, Scriptable scope,
@@ -203,8 +205,7 @@
NativeJavaObject njo = (NativeJavaObject)thisObj;
if (args[1] instanceof Function) {
EventListener evtListener = new FunctionEventListener
- ((Function)args[1],
- ((RhinoInterpreter.ExtendedContext)ctx).getInterpreter());
+ ((Function)args[1], interpreter);
listenerMap.put(args[1], new SoftReference(evtListener));
// we need to marshall args
Class[] paramTypes = { String.class, Function.class,
@@ -219,8 +220,7 @@
if (args[1] instanceof NativeObject) {
EventListener evtListener =
new HandleEventListener((Scriptable)args[1],
- ((RhinoInterpreter.ExtendedContext)
- ctx).getInterpreter());
+ interpreter);
listenerMap.put(args[1], new SoftReference(evtListener));
// we need to marshall args
Class[] paramTypes = { String.class, Scriptable.class,
@@ -237,7 +237,7 @@
}
static class FunctionRemoveProxy extends FunctionProxy {
- private Map listenerMap;
+ public Map listenerMap;
FunctionRemoveProxy(Function delegate, Map listenerMap) {
super(delegate);
@@ -286,11 +286,14 @@
}
static class FunctionAddNSProxy extends FunctionProxy {
- private Map listenerMap;
+ protected Map listenerMap;
+ protected RhinoInterpreter interpreter;
- FunctionAddNSProxy(Function delegate, Map listenerMap) {
+ FunctionAddNSProxy(RhinoInterpreter interpreter,
+ Function delegate, Map listenerMap) {
super(delegate);
this.listenerMap = listenerMap;
+ this.interpreter = interpreter;
}
public Object call(Context ctx, Scriptable scope,
@@ -299,8 +302,7 @@
NativeJavaObject njo = (NativeJavaObject)thisObj;
if (args[2] instanceof Function) {
EventListener evtListener = new FunctionEventListener
- ((Function)args[2],
- ((RhinoInterpreter.ExtendedContext)ctx).getInterpreter());
+ ((Function)args[2], interpreter);
listenerMap.put(args[2], new SoftReference(evtListener));
// we need to marshall args
Class[] paramTypes = { String.class, String.class,
@@ -319,9 +321,7 @@
}
if (args[2] instanceof NativeObject) {
EventListener evtListener =
- new HandleEventListener((Scriptable)args[2],
- ((RhinoInterpreter.ExtendedContext)
- ctx).getInterpreter());
+ new HandleEventListener((Scriptable)args[2], interpreter);
listenerMap.put(args[2], new SoftReference(evtListener));
// we need to marshall args
Class[] paramTypes = { String.class, String.class,
@@ -343,7 +343,7 @@
}
static class FunctionRemoveNSProxy extends FunctionProxy {
- private Map listenerMap;
+ protected Map listenerMap;
FunctionRemoveNSProxy(Function delegate, Map listenerMap) {
super(delegate);
@@ -402,20 +402,22 @@
// the keys are the underlying Java object, in order
// to remove potential memory leaks use a WeakHashMap to allow
// to collect entries as soon as the underlying Java object is
- // not anymore available.
- private static WeakHashMap mapOfListenerMap;
+ // not available anymore.
+ protected static WeakHashMap mapOfListenerMap;
- private final static String ADD_NAME = "addEventListener";
- private final static String ADDNS_NAME = "addEventListenerNS";
- private final static String REMOVE_NAME = "removeEventListener";
- private final static String REMOVENS_NAME = "removeEventListenerNS";
- private final static Class[] ARGS_TYPE = { String.class,
+ public final static String ADD_NAME = "addEventListener";
+ public final static String ADDNS_NAME = "addEventListenerNS";
+ public final static String REMOVE_NAME = "removeEventListener";
+ public final static String REMOVENS_NAME = "removeEventListenerNS";
+ public final static Class[] ARGS_TYPE = { String.class,
EventListener.class,
Boolean.TYPE };
- private final static String NAME = "name";
- EventTargetWrapper(Scriptable scope, EventTarget object) {
+ protected RhinoInterpreter interpreter;
+ EventTargetWrapper(Scriptable scope, EventTarget object,
+ RhinoInterpreter interpreter) {
super(scope, object, null);
+ this.interpreter = interpreter;
}
/**
@@ -426,13 +428,16 @@
if (name.equals(ADD_NAME)) {
// prevent creating a Map for all JavaScript objects
// when we need it only from time to time...
- method = new FunctionAddProxy((Function)method, initMap());
+ method = new FunctionAddProxy(interpreter,
+ (Function)method, initMap());
} else if (name.equals(REMOVE_NAME)) {
// prevent creating a Map for all JavaScript objects
// when we need it only from time to time...
- method = new FunctionRemoveProxy((Function)method, initMap());
+ method = new FunctionRemoveProxy
+ ((Function)method, initMap());
} else if (name.equals(ADDNS_NAME)) {
- method = new FunctionAddNSProxy((Function) method, initMap());
+ method = new FunctionAddNSProxy(interpreter,
+ (Function) method, initMap());
} else if (name.equals(REMOVENS_NAME)) {
method = new FunctionRemoveNSProxy((Function) method, initMap());
}
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/RhinoClassShutter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/RhinoClassShutter.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/RhinoClassShutter.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/RhinoClassShutter.java Mon Jul 11 19:05:44 2005
@@ -24,7 +24,7 @@
*
* Complete Class Desc
*
- * @author <a href="mailto:deweese@apache.org>deweese</a>
+ * @author <a href="mailto:deweese@apache.org">deweese</a>
* @version $Id$
*/
public class RhinoClassShutter implements ClassShutter {
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/RhinoInterpreter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/RhinoInterpreter.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/RhinoInterpreter.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/RhinoInterpreter.java Mon Jul 11 19:05:44 2005
@@ -28,9 +28,8 @@
import java.security.PrivilegedAction;
import java.util.Iterator;
import java.util.LinkedList;
+import java.util.List;
import java.util.Locale;
-import java.util.Map;
-import java.util.HashMap;
import org.apache.batik.bridge.InterruptedBridgeException;
import org.apache.batik.script.Interpreter;
@@ -103,8 +102,7 @@
private ScriptableObject globalObject = null;
private LinkedList compiledScripts = new LinkedList();
- private WrapFactory wrapFactory =
- new BatikWrapFactory(this);
+ private WrapFactory wrapFactory = new BatikWrapFactory(this);
/**
* The Rhino 'security domain'. We use the RhinoClassLoader
@@ -122,6 +120,18 @@
= new BatikSecurityController();
/**
+ * Default Context for scripts. This is used only for efficiency
+ * reason.
+ */
+ protected Context defaultContext;
+
+ /**
+ * Context vector, to make sure we are not
+ * setting the security context too many times
+ */
+ protected List contexts = new LinkedList();
+
+ /**
* Build a <code>Interpreter</code> for ECMAScript using Rhino.
*
* @param documentURL the URL for the document which references
@@ -180,15 +190,23 @@
* on the context.
*/
public Context enterContext(){
- Context ctx = Context.getCurrentContext();
- if (ctx == null) {
- ctx = new ExtendedContext();
+ Context ctx = Context.enter();
+ if (ctx == defaultContext)
+ return ctx;
+
+ if (!contexts.contains(ctx)) {
ctx.setWrapFactory(wrapFactory);
ctx.setSecurityController(securityController);
ctx.setClassShutter(new RhinoClassShutter());
- }
- ctx = Context.enter(ctx);
+ // No class loader so don't try and optmize.
+ if (rhinoClassLoader == null) {
+ ctx.setOptimizationLevel(-1);
+ ctx.setCachingEnabled(false);
+ }
+ contexts.add(ctx);
+ }
+ defaultContext = ctx;
return ctx;
}
@@ -352,11 +370,14 @@
}
/**
- * For <code>RhinoInterpreter</code> this method does nothing.
+ * For <code>RhinoInterpreter</code> this method flushes the
+ * Rhino caches to avoid memory leaks.
*/
public void dispose() {
- Context.setCachingEnabled(false);
- Context.setCachingEnabled(true);
+ if (rhinoClassLoader != null) {
+ Context.setCachingEnabled(false);
+ Context.setCachingEnabled(true);
+ }
}
/**
@@ -369,66 +390,22 @@
enterContext();
try {
if (name.equals(BIND_NAME_WINDOW) && object instanceof Window) {
+ ((WindowWrapper)globalObject).window = (Window)object;
window = (Window)object;
object = globalObject;
}
- try {
Scriptable jsObject;
jsObject = Context.toObject(object, globalObject);
- objects.put(name, jsObject);
- if (ScriptableObject.getProperty(globalObject, name) ==
- ScriptableObject.NOT_FOUND)
- globalObject.defineProperty
- (name, new RhinoGetDelegate(name),
- rhinoGetter, null, ScriptableObject.READONLY);
- } catch (PropertyException pe) {
- pe.printStackTrace();
- }
+ globalObject.put(name, globalObject, jsObject);
} finally {
Context.exit();
}
}
- /**
- * HashTable to store properties bounds on the global object.
- * So they don't end up in the JavaMethods static table.
- */
- Map objects = new HashMap(4);
-
- /**
- * Class to act as 'get' delegate for Rhino. This uses the
- * currentContext to get the current Interpreter object which
- * allows it to lookup the object requested. This gets around the
- * fact that the global object gets referenced from a static
- * context but the Context does not.
- */
- public static class RhinoGetDelegate {
- String name;
- RhinoGetDelegate(String name) {
- this.name = name;
- }
- public Object get(ScriptableObject so) {
- Context ctx = Context.getCurrentContext();
- if (ctx == null ) return null;
- return ((ExtendedContext)ctx).getInterpreter().objects.get(name);
- }
- }
- // The method to use for getting the value from the
- // RhinoGetDelegate.
- static Method rhinoGetter;
- static {
- try {
- Class [] getterArgs = { ScriptableObject.class };
- rhinoGetter = RhinoGetDelegate.class.getDeclaredMethod
- ("get", getterArgs);
- } catch (NoSuchMethodException nsm) { }
- }
-
/**
* To be used by <code>EventTargetWrapper</code>.
*/
- void callHandler(Function handler,
- Object arg)
+ void callHandler(Function handler, Object arg)
throws JavaScriptException {
Context ctx = enterContext();
try {
@@ -494,13 +471,13 @@
* Build the wrapper for objects implement <code>EventTarget</code>.
*/
Scriptable buildEventTargetWrapper(EventTarget obj) {
- return new EventTargetWrapper(globalObject, obj);
+ return new EventTargetWrapper(globalObject, obj, this);
}
/**
* By default Rhino has no output method in its language. That's why
* this method does nothing.
- * @param output the new out <code>Writer</code>.
+ * @param out the new out <code>Writer</code>.
*/
public void setOut(Writer out) {
// no implementation of a default output function in Rhino
@@ -509,10 +486,8 @@
// org.apache.batik.i18n.Localizable implementation
/**
- * Provides a way to the user to specify a locale which override the
- * default one. If null is passed to this method, the used locale
- * becomes the global one.
- * @param l The locale to set.
+ * Returns the current locale or null if the locale currently used is
+ * the default one.
*/
public Locale getLocale() {
// <!> TODO : in Rhino the local is for a thread not a scope..
@@ -520,8 +495,10 @@
}
/**
- * Returns the current locale or null if the locale currently used is
- * the default one.
+ * Provides a way to the user to specify a locale which override the
+ * default one. If null is passed to this method, the used locale
+ * becomes the global one.
+ * @param locale The locale to set.
*/
public void setLocale(Locale locale) {
// <!> TODO : in Rhino the local is for a thread not a scope..
@@ -539,23 +516,5 @@
*/
public String formatMessage(String key, Object[] args) {
return null;
- }
-
- public class ExtendedContext extends Context {
- public ExtendedContext() {
- super();
- }
-
- public RhinoInterpreter getInterpreter() {
- return RhinoInterpreter.this;
- }
-
- public Window getWindow() {
- return RhinoInterpreter.this.getWindow();
- }
-
- public ScriptableObject getGlobalObject() {
- return RhinoInterpreter.this.getGlobalObject();
- }
}
}
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/WindowWrapper.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/WindowWrapper.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/WindowWrapper.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/script/rhino/WindowWrapper.java Mon Jul 11 19:05:44 2005
@@ -47,12 +47,23 @@
private final static Object[] EMPTY_ARGUMENTS = new Object[0];
/**
+ * The rhino interpreter.
+ */
+ protected RhinoInterpreter interpreter;
+
+ /**
+ * The wrapped window.
+ */
+ protected Window window;
+
+ /**
* Creates a new WindowWrapper.
*/
public WindowWrapper(Context context) {
super(context);
- String[] names = { "setInterval", "setTimeout", "clearInterval", "clearTimeout",
- "parseXML", "getURL", "alert", "confirm", "prompt" };
+ String[] names = { "setInterval", "setTimeout", "clearInterval",
+ "clearTimeout", "parseXML", "getURL", "postURL",
+ "alert", "confirm", "prompt" };
try {
this.defineFunctionProperties(names, WindowWrapper.class,
ScriptableObject.DONTENUM);
@@ -78,7 +89,9 @@
Function funObj)
throws JavaScriptException {
int len = args.length;
- Window window = ((RhinoInterpreter.ExtendedContext)cx).getWindow();
+ WindowWrapper ww = (WindowWrapper)thisObj;
+ Window window = ww.window;
+
if (len < 2) {
throw Context.reportRuntimeError("invalid argument count");
}
@@ -105,7 +118,8 @@
Function funObj)
throws JavaScriptException {
int len = args.length;
- Window window = ((RhinoInterpreter.ExtendedContext)cx).getWindow();
+ WindowWrapper ww = (WindowWrapper)thisObj;
+ Window window = ww.window;
if (len < 2) {
throw Context.reportRuntimeError("invalid argument count");
}
@@ -132,7 +146,8 @@
Function funObj)
throws JavaScriptException {
int len = args.length;
- Window window = ((RhinoInterpreter.ExtendedContext)cx).getWindow();
+ WindowWrapper ww = (WindowWrapper)thisObj;
+ Window window = ww.window;
if (len >= 1) {
window.clearInterval(Context.toType(args[0], Object.class));
}
@@ -147,7 +162,8 @@
Function funObj)
throws JavaScriptException {
int len = args.length;
- Window window = ((RhinoInterpreter.ExtendedContext)cx).getWindow();
+ WindowWrapper ww = (WindowWrapper)thisObj;
+ Window window = ww.window;
if (len >= 1) {
window.clearTimeout(Context.toType(args[0], Object.class));
}
@@ -162,8 +178,8 @@
Function funObj)
throws JavaScriptException {
int len = args.length;
- final Window window =
- ((RhinoInterpreter.ExtendedContext)cx).getWindow();
+ WindowWrapper ww = (WindowWrapper)thisObj;
+ final Window window = ww.window;
if (len < 2) {
throw Context.reportRuntimeError("invalid argument count");
}
@@ -190,8 +206,8 @@
Function funObj)
throws JavaScriptException {
int len = args.length;
- final Window window = ((RhinoInterpreter.ExtendedContext)cx).getWindow();
- final ScriptableObject go = ((RhinoInterpreter.ExtendedContext)cx).getGlobalObject();
+ WindowWrapper ww = (WindowWrapper)thisObj;
+ final Window window = ww.window;
if (len < 2) {
throw Context.reportRuntimeError("invalid argument count");
}
@@ -201,10 +217,10 @@
Window.URLResponseHandler urlHandler = null;
if (args[1] instanceof Function) {
urlHandler = new GetURLFunctionWrapper
- (interp, (Function)args[1], go);
+ (interp, (Function)args[1], ww);
} else {
urlHandler = new GetURLObjectWrapper
- (interp, (NativeObject)args[1], go);
+ (interp, (NativeObject)args[1], ww);
}
final Window.URLResponseHandler fw = urlHandler;
@@ -239,8 +255,8 @@
Function funObj)
throws JavaScriptException {
int len = args.length;
- final Window window = ((RhinoInterpreter.ExtendedContext)cx).getWindow();
- final ScriptableObject go = ((RhinoInterpreter.ExtendedContext)cx).getGlobalObject();
+ WindowWrapper ww = (WindowWrapper)thisObj;
+ final Window window = ww.window;
if (len < 3) {
throw Context.reportRuntimeError("invalid argument count");
}
@@ -251,10 +267,10 @@
Window.URLResponseHandler urlHandler = null;
if (args[2] instanceof Function) {
urlHandler = new GetURLFunctionWrapper
- (interp, (Function)args[2], go);
+ (interp, (Function)args[2], ww);
} else {
urlHandler = new GetURLObjectWrapper
- (interp, (NativeObject)args[2], go);
+ (interp, (NativeObject)args[2], ww);
}
final Window.URLResponseHandler fw = urlHandler;
@@ -269,6 +285,7 @@
return null;
}
}, acc);
+ break;
case 4:
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
@@ -278,6 +295,7 @@
return null;
}
}, acc);
+ break;
default:
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
@@ -300,7 +318,8 @@
Function funObj)
throws JavaScriptException {
int len = args.length;
- Window window = ((RhinoInterpreter.ExtendedContext)cx).getWindow();
+ WindowWrapper ww = (WindowWrapper)thisObj;
+ Window window = ww.window;
if (len >= 1) {
String message =
(String)Context.toType(args[0], String.class);
@@ -317,7 +336,8 @@
Function funObj)
throws JavaScriptException {
int len = args.length;
- Window window = ((RhinoInterpreter.ExtendedContext)cx).getWindow();
+ WindowWrapper ww = (WindowWrapper)thisObj;
+ Window window = ww.window;
if (len >= 1) {
String message =
(String)Context.toType(args[0], String.class);
@@ -338,7 +358,8 @@
Function funObj)
throws JavaScriptException {
int len = args.length;
- Window window = ((RhinoInterpreter.ExtendedContext)cx).getWindow();
+ WindowWrapper ww = (WindowWrapper)thisObj;
+ Window window = ww.window;
switch (len) {
case 0:
return Context.toObject("", thisObj);
@@ -417,18 +438,18 @@
protected Function function;
/**
- * The Scope for callback
+ * The WindowWrapper
*/
- protected ScriptableObject scope;
+ protected WindowWrapper windowWrapper;
/**
* Creates a wrapper.
*/
public GetURLFunctionWrapper(RhinoInterpreter ri, Function fct,
- ScriptableObject sc) {
+ WindowWrapper ww) {
interpreter = ri;
function = fct;
- scope = sc;
+ windowWrapper = ww;
}
/**
@@ -443,7 +464,8 @@
try {
interpreter.callHandler
(function,
- new GetURLDoneArgBuilder(success, mime, content, scope));
+ new GetURLDoneArgBuilder(success, mime,
+ content, windowWrapper));
} catch (JavaScriptException e) {
throw new WrappedException(e);
}
@@ -469,7 +491,7 @@
/**
* The Scope for the callback.
*/
- private ScriptableObject scope;
+ private WindowWrapper windowWrapper;
private static final String COMPLETE = "operationComplete";
@@ -478,10 +500,10 @@
*/
public GetURLObjectWrapper(RhinoInterpreter ri,
ScriptableObject obj,
- ScriptableObject sc) {
+ WindowWrapper ww) {
interpreter = ri;
object = obj;
- scope = sc;
+ windowWrapper = ww;
}
/**
@@ -496,7 +518,8 @@
try {
interpreter.callMethod
(object, COMPLETE,
- new GetURLDoneArgBuilder(success, mime, content, scope));
+ new GetURLDoneArgBuilder(success, mime,
+ content, windowWrapper));
} catch (JavaScriptException e) {
Context.exit();
throw new WrappedException(e);
@@ -508,14 +531,14 @@
implements RhinoInterpreter.ArgumentsBuilder {
boolean success;
String mime, content;
- ScriptableObject scope;
+ WindowWrapper windowWrapper;
public GetURLDoneArgBuilder(boolean success,
String mime, String content,
- ScriptableObject scope) {
+ WindowWrapper ww) {
this.success = success;
this.mime = mime;
this.content = content;
- this.scope = scope;
+ this.windowWrapper = ww;
}
public Object[] buildArguments() {
@@ -524,11 +547,11 @@
(success) ? Boolean.TRUE : Boolean.FALSE);
if (mime != null) {
so.put("contentType", so,
- Context.toObject(mime, scope));
+ Context.toObject(mime, windowWrapper));
}
if (content != null) {
so.put("content", so,
- Context.toObject(content, scope));
+ Context.toObject(content, windowWrapper));
}
return new Object [] { so };
}
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/AbstractImageHandlerEncoder.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/AbstractImageHandlerEncoder.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/AbstractImageHandlerEncoder.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/AbstractImageHandlerEncoder.java Mon Jul 11 19:05:44 2005
@@ -98,7 +98,6 @@
}
/**
- * @param generatorContext the context in which the handler will work.
* @param imageDir directory where this handler should generate images.
* If null, an SVGGraphics2DRuntimeException is thrown.
* @param urlRoot root for the urls that point to images created by this
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/AbstractSVGConverter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/AbstractSVGConverter.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/AbstractSVGConverter.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/AbstractSVGConverter.java Mon Jul 11 19:05:44 2005
@@ -53,7 +53,7 @@
protected List defSet = new LinkedList();
/**
- * @param genratorContext can be used by the SVGConverter extentions
+ * @param generatorContext can be used by the SVGConverter extensions
* to create Elements and other types of DOM objects.
*/
public AbstractSVGConverter(SVGGeneratorContext generatorContext) {
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/DOMGroupManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/DOMGroupManager.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/DOMGroupManager.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/DOMGroupManager.java Mon Jul 11 19:05:44 2005
@@ -65,22 +65,22 @@
* Reference to the GraphicContext this manager will use to
* reflect style attributes in the tree nodes.
*/
- private GraphicContext gc;
+ protected GraphicContext gc;
/**
* DOMTreeManager that this group manager cooperates with
*/
- private DOMTreeManager domTreeManager;
+ protected DOMTreeManager domTreeManager;
/**
* Current group's SVG GraphicContext state
*/
- private SVGGraphicContext groupGC;
+ protected SVGGraphicContext groupGC;
/**
* Current group node
*/
- private Element currentGroup;
+ protected Element currentGroup;
/**
* Constructor
@@ -136,8 +136,9 @@
currentGroup.appendChild(element);
groupGC = domTreeManager.gcConverter.toSVG(gc);
- SVGGraphicContext deltaGC = processDeltaGC(groupGC,
- domTreeManager.defaultGC);
+ SVGGraphicContext deltaGC;
+ deltaGC = processDeltaGC(groupGC,
+ domTreeManager.defaultGC);
domTreeManager.getStyleHandler().
setStyle(currentGroup, deltaGC.getGroupContext(),
domTreeManager.getGeneratorContext());
@@ -217,14 +218,14 @@
* overrides. Only differences in the group context are considered
* overrides.
*/
- private int countOverrides(SVGGraphicContext deltaGC) {
+ protected int countOverrides(SVGGraphicContext deltaGC) {
return deltaGC.getGroupContext().size();
}
/**
* Removes properties that do not apply for a specific element
*/
- private void trimContextForElement(SVGGraphicContext svgGC, Element element) {
+ protected void trimContextForElement(SVGGraphicContext svgGC, Element element) {
String tag = element.getTagName();
Map groupAttrMap = svgGC.getGroupContext();
if (tag != null) {
@@ -246,7 +247,7 @@
* Processes the transform attribute value corresponding to a
* given transform stack
*/
- private void setTransform(Element element,
+ protected void setTransform(Element element,
TransformStackElement transformStack[]) {
String transform = domTreeManager.gcConverter.
toSVG(transformStack).trim();
@@ -259,7 +260,7 @@
* in gc that are different from the values in referenceGc will be
* present in the delta. Other values will no.
*/
- private SVGGraphicContext processDeltaGC(SVGGraphicContext gc,
+ protected SVGGraphicContext processDeltaGC(SVGGraphicContext gc,
SVGGraphicContext referenceGc) {
Map groupDelta = processDeltaMap(gc.getGroupContext(),
referenceGc.getGroupContext());
@@ -310,7 +311,7 @@
* are different from values in referenceMap are place in the
* returned delta Map.
*/
- private Map processDeltaMap(Map map, Map referenceMap) {
+ protected Map processDeltaMap(Map map, Map referenceMap) {
// no need to be synch => HashMap
Map mapDelta = new HashMap();
Iterator iter = map.keySet().iterator();
Modified: xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/DOMTreeManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/DOMTreeManager.java?rev=215909&r1=215908&r2=215909&view=diff
==============================================================================
--- xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/DOMTreeManager.java (original)
+++ xmlgraphics/batik/branches/svg12/sources/org/apache/batik/svggen/DOMTreeManager.java Mon Jul 11 19:05:44 2005
@@ -70,13 +70,13 @@
* Set of group managers that build groups for
* this manager
*/
- private Vector groupManagers = new Vector();
+ protected Vector groupManagers = new Vector();
/**
* Set of definitions that are to be placed at the top of the
* document tree
*/
- private List genericDefSet = new LinkedList();
+ protected List genericDefSet = new LinkedList();
/**
* Default SVG GraphicContext state
@@ -86,7 +86,7 @@
/**
* Top level group
*/
- private Element topLevelGroup;
+ protected Element topLevelGroup;
/**
* Used to convert the Java 2D API graphic context state
@@ -99,30 +99,25 @@
* The context that stores the domFactory, the imageHandler
* and the extensionHandler.
*/
- private SVGGeneratorContext generatorContext;
+ protected SVGGeneratorContext generatorContext;
/**
* Converters used bVy this object to translate graphic context
* attributes
*/
- private SVGBufferedImageOp filterConverter;
+ protected SVGBufferedImageOp filterConverter;
/**
* Set of definitions which can be used by custom extensions
*/
- private List otherDefs;
+ protected List otherDefs;
/**
* Constructor
* @param gc default graphic context state
- * @param domFactory used to create top level svg root node
- * and children group nodes.
- * @param extensionHandler used by SVGConverters to handle custom
- * implementations of interfaces such as Paint,
- * Composite and BufferedImageOp.
+ * @param generatorContext the SVG generator context
* @param maxGCOverrides defines how many overrides are allowed
* in children nodes of the current group.
- * @param imageHandler used by SVGConverters to handle image elements.
*/
public DOMTreeManager(GraphicContext gc,
SVGGeneratorContext generatorContext,
@@ -185,7 +180,7 @@
/**
* Reset the state of this object to handler a new topLevelGroup
*/
- private void recycleTopLevelGroup(){
+ protected void recycleTopLevelGroup(){
recycleTopLevelGroup(true);
}
@@ -193,7 +188,7 @@
/**
* Reset the state of this object to handler a new topLevelGroup
*/
- private void recycleTopLevelGroup(boolean recycleConverters){
+ protected void recycleTopLevelGroup(boolean recycleConverters){
// First, recycle group managers
int nManagers = groupManagers.size();
for(int i=0; i<nManagers; i++){
@@ -215,8 +210,9 @@
}
/**
- * Sets the topLevelGroup to the input element. This will throw an exception
- * if the input element is not of type 'g' or if it is null.
+ * Sets the topLevelGroup to the input element. This will throw an
+ * exception if the input element is not of type 'g' or if it is
+ * null.
*/
public void setTopLevelGroup(Element topLevelGroup){
if(topLevelGroup == null)
@@ -280,8 +276,8 @@
* definitions
*/
public Element getGenericDefinitions() {
- // when called several times, this will create several generic definition
- // elements... not sure it is desired behavior...
+ // when called several times, this will create several generic
+ // definition elements... not sure it is desired behavior...
Element genericDefs =
generatorContext.domFactory.createElementNS(SVG_NAMESPACE_URI,
SVG_DEFS_TAG);
@@ -304,7 +300,7 @@
/**
* This will change the extension handler on the
* <code>SVGGeneratorContext</code>.
- * @param new extension handler this object should use
+ * @param extensionHandler new extension handler this object should use
*/
void setExtensionHandler(ExtensionHandler extensionHandler) {
generatorContext.setExtensionHandler(extensionHandler);