tkormann 01/09/19 08:09:30
Modified: sources/org/apache/batik/bridge BridgeContext.java
SVGTextElementBridge.java
sources/org/apache/batik/gvt TextNode.java
sources/org/apache/batik/gvt/renderer
StrokingTextPainter.java
Log:
Add a way to set the TextPainter (on GVT and on the Bridge). Our current
behavior is unchanged.
In order to set on a particular TextNode, a particular TextPainter, use the
setTextPainter method.
In order to set a TextPainter for all TextNode created by the bridge, use the
BridgeContext setTextPainter method.
In order to set a TextPainter on some TextNode depending on the context (basic
or advanced text features) - override the SVGTextElementBridge and do your job.
Revision Changes Path
1.28 +26 -1 xml-batik/sources/org/apache/batik/bridge/BridgeContext.java
Index: BridgeContext.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/BridgeContext.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- BridgeContext.java 2001/09/18 21:18:59 1.27
+++ BridgeContext.java 2001/09/19 15:09:29 1.28
@@ -23,6 +23,7 @@
import org.apache.batik.css.HiddenChildElementSupport;
import org.apache.batik.gvt.GraphicsNode;
+import org.apache.batik.gvt.TextPainter;
import org.apache.batik.script.InterpreterPool;
import org.apache.batik.util.Service;
import org.apache.batik.util.SVGConstants;
@@ -44,7 +45,7 @@
* a SVG DOM tree such as the current viewport or the user agent.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
- * @version $Id: BridgeContext.java,v 1.27 2001/09/18 21:18:59 deweese Exp $
+ * @version $Id: BridgeContext.java,v 1.28 2001/09/19 15:09:29 tkormann Exp $
*/
public class BridgeContext implements ErrorConstants {
@@ -121,6 +122,12 @@
protected Dimension2D documentSize;
/**
+ * The text painter to use. Typically, you can specify the text painter that
+ * will be used be text nodes.
+ */
+ protected TextPainter textPainter;
+
+ /**
* Constructs a new empty bridge context.
*/
protected BridgeContext() {}
@@ -169,6 +176,24 @@
/////////////////////////////////////////////////////////////////////////
// properties
/////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sets the text painter that will be used by text nodes. This attributes
+ * might be used by bridges (especially SVGTextElementBridge) to set the
+ * text painter of each TextNode.
+ *
+ * @param textPainter the text painter for text nodes
+ */
+ public void setTextPainter(TextPainter textPainter) {
+ this.textPainter = textPainter;
+ }
+
+ /**
+ * Returns the text painter that will be used be text nodes.
+ */
+ public TextPainter getTextPainter() {
+ return textPainter;
+ }
/**
* Returns the user agent of this bridge context.
1.36 +7 -1
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.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- SVGTextElementBridge.java 2001/09/18 21:18:59 1.35
+++ SVGTextElementBridge.java 2001/09/19 15:09:29 1.36
@@ -56,7 +56,7 @@
* Bridge class for the <text> element.
*
* @author <a href="[EMAIL PROTECTED]>Bill Haneman</a>
- * @version $Id: SVGTextElementBridge.java,v 1.35 2001/09/18 21:18:59 deweese Exp $
+ * @version $Id: SVGTextElementBridge.java,v 1.36 2001/09/19 15:09:29 tkormann Exp $
*/
public class SVGTextElementBridge extends AbstractSVGBridge
implements GraphicsNodeBridge, ErrorConstants {
@@ -84,6 +84,12 @@
public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
TextNode node = new TextNode();
+ // specify the text painter to use if one has been provided in the
+ // bridge context
+ if (ctx.getTextPainter() != null) {
+ node.setTextPainter(ctx.getTextPainter());
+ }
+
// 'transform'
String s = e.getAttributeNS(null, SVG_TRANSFORM_ATTRIBUTE);
if (s.length() != 0) {
1.18 +23 -2 xml-batik/sources/org/apache/batik/gvt/TextNode.java
Index: TextNode.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/TextNode.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- TextNode.java 2001/09/18 21:19:00 1.17
+++ TextNode.java 2001/09/19 15:09:29 1.18
@@ -35,7 +35,7 @@
* A graphics node that represents text.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
- * @version $Id: TextNode.java,v 1.17 2001/09/18 21:19:00 deweese Exp $
+ * @version $Id: TextNode.java,v 1.18 2001/09/19 15:09:29 tkormann Exp $
*/
public class TextNode extends AbstractGraphicsNode implements Selectable {
@@ -78,7 +78,7 @@
/**
* The text painter used to display the text of this text node.
*/
- protected static TextPainter textPainter = new StrokingTextPainter();
+ protected TextPainter textPainter = StrokingTextPainter.getInstance();
/**
* Internal Cache: Bounds for this text node, without taking any of the
@@ -102,6 +102,27 @@
public TextNode() {
}
+ /**
+ * Sets the text painter of this text node. If the specified text painter is
+ * null, this text node will use its default text painter
+ * (StrokingTextPainter.getInstance()).
+ *
+ * @param textPainter the text painter to use
+ */
+ public void setTextPainter(TextPainter textPainter) {
+ if (textPainter == null) {
+ this.textPainter = StrokingTextPainter.getInstance();
+ } else {
+ this.textPainter = textPainter;
+ }
+ }
+
+ /**
+ * Returns the text painter of this text node.
+ */
+ public TextPainter getTextPainter() {
+ return textPainter;
+ }
/**
* Returns a list of text runs.
1.15 +14 -1
xml-batik/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java
Index: StrokingTextPainter.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- StrokingTextPainter.java 2001/09/18 21:19:01 1.14
+++ StrokingTextPainter.java 2001/09/19 15:09:30 1.15
@@ -35,6 +35,7 @@
import java.util.Vector;
import org.apache.batik.gvt.TextNode;
+import org.apache.batik.gvt.TextPainter;
import org.apache.batik.gvt.font.FontFamilyResolver;
import org.apache.batik.gvt.font.GVTFont;
@@ -59,7 +60,7 @@
* @see org.apache.batik.gvt.text.GVTAttributedCharacterIterator
*
* @author <a href="[EMAIL PROTECTED]>Bill Haneman</a>
- * @version $Id: StrokingTextPainter.java,v 1.14 2001/09/18 21:19:01 deweese Exp $
+ * @version $Id: StrokingTextPainter.java,v 1.15 2001/09/19 15:09:30 tkormann Exp $
*/
public class StrokingTextPainter extends BasicTextPainter {
@@ -69,6 +70,18 @@
extendedAtts.add(GVTAttributedCharacterIterator.TextAttribute.TEXT_COMPOUND_DELIMITER);
extendedAtts.add(GVTAttributedCharacterIterator.TextAttribute.GVT_FONT);
extendedAtts.add(GVTAttributedCharacterIterator.TextAttribute.BIDI_LEVEL);
+ }
+
+ /**
+ * A unique instance of this class.
+ */
+ protected static TextPainter singleton = new StrokingTextPainter();
+
+ /**
+ * Returns a unique instance of this class.
+ */
+ public static TextPainter getInstance() {
+ return singleton;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]