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 de...@apache.org on 2005/03/18 01:38:12 UTC
cvs commit: xml-batik/sources/org/apache/batik/parser NumberParser.java
deweese 2005/03/17 16:38:12
Modified: resources/org/apache/batik/dom/resources Messages.properties
sources/org/apache/batik/apps/svgbrowser
ThumbnailDialog.java
sources/org/apache/batik/bridge SVGTextElementBridge.java
sources/org/apache/batik/dom AbstractParentNode.java
sources/org/apache/batik/gvt/font SVGGVTGlyphVector.java
sources/org/apache/batik/parser NumberParser.java
Log:
1) Fixed updates to SVG Font based text (PR 34041)
The problem was that with a Null TextPainter the SVG
Font based text computed zero size.
Thanks Andreas for reporting the problem.
2) AbstractParentNode will now throw a DOM Hierarchy exception
if you try to append a node as a child of it's self (PR 34030)
3) Some code cleanup in the ThumbnailDialog.
4) Bug fix in NumberParser (thanks dvholten)
PR: 34030, 34041
Revision Changes Path
1.8 +3 -0 xml-batik/resources/org/apache/batik/dom/resources/Messages.properties
Index: Messages.properties
===================================================================
RCS file: /home/cvs/xml-batik/resources/org/apache/batik/dom/resources/Messages.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Messages.properties 22 Feb 2005 09:12:55 -0000 1.7
+++ Messages.properties 18 Mar 2005 00:38:12 -0000 1.8
@@ -54,6 +54,9 @@
Cannot add the given node as a child of the current node (type: {0}, \
name: {1}) since it is an ancestor of this one.
+add.self = \
+Cannot add a node as a child of it's self (name: {1})
+
attribute.missing = \
The "{0}" attribute was not found.
1.14 +25 -11 xml-batik/sources/org/apache/batik/apps/svgbrowser/ThumbnailDialog.java
Index: ThumbnailDialog.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/ThumbnailDialog.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ThumbnailDialog.java 18 Aug 2004 07:12:27 -0000 1.13
+++ ThumbnailDialog.java 18 Mar 2005 00:38:12 -0000 1.14
@@ -35,6 +35,7 @@
import java.awt.geom.NoninvertibleTransformException;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
+import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
@@ -53,6 +54,7 @@
import org.apache.batik.swing.svg.SVGDocumentLoaderAdapter;
import org.apache.batik.swing.svg.SVGDocumentLoaderEvent;
import org.apache.batik.util.gui.resource.ResourceManager;
+import org.apache.batik.util.SVGConstants;
import org.w3c.dom.svg.SVGDocument;
import org.w3c.dom.svg.SVGSVGElement;
@@ -159,6 +161,9 @@
if (!(gn instanceof CompositeGraphicsNode))
return null;
CompositeGraphicsNode cgn = (CompositeGraphicsNode)gn;
+ List children = cgn.getChildren();
+ if (children.size() == 0)
+ return null;
gn = (GraphicsNode)cgn.getChildren().get(0);
if (!(gn instanceof CanvasGraphicsNode))
return null;
@@ -174,9 +179,16 @@
SVGSVGElement elt = svgDocument.getRootElement();
Dimension dim = svgThumbnailCanvas.getSize();
- AffineTransform Tx
- = ViewBox.getViewTransform(null, elt, dim.width, dim.height);
- if (Tx.isIdentity()) {
+ String viewBox = elt.getAttributeNS
+ (null, SVGConstants.SVG_VIEW_BOX_ATTRIBUTE);
+
+ AffineTransform Tx;
+ if (viewBox.length() != 0) {
+ String aspectRatio = elt.getAttributeNS
+ (null, SVGConstants.SVG_PRESERVE_ASPECT_RATIO_ATTRIBUTE);
+ Tx = ViewBox.getPreserveAspectRatioTransform
+ (elt, viewBox, aspectRatio, dim.width, dim.height);
+ }else {
// no viewBox has been specified, create a scale transform
Dimension2D docSize = svgCanvas.getSVGDocumentSize();
double sx = dim.width / docSize.getWidth();
@@ -187,13 +199,15 @@
GraphicsNode gn = svgCanvas.getGraphicsNode();
CanvasGraphicsNode cgn = getCanvasGraphicsNode(gn);
- AffineTransform vTx = cgn.getViewingTransform();
- if ((vTx != null) && !vTx.isIdentity()) {
- try {
- AffineTransform invVTx = vTx.createInverse();
- Tx.concatenate(invVTx);
- } catch (NoninvertibleTransformException nite) {
- /* nothing */
+ if (cgn != null) {
+ AffineTransform vTx = cgn.getViewingTransform();
+ if ((vTx != null) && !vTx.isIdentity()) {
+ try {
+ AffineTransform invVTx = vTx.createInverse();
+ Tx.concatenate(invVTx);
+ } catch (NoninvertibleTransformException nite) {
+ /* nothing */
+ }
}
}
1.105 +8 -2 xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java
Index: SVGTextElementBridge.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGTextElementBridge.java,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- SVGTextElementBridge.java 3 Mar 2005 01:19:52 -0000 1.104
+++ SVGTextElementBridge.java 18 Mar 2005 00:38:12 -0000 1.105
@@ -18,6 +18,7 @@
package org.apache.batik.bridge;
import java.awt.AlphaComposite;
+import java.awt.Color;
import java.awt.Composite;
import java.awt.Paint;
import java.awt.RenderingHints;
@@ -521,9 +522,10 @@
// Install the attributes.
addPaintAttributes(as, e, tn, pi, ctx);
- if (usingComplexSVGFont)
+ if (usingComplexSVGFont) {
// Force Complex SVG fonts to be recreated, if we have them.
tn.setAttributedCharacterIterator(as.getIterator());
+ }
}
/**
@@ -549,6 +551,10 @@
int lastChar = getElementEndIndex(aci, element);
TextPaintInfo pi = new TextPaintInfo();
+ // Set some basic props so we can get bounds info for complex paints.
+ pi.visible = true;
+ pi.fillPaint = Color.black;
+
as.addAttribute(PAINT_INFO, pi, firstChar, lastChar+1);
elemTPI.put(element, pi);
1.27 +6 -2 xml-batik/sources/org/apache/batik/dom/AbstractParentNode.java
Index: AbstractParentNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractParentNode.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- AbstractParentNode.java 22 Feb 2005 09:12:58 -0000 1.26
+++ AbstractParentNode.java 18 Mar 2005 00:38:12 -0000 1.27
@@ -440,7 +440,11 @@
"node.from.wrong.document",
new Object[] { new Integer(getNodeType()),
getNodeName() });
-
+ if (this == n)
+ throw createDOMException
+ (DOMException.HIERARCHY_REQUEST_ERR,
+ "add.self", new Object[] { getNodeName() });
+
Node np = n.getParentNode();
if (np == null)
return; // Already removed from tree, do nothing.
1.22 +2 -2 xml-batik/sources/org/apache/batik/gvt/font/SVGGVTGlyphVector.java
Index: SVGGVTGlyphVector.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/font/SVGGVTGlyphVector.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- SVGGVTGlyphVector.java 21 Nov 2004 21:20:23 -0000 1.21
+++ SVGGVTGlyphVector.java 18 Mar 2005 00:38:12 -0000 1.22
@@ -502,7 +502,7 @@
if ( bounds2D == null ){
bounds2D = new Rectangle2D.Float();
}
- cacheTPI = tpi;
+ cacheTPI = new TextPaintInfo(tpi);
return bounds2D;
}
1.11 +3 -3 xml-batik/sources/org/apache/batik/parser/NumberParser.java
Index: NumberParser.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/parser/NumberParser.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- NumberParser.java 18 Aug 2004 07:14:47 -0000 1.10
+++ NumberParser.java 18 Mar 2005 00:38:12 -0000 1.11
@@ -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.
}