Hi ,

control_batik <[EMAIL PROTECTED]> wrote on 09/22/2008 11:45:47 AM:

> I realized something new.
> Due to your question, I started to draw many icons, more than 378, and 
the
> white regions didn't  appear, but after this, I drag one , white areas
> everywhere!!!!.
> 
> this is the way I drag an icon: 

   So I think the code is ok, but the real question is where do
you run this code?  I'm guessing in the Swing thread.  If so that 
is your problem.

   I will repeat that _ALL_ interaction with the DOM _MUST_ be done in
the update manager thread.  So getting an element by ID, getting and
most importantly setting attributes _MUST_ be done in the update
manager's thread or bad things will happen.

> public void moveElement(SVGGraphicElement e, Point2D.Double point)
>     {
>         if (e != null) 
>         {
>             Element elt = 
this.getBasedocument().getElementById(e.getId());
>             if (elt != null) 
>             {
>                 Element elementg = (Element)
> elt.getElementsByTagName("g").item(0);
>                 Point2D.Double newpoint = this.scaledPoint(new
> Point2D.Double(point.getX(), point.getY()));
>                 elementg.setAttribute("transform", "translate(" + 
newpoint.x
> + "," + newpoint.y + ")");
>                 e.setPosition(newpoint);
>             }
>         }
>     }
> 
> 
> public Point2D.Double scaledPoint(Point2D.Double originalPoint) {
>         AffineTransform viewBoxTranfrom =
> this.getSvgCanvas().getViewBoxTransform();
>         Point2D.Double destinypoint = new Point2D.Double();
>         try {
>             viewBoxTranfrom = viewBoxTranfrom.createInverse();
>         } catch (NoninvertibleTransformException e) {
>             e.printStackTrace();
>         }
>         double[] matrix = new double[6];
>         viewBoxTranfrom.getMatrix(matrix);
>         destinypoint.x = (float) (matrix[0] * originalPoint.x + 
matrix[2] *
> originalPoint.y + matrix[4]);
>         destinypoint.y = (float) (matrix[1] * originalPoint.x + 
matrix[3] *
> originalPoint.y + matrix[5]);
>         return destinypoint;
>     }
> Do you see something wrong, inefficient or unecessary?.

Reply via email to