deweese 2004/12/01 17:24:37
Modified: sources/org/apache/batik/bridge RepaintManager.java
SVGTextElementBridge.java
sources/org/apache/batik/bridge/svg12
SVGFlowRootElementBridge.java
sources/org/apache/batik/ext/awt/geom Cubic.java
Quadradic.java
sources/org/apache/batik/gvt ShapeNode.java
sources/org/apache/batik/gvt/flow FlowGlyphLayout.java
LineInfo.java
sources/org/apache/batik/util RunnableQueue.java
test-references/samples/tests/spec12/text flowText.png
Log:
1) Refactored the text and flow bridges so make things cleaner.
2) Now using QuadCurve2d/CubicCurve2D methods to solve cubic/quadradic eqns.
3) Fixed potential interrupted bug in the RunnableQueue class.
Revision Changes Path
1.17 +2 -2
xml-batik/sources/org/apache/batik/bridge/RepaintManager.java
Index: RepaintManager.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/bridge/RepaintManager.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- RepaintManager.java 18 Aug 2004 07:12:32 -0000 1.16
+++ RepaintManager.java 2 Dec 2004 01:24:36 -0000 1.17
@@ -38,7 +38,7 @@
* @version $Id$
*/
public class RepaintManager {
- final static int COPY_OVERHEAD = 1000;
+ final static int COPY_OVERHEAD = 10000;
final static int COPY_LINE_OVERHEAD = 10;
/**
1.101 +49 -78
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.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- SVGTextElementBridge.java 21 Nov 2004 21:20:23 -0000 1.100
+++ SVGTextElementBridge.java 2 Dec 2004 01:24:36 -0000 1.101
@@ -194,6 +194,29 @@
return new Point2D.Float(x, y);
}
+ protected boolean isTextElement(Element e) {
+ if (!SVG_NAMESPACE_URI.equals(e.getNamespaceURI()))
+ return false;
+ String nodeName = e.getLocalName();
+ return (nodeName.equals(SVG_TEXT_TAG) ||
+ nodeName.equals(SVG_TSPAN_TAG) ||
+ nodeName.equals(SVG_ALT_GLYPH_TAG) ||
+ nodeName.equals(SVG_A_TAG) ||
+ nodeName.equals(SVG_TEXT_PATH_TAG) ||
+ nodeName.equals(SVG_TREF_TAG));
+ }
+
+ protected boolean isTextChild(Element e) {
+ if (!SVG_NAMESPACE_URI.equals(e.getNamespaceURI()))
+ return false;
+ String nodeName = e.getLocalName();
+ return (nodeName.equals(SVG_TSPAN_TAG) ||
+ nodeName.equals(SVG_ALT_GLYPH_TAG) ||
+ nodeName.equals(SVG_A_TAG) ||
+ nodeName.equals(SVG_TEXT_PATH_TAG) ||
+ nodeName.equals(SVG_TREF_TAG));
+ }
+
/**
* Builds using the specified BridgeContext and element, the
* specified graphics node.
@@ -360,24 +383,19 @@
//in the case of <title> or <desc> or <metadata>, the layout
//is unchanged
switch( childNode.getNodeType() ){
- case Node.TEXT_NODE:
- case Node.CDATA_SECTION_NODE:
+ case Node.TEXT_NODE:
+ case Node.CDATA_SECTION_NODE:
+ laidoutText = null;
+ break;
+ case Node.ELEMENT_NODE: {
+ Element childElement = (Element)childNode;
+ if (isTextChild(childElement)) {
+ addContextToChild( ctx, childElement);
laidoutText = null;
- break;
- case Node.ELEMENT_NODE:
- if (SVG_NAMESPACE_URI.equals(childNode.getNamespaceURI())) {
- String nodeName = childNode.getLocalName();
- if (nodeName.equals(SVG_TSPAN_TAG) ||
- nodeName.equals(SVG_ALT_GLYPH_TAG) ||
- nodeName.equals(SVG_A_TAG) ||
- nodeName.equals(SVG_TEXT_PATH_TAG) ||
- nodeName.equals(SVG_TREF_TAG)) {
- addContextToChild( ctx, (Element)childNode );
- laidoutText = null;
- }
- }
- break;
- default:
+ }
+ }
+ break;
+ default:
}
if (laidoutText == null) {
computeLaidoutText(ctx, e, node);
@@ -403,7 +421,7 @@
*/
public void handleDOMChildNodeRemovedEvent(MutationEvent evt) {
Node childNode = (Node)evt.getTarget();
-
+
//check the type of the node inserted before discard the layout
//in the case of <title> or <desc> or <metadata>, the layout
//is unchanged
@@ -415,17 +433,9 @@
laidoutText = null;
}
break;
- case Node.ELEMENT_NODE:
- if (SVG_NAMESPACE_URI.equals(childNode.getNamespaceURI())) {
- String nodeName = childNode.getLocalName();
- if (nodeName.equals(SVG_TSPAN_TAG) ||
- nodeName.equals(SVG_ALT_GLYPH_TAG) ||
- nodeName.equals(SVG_A_TAG) ||
- nodeName.equals(SVG_TEXT_PATH_TAG) ||
- nodeName.equals(SVG_TREF_TAG)) {
-
- laidoutText = null;
- }
+ case Node.ELEMENT_NODE:
+ if (isTextChild((Element)childNode)) {
+ laidoutText = null;
}
break;
default:
@@ -469,21 +479,7 @@
*/
protected boolean isParentDisplayed(Node childNode) {
Node parentNode = childNode.getParentNode();
- if (parentNode.getNodeType() == Node.ELEMENT_NODE) {
- if (SVG_NAMESPACE_URI.equals(parentNode.getNamespaceURI())) {
- String nodeName = parentNode.getLocalName();
- if (nodeName.equals(SVG_TEXT_TAG) ||
- nodeName.equals(SVG_TSPAN_TAG) ||
- nodeName.equals(SVG_ALT_GLYPH_TAG) ||
- nodeName.equals(SVG_A_TAG) ||
- nodeName.equals(SVG_TEXT_PATH_TAG) ||
- nodeName.equals(SVG_TREF_TAG)) {
-
- return true;
- }
- }
- }
- return false;
+ return isTextElement((Element)parentNode);
}
/**
@@ -562,19 +558,11 @@
for (Node child = element.getFirstChild();
child != null;
child = child.getNextSibling()) {
- if (child.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
- if (!SVG_NAMESPACE_URI.equals(child.getNamespaceURI())) {
+ if (child.getNodeType() != Node.ELEMENT_NODE)
continue;
- }
- String ln = child.getLocalName();
- if (ln.equals(SVG_TSPAN_TAG) ||
- ln.equals(SVG_ALT_GLYPH_TAG) ||
- ln.equals(SVG_A_TAG) ||
- ln.equals(SVG_TEXT_PATH_TAG) ||
- ln.equals(SVG_TREF_TAG)) {
- Element childElement = (Element)child;
+
+ Element childElement = (Element)child;
+ if (isTextChild(childElement)) {
addNullPaintAttributes(as, childElement, ctx);
}
}
@@ -1259,19 +1247,10 @@
for (Node child = element.getFirstChild();
child != null;
child = child.getNextSibling()) {
- if (child.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
- if (!SVG_NAMESPACE_URI.equals(child.getNamespaceURI()))
- continue;
+ if (child.getNodeType() != Node.ELEMENT_NODE) continue;
- String ln = child.getLocalName();
- if (ln.equals(SVG_TSPAN_TAG) ||
- ln.equals(SVG_ALT_GLYPH_TAG) ||
- ln.equals(SVG_A_TAG) ||
- ln.equals(SVG_TEXT_PATH_TAG) ||
- ln.equals(SVG_TREF_TAG)) {
- Element childElement = (Element)child;
+ Element childElement = (Element)child;
+ if (isTextChild(childElement)) {
addGlyphPositionAttributes(as, childElement, ctx);
}
}
@@ -1308,16 +1287,8 @@
if (child.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
- if (!SVG_NAMESPACE_URI.equals(child.getNamespaceURI()))
- continue;
-
Element childElement = (Element)child;
- String ln = child.getLocalName();
- if (ln.equals(SVG_TSPAN_TAG) ||
- ln.equals(SVG_ALT_GLYPH_TAG) ||
- ln.equals(SVG_A_TAG) ||
- ln.equals(SVG_TEXT_PATH_TAG) ||
- ln.equals(SVG_TREF_TAG)) {
+ if (isTextChild(childElement)) {
TextPaintInfo pi = getTextPaintInfo(childElement, node,
parentPI, ctx);
addPaintAttributes(as, childElement, node, pi, ctx);
1.2 +52 -191
xml-batik/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java
Index: SVGFlowRootElementBridge.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SVGFlowRootElementBridge.java 18 Nov 2004 01:46:55 -0000 1.1
+++ SVGFlowRootElementBridge.java 2 Dec 2004 01:24:37 -0000 1.2
@@ -146,6 +146,34 @@
return new Point2D.Float(0,0);
}
+ protected boolean isTextElement(Element e) {
+ if (!SVG_NAMESPACE_URI.equals(e.getNamespaceURI()))
+ return false;
+ String nodeName = e.getLocalName();
+ return (nodeName.equals(SVG12Constants.SVG_FLOW_DIV_TAG) ||
+ nodeName.equals(SVG12Constants.SVG_FLOW_LINE_TAG) ||
+ nodeName.equals(SVG12Constants.SVG_FLOW_PARA_TAG) ||
+ nodeName.equals(SVG12Constants.SVG_FLOW_REGION_BREAK_TAG) ||
+ nodeName.equals(SVG12Constants.SVG_FLOW_SPAN_TAG));
+ }
+
+ protected boolean isTextChild(Element e) {
+ if (!SVG_NAMESPACE_URI.equals(e.getNamespaceURI()))
+ return false;
+ String nodeName = e.getLocalName();
+ return (nodeName.equals(SVG12Constants.SVG_A_TAG) ||
+ nodeName.equals(SVG12Constants.SVG_FLOW_LINE_TAG) ||
+ nodeName.equals(SVG12Constants.SVG_FLOW_PARA_TAG) ||
+ nodeName.equals(SVG12Constants.SVG_FLOW_REGION_BREAK_TAG) ||
+ nodeName.equals(SVG12Constants.SVG_FLOW_SPAN_TAG));
+ }
+
+ protected void computeLaidoutText(BridgeContext ctx,
+ Element e,
+ GraphicsNode node) {
+ super.computeLaidoutText(ctx, getFlowDivElement(e), node);
+ }
+
/**
* Creates the attributed string which represents the given text
* element children.
@@ -184,204 +212,35 @@
System.out.println(brkStr);
}
- /**
- * Adds glyph position attributes to an AttributedString.
- */
- protected void addGlyphPositionAttributes(AttributedString as,
- Element element,
- BridgeContext ctx) {
- if (element.getNodeType() != Node.ELEMENT_NODE) return;
- String eNS = element.getNamespaceURI();
- if ((!eNS.equals(getNamespaceURI())) &&
- (!eNS.equals(SVG_NAMESPACE_URI)))
- return;
- if (element.getLocalName() != SVG12Constants.SVG_FLOW_ROOT_TAG) {
- // System.out.println("Elem: " + element);
- super.addGlyphPositionAttributes(as, element, ctx);
- return;
- }
-
- for (Node n = element.getFirstChild();
- n != null; n = n.getNextSibling()) {
- if (n.getNodeType() != Node.ELEMENT_NODE) continue;
- String nNS = n.getNamespaceURI();
- if ((!getNamespaceURI().equals(nNS)) &&
- (!SVG_NAMESPACE_URI.equals(nNS))) {
- continue;
- }
- Element e = (Element)n;
- String ln = e.getLocalName();
- if (ln.equals(SVG12Constants.SVG_FLOW_DIV_TAG)) {
- // System.out.println("D Elem: " + e);
- super.addGlyphPositionAttributes(as, e, ctx);
- return;
- }
- }
- }
-
- protected void addChildGlyphPositionAttributes(AttributedString as,
- Element element,
- BridgeContext ctx) {
- // Add Paint attributres for children of text element
- for (Node child = element.getFirstChild();
- child != null;
- child = child.getNextSibling()) {
- if (child.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
- String cNS = child.getNamespaceURI();
- if ((!getNamespaceURI().equals(cNS)) &&
- (!SVG_NAMESPACE_URI.equals(cNS))) {
- continue;
- }
- String ln = child.getLocalName();
- if (ln.equals(SVG12Constants.SVG_FLOW_PARA_TAG) ||
- ln.equals(SVG12Constants.SVG_FLOW_REGION_BREAK_TAG) ||
- ln.equals(SVG12Constants.SVG_FLOW_LINE_TAG) ||
- ln.equals(SVG12Constants.SVG_FLOW_SPAN_TAG) ||
- ln.equals(SVG12Constants.SVG_A_TAG) ||
- ln.equals(SVG12Constants.SVG_TREF_TAG)) {
- addGlyphPositionAttributes(as, (Element)child, ctx);
- }
- }
- }
+ protected Element getFlowDivElement(Element elem) {
+ String eNS = elem.getNamespaceURI();
+ if (!eNS.equals(SVG_NAMESPACE_URI)) return null;
- protected void addNullPaintAttributes(AttributedString as,
- Element element,
- BridgeContext ctx) {
- if (element.getNodeType() != Node.ELEMENT_NODE) return;
- String eNS = element.getNamespaceURI();
- if ((!eNS.equals(getNamespaceURI())) &&
- (!eNS.equals(SVG_NAMESPACE_URI)))
- return;
- if (element.getLocalName() != SVG12Constants.SVG_FLOW_ROOT_TAG) {
- // System.out.println("Elem: " + element);
- super.addNullPaintAttributes(as, element, ctx);
- return;
- }
+ String nodeName = elem.getLocalName();
+ if (nodeName.equals(SVG12Constants.SVG_FLOW_DIV_TAG)) return elem;
- for (Node n = element.getFirstChild();
+ if (!nodeName.equals(SVG12Constants.SVG_FLOW_ROOT_TAG)) return null;
+
+ for (Node n = elem.getFirstChild();
n != null; n = n.getNextSibling()) {
if (n.getNodeType() != Node.ELEMENT_NODE) continue;
- if (!getNamespaceURI().equals(n.getNamespaceURI())) continue;
- Element e = (Element)n;
- String ln = e.getLocalName();
- if (ln.equals(SVG12Constants.SVG_FLOW_DIV_TAG)) {
- // System.out.println("D Elem: " + e);
- super.addNullPaintAttributes(as, e, ctx);
- return;
- }
- }
- }
-
- protected void addChildNullPaintAttributes(AttributedString as,
- Element element,
- BridgeContext ctx) {
- // Add Paint attributres for children of text element
- for (Node child = element.getFirstChild();
- child != null;
- child = child.getNextSibling()) {
- if (child.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
- String cNS = child.getNamespaceURI();
- if ((!getNamespaceURI().equals(cNS)) &&
- (!SVG_NAMESPACE_URI.equals(cNS))) {
- continue;
- }
- String ln = child.getLocalName();
- if (ln.equals(SVG12Constants.SVG_FLOW_PARA_TAG) ||
- ln.equals(SVG12Constants.SVG_FLOW_REGION_BREAK_TAG) ||
- ln.equals(SVG12Constants.SVG_FLOW_LINE_TAG) ||
- ln.equals(SVG12Constants.SVG_FLOW_SPAN_TAG) ||
- ln.equals(SVG12Constants.SVG_A_TAG) ||
- ln.equals(SVG12Constants.SVG_TREF_TAG)) {
- Element childElement = (Element)child;
- addNullPaintAttributes(as, childElement, ctx);
- }
- }
- }
-
- /**
- * Adds painting attributes to an AttributedString.
- */
- protected void addPaintAttributes(AttributedString as,
- Element element,
- TextNode node,
- TextPaintInfo parentPI,
- BridgeContext ctx) {
- if (element.getNodeType() != Node.ELEMENT_NODE) return;
- String eNS = element.getNamespaceURI();
- if ((!eNS.equals(getNamespaceURI())) &&
- (!eNS.equals(SVG_NAMESPACE_URI)))
- return;
- if (element.getLocalName() != SVG12Constants.SVG_FLOW_ROOT_TAG) {
- // System.out.println("Elem: " + element);
- super.addPaintAttributes(as, element, node, parentPI, ctx);
- return;
- }
+ String nNS = n.getNamespaceURI();
+ if (!SVG_NAMESPACE_URI.equals(nNS)) continue;
- for (Node n = element.getFirstChild();
- n != null; n = n.getNextSibling()) {
- if (n.getNodeType() != Node.ELEMENT_NODE) continue;
- if (!getNamespaceURI().equals(n.getNamespaceURI())) continue;
Element e = (Element)n;
String ln = e.getLocalName();
- if (ln.equals(SVG12Constants.SVG_FLOW_DIV_TAG)) {
- // System.out.println("D Elem: " + e);
- super.addPaintAttributes(as, e, node, parentPI, ctx);
- return;
- }
- }
- }
-
- protected void addChildPaintAttributes(AttributedString as,
- Element element,
- TextNode node,
- TextPaintInfo parentPI,
- BridgeContext ctx) {
- // Add Paint attributres for children of text element
- for (Node child = element.getFirstChild();
- child != null;
- child = child.getNextSibling()) {
- if (child.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
- String cNS = child.getNamespaceURI();
- if ((!getNamespaceURI().equals(cNS)) &&
- (!SVG_NAMESPACE_URI.equals(cNS))) {
- continue;
- }
- String ln = child.getLocalName();
- if (ln.equals(SVG12Constants.SVG_FLOW_PARA_TAG) ||
- ln.equals(SVG12Constants.SVG_FLOW_REGION_BREAK_TAG) ||
- ln.equals(SVG12Constants.SVG_FLOW_LINE_TAG) ||
- ln.equals(SVG12Constants.SVG_FLOW_SPAN_TAG) ||
- ln.equals(SVG12Constants.SVG_A_TAG) ||
- ln.equals(SVG12Constants.SVG_TREF_TAG)) {
- Element childElement = (Element)child;
- TextPaintInfo pi = getTextPaintInfo(childElement, node,
- parentPI, ctx);
- addPaintAttributes(as, childElement, node, pi, ctx);
- }
+ if (ln.equals(SVG12Constants.SVG_FLOW_DIV_TAG))
+ return e;
}
+ return null;
}
- protected AttributedString getFlowDiv
- (BridgeContext ctx, Element element) {
- for (Node n = element.getFirstChild();
- n != null; n = n.getNextSibling()) {
- if (n.getNodeType() != Node.ELEMENT_NODE) continue;
- if (!getNamespaceURI().equals(n.getNamespaceURI())) continue;
- Element e = (Element)n;
+ protected AttributedString getFlowDiv(BridgeContext ctx, Element
element) {
+ Element flowDiv = getFlowDivElement(element);
+ if (flowDiv == null) return null;
- String ln = n.getLocalName();
- if (ln.equals(SVG12Constants.SVG_FLOW_DIV_TAG)) {
- return gatherFlowPara(ctx, e);
- }
- }
- return null;
+ return gatherFlowPara(ctx, flowDiv);
}
protected AttributedString gatherFlowPara
@@ -454,15 +313,17 @@
}
protected List getRegions(BridgeContext ctx, Element element) {
+ // Element comes in as flowDiv element we want flowRoot.
+ element = (Element)element.getParentNode();
List ret = new LinkedList();
for (Node n = element.getFirstChild();
n != null; n = n.getNextSibling()) {
if (n.getNodeType() != Node.ELEMENT_NODE) continue;
- if (!getNamespaceURI().equals(n.getNamespaceURI())) continue;
+ if
(!SVG12Constants.SVG_NAMESPACE_URI.equals(n.getNamespaceURI()))
+ continue;
Element e = (Element)n;
-
String ln = e.getLocalName();
if (!SVG12Constants.SVG_FLOW_REGION_TAG.equals(ln)) continue;
@@ -759,8 +620,9 @@
Value v = CSSUtilities.getComputedStyle(element, lineHeightIndex);
if ((v == ValueConstants.INHERIT_VALUE) ||
- (v == SVG12ValueConstants.NORMAL_VALUE))
+ (v == SVG12ValueConstants.NORMAL_VALUE)) {
return fontSize*1.1f;
+ }
float lineHeight = v.getFloatValue();
if (v instanceof ComputedValue)
@@ -768,7 +630,6 @@
if ((v instanceof LineHeightValue) &&
((LineHeightValue)v).getFontSizeRelative())
lineHeight *= fontSize;
-
return lineHeight;
}
}
1.2 +11 -38
xml-batik/sources/org/apache/batik/ext/awt/geom/Cubic.java
Index: Cubic.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/ext/awt/geom/Cubic.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Cubic.java 18 Nov 2004 01:46:58 -0000 1.1
+++ Cubic.java 2 Dec 2004 01:24:37 -0000 1.2
@@ -8,7 +8,9 @@
package org.apache.batik.ext.awt.geom;
+import java.awt.geom.CubicCurve2D;
import java.awt.geom.Point2D;
+import java.awt.geom.QuadCurve2D;
import java.awt.geom.Rectangle2D;
public class Cubic extends AbstractSegment {
@@ -63,44 +65,17 @@
double c0 = 3*(p2-p1);
double c1 = 6*(p3-p2);
double c2 = 3*(p4-p3);
- double c = c0;
- double b = c1-2*c0;
- double a = c2-c1+c0;
- double det = b*b-4*a*c;
- if (det == 0) {
- // one real root.
- double tv = -b/(2*a);
- if ((tv <= 0) || (tv >= 1)) return;
+ double [] eqn = { c0, c1-2*c0, c2-c1+c0 };
+ int roots = QuadCurve2D.solveQuadratic(eqn);
+ for (int r=0; r<roots; r++) {
+ double tv = eqn[r];
+ if ((tv <= 0) || (tv >= 1)) continue;
tv = ((1-tv)*(1-tv)*(1-tv)*p1 +
3*tv*(1-tv)*(1-tv)*p2 +
3*tv*tv*(1-tv)*p3 +
tv*tv*tv*p4);
if (tv < minMax[0]) minMax[0] = tv;
else if (tv > minMax[1]) minMax[1] = tv;
- } else if (det > 0) {
- // Two real roots
- det = Math.sqrt(det);
- double w = -(b + matchSign(det, b));
-
- double tv = (2*c)/w;
- if ((tv > 0) && (tv < 1)) {
- tv = ((1-tv)*(1-tv)*(1-tv)*p1 +
- 3*tv*(1-tv)*(1-tv)*p2 +
- 3*tv*tv*(1-tv)*p3 +
- tv*tv*tv*p4);
- if (tv < minMax[0]) minMax[0] = tv;
- else if (tv > minMax[1]) minMax[1] = tv;
- }
-
- tv = w/(2*a);
- if ((tv > 0) && (tv < 1)) {
- tv = ((1-tv)*(1-tv)*(1-tv)*p1 +
- 3*tv*(1-tv)*(1-tv)*p2 +
- 3*tv*tv*(1-tv)*p3 +
- tv*tv*tv*p4);
- if (tv < minMax[0]) minMax[0] = tv;
- else if (tv > minMax[1]) minMax[1] = tv;
- }
}
}
public double minX() {
@@ -136,12 +111,10 @@
}
protected int findRoots(double y, double [] roots) {
- double d = p1.y-y;
- double c = 3*(p2.y-p1.y);
- double b = 3*(p1.y-2*p2.y+p3.y);
- double a = 3*p2.y-p1.y+p4.y-3*p3.y;
-
- return solveCubic(a, b, c, d, roots);
+ double [] eqn = { p1.y-y, 3*(p2.y-p1.y), 3*(p1.y-2*p2.y+p3.y),
+ 3*p2.y-p1.y+p4.y-3*p3.y };
+ return CubicCurve2D.solveCubic(eqn, roots);
+ // return solveCubic(eqn[3], eqn[2], eqn[1], eqn[0], roots);
}
public Point2D.Double evalDt(double t) {
1.2 +8 -13
xml-batik/sources/org/apache/batik/ext/awt/geom/Quadradic.java
Index: Quadradic.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/ext/awt/geom/Quadradic.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Quadradic.java 18 Nov 2004 01:46:58 -0000 1.1
+++ Quadradic.java 2 Dec 2004 01:24:37 -0000 1.2
@@ -8,11 +8,10 @@
package org.apache.batik.ext.awt.geom;
-import java.util.Arrays;
+import java.awt.geom.CubicCurve2D;
import java.awt.geom.Point2D;
+import java.awt.geom.QuadCurve2D;
import java.awt.geom.Rectangle2D;
-import java.io.PrintStream;
-import java.io.FileOutputStream;
public class Quadradic extends AbstractSegment {
public Point2D.Double p1, p2, p3;
@@ -60,12 +59,10 @@
}
double a = (p1-2*p2+p3);
- double eps = 0.00001;
- if (Math.abs(a) < 4*eps) {
- return;
- }
-
double b = (p2-p1);
+
+ if (a == 0) return;
+
double tv = b/a;
if ((tv <= 0) || (tv >= 1)) return;
@@ -106,11 +103,9 @@
}
protected int findRoots(double y, double [] roots) {
- double a = p1.y-2*p2.y+p3.y;
- double b = 2*(p2.y-p1.y);
- double c = p1.y-y;
-
- return solveQuad(a, b, c, roots);
+ double [] eqn = { p1.y-y, 2*(p2.y-p1.y), p1.y-2*p2.y+p3.y };
+ return QuadCurve2D.solveQuadratic(eqn, roots);
+ // return solveQuad(eqn[2], eqn[1], eqn[0], roots);
}
public Point2D.Double evalDt(double t) {
1.31 +5 -4 xml-batik/sources/org/apache/batik/gvt/ShapeNode.java
Index: ShapeNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/ShapeNode.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- ShapeNode.java 30 Nov 2004 03:23:58 -0000 1.30
+++ ShapeNode.java 2 Dec 2004 01:24:37 -0000 1.31
@@ -417,9 +417,10 @@
}
/**
- * Returns the bounds of the area covered by this node, without taking
any
- * of its rendering attribute into account. i.e., exclusive of any
clipping,
- * masking, filtering or stroking, for example.
+ * Returns the bounds of the area covered by this node, without
+ * taking any of its rendering attribute into account. i.e.,
+ * exclusive of any clipping, masking, filtering or stroking, for
+ * example.
*/
public Rectangle2D getGeometryBounds(){
if (geometryBounds == null) {
1.2 +3 -2
xml-batik/sources/org/apache/batik/gvt/flow/FlowGlyphLayout.java
Index: FlowGlyphLayout.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/gvt/flow/FlowGlyphLayout.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FlowGlyphLayout.java 18 Nov 2004 01:46:59 -0000 1.1
+++ FlowGlyphLayout.java 2 Dec 2004 01:24:37 -0000 1.2
@@ -290,6 +290,7 @@
}
aciIdx = aci.getBeginIndex();
+ int aciEnd = aci.getEndIndex();
char ch = aci.setIndex(aciIdx);
int aciWordStart = aciIdx;
@@ -349,7 +350,7 @@
}
aciIdx += chCnt;
- if (aciIdx > runLimit) {
+ if ((aciIdx > runLimit) && (aciIdx < aciEnd)) {
// Possible font size/style change so record current
// line metrics and start fresh.
GVTLineMetrics lm = gvtFont.getLineMetrics
1.3 +1 -2 xml-batik/sources/org/apache/batik/gvt/flow/LineInfo.java
Index: LineInfo.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/gvt/flow/LineInfo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LineInfo.java 30 Nov 2004 03:23:58 -0000 1.2
+++ LineInfo.java 2 Dec 2004 01:24:37 -0000 1.3
@@ -66,7 +66,6 @@
this.baseline = (float)(fr.getCurrentY()+hLeading+ascent);
this.paraStart = paraStart;
this.paraEnd = false;
-
if (lineHeight > 0) {
fr.newLineHeight(lineHeight);
updateRangeInfo();
1.20 +6 -2
xml-batik/sources/org/apache/batik/util/RunnableQueue.java
Index: RunnableQueue.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/util/RunnableQueue.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- RunnableQueue.java 29 Oct 2004 14:40:54 -0000 1.19
+++ RunnableQueue.java 2 Dec 2004 01:24:37 -0000 1.20
@@ -164,7 +164,11 @@
if (preemptCount != 0) preemptCount--;
if (l == null) {
// No item to run, wait till there is one.
- list.wait();
+ try {
+ list.wait();
+ } catch (InterruptedException ie) {
+ // just loop again.
+ }
continue; // start loop over again...
}
1.2 +410 -115
xml-batik/test-references/samples/tests/spec12/text/flowText.png
<<Binary file>>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]