tkormann 01/12/10 06:20:12
Modified: sources/org/apache/batik/bridge
SVGClipPathElementBridge.java
sources/org/apache/batik/gvt AbstractGraphicsNode.java
GraphicsNode.java
sources/org/apache/batik/gvt/text GlyphLayout.java
test-resources/org/apache/batik/test samplesRendering.xml
Log:
- fix bug in GlyphLayout (combining x and dx didn't work)
- fix bug in clipPath (transform attribute is taken into account)
- 2 new tests added for GlyphLayout (including regard)
- test for clipPath is comming
Revision Changes Path
1.13 +3 -2
xml-batik/sources/org/apache/batik/bridge/SVGClipPathElementBridge.java
Index: SVGClipPathElementBridge.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGClipPathElementBridge.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SVGClipPathElementBridge.java 2001/09/18 21:18:59 1.12
+++ SVGClipPathElementBridge.java 2001/12/10 14:20:11 1.13
@@ -27,7 +27,7 @@
* Bridge class for the <clipPath> element.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
- * @version $Id: SVGClipPathElementBridge.java,v 1.12 2001/09/18 21:18:59 deweese
Exp $
+ * @version $Id: SVGClipPathElementBridge.java,v 1.13 2001/12/10 14:20:11 tkormann
Exp $
*/
public class SVGClipPathElementBridge extends AbstractSVGBridge
implements ClipBridge {
@@ -114,7 +114,8 @@
// compute the outline of the current clipPath's child
int wr = CSSUtilities.convertClipRule(child);
- GeneralPath path = new GeneralPath(clipNode.getOutline());
+ GeneralPath path =
+ new GeneralPath(clipNode.getTransformedOutline());
path.setWindingRule(wr);
Shape outline = Tx.createTransformedShape(path);
1.27 +28 -17 xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java
Index: AbstractGraphicsNode.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- AbstractGraphicsNode.java 2001/09/18 21:18:59 1.26
+++ AbstractGraphicsNode.java 2001/12/10 14:20:11 1.27
@@ -51,7 +51,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Emmanuel Tissandier</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a>
- * @version $Id: AbstractGraphicsNode.java,v 1.26 2001/09/18 21:18:59 deweese Exp $
+ * @version $Id: AbstractGraphicsNode.java,v 1.27 2001/12/10 14:20:11 tkormann Exp $
*/
public abstract class AbstractGraphicsNode implements GraphicsNode {
@@ -241,7 +241,7 @@
*
* @param key the key of the hint to be set
* @param value the value indicating preferences for the specified
- * hint category.
+ * hint category.
*/
public void setRenderingHint(RenderingHints.Key key, Object value) {
if (this.hints == null) {
@@ -479,7 +479,7 @@
/**
* Returns true of an offscreen buffer is needed to render this node, false
- * otherwise.
+ * otherwise.
*/
protected boolean isOffscreenBufferNeeded() {
return ((filter != null) ||
@@ -555,7 +555,7 @@
* Adds the specified graphics node mouse listener to receive graphics node
* mouse events from this node.
*
- * @param l the graphics node mouse listener to add
+ * @param l the graphics node mouse listener to add
*/
public void addGraphicsNodeMouseListener(GraphicsNodeMouseListener l) {
if (listeners == null) {
@@ -568,7 +568,7 @@
* Removes the specified graphics node mouse listener so that it no longer
* receives graphics node mouse events from this node.
*
- * @param l the graphics node mouse listener to remove
+ * @param l the graphics node mouse listener to remove
*/
public void removeGraphicsNodeMouseListener(GraphicsNodeMouseListener l) {
if (listeners != null) {
@@ -580,7 +580,7 @@
* Adds the specified graphics node key listener to receive graphics node
* key events from this node.
*
- * @param l the graphics node key listener to add
+ * @param l the graphics node key listener to add
*/
public void addGraphicsNodeKeyListener(GraphicsNodeKeyListener l) {
if (listeners == null) {
@@ -593,7 +593,7 @@
* Removes the specified graphics node key listener so that it no longer
* receives graphics node key events from this node.
*
- * @param l the graphics node key listener to remove
+ * @param l the graphics node key listener to remove
*/
public void removeGraphicsNodeKeyListener(GraphicsNodeKeyListener l) {
if (listeners != null) {
@@ -709,7 +709,7 @@
* Returns an array of listeners that were added to this node and of the
* specified type.
*
- * @param listenerType the type of the listeners to return
+ * @param listenerType the type of the listeners to return
*/
public EventListener [] getListeners(Class listenerType) {
return listeners.getListeners(listenerType);
@@ -738,7 +738,7 @@
/**
* Returns the root of the GVT tree or null if the node is not part of a GVT
- * tree.
+ * tree.
*/
public RootGraphicsNode getRoot() {
return root;
@@ -839,27 +839,27 @@
// filter.
Rectangle2D tBounds = null;
if (filter == null) {
- // Use txf, not t
+ // Use txf, not t
tBounds = getTransformedPrimitiveBounds(txf);
} else {
tBounds = t.createTransformedShape
- (filter.getBounds2D()).getBounds2D();
+ (filter.getBounds2D()).getBounds2D();
}
// Factor in the clipping area, if any
if (tBounds != null) {
if (clip != null) {
tBounds.intersect
- (tBounds,
- t.createTransformedShape(clip.getClipPath()).getBounds2D(),
- tBounds);
+ (tBounds,
+ t.createTransformedShape(clip.getClipPath()).getBounds2D(),
+ tBounds);
}
// Factor in the mask, if any
if(mask != null) {
tBounds.intersect
- (tBounds,
- t.createTransformedShape(mask.getBounds2D()).getBounds2D(),
- tBounds);
+ (tBounds,
+ t.createTransformedShape(mask.getBounds2D()).getBounds2D(),
+ tBounds);
}
}
@@ -924,6 +924,17 @@
*/
public boolean intersects(Rectangle2D r) {
return getBounds().intersects(r);
+ }
+
+ /**
+ * Returns the transformed outline of this node.
+ */
+ public Shape getTransformedOutline() {
+ if (transform != null) {
+ return transform.createTransformedShape(getOutline());
+ } else {
+ return getOutline();
+ }
}
/**
1.29 +14 -8 xml-batik/sources/org/apache/batik/gvt/GraphicsNode.java
Index: GraphicsNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/GraphicsNode.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- GraphicsNode.java 2001/09/18 21:18:59 1.28
+++ GraphicsNode.java 2001/12/10 14:20:12 1.29
@@ -34,7 +34,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Emmanuel Tissandier</a>
- * @version $Id: GraphicsNode.java,v 1.28 2001/09/18 21:18:59 deweese Exp $
+ * @version $Id: GraphicsNode.java,v 1.29 2001/12/10 14:20:12 tkormann Exp $
*/
public interface GraphicsNode {
@@ -112,7 +112,7 @@
*
* @param key the key of the hint to be set
* @param value the value indicating preferences for the specified
- * hint category.
+ * hint category.
*/
void setRenderingHint(RenderingHints.Key key, Object value);
@@ -199,7 +199,7 @@
* Adds the specified graphics node mouse listener to receive graphics node
* mouse events from this node.
*
- * @param l the graphics node mouse listener to add
+ * @param l the graphics node mouse listener to add
*/
void addGraphicsNodeMouseListener(GraphicsNodeMouseListener l);
@@ -207,7 +207,7 @@
* Removes the specified graphics node mouse listener so that it no longer
* receives graphics node mouse events from this node.
*
- * @param l the graphics node mouse listener to remove
+ * @param l the graphics node mouse listener to remove
*/
void removeGraphicsNodeMouseListener(GraphicsNodeMouseListener l);
@@ -215,7 +215,7 @@
* Adds the specified graphics node key listener to receive graphics node
* key events from this node.
*
- * @param l the graphics node key listener to add
+ * @param l the graphics node key listener to add
*/
void addGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
@@ -223,7 +223,7 @@
* Removes the specified graphics node key listener so that it no longer
* receives graphics node key events from this node.
*
- * @param l the graphics node key listener to remove
+ * @param l the graphics node key listener to remove
*/
void removeGraphicsNodeKeyListener(GraphicsNodeKeyListener l);
@@ -257,7 +257,7 @@
* Returns an array of listeners that were added to this node and of the
* specified type.
*
- * @param listenerType the type of the listeners to return
+ * @param listenerType the type of the listeners to return
*/
EventListener [] getListeners(Class listenerType);
@@ -272,7 +272,7 @@
/**
* Returns the root of the GVT tree or null if the node is not part of a GVT
- * tree.
+ * tree.
*/
RootGraphicsNode getRoot();
@@ -356,4 +356,10 @@
* Returns the outline of this node.
*/
Shape getOutline();
+
+ /**
+ * Returns the transformed outline of this node.
+ */
+ Shape getTransformedOutline();
+
}
1.30 +47 -45 xml-batik/sources/org/apache/batik/gvt/text/GlyphLayout.java
Index: GlyphLayout.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/text/GlyphLayout.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- GlyphLayout.java 2001/11/29 23:11:02 1.29
+++ GlyphLayout.java 2001/12/10 14:20:12 1.30
@@ -42,7 +42,7 @@
* @see org.apache.batik.gvt.text.TextSpanLayout
*
* @author <a href="[EMAIL PROTECTED]>Bill Haneman</a>
- * @version $Id: GlyphLayout.java,v 1.29 2001/11/29 23:11:02 deweese Exp $
+ * @version $Id: GlyphLayout.java,v 1.30 2001/12/10 14:20:12 tkormann Exp $
*/
public class GlyphLayout implements TextSpanLayout {
@@ -108,7 +108,7 @@
* @param offset The offset position of this text layout
* @param frc the FontRenderContext to use for generating glyphs.
*/
- public GlyphLayout(AttributedCharacterIterator aci,
+ public GlyphLayout(AttributedCharacterIterator aci,
int [] charMap,
Point2D offset,
FontRenderContext frc) {
@@ -122,7 +122,7 @@
this.metrics = font.getLineMetrics
(aci, aci.getBeginIndex(), aci.getEndIndex(), frc);
-
+
// create the glyph vector
this.gv = null;
this.aci.first();
@@ -279,7 +279,7 @@
int count = getCharacterCount(i, i);
for (int n=0; n<count; n++) {
int glyphCharIndex = charMap[j++];
- if (charIndex == glyphCharIndex)
+ if (charIndex == glyphCharIndex)
return i;
if (j >= charMap.length)
return -1;
@@ -322,7 +322,7 @@
for (int i = 0; i < numGlyphs; i++) {
char ch = aci.setIndex(currentChar);
int glyphCharIndex = charMap[currentChar-start];
- if ((glyphCharIndex >= beginCharIndex) &&
+ if ((glyphCharIndex >= beginCharIndex) &&
(glyphCharIndex <= endCharIndex)) {
Shape gbounds = gv.getGlyphLogicalBounds(i);
if (gbounds != null) {
@@ -462,7 +462,7 @@
}
// System.out.println("Sorted");
-
+
Point2D.Float pt0 = pts[0];
Point2D.Float pt1 = pts[numPts-1];
Point2D.Float dxdy = new Point2D.Float(pt1.x-pt0.x, pt1.y-pt0.y);
@@ -471,7 +471,7 @@
Point2D.Float [] topList = new Point2D.Float[numPts];
Point2D.Float [] botList = new Point2D.Float[numPts];
botList[0] = topList[0] = pts[0];
- int nTopPts=1;
+ int nTopPts=1;
int nBotPts=1;
for (int i=1; i<numPts-1; i++) {
Point2D.Float pt = pts[i];
@@ -530,7 +530,7 @@
float dy = pt1.y-pt0.y;
float c0 = dy*pt0.x-dx*pt0.y;
soln = dx*pt.y-dy*pt.x+c0;
- if (soln > eps)
+ if (soln > eps)
// Left turn add and we are done..
break;
if (soln > -eps) {
@@ -549,7 +549,7 @@
float dy = pt1.y-pt0.y;
float c0 = dy*pt0.x-dx*pt0.y;
soln = dx*pt.y-dy*pt.x+c0;
- if (soln < -eps)
+ if (soln < -eps)
// Right turn done...
break;
if (soln < eps) {
@@ -575,7 +575,7 @@
// System.out.println("CHull has " + i + " pts");
return i;
}
-
+
public static void addPtsToPath(GeneralPath shape,
Point2D.Float [] topPts,
Point2D.Float [] botPts,
@@ -628,7 +628,7 @@
delta = boxes[6].y-boxes[4].y;
dist += delta*delta;
sz += (float)Math.sqrt(dist);
-
+
delta = ((boxes[0].x+boxes[1].x+boxes[2].x+boxes[3].x)-
(boxes[4].x+boxes[5].x+boxes[6].x+boxes[7].x))/4;
dist = delta*delta;
@@ -659,7 +659,7 @@
// Merge all previous areas
mergeAreas(shape, areas, nAreas);
nAreas = 0; // Start fresh...
-
+
// Then just add box (add the previous char box if first pts)
if (i==2) {
gp.moveTo(boxes[0].x, boxes[0].y);
@@ -682,7 +682,7 @@
mergeAreas(shape, areas, nAreas);
}
- public static void mergeAreas(GeneralPath shape,
+ public static void mergeAreas(GeneralPath shape,
Area []shapes, int nShapes) {
// Merge areas hierarchically, this means that while there are
// the same number of Area.add calls (n-1) the great majority
@@ -871,12 +871,12 @@
protected GVTFont getFont(AttributedCharacterIterator aci) {
aci.first();
GVTFont gvtFont = (GVTFont)aci.getAttributes().get
- (GVTAttributedCharacterIterator.TextAttribute.GVT_FONT);
- if (gvtFont != null)
+ (GVTAttributedCharacterIterator.TextAttribute.GVT_FONT);
+ if (gvtFont != null)
return gvtFont;
- // shouldn't get here
- return new AWTGVTFont(aci.getAttributes());
+ // shouldn't get here
+ return new AWTGVTFont(aci.getAttributes());
}
/**
@@ -890,7 +890,7 @@
aci.first();
textPath = (TextPath) aci.getAttribute
- (GVTAttributedCharacterIterator.TextAttribute.TEXTPATH);
+ (GVTAttributedCharacterIterator.TextAttribute.TEXTPATH);
// if doesn't have an attached text path, just return
if (textPath == null) {
@@ -969,15 +969,15 @@
Point2D nextGlyphPosition = gv.getGlyphPosition(i+1);
if (horizontal) {
- glyphAdvance = (float)(nextGlyphPosition.getX() -
- currentGlyphPosition.getX());
- nextGlyphOffset = (float)(nextGlyphPosition.getY() -
- currentGlyphPosition.getY());
+ glyphAdvance = (float)(nextGlyphPosition.getX() -
+ currentGlyphPosition.getX());
+ nextGlyphOffset = (float)(nextGlyphPosition.getY() -
+ currentGlyphPosition.getY());
} else {
- glyphAdvance = (float)(nextGlyphPosition.getY() -
- currentGlyphPosition.getY());
- nextGlyphOffset = (float)(nextGlyphPosition.getX() -
- currentGlyphPosition.getX());
+ glyphAdvance = (float)(nextGlyphPosition.getY() -
+ currentGlyphPosition.getY());
+ nextGlyphOffset = (float)(nextGlyphPosition.getX() -
+ currentGlyphPosition.getX());
}
} else {
// last glyph, use the glyph metrics
@@ -992,8 +992,8 @@
glyphAdvance = gm.getVerticalAdvance();
}
} else {
- if ((glyphOrientationAngle == 0) ||
- (glyphOrientationAngle == 180)) {
+ if ((glyphOrientationAngle == 0) ||
+ (glyphOrientationAngle == 180)) {
glyphAdvance = gm.getVerticalAdvance();
} else { // 90 || 270
glyphAdvance = gm.getHorizontalAdvance();
@@ -1081,8 +1081,8 @@
currentPosition += glyphAdvance;
glyphOffset += nextGlyphOffset;
currentChar += gv.getCharacterCount(i,i);
- ch = aci.setIndex(aci.getBeginIndex() + i +
- gv.getCharacterCount(i,i));
+ ch = aci.setIndex(aci.getBeginIndex() + i +
+ gv.getCharacterCount(i,i));
}
// store the position where a following glyph should be drawn,
@@ -1092,12 +1092,12 @@
Point2D lastGlyphPos = gv.getGlyphPosition(lastGlyphDrawn);
if (horizontal) {
textPathAdvance = new Point2D.Double
- (lastGlyphPos.getX()+lastGlyphAdvance,
- lastGlyphPos.getY());
+ (lastGlyphPos.getX()+lastGlyphAdvance,
+ lastGlyphPos.getY());
} else {
textPathAdvance = new Point2D.Double
- (lastGlyphPos.getX(),
- lastGlyphPos.getY()+lastGlyphAdvance);
+ (lastGlyphPos.getX(),
+ lastGlyphPos.getY()+lastGlyphAdvance);
}
} else {
textPathAdvance = new Point2D.Double(0,0);
@@ -1152,7 +1152,7 @@
// transform the glyph position
Point2D glyphPos = gv.getGlyphPosition(i);
AffineTransform t = AffineTransform.getTranslateInstance
- (startPos.getX(), startPos.getY());
+ (startPos.getX(), startPos.getY());
t.scale(xscale,yscale);
t.translate(-startPos.getX(), -startPos.getY());
Point2D newGlyphPos = new Point2D.Float();
@@ -1163,11 +1163,11 @@
AffineTransform glyphTransform = gv.getGlyphTransform(i);
if (glyphTransform != null) {
glyphTransform.preConcatenate
- (AffineTransform.getScaleInstance(xscale, yscale));
+ (AffineTransform.getScaleInstance(xscale, yscale));
gv.setGlyphTransform(i, glyphTransform);
} else {
gv.setGlyphTransform
- (i, AffineTransform.getScaleInstance(xscale, yscale));
+ (i, AffineTransform.getScaleInstance(xscale, yscale));
}
}
}
@@ -1581,7 +1581,7 @@
float oy = 0f;
float verticalGlyphRotation = 0f;
float glyphRotation = 0f;
-
+
if (ch != CharacterIterator.DONE) {
if (vertical) {
@@ -1611,11 +1611,11 @@
if (rotation == null || rotation.isNaN()) {
glyphRotation = verticalGlyphRotation;
} else {
- glyphRotation = (rotation.floatValue() +
+ glyphRotation = (rotation.floatValue() +
verticalGlyphRotation);
}
- if (x!= null && !x.isNaN()) {
+ if (x != null && !x.isNaN()) {
if (i==0) {
if (applyOffset) {
curr_x_pos = (float) offset.getX();
@@ -1626,7 +1626,8 @@
} else {
curr_x_pos = x.floatValue();
}
- } else if (dx != null && !dx.isNaN()) {
+ }
+ if (dx != null && !dx.isNaN()) {
curr_x_pos += dx.floatValue();
}
@@ -1641,9 +1642,10 @@
} else {
curr_y_pos = y.floatValue();
}
- } else if (dy != null && !dy.isNaN()) {
+ }
+ if (dy != null && !dy.isNaN()) {
curr_y_pos += dy.floatValue();
- } else if (i>0) {
+ } else if (i > 0) {
curr_y_pos += gp[i*2 + 1]-gp[i*2 - 1];
}
@@ -1709,7 +1711,7 @@
advanceY = gm.getVerticalAdvance();
}
} else {
- if ((glyphOrientationAngle == 0) ||
+ if ((glyphOrientationAngle == 0) ||
(glyphOrientationAngle == 180)) {
advanceY = gm.getVerticalAdvance();
} else if (glyphOrientationAngle == 90) {
@@ -1736,7 +1738,7 @@
glyphTransform.rotate(glyphRotation);
gv.setGlyphTransform(i, glyphTransform);
}
-
+
aciIndex += gv.getCharacterCount(i,i);
ch = aci.setIndex(aciIndex);
i++;
1.57 +3 -1
xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml
Index: samplesRendering.xml
===================================================================
RCS file:
/home/cvs/xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- samplesRendering.xml 2001/12/06 08:13:47 1.56
+++ samplesRendering.xml 2001/12/10 14:20:12 1.57
@@ -8,7 +8,7 @@
<!-- ========================================================================= -->
<!-- @author [EMAIL PROTECTED] -->
-<!-- @version $Id: samplesRendering.xml,v 1.56 2001/12/06 08:13:47 vhardy Exp $ -->
+<!-- @version $Id: samplesRendering.xml,v 1.57 2001/12/10 14:20:12 tkormann Exp $
-->
<!-- ========================================================================= -->
<testSuite id="samplesRendering" name="samples and samples/test Rendering"
class="org.apache.batik.test.svg.SamplesRenderingTest">
@@ -246,6 +246,8 @@
<test id="samples/tests/spec/text/textStyles.svg" />
<test id="samples/tests/spec/text/verticalText.svg" />
<test id="samples/tests/spec/text/verticalTextOnPath.svg" />
+ <test id="samples/tests/spec/text/textPosition.svg" />
+ <test id="samples/tests/spec/text/textPosition2.svg" />
</testGroup>
</testSuite>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]