You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Hervé Girod <he...@club-internet.fr> on 2003/06/13 03:10:03 UTC
Retriveing TextNodes Characteristics
Hello,
I'm currently trying to use Batik with an EMFGraphics2D (coming from FreeHep package) in order to generate a windows Metafile corresponding with a SVG document.
In fact, I have developped a new transcoder, which inherits from the SVGAbstractTranscoder class.
The main method i use iterates in the GVT Tree (using GVTTreeWalker), beginning by the root GraphicsNode. For each node in the iteration, I set the AffineTransform of this node, and then I paint using the appropriate painter. By example :
if (node instanceof ShapeNode) {
ShapePainter painter = ((ShapeNode)node).getShapePainter();
if (painter != null) painter.paint(graphics2d);
...
My problem is that I would like to paint the TextNodes I encounter, not by using Batik default TextPainters, but by directly drawing the associated String in the EMFGraphics2D - with the classic drawString method (if I use a default TextPainter, texts are represented by bits of lines, but I want to obtain vector EMF text instead) : and although I'm able to retrieve the GVTFont (and its proper size), I'm not able to retrieve the text color in a TextNode =>
Example :
java.util.List runlist = node.getTextRuns();
Iterator it = runlist.iterator();
while (it.hasNext()) {
StrokingTextPainter.TextRun run = (StrokingTextPainter.TextRun)(it.next());
AttributedCharacterIterator aci = run.getACI();
aci.first();
Paint paint = (Paint)aci.getAttribute(STROKE_PAINT); <= always null !!
I'm surely completely forgetting something basic, but what ?...
Thanks !
Re: Retriveing TextNodes Characteristics
Posted by Hervé Girod <he...@club-internet.fr>.
Thank you. Of course, you were right. It's now working well !
----- Original Message -----
From: "Thomas E Deweese" <th...@kodak.com>
To: <ba...@xml.apache.org>; "Hervé Girod" <he...@club-internet.fr>
Sent: Friday, June 13, 2003 12:33 PM
Subject: RE: Retriveing TextNodes Characteristics
>>>>> "HG" == Hervé Girod <he...@club-internet.fr> writes:
HG> Hello, I'm currently trying to use Batik with an EMFGraphics2D
HG> (coming from FreeHep package) in order to generate a windows
HG> Metafile corresponding with a SVG document.
HG> (if I use a default TextPainter, texts are represented by bits of
HG> lines, but I want to obtain vector EMF text instead) : and
HG> although I'm able to retrieve the GVTFont (and its proper size),
HG> I'm not able to retrieve the text color in a TextNode =>
You were very close (from batik.gvt.font.AWTGVTGlyphVector):
Paint fillPaint = (Paint)aci.getAttribute(TextAttribute.FOREGROUND);
Stroke stroke = (Stroke) aci.getAttribute
(GVTAttributedCharacterIterator.TextAttribute.STROKE);
Paint strokePaint = (Paint) aci.getAttribute
(GVTAttributedCharacterIterator.TextAttribute.STROKE_PAINT);
HG> I'm surely completely forgetting something basic, but what ?...
You were getting the value of the 'stroke' (the outline) not the
fill.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org
RE: Retriveing TextNodes Characteristics
Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "HG" == Hervé Girod <he...@club-internet.fr> writes:
HG> Hello, I'm currently trying to use Batik with an EMFGraphics2D
HG> (coming from FreeHep package) in order to generate a windows
HG> Metafile corresponding with a SVG document.
HG> (if I use a default TextPainter, texts are represented by bits of
HG> lines, but I want to obtain vector EMF text instead) : and
HG> although I'm able to retrieve the GVTFont (and its proper size),
HG> I'm not able to retrieve the text color in a TextNode =>
You were very close (from batik.gvt.font.AWTGVTGlyphVector):
Paint fillPaint = (Paint)aci.getAttribute(TextAttribute.FOREGROUND);
Stroke stroke = (Stroke) aci.getAttribute
(GVTAttributedCharacterIterator.TextAttribute.STROKE);
Paint strokePaint = (Paint) aci.getAttribute
(GVTAttributedCharacterIterator.TextAttribute.STROKE_PAINT);
HG> I'm surely completely forgetting something basic, but what ?...
You were getting the value of the 'stroke' (the outline) not the
fill.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org