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/02/24 12:15:14 UTC
svn commit: r380641 - in /xmlgraphics/batik/trunk: samples/extensions/
sources/org/apache/batik/bridge/ sources/org/apache/batik/extension/svg/
sources/org/apache/batik/gvt/ sources/org/apache/batik/gvt/font/
sources/org/apache/batik/gvt/text/ sources/...
Author: deweese
Date: Fri Feb 24 03:15:03 2006
New Revision: 380641
URL: http://svn.apache.org/viewcvs?rev=380641&view=rev
Log:
1) Fixed NPE when the Batik flowText extension lacks any text.
2) Optimizations in Arabic text handling (thanks dvholten)
3) Added 'getters' for fill and stroke properties on GVT Painters.
4) Corrected bounding code in Image Zoom Interactor (Thanks Urs)
Modified:
xmlgraphics/batik/trunk/samples/extensions/flowTextAlign.svg
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGTextElementBridge.java
xmlgraphics/batik/trunk/sources/org/apache/batik/extension/svg/BatikFlowTextElementBridge.java
xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/FillShapePainter.java
xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/StrokeShapePainter.java
xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java
xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/text/ArabicTextHandler.java
xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractImageZoomInteractor.java
xmlgraphics/batik/trunk/test-references/samples/extensions/flowTextAlign.png
xmlgraphics/batik/trunk/test-resources/org/apache/batik/test/samplesRendering.xml
Modified: xmlgraphics/batik/trunk/samples/extensions/flowTextAlign.svg
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/samples/extensions/flowTextAlign.svg?rev=380641&r1=380640&r2=380641&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/samples/extensions/flowTextAlign.svg (original)
+++ xmlgraphics/batik/trunk/samples/extensions/flowTextAlign.svg Fri Feb 24 03:15:03 2006
@@ -163,6 +163,21 @@
</g>
</g>
+ <!-- check a totally empty flow text element. -->
+ <g font-family="serif" transform="translate(0,405)" >
+ <g fill="rgb(220,220,255)">
+ <rect x="12.5" y="0" width="125" height="72"/>
+ </g>
+
+ <flowText xmlns="http://xml.apache.org/batik/ext"
+ font-size="24" xml:space="preserve">
+ <flowRegion vertical-align="top">
+ <rect x="12.5" y="0" width="125" height="72"/>
+ </flowRegion>
+ <flowPara/>
+ </flowText>
+ </g>
+
<!-- ============================================================= -->
<!-- Batik sample mark -->
<!-- ============================================================= -->
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGTextElementBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGTextElementBridge.java?rev=380641&r1=380640&r2=380641&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGTextElementBridge.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/SVGTextElementBridge.java Fri Feb 24 03:15:03 2006
@@ -877,10 +877,10 @@
if (preserve)
endLimit = asb.length();
- Map map = getAttributeMap(ctx, element, textPath, bidiLevel);
- Object o = map.get(TextAttribute.BIDI_EMBEDDING);
+ Map map = getAttributeMap(ctx, element, textPath, bidiLevel);
+ Object o = map.get(TextAttribute.BIDI_EMBEDDING);
Integer subBidiLevel = bidiLevel;
- if (o != null)
+ if (o != null)
subBidiLevel = ((Integer)o);
for (Node n = getFirstChild(element);
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/extension/svg/BatikFlowTextElementBridge.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/extension/svg/BatikFlowTextElementBridge.java?rev=380641&r1=380640&r2=380641&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/extension/svg/BatikFlowTextElementBridge.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/extension/svg/BatikFlowTextElementBridge.java Fri Feb 24 03:15:03 2006
@@ -137,6 +137,8 @@
Element element) {
List rgns = getRegions(ctx, element);
AttributedString ret = getFlowDiv(ctx, element);
+ if (ret == null) return ret;
+
ret.addAttribute(FLOW_REGIONS, rgns, 0, 1);
return ret;
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/FillShapePainter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/FillShapePainter.java?rev=380641&r1=380640&r2=380641&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/FillShapePainter.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/FillShapePainter.java Fri Feb 24 03:15:03 2006
@@ -65,6 +65,13 @@
}
/**
+ * Gets the paint used to draw the outline of the shape.
+ */
+ public Paint getPaint() {
+ return paint;
+ }
+
+ /**
* Paints the specified shape using the specified Graphics2D.
*
* @param g2d the Graphics2D to use
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/StrokeShapePainter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/StrokeShapePainter.java?rev=380641&r1=380640&r2=380641&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/StrokeShapePainter.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/StrokeShapePainter.java Fri Feb 24 03:15:03 2006
@@ -77,12 +77,26 @@
}
/**
+ * Gets the stroke used to draw the outline of the shape.
+ */
+ public Stroke getStroke() {
+ return stroke;
+ }
+
+ /**
* Sets the paint used to fill a shape.
*
* @param newPaint the paint object used to draw the shape
*/
public void setPaint(Paint newPaint) {
this.paint = newPaint;
+ }
+
+ /**
+ * Gets the paint used to draw the outline of the shape.
+ */
+ public Paint getPaint() {
+ return paint;
}
/**
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java?rev=380641&r1=380640&r2=380641&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/font/AWTGVTGlyphVector.java Fri Feb 24 03:15:03 2006
@@ -799,11 +799,7 @@
int end = endGlyphIndex+ci.getBeginIndex();
for (char c = ci.setIndex(start); ci.getIndex() <= end; c=ci.next()) {
- if (ArabicTextHandler.isLigature(c)) {
- charCount += ArabicTextHandler.getNumChars(c);
- } else {
- charCount++;
- }
+ charCount += ArabicTextHandler.getNumChars(c);
}
return charCount;
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/text/ArabicTextHandler.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/text/ArabicTextHandler.java?rev=380641&r1=380640&r2=380641&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/text/ArabicTextHandler.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/gvt/text/ArabicTextHandler.java Fri Feb 24 03:15:03 2006
@@ -263,11 +263,14 @@
*/
public static boolean arabicCharTransparent(char c) {
int charVal = c;
- if ((charVal >= 0x064B && charVal <= 0x0655) ||
+ if ((charVal < 0x064B) || (charVal > 0x06ED))
+ return false;
+
+ if ((charVal <= 0x0655) ||
(charVal == 0x0670) ||
(charVal >= 0x06D6 && charVal <= 0x06E4) ||
(charVal >= 0x06E7 && charVal <= 0x06E8) ||
- (charVal >= 0x06EA && charVal <= 0x06ED)) {
+ (charVal >= 0x06EA)) {
return true;
}
return false;
@@ -466,33 +469,37 @@
}
/**
- * Returns the number of characters the glyph for the specified character
- * represents. If the glyph represents a ligature this will be 2, otherwise 1.
+ * Returns the number of characters the glyph for the specified
+ * character represents. If the glyph represents a ligature this
+ * will be 2, otherwise 1.
*
* @param c The character to test.
* @return The number of characters the glyph for c represents.
*/
public static int getNumChars(char c) {
// if c is a ligature returns 2, else returns 1
- if (isLigature(c)) {
+ if (isLigature(c))
// at the moment only support ligatures with two chars
return 2;
- }
return 1;
}
/**
- * Returns true if the glyph for the specified character respresents a ligature.
+ * Returns true if the glyph for the specified character
+ * respresents a ligature.
*
* @param c The character to test.
* @return True if c is a ligature, false otherwise.
*/
public static boolean isLigature(char c) {
int charVal = c;
- if ((charVal >= 0xFE70 && charVal <= 0xFE72)
- || (charVal == 0xFE74)
- || (charVal >= 0xFE76 && charVal <= 0xFE7F)
- || (charVal >= 0xFEF5 && charVal <= 0xFEFC)) {
+ if ((charVal < 0xFE70) || (charVal > 0xFEFC))
+ return false;
+
+ if ((charVal <= 0xFE72) ||
+ (charVal == 0xFE74) ||
+ (charVal >= 0xFE76 && charVal <= 0xFE7F) ||
+ (charVal >= 0xFEF5)) {
return true;
}
return false;
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractImageZoomInteractor.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractImageZoomInteractor.java?rev=380641&r1=380640&r2=380641&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractImageZoomInteractor.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractImageZoomInteractor.java Fri Feb 24 03:15:03 2006
@@ -106,20 +106,22 @@
* bounds of the component).
*/
public void mouseDragged(MouseEvent e) {
+ AffineTransform at;
JGVTComponent c = (JGVTComponent)e.getSource();
xCurrent = e.getX();
yCurrent = e.getY();
- AffineTransform at = AffineTransform.getTranslateInstance(xStart, yStart);
+ at = AffineTransform.getTranslateInstance(xStart, yStart);
int dy = yCurrent - yStart;
+ double s;
if (dy < 0) {
- dy = (dy > -5) ? 15 : dy - 10;
+ dy -= 10;
+ s = (dy > -15) ? 1.0 : -15.0/dy;
} else {
- dy = (dy < 5) ? 15 : dy + 10;
+ dy += 10;
+ s = (dy < 15) ? 1.0 : dy/15.0;
}
- double s = dy / 15.0;
- s = (s > 0) ? s : -1 / s;
at.scale(s, s);
at.translate(-xStart, -yStart);
Modified: xmlgraphics/batik/trunk/test-references/samples/extensions/flowTextAlign.png
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/test-references/samples/extensions/flowTextAlign.png?rev=380641&r1=380640&r2=380641&view=diff
==============================================================================
Binary files - no diff available.
Modified: xmlgraphics/batik/trunk/test-resources/org/apache/batik/test/samplesRendering.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/test-resources/org/apache/batik/test/samplesRendering.xml?rev=380641&r1=380640&r2=380641&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/test-resources/org/apache/batik/test/samplesRendering.xml (original)
+++ xmlgraphics/batik/trunk/test-resources/org/apache/batik/test/samplesRendering.xml Fri Feb 24 03:15:03 2006
@@ -53,10 +53,10 @@
<test id="samples/textRotateShadows.svg" />
</testGroup>
- <testGroup id="svg1.2" name="SVG Version 1.2 functionality tests">
+ <testGroup id="tests.spec12" name="SVG Version 1.2 functionality tests">
<test id="samples/tests/spec12/text/flowBidi.svg" >
<property name="Validating" class="java.lang.Boolean" value="false" />
- </test>
+ </test>
<test id="samples/tests/spec12/text/flowText.svg" >
<property name="Validating" class="java.lang.Boolean" value="false" />
</test>