xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tonny Kohar <to...@kiyut.com>
Subject Re: Multiple Group Elements Selection and Moving
Date Wed, 21 Jun 2006 03:20:49 GMT
On Mon, 2006-06-19 at 22:52 -0700, Sudhakar S wrote:
> Hi Tonny Kohar, 
> Problem is, finding the transform attribute for multiple group elements.
> After saved into xml file, if i check the values, it is correct for last
> selected group element. But other group elements transform value is not
> correct. so can you please explain how to find the transform attributes for
> all the selected elements correctly?

Here is what we done in our SVG editor

// on mouse pressed we keep the x, y position of the mouse
// and reset the tx,ty (for transform attr later)
public void mousePressed(MouseEvent e) {
        startX = e.getX();
        startY = e.getY();
        tx = 0;
        ty = 0;

// on mouse dragged we keep updating the tx and ty to calculate the
public void mouseDragged(MouseEvent e) {
        tx = e.getX() - startX;
        ty = e.getY() - startY;

// on mouse released we apply the delta to the element (either single or
multiple element
public void mouseReleased(MouseEvent e) {
/* for each element that selected
	calculate the element transform (if any), or any transform into the tx
and ty
	change the attribute for element x and y according to the tx n ty by
adding existing element.x with tx and element.y with ty eg:
	SVGRectElement svgElement = (SVGRectElement)element;
        SVGLength lengthX = svgElement.getX().getBaseVal();
        SVGLength lengthY = svgElement.getY().getBaseVal();


Tonny Kohar
SVG Graphics Editor

To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

View raw message