Hi Mistercaste,
mistercaste <[email protected]> wrote on 11/09/2009 03:39:09 AM:
> The following function allows to keep constant or proportional (see
comments)
> the text of a JSVGCanvas after zoom operations. Hope it can be useful.
> Thanks to Thomas Deweese for support.
I'm glad you were able to get things working. Could I ask one
little thing?
Batik has a Wiki which would be a good place to put example code
like this. Could you write a small 'article' and attach this code:
http://wiki.apache.org/xmlgraphics-batik/FrontPage
Thanks
> private void antiTransformText() {
>
> final Element textElementsGroup =
>
canvas.getSVGDocument().getElementById(AbstractDOM.STRIDSYMTESTOCENTROIDI);
> final NodeList textElement = textElementsGroup.getChildNodes();
> final int multiplier = 15;// Scale factor multiplier
>
> for (int i = 0; i < textElement.getLength(); i++) {
>
> final Element element = (Element) textElement.item(i);
>
> try {
> final AffineTransform crt =
> canvas.getRenderingTransform().createInverse();
>
> // Constant scale factor
> // final double scala = (crt.getScaleX() < crt.getScaleY())?
> crt.getScaleX() * multiplier : crt.getScaleY() * multiplier;
>
> // Autoreduced scale factor
> final double scala = Math.sqrt((crt.getScaleX() <
> crt.getScaleY()) ? crt.getScaleX() * multiplier : crt.getScaleY() *
> multiplier);
>
> final SVGLocatable loc = (SVGLocatable) element;
> final SVGRect bbox = loc.getBBox();
> if (bbox != null) {
> final float cx = bbox.getX();
> final float cy = bbox.getY();
>
> canvas.getUpdateManager().getUpdateRunnableQueue().
> invokeLater(new Runnable() {
>
> @Override
> public void run() {
> // DOM Actions
> element.setAttributeNS(
> null,
> "transform",
> "translate(" + cx + "," + cy + "), " +
> "scale(" + scala + "), " +
> "translate(" + (-cx) + "," + (-cy) +
")");
> }
> });
> }
> } catch (NoninvertibleTransformException ex) {
> Logger.getLogger(JFrameSvg.class.getName()).log(Level.SEVERE,
> null, ex);
> }
> }
> }
> --
> View this message in context: http://old.nabble.com/JSVGCanvas---
> Constant-text-size-tp26262831p26262831.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>