I have solved this trivially using the SVG attributes.
The fields x and y can't be null, so I can always take
them to locate an element. Here is my code:
private void antiTransformSymbols() {
final Element symbolsGroup =
canvas.getSVGDocument().getElementById(ID_SYMBOLS_GROUP);
LinkedList list = new LinkedList();
recurseLeaves((Node) symbolsGroup, list);// Takes all the leaves of
the symbols group
while (!list.isEmpty()) {// For every symbol..
final Node node = (Node) lista.remove();
// Scale factor
final double scale = (1 /
canvas.getSVGDocument().getRootElement().getCurrentScale()) *
ANTI_ZOOM_MULTIPLIER_SYMBOLS;
/*
* Gets the current element coordinates.
* The fields x and y can't be null because of SVG definition.
*/
final float cx = Float.valueOf(((Element)
node).getAttribute("x"));
final float cy = Float.valueOf(((Element)
node).getAttribute("y"));
canvas.getUpdateManager().getUpdateRunnableQueue().
invokeLater(new Runnable() {
@Override
public void run() {
/*
* DOM actions
* Translation -> Scale -> Translation because the
element
* must be scaled on the center of the reference system.
*/
((Element) node).setAttributeNS(
null,
SVG_TRANSFORM_ATTRIBUTE,
"translate(" + (cx) + "," + (cy) + ")" +
"scale(" + scale + ") " +
"translate(" + (-cx) + "," + (-cy) + ")");
}
});
}
}
Thanks for support.
--
View this message in context:
http://old.nabble.com/SVG-Symbol-Bbox-tp27622473p27685811.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]