tkormann 01/09/17 01:11:05
Modified: sources/org/apache/batik/gvt TextNode.java
sources/org/apache/batik/gvt/renderer
StrokingTextPainter.java
Log:
start cleaning GVT.
Revision Changes Path
1.14 +38 -34 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- TextNode.java 2001/09/13 13:10:55 1.13
+++ TextNode.java 2001/09/17 08:11:04 1.14
@@ -13,6 +13,8 @@
import java.awt.RenderingHints;
import java.awt.Shape;
+import java.awt.font.FontRenderContext;
+
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
@@ -23,6 +25,8 @@
import java.util.List;
+import org.apache.batik.gvt.renderer.StrokingTextPainter;
+
import org.apache.batik.gvt.text.AttributedCharacterSpanIterator;
import org.apache.batik.gvt.text.GVTAttributedCharacterIterator;
import org.apache.batik.gvt.text.Mark;
@@ -31,7 +35,7 @@
* A graphics node that represents text.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
- * @version $Id: TextNode.java,v 1.13 2001/09/13 13:10:55 tkormann Exp $
+ * @version $Id: TextNode.java,v 1.14 2001/09/17 08:11:04 tkormann Exp $
*/
public class TextNode extends AbstractGraphicsNode implements Selectable {
@@ -72,6 +76,17 @@
protected AttributedCharacterIterator[] chunkACIs = null;
/**
+ * The text painter used to display the text of this text node.
+ */
+ protected TextPainter textPainter = new StrokingTextPainter();
+
+ /**
+ * The font render context to use.
+ */
+ protected FontRenderContext fontRenderContext =
+ new FontRenderContext(new AffineTransform(), true, true);
+
+ /**
* Internal Cache: Bounds for this text node, without taking any of the
* rendering attributes (e.g., stroke) into account
*/
@@ -92,6 +107,7 @@
*/
public TextNode() {}
+
/**
* Returns a list of text runs.
*/
@@ -203,8 +219,8 @@
public Rectangle2D getPrimitiveBounds(GraphicsNodeRenderContext rc){
if (primitiveBounds == null) {
if (aci != null) {
- primitiveBounds = rc.getTextPainter().getPaintedBounds(this,
- rc.getFontRenderContext());
+ primitiveBounds = textPainter.getPaintedBounds
+ (this, fontRenderContext);
} else {
// Don't cache if ACI is null
System.out.println("ACI is null for " + this);
@@ -223,8 +239,7 @@
public Rectangle2D getGeometryBounds(GraphicsNodeRenderContext rc){
if (geometryBounds == null){
if (aci != null) {
- geometryBounds = rc.getTextPainter().getBounds(this,
- rc.getFontRenderContext());
+ geometryBounds = textPainter.getBounds(this, fontRenderContext);
} else {
// Don't cache if ACI is null
System.out.println("ACI is null for " + this);
@@ -251,8 +266,7 @@
public Shape getOutline(GraphicsNodeRenderContext rc) {
Shape outline;
if (aci != null) {
- outline = rc.getTextPainter().getDecoratedShape
- (this, rc.getFontRenderContext());
+ outline = textPainter.getDecoratedShape(this, fontRenderContext);
} else {
// don't cache this now
return new Rectangle2D.Float(0, 0, 0, 0);
@@ -270,8 +284,8 @@
* @param the anchor of this node
*/
public boolean selectAt(double x, double y, GraphicsNodeRenderContext rc) {
- beginMark = rc.getTextPainter().selectAt(x, y, aci, this, rc);
- return true; // assume this always changes selection, for now.
+ beginMark = textPainter.selectAt(x, y, aci, this, rc);
+ return true; // assume this always changes selection, for now.
}
/**
@@ -280,9 +294,7 @@
* @param the anchor of this node
*/
public boolean selectTo(double x, double y, GraphicsNodeRenderContext rc) {
- Mark tmpMark =
- rc.getTextPainter().selectTo(x, y, beginMark, aci, this, rc);
-
+ Mark tmpMark = textPainter.selectTo(x, y, beginMark, aci, this, rc);
boolean result = false;
if (tmpMark != endMark) {
endMark = tmpMark;
@@ -297,8 +309,8 @@
* @param the anchor of this node
*/
public boolean selectAll(double x, double y, GraphicsNodeRenderContext rc) {
- beginMark = rc.getTextPainter().selectFirst(x, y, aci, this, rc);
- endMark = rc.getTextPainter().selectLast(x, y, aci, this, rc);
+ beginMark = textPainter.selectFirst(x, y, aci, this, rc);
+ endMark = textPainter.selectLast(x, y, aci, this, rc);
return true;
}
@@ -308,22 +320,20 @@
* @return an object containing the selected content.
*/
public Object getSelection(GraphicsNodeRenderContext rc) {
- int[] ranges = rc.getTextPainter().getSelected(
- aci, beginMark, endMark);
+ int[] ranges = textPainter.getSelected(aci, beginMark, endMark);
Object o = null;
- // TODO: later we can return more complex things like
+ // TODO: later we can return more complex things like
// noncontiguous selections
if ((ranges != null) && (ranges.length > 1)) {
-
// make sure that they are in order
if (ranges[0] > ranges[1]) {
int temp = ranges[1];
ranges[1] = ranges[0];
ranges[0] = temp;
}
- o = new AttributedCharacterSpanIterator(
- aci, ranges[0], ranges[1]+1);
+ o = new AttributedCharacterSpanIterator
+ (aci, ranges[0], ranges[1]+1);
}
return o;
}
@@ -334,12 +344,8 @@
* @return a Shape which encloses the current text selection.
*/
public Shape getHighlightShape(GraphicsNodeRenderContext rc) {
- Shape highlightShape;
- // System.out.println("getting highlight shape for " + this);
- highlightShape =
- rc.getTextPainter().getHighlightShape(beginMark,
- endMark);
-
+ Shape highlightShape =
+ textPainter.getHighlightShape(beginMark, endMark);
AffineTransform t = getGlobalTransform();
highlightShape = t.createTransformedShape(highlightShape);
return highlightShape;
@@ -358,7 +364,6 @@
if (isVisible) {
super.paint(g2d, rc);
}
-
}
/**
@@ -376,13 +381,8 @@
if(clip != null && !(clip instanceof GeneralPath)){
g2d.setClip(new GeneralPath(clip));
}
-
// Paint the text
- TextPainter textPainter = rc.getTextPainter();
- if(textPainter != null) {
- textPainter.paint(this, g2d, rc);
- }
-
+ textPainter.paint(this, g2d, rc);
}
/**
@@ -395,10 +395,12 @@
* The type of the START anchor.
*/
public static final int ANCHOR_START = 0;
+
/**
* The type of the MIDDLE anchor.
*/
public static final int ANCHOR_MIDDLE = 1;
+
/**
* The type of the END anchor.
*/
@@ -430,7 +432,9 @@
*/
private int type;
- /** No instance of this class. */
+ /**
+ * No instance of this class.
+ */
private Anchor(int type) {
this.type = type;
}
1.11 +7 -6
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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- StrokingTextPainter.java 2001/09/13 08:42:49 1.10
+++ StrokingTextPainter.java 2001/09/17 08:11:05 1.11
@@ -8,7 +8,6 @@
package org.apache.batik.gvt.renderer;
-
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Color;
@@ -58,7 +57,7 @@
* @see org.apache.batik.gvt.text.GVTAttributedCharacterIterator
*
* @author <a href="[EMAIL PROTECTED]>Bill Haneman</a>
- * @version $Id: StrokingTextPainter.java,v 1.10 2001/09/13 08:42:49 tkormann Exp $
+ * @version $Id: StrokingTextPainter.java,v 1.11 2001/09/17 08:11:05 tkormann Exp $
*/
public class StrokingTextPainter extends BasicTextPainter {
@@ -82,7 +81,7 @@
* @param context the rendering context.
*/
public void paint(TextNode node, Graphics2D g2d,
- GraphicsNodeRenderContext context) {
+ GraphicsNodeRenderContext context) {
FontRenderContext frc = context.getFontRenderContext();
AttributedCharacterIterator aci = node.getAttributedCharacterIterator();
@@ -672,9 +671,9 @@
* in bounds computation.
*/
protected Rectangle2D getBounds(TextNode node,
- FontRenderContext context,
- boolean includeDecoration,
- boolean includeStrokeWidth) {
+ FontRenderContext context,
+ boolean includeDecoration,
+ boolean includeStrokeWidth) {
Rectangle2D bounds = getOutline(node, context,
includeDecoration).getBounds2D();
@@ -1236,6 +1235,7 @@
// inner classes
class TextChunk {
+
public int begin;
public int end;
public Point2D advance;
@@ -1254,6 +1254,7 @@
* sub-spans, and the ACI which iterates over that subspan.
*/
class TextRun {
+
private AttributedCharacterIterator aci;
private TextSpanLayout layout;
private int anchorType;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]