opensubscriber
   Find in this group all groups
 
Unknown more information…

b : batik-users@xmlgraphics.apache.org 23 March 2005 • 10:35PM -0500

Re: Adding a BufferedImage to an SVG document?
by Steve Lamont

REPLY TO AUTHOR
 
REPLY TO GROUP




>     Text is quite tricky.  You need to manipulate the TextPaintInfo
> object that is attached to the AttributedString associated with the
> TextNode.  The tricky bit is that all of the tspan's are built into
> the one AttributedString so if you have 'complex' text you would have
> to track down the proper TextPaintInfo to update.

Do you mean `AttributedCharacterIterator'?  I see no AttributedString'
in a `TextNode'.

Is there a reason why all of this is so darned Byzantine?

Why, for instance, is a `StrokingTextPainter' so radically different
than a 'StrokeShapePainter'?  In the `StrokeShapePainter' there's a
`setPaint()' method that allows one to set the color of the object,
whereas in the `StrokingTextPainter' no such method exists and one has
to go through extraordinary contortions to get at the `TextPaintInfo'
for each individual *character* in a text string in order to set
color:

    private void updateTextNodeColor( Color rgb, TextNode text_node )

    {

AttributedCharacterIterator aci =
    text_node.getAttributedCharacterIterator();

for( char c = aci.first();
     c != CharacterIterator.DONE;
     c = aci.next() ) {

    TextPaintInfo tpi =
( TextPaintInfo ) aci.getAttribute( TextNode.PAINT_INFO );
    
    if ( tpi.fillPaint != null )
tpi.fillPaint = rgb;
    if ( tpi.strokePaint != null )
tpi.strokePaint = rgb;

}

    }

It took me most of a day to figure out that you had to slog through
each character, one by one, in order to get all the characters in the
same string the same color.

I beg your pardon but that's just bizarre.

Oh, one minor point.  In `TextPaintInfo', the method name
`equivilent()' should be `equivalent()'.  I know in computing that
spelling doesn't necessarily have to be correct, but still. . .

spl

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlg...
For additional commands, e-mail: batik-users-help@xmlg...

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.