Hi
I have a problem that seems to be quite simple, but I have had quite a
headache trying to solve it.
I have an external library that produces SVG-images (pretty simple,
lines, paths, rectangles, circles, polygons, and text, nothing fancy). I
also have an external component where I need to draw these images (this
I can't change, so using JSVGCanvas is not possible). Everything else
works just fine, but I am having trouble with texts. In certain
circumstances texts need to be drawn upside down. Ascii is an bit bad
format to present what I mean, but hopefully next image helps to
understand:
Library produces:
+--------+
| AW |
| |
+--------+
And it needs to be converted to:
+--------+
| VM | // V is A upside down and M is W upside down
| | // note that this is not rotated string, only each letter
+--------+ // is rotated
I've figured out that the AffineTransformation I need to use is simple
scale(1.0, -1,0), but the problem is that the TextNodes do not seem to
do transformation at all. Here is how I have tried to solve the
situation:
First I naturally build a GVT-tree from a generated SVG-document. When
encountering a TextNode I've tried following:
AttributedCharacterIterator iter =
textnode.getAttributedCharacterIterator();
if (iter == null) {
return;
}
AttributedString text = new AttributedString(iter);
// I doesn't matter if rotate_letters is concatenated with orig or not
AffineTransform orig = textnode.getTransform();
AffineTransform rotate_letters = AffineTransform.getScaleInstance(1.0,
-1.0);
rotate_letters.concatenate(orig);
TransformAttribute tranformAttribute = new
TransformAttribute(rotate_letters);
text.addAttribute(java.awt.font.TextAttribute.TRANSFORM,
tranformAttribute);
// this doen't seem to have effect
textnode.setAttributedCharacterIterator(text.getIterator());
textnode.paint(g2d);
Also following does not work
// I doesn't matter if rotate_letters is concatenated with orig or not
AffineTransform orig = textnode.getTransform();
AffineTransform rotate_letters = AffineTransform.getScaleInstance(1.0,
-1.0);
rotate_letters.concatenate(orig);
textnode.setTransform(rotate_letters);
These and all other solutions I've tried do not seem to work at all
(text doesn't change). Can anyone point me to right direction or tell
what I am doing wrong? Thanks in advance.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]