batik-users@xmlgraphics.apache.org
[Top] [All Lists]

Re: Some white areas appear after many zoom in, zoom out and pan action

Subject: Re: Some white areas appear after many zoom in, zoom out and pan actions
From:
Date: Mon, 22 Sep 2008 12:39:35 -0400

Hi ,

control_batik <a20022065@xxxxxxxxxxx> 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?.
<Prev in Thread] Current Thread [Next in Thread>