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 2006/09/14 12:35:35 UTC
svn commit: r443308 - in
/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge:
SVGTextElementBridge.java svg12/SVGFlowRootElementBridge.java
Author: deweese
Date: Thu Sep 14 03:35:32 2006
New Revision: 443308
URL: http://svn.apache.org/viewvc?view=rev&rev=443308
Log:
Fixed SVGTextContent interfaces on FlowRoot Elements
Modified:
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGTextElementBridge.java
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGTextElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGTextElementBridge.java?view=diff&rev=443308&r1=443307&r2=443308
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGTextElementBridge.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGTextElementBridge.java Thu Sep 14 03:35:32 2006
@@ -163,6 +163,9 @@
return new SVGTextElementBridge();
}
+ protected TextNode getTextNode() {
+ return (TextNode)node;
+ }
/**
* Creates a <tt>GraphicsNode</tt> according to the specified parameters.
*
@@ -647,7 +650,7 @@
|| ln.equals(SVG_LENGTH_ADJUST_ATTRIBUTE)) {
char c = ln.charAt(0);
if (c == 'x' || c == 'y') {
- ((TextNode) node).setLocation(getLocation(ctx, e));
+ getTextNode().setLocation(getLocation(ctx, e));
}
computeLaidoutText(ctx, e, node);
return;
@@ -748,8 +751,8 @@
if (hasNewACI)
return;
- TextNode tn = (TextNode)node;
- if (tn.getAttributedCharacterIterator() == null)
+ TextNode textNode = getTextNode();
+ if (textNode.getAttributedCharacterIterator() == null)
return;
TextPaintInfo pi, oldPI;
@@ -765,16 +768,16 @@
//the child
TextPaintInfo parentPI;
parentPI = getParentTextPaintInfo(cssProceedElement);
- pi = getTextPaintInfo(cssProceedElement, tn, parentPI, ctx);
+ pi = getTextPaintInfo(cssProceedElement, textNode, parentPI, ctx);
oldPI = (TextPaintInfo)elemTPI.get(cssProceedElement);
}
if (oldPI == null) return;
- tn.swapTextPaintInfo(pi, oldPI);
+ textNode.swapTextPaintInfo(pi, oldPI);
if (usingComplexSVGFont)
// Force Complex SVG fonts to be recreated
- tn.setAttributedCharacterIterator
- (tn.getAttributedCharacterIterator());
+ textNode.setAttributedCharacterIterator
+ (textNode.getAttributedCharacterIterator());
}
int getElementStartIndex(Element element) {
@@ -2265,7 +2268,7 @@
protected int getNumberOfChars(Element element){
AttributedCharacterIterator aci;
- aci = ((TextNode)node).getAttributedCharacterIterator();
+ aci = getTextNode().getAttributedCharacterIterator();
if (aci == null)
return 0;
@@ -2287,9 +2290,10 @@
* org.w3c.dom.svg.SVGTextContentElement#getExtentOfChar(int charnum)}.
*/
protected Rectangle2D getExtentOfChar(Element element,int charnum ){
+ TextNode textNode = getTextNode();
AttributedCharacterIterator aci;
- aci = ((TextNode)node).getAttributedCharacterIterator();
+ aci = textNode.getAttributedCharacterIterator();
if (aci == null) return null;
int firstChar = getElementStartIndex(element);
@@ -2298,7 +2302,7 @@
return null;
//retrieve the text run for the text node
- List list = getTextRuns((TextNode)node);
+ List list = getTextRuns(textNode);
//find the character 'charnum' in the text run
CharacterInformation info;
@@ -2346,9 +2350,10 @@
* org.w3c.dom.svg.SVGTextContentElement#getStartPositionOfChar(int charnum)}.
*/
protected Point2D getStartPositionOfChar(Element element,int charnum){
+ TextNode textNode = getTextNode();
AttributedCharacterIterator aci;
- aci = ((TextNode)node).getAttributedCharacterIterator();
+ aci = textNode.getAttributedCharacterIterator();
if (aci == null)
return null;
@@ -2357,7 +2362,7 @@
return null;
//retrieve the text run for the text node
- List list = getTextRuns((TextNode)node);
+ List list = getTextRuns(textNode);
//find the character 'charnum' in the text run
CharacterInformation info;
@@ -2397,9 +2402,10 @@
* org.w3c.dom.svg.SVGTextContentElement#getEndPositionOfChar(int charnum)}.
*/
protected Point2D getEndPositionOfChar(Element element,int charnum ){
+ TextNode textNode = getTextNode();
AttributedCharacterIterator aci;
- aci = ((TextNode)node).getAttributedCharacterIterator();
+ aci = textNode.getAttributedCharacterIterator();
if (aci == null)
return null;
@@ -2408,7 +2414,7 @@
return null;
//retrieve the text run for the text node
- List list = getTextRuns((TextNode)node);
+ List list = getTextRuns(textNode);
//find the glyph information for the character 'charnum'
CharacterInformation info;
@@ -2449,9 +2455,10 @@
* org.w3c.dom.svg.SVGTextContentElement#getRotationOfChar(int charnum)}.
*/
protected float getRotationOfChar(Element element, int charnum){
+ TextNode textNode = getTextNode();
AttributedCharacterIterator aci;
- aci = ((TextNode)node).getAttributedCharacterIterator();
+ aci = textNode.getAttributedCharacterIterator();
if (aci == null)
return 0;
@@ -2461,7 +2468,7 @@
return 0;
//retrieve the text run for the text node
- List list = getTextRuns((TextNode)node);
+ List list = getTextRuns(textNode);
//find the glyph information for the character 'charnum'
CharacterInformation info;
@@ -2531,12 +2538,13 @@
float length = 0;
+ TextNode textNode = getTextNode();
+
AttributedCharacterIterator aci;
- aci = ((TextNode)node).getAttributedCharacterIterator();
+ aci = textNode.getAttributedCharacterIterator();
if (aci == null)
return -1;
- TextNode textNode = (TextNode)node;
int firstChar = getElementStartIndex(element);
if ( firstChar == -1 )
@@ -2667,12 +2675,13 @@
* manager in JSVGComponent.
*/
protected void selectSubString(Element element, int charnum, int nchars) {
+ TextNode textNode = getTextNode();
+
AttributedCharacterIterator aci;
- aci = ((TextNode)node).getAttributedCharacterIterator();
+ aci = textNode.getAttributedCharacterIterator();
if (aci == null)
return;
- TextNode textNode = (TextNode)node;
int firstChar = getElementStartIndex(element);
if ( firstChar == -1 )
@@ -2700,8 +2709,8 @@
}
protected int getCharNumAtPosition(Element e, float x, float y){
+ TextNode textNode = getTextNode();
- TextNode textNode = (TextNode)node;
AttributedCharacterIterator aci;
aci = textNode.getAttributedCharacterIterator();
if (aci == null)
@@ -2838,7 +2847,8 @@
Rectangle2D rect) {
Set elems = new HashSet();
- TextNode tn = (TextNode)node;
+ TextNode tn = getTextNode();
+
List list = tn.getTextRuns();
if (list == null)
return elems;
@@ -2882,7 +2892,7 @@
public Set getTextEnclosureSet(AffineTransform at,
Rectangle2D rect) {
- TextNode tn = (TextNode)node;
+ TextNode tn = getTextNode();
Set elems = new HashSet();
List list = tn.getTextRuns();
@@ -2943,7 +2953,7 @@
}
if (txtBridge == null) return false;
- TextNode tn = (TextNode)txtBridge.node;
+ TextNode tn = txtBridge.getTextNode();
List list = tn.getTextRuns();
if (list == null)
return false;
@@ -3015,7 +3025,7 @@
}
if (txtBridge == null) return null;
- TextNode tn = (TextNode)txtBridge.node;
+ TextNode tn = txtBridge.getTextNode();
List list = tn.getTextRuns();
if (list == null)
return null;
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java?view=diff&rev=443308&r1=443307&r2=443308
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/svg12/SVGFlowRootElementBridge.java Thu Sep 14 03:35:32 2006
@@ -61,6 +61,7 @@
import org.apache.batik.dom.util.XLinkSupport;
import org.apache.batik.gvt.CompositeGraphicsNode;
import org.apache.batik.gvt.GraphicsNode;
+import org.apache.batik.gvt.TextNode;
import org.apache.batik.gvt.flow.BlockInfo;
import org.apache.batik.gvt.flow.FlowTextNode;
import org.apache.batik.gvt.flow.RegionInfo;
@@ -128,6 +129,10 @@
*/
protected Map flowRegionNodes;
+ protected TextNode textNode;
+
+ protected TextNode getTextNode() { return textNode; }
+
/**
* Listener for flowRegion changes.
*/
@@ -211,11 +216,20 @@
if (ctx.getTextPainter() != null) {
tn.setTextPainter(ctx.getTextPainter());
}
-
+ textNode = tn;
cgn.add(tn);
associateSVGContext(ctx, e, cgn);
+ // traverse the children to add SVGContext
+ Node child = getFirstChild(e);
+ while (child != null) {
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ addContextToChild(ctx,(Element)child);
+ }
+ child = getNextSibling(child);
+ }
+
return cgn;
}
@@ -348,7 +362,14 @@
}
}
- super.addContextToChild(ctx, e);
+ // traverse the children to add SVGContext
+ Node child = getFirstChild(e);
+ while (child != null) {
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ addContextToChild(ctx,(Element)child);
+ }
+ child = getNextSibling(child);
+ }
}
/**