Repainting a JSVGCanvas

View: New views
11 Messages — Rating Filter:   Alert me  

Repainting a JSVGCanvas

by aaaa aaaa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

how can I force a JSVGCanvas to "repaint" itself? I do not mean the repaint method but the kind of repaint when I resize the internal frame the JSVGCanvas is located in or move the JSVGScrollPane scrollbar.


Thanks in advance.



Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.

Re: Repainting a JSVGCanvas

by Cameron McCormack-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

aaaa aaaa:
> Hi,how can I force a JSVGCanvas to "repaint" itself? I do not mean
> the repaint method but the kind of repaint when I resize the internal
> frame the JSVGCanvas is located in or move the JSVGScrollPane
> scrollbar.Thanks in advance.

Can you be a bit more specific about what behaviour you see and what you
expect?  When you resize the frame the canvas is in, does it just paint
white in the areas you’d expect to see more of your SVG document?  If
so, then the solution might be as simple as putting an
overflow="visible" attribute on your root <svg> element.

--
Cameron McCormack ≝ http://mcc.id.au/

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


Re: Repainting a JSVGCanvas

by aaaa aaaa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

the problem is that I get occasionally a NullPointerException in the ScrollListener of the JSVGCanvas. The variable "newview" is null in the updateCompleted method .

Rectangle2D newview = getViewBoxRect();

So sometimes the canvas gets white and it has to be repaint. It's immediatly repainted when I resize the frame or when I'm using the scrollbars. But I've inserted

if (newview == null) {
canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new Runnable() {

@Override
public void run() {
canvas.repaint();
}

});
return;
}

and this does not have any effect. Another solution maybe would be to avoid to get the Exception. But I don't see what I'm doing wrong.


--- Cameron McCormack <cam@...> schrieb am Mi, 28.5.2008:
Von: Cameron McCormack <cam@...>
Betreff: Re: Repainting a JSVGCanvas
An: batik-users@...
Datum: Mittwoch, 28. Mai 2008, 3:09

aaaa aaaa: > Hi,how can I force a JSVGCanvas to "repaint" itself? I do not mean > the repaint method but the kind of repaint when I resize the internal > frame the JSVGCanvas is located in or move the JSVGScrollPane > scrollbar.Thanks in advance.  Can you be a bit more specific about what behaviour you see and what you expect?  When you resize the frame the canvas is in, does it just paint white in the areas you’d expect to see more of your SVG document?  If so, then the solution might be as simple as putting an
 overflow="visible" attribute on your root <svg> element.  --  Cameron McCormack ≝ http://mcc.id.au/  --------------------------------------------------------------------- To unsubscribe, e-mail: batik-users-unsubscribe@... For additional commands, e-mail: batik-users-help@...


Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.

Re: Repainting a JSVGCanvas

by Cameron McCormack-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

aaaa aaaa:
> the problem is that I get occasionally a NullPointerException in the
> ScrollListener of the JSVGCanvas. The variable "newview" is null in
> the updateCompleted method .

Hmm.  I’m not sure what would cause getViewBoxRect() to return null if
all you are doing is resizing, unless there’s a threading issue.

> Rectangle2D newview = getViewBoxRect();
>
> So sometimes the canvas gets white and it has to be repaint. It's
> immediatly repainted when I resize the frame or when I'm using the
> scrollbars. But I've inserted
>
> if (newview == null) {
> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new Runnable() {
>
> @Override
> public void run() {
> canvas.repaint();
> }
>
> });
> return;
> }
>
> and this does not have any effect. Another solution maybe would be to
> avoid to get the Exception. But I don't see what I'm doing wrong.

I don’t think calling canvas.repaint() is the right thing to fix the
problem.  It sounds like there is a problem with JSVGScrollPane or
JSVGCanvas.  Are you able to provide a reduced test case that
demonstrates the problem (perhaps just loading a small SVG document in a
JSVGScrollPane/JSVGCanvas, where continually resizing it will trigger
the bug)?

Thanks,

Cameron

--
Cameron McCormack ≝ http://mcc.id.au/

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


Re: Repainting a JSVGCanvas

by aaaa aaaa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
not the resizing triggers the exception. The occurance of the exception seems completely arbitrary to me and is not reproduced easily.

I think it only occurs when I move the cursor over an svg element where the set attribute is used so that the fill attribute changes. Resizing repaints the canvas. So my first (and dirty) solution was to make this kind of repaint when the variable is null.

Of course it would be better when I would understand why I get this NullPointer Exception.


I have following classes (SVGArea and SVGAreaPainter) which displays the document. The SVGArea is used by the SVGAreaPainter. The SVGAreaPainter has a lot methods. The one that makes the mouseover effect for some elements is

        private void addMouseOverEffect(Element el, String color) {
                Element mouseOver = doc.createElementNS(svgNS, "set");
                mouseOver.setAttributeNS(null, "attributeName", "fill");
                mouseOver.setAttributeNS(null, "attributeType", "XML");
                mouseOver.setAttributeNS(null, "to", color);
                mouseOver.setAttributeNS(null, "begin", "mouseover");
                el.appendChild(mouseOver);
                Element mouseOut = doc.createElementNS(svgNS, "set");
                mouseOut.setAttributeNS(null, "attributeName", "fill");
                mouseOut.setAttributeNS(null, "attributeType", "XML");
                mouseOut.setAttributeNS(null, "to", el.getAttribute("fill"));
                mouseOut.setAttributeNS(null, "begin", "mouseout");
                el.appendChild(mouseOut);
        }
----------------------------------------------------------------
SVGArea class:

package de.unidue.inf.xmlvis.gui.svg;

import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;

import javax.swing.SwingUtilities;

import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.swing.JSVGCanvas;
import org.apache.batik.swing.gvt.GVTTreeRendererEvent;
import org.apache.batik.swing.gvt.GVTTreeRendererListener;
import org.apache.batik.swing.svg.GVTTreeBuilderEvent;
import org.apache.batik.swing.svg.GVTTreeBuilderListener;
import org.apache.batik.swing.svg.SVGLoadEventDispatcherEvent;
import org.apache.batik.swing.svg.SVGLoadEventDispatcherListener;
import org.apache.log4j.Logger;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.svg.SVGDocument;

import de.unidue.inf.xmlvis.gui.StatusBarManager;

public class SVGArea extends JSVGCanvas implements SVGLoadEventDispatcherListener, GVTTreeRendererListener, GVTTreeBuilderListener,
                MouseWheelListener {

        private static final long serialVersionUID = -4835732750510548844L;
        @SuppressWarnings("unused")
        private static final Logger logger = Logger.getLogger(SVGArea.class);
        private static final String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
        private static final DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
        private int width;
        private int height;
        private Document doc = null;
        private Element svgRoot;
        private JSVGScrollPane scroll;

        public SVGArea() {
                super(null, true, false);
                addSVGLoadEventDispatcherListener(this);
                addGVTTreeRendererListener(this);
                addGVTTreeBuilderListener(this);
                addMouseWheelListener(this);
                setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
                doc = impl.createDocument(svgNS, "svg", null);
                svgRoot = doc.getDocumentElement();
        }

        public void setDocument() {
                setSVGDocument((SVGDocument) doc);
        }

        public Document getDocument() {
                return doc;
        }

        public void resetSVGDocument() {
                doc = impl.createDocument(svgNS, "svg", null);
                svgRoot = doc.getDocumentElement();
        }

        @Override
        public void svgLoadEventDispatchCancelled(SVGLoadEventDispatcherEvent e) {
                StatusBarManager.svgLoadEventDispatchCancelled();
        }

        @Override
        public void svgLoadEventDispatchCompleted(SVGLoadEventDispatcherEvent e) {
        }

        @Override
        public void svgLoadEventDispatchFailed(SVGLoadEventDispatcherEvent e) {
                StatusBarManager.svgLoadEventDispatchFailed();
        }

        @Override
        public void svgLoadEventDispatchStarted(SVGLoadEventDispatcherEvent e) {
                StatusBarManager.svgLoadEventDispatchStarted();
        }

        @Override
        public void gvtRenderingCancelled(GVTTreeRendererEvent e) {
        }

        @Override
        public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
                StatusBarManager.gvtRenderingCompleted();
        }

        @Override
        public void gvtRenderingFailed(GVTTreeRendererEvent e) {
        }

        @Override
        public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
        }

        @Override
        public void gvtRenderingStarted(GVTTreeRendererEvent e) {
        }

        @Override
        public void gvtBuildCancelled(GVTTreeBuilderEvent e) {
        }

        @Override
        public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
        }

        @Override
        public void gvtBuildFailed(GVTTreeBuilderEvent e) {
        }

        @Override
        public void gvtBuildStarted(GVTTreeBuilderEvent e) {
        }

        public void setSVGSize(int width, int height) {
                this.width = width;
                this.height = height;
                svgRoot.setAttributeNS(null, "width", String.valueOf(width));
                svgRoot.setAttributeNS(null, "height", String.valueOf(height));
                SVGAreaPainter painter = new SVGAreaPainter(this);
                painter.drawText(0, 0, ".", 1);
                painter.drawText(width, height, ".", 1);
        }

        public float getSVGWidth() {
                return width;
        }

        public float getSVGHeight() {
                return height;
        }

        @Override
        public void mouseWheelMoved(final MouseWheelEvent e) {
                SwingUtilities.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                                // An das passende ScrollPane weiterleiten
                                if (scroll != null) {
                                        scroll.dispatchEvent(e);
                                }
                        }

                });

        }
       
        public void setScroll(JSVGScrollPane scroll) {
                this.scroll = scroll;
        }
}

--- Cameron McCormack <cam@...> schrieb am Mi, 28.5.2008:
Von: Cameron McCormack <cam@...>
Betreff: Re: Repainting a JSVGCanvas
An: batik-users@...
Datum: Mittwoch, 28. Mai 2008, 9:04

aaaa aaaa: > the problem is that I get occasionally a NullPointerException in the > ScrollListener of the JSVGCanvas. The variable "newview" is null in > the updateCompleted method .  Hmm.  I’m not sure what would cause getViewBoxRect() to return null if all you are doing is resizing, unless there’s a threading issue.  > Rectangle2D newview = getViewBoxRect(); >  > So sometimes the canvas gets white and it has to be repaint. It's > immediatly repainted when I resize the frame or when I'm using the > scrollbars. But I've inserted > > if (newview == null) { > canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new Runnable() { >  > @Override > public void run() { > canvas.repaint(); > } >  > }); > return; > } >  > and this does not have any effect. Another solution maybe would be to > avoid to get the Exception. But I don't see what I'm doing wrong.  I don’t think calling canvas.repaint() is the right
 thing to fix the problem.  It sounds like there is a problem with JSVGScrollPane or JSVGCanvas.  Are you able to provide a reduced test case that demonstrates the problem (perhaps just loading a small SVG document in a JSVGScrollPane/JSVGCanvas, where continually resizing it will trigger the bug)?  Thanks,  Cameron  --  Cameron McCormack ≝ http://mcc.id.au/  --------------------------------------------------------------------- To unsubscribe, e-mail: batik-users-unsubscribe@... For additional commands, e-mail: batik-users-help@...


      __________________________________________________________
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com

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


Re: Repainting a JSVGCanvas

by aaaa aaaa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I found out that when the Exception occurs "bounds" in the getViewBoxRect method is null. That's why it returns null.

Rectangle2D bounds = gn.getBounds();

Maybe this is part of the problem? What does getBounds() do?

--- aaaa aaaa <scorefande@...> schrieb am Mi, 28.5.2008:

> Von: aaaa aaaa <scorefande@...>
> Betreff: Re: Repainting a JSVGCanvas
> An: batik-users@...
> Datum: Mittwoch, 28. Mai 2008, 11:02
> Hi,
> not the resizing triggers the exception. The occurance of
> the exception seems completely arbitrary to me and is not
> reproduced easily.
>
> I think it only occurs when I move the cursor over an svg
> element where the set attribute is used so that the fill
> attribute changes. Resizing repaints the canvas. So my
> first (and dirty) solution was to make this kind of repaint
> when the variable is null.
>
> Of course it would be better when I would understand why I
> get this NullPointer Exception.
>
>
> I have following classes (SVGArea and SVGAreaPainter) which
> displays the document. The SVGArea is used by the
> SVGAreaPainter. The SVGAreaPainter has a lot methods. The
> one that makes the mouseover effect for some elements is
>
> private void addMouseOverEffect(Element el, String color)
> {
> Element mouseOver = doc.createElementNS(svgNS,
> "set");
> mouseOver.setAttributeNS(null, "attributeName",
> "fill");
> mouseOver.setAttributeNS(null, "attributeType",
> "XML");
> mouseOver.setAttributeNS(null, "to", color);
> mouseOver.setAttributeNS(null, "begin",
> "mouseover");
> el.appendChild(mouseOver);
> Element mouseOut = doc.createElementNS(svgNS,
> "set");
> mouseOut.setAttributeNS(null, "attributeName",
> "fill");
> mouseOut.setAttributeNS(null, "attributeType",
> "XML");
> mouseOut.setAttributeNS(null, "to",
> el.getAttribute("fill"));
> mouseOut.setAttributeNS(null, "begin",
> "mouseout");
> el.appendChild(mouseOut);
> }
> ----------------------------------------------------------------
> SVGArea class:
>
> package de.unidue.inf.xmlvis.gui.svg;
>
> import java.awt.event.MouseWheelEvent;
> import java.awt.event.MouseWheelListener;
>
> import javax.swing.SwingUtilities;
>
> import org.apache.batik.dom.svg.SVGDOMImplementation;
> import org.apache.batik.swing.JSVGCanvas;
> import org.apache.batik.swing.gvt.GVTTreeRendererEvent;
> import org.apache.batik.swing.gvt.GVTTreeRendererListener;
> import org.apache.batik.swing.svg.GVTTreeBuilderEvent;
> import org.apache.batik.swing.svg.GVTTreeBuilderListener;
> import
> org.apache.batik.swing.svg.SVGLoadEventDispatcherEvent;
> import
> org.apache.batik.swing.svg.SVGLoadEventDispatcherListener;
> import org.apache.log4j.Logger;
> import org.w3c.dom.DOMImplementation;
> import org.w3c.dom.Document;
> import org.w3c.dom.Element;
> import org.w3c.dom.svg.SVGDocument;
>
> import de.unidue.inf.xmlvis.gui.StatusBarManager;
>
> public class SVGArea extends JSVGCanvas implements
> SVGLoadEventDispatcherListener, GVTTreeRendererListener,
> GVTTreeBuilderListener,
> MouseWheelListener {
>
> private static final long serialVersionUID =
> -4835732750510548844L;
> @SuppressWarnings("unused")
> private static final Logger logger =
> Logger.getLogger(SVGArea.class);
> private static final String svgNS =
> SVGDOMImplementation.SVG_NAMESPACE_URI;
> private static final DOMImplementation impl =
> SVGDOMImplementation.getDOMImplementation();
> private int width;
> private int height;
> private Document doc = null;
> private Element svgRoot;
> private JSVGScrollPane scroll;
>
> public SVGArea() {
> super(null, true, false);
> addSVGLoadEventDispatcherListener(this);
> addGVTTreeRendererListener(this);
> addGVTTreeBuilderListener(this);
> addMouseWheelListener(this);
> setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> doc = impl.createDocument(svgNS, "svg", null);
> svgRoot = doc.getDocumentElement();
> }
>
> public void setDocument() {
> setSVGDocument((SVGDocument) doc);
> }
>
> public Document getDocument() {
> return doc;
> }
>
> public void resetSVGDocument() {
> doc = impl.createDocument(svgNS, "svg", null);
> svgRoot = doc.getDocumentElement();
> }
>
> @Override
> public void
> svgLoadEventDispatchCancelled(SVGLoadEventDispatcherEvent
> e) {
> StatusBarManager.svgLoadEventDispatchCancelled();
> }
>
> @Override
> public void
> svgLoadEventDispatchCompleted(SVGLoadEventDispatcherEvent
> e) {
> }
>
> @Override
> public void
> svgLoadEventDispatchFailed(SVGLoadEventDispatcherEvent e) {
> StatusBarManager.svgLoadEventDispatchFailed();
> }
>
> @Override
> public void
> svgLoadEventDispatchStarted(SVGLoadEventDispatcherEvent e)
> {
> StatusBarManager.svgLoadEventDispatchStarted();
> }
>
> @Override
> public void gvtRenderingCancelled(GVTTreeRendererEvent e)
> {
> }
>
> @Override
> public void gvtRenderingCompleted(GVTTreeRendererEvent e)
> {
> StatusBarManager.gvtRenderingCompleted();
> }
>
> @Override
> public void gvtRenderingFailed(GVTTreeRendererEvent e) {
> }
>
> @Override
> public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
> }
>
> @Override
> public void gvtRenderingStarted(GVTTreeRendererEvent e) {
> }
>
> @Override
> public void gvtBuildCancelled(GVTTreeBuilderEvent e) {
> }
>
> @Override
> public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
> }
>
> @Override
> public void gvtBuildFailed(GVTTreeBuilderEvent e) {
> }
>
> @Override
> public void gvtBuildStarted(GVTTreeBuilderEvent e) {
> }
>
> public void setSVGSize(int width, int height) {
> this.width = width;
> this.height = height;
> svgRoot.setAttributeNS(null, "width",
> String.valueOf(width));
> svgRoot.setAttributeNS(null, "height",
> String.valueOf(height));
> SVGAreaPainter painter = new SVGAreaPainter(this);
> painter.drawText(0, 0, ".", 1);
> painter.drawText(width, height, ".", 1);
> }
>
> public float getSVGWidth() {
> return width;
> }
>
> public float getSVGHeight() {
> return height;
> }
>
> @Override
> public void mouseWheelMoved(final MouseWheelEvent e) {
> SwingUtilities.invokeLater(new Runnable() {
>
> @Override
> public void run() {
> // An das passende ScrollPane weiterleiten
> if (scroll != null) {
> scroll.dispatchEvent(e);
> }
> }
>
> });
>
> }
>
> public void setScroll(JSVGScrollPane scroll) {
> this.scroll = scroll;
> }
> }
>
> --- Cameron McCormack <cam@...> schrieb am Mi,
> 28.5.2008:
> Von: Cameron McCormack <cam@...>
> Betreff: Re: Repainting a JSVGCanvas
> An: batik-users@...
> Datum: Mittwoch, 28. Mai 2008, 9:04
>
> aaaa aaaa: > the problem is that I get occasionally a
> NullPointerException in the > ScrollListener of the
> JSVGCanvas. The variable "newview" is null in
> > the updateCompleted method .  Hmm.  I’m not sure
> what would cause getViewBoxRect() to return null if all you
> are doing is resizing, unless there’s a threading issue.
> > Rectangle2D newview = getViewBoxRect(); >  > So
> sometimes the canvas gets white and it has to be repaint.
> It's > immediatly repainted when I resize the frame
> or when I'm using the > scrollbars. But I've
> inserted > > if (newview == null) { >
> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> Runnable() { >  > @Override > public void
> run() { > canvas.repaint(); > } >  >
> }); > return; > } >  > and this does
> not have any effect. Another solution maybe would be to >
> avoid to get the Exception. But I don't see what I'm
> doing wrong.  I don’t think calling canvas.repaint() is
> the right
>  thing to fix the problem.  It sounds like there is a
> problem with JSVGScrollPane or JSVGCanvas.  Are you able to
> provide a reduced test case that demonstrates the problem
> (perhaps just loading a small SVG document in a
> JSVGScrollPane/JSVGCanvas, where continually resizing it
> will trigger the bug)?  Thanks,  Cameron  --  Cameron
> McCormack ≝ http://mcc.id.au/ 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> batik-users-unsubscribe@... For
> additional commands, e-mail:
> batik-users-help@...
>
>
>      
> __________________________________________________________
> Gesendet von Yahoo! Mail.
> Dem pfiffigeren Posteingang.
> http://de.overview.mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> batik-users-unsubscribe@...
> For additional commands, e-mail:
> batik-users-help@...


      __________________________________________________________
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com

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


Re: Repainting a JSVGCanvas

by Cameron McCormack-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

aaaa aaaa:

> I have following classes (SVGArea and SVGAreaPainter) which displays
> the document. The SVGArea is used by the SVGAreaPainter. The
> SVGAreaPainter has a lot methods. The one that makes the mouseover
> effect for some elements is
>
> private void addMouseOverEffect(Element el, String color) {
> Element mouseOver = doc.createElementNS(svgNS, "set");
> mouseOver.setAttributeNS(null, "attributeName", "fill");
> mouseOver.setAttributeNS(null, "attributeType", "XML");
> mouseOver.setAttributeNS(null, "to", color);
> mouseOver.setAttributeNS(null, "begin", "mouseover");
> el.appendChild(mouseOver);
> Element mouseOut = doc.createElementNS(svgNS, "set");
> mouseOut.setAttributeNS(null, "attributeName", "fill");
> mouseOut.setAttributeNS(null, "attributeType", "XML");
> mouseOut.setAttributeNS(null, "to", el.getAttribute("fill"));
> mouseOut.setAttributeNS(null, "begin", "mouseout");
> el.appendChild(mouseOut);
> }

Are these changes being made in the UpdateManager’s thread?  If not,
then it might explain the problem.  See:

  http://xmlgraphics.apache.org/batik/faq.html#N10215

--
Cameron McCormack ≝ http://mcc.id.au/

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


Re: Repainting a JSVGCanvas

by aaaa aaaa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No, because this method is only called before the first rendering.


--- Cameron McCormack <cam@...> schrieb am Sa, 31.5.2008:

> Von: Cameron McCormack <cam@...>
> Betreff: Re: Repainting a JSVGCanvas
> An: batik-users@...
> Datum: Samstag, 31. Mai 2008, 13:28
> aaaa aaaa:
> > I have following classes (SVGArea and SVGAreaPainter)
> which displays
> > the document. The SVGArea is used by the
> SVGAreaPainter. The
> > SVGAreaPainter has a lot methods. The one that makes
> the mouseover
> > effect for some elements is
> >
> > private void addMouseOverEffect(Element el, String
> color) {
> > Element mouseOver = doc.createElementNS(svgNS,
> "set");
> > mouseOver.setAttributeNS(null,
> "attributeName", "fill");
> > mouseOver.setAttributeNS(null,
> "attributeType", "XML");
> > mouseOver.setAttributeNS(null, "to",
> color);
> > mouseOver.setAttributeNS(null, "begin",
> "mouseover");
> > el.appendChild(mouseOver);
> > Element mouseOut = doc.createElementNS(svgNS,
> "set");
> > mouseOut.setAttributeNS(null,
> "attributeName", "fill");
> > mouseOut.setAttributeNS(null,
> "attributeType", "XML");
> > mouseOut.setAttributeNS(null, "to",
> el.getAttribute("fill"));
> > mouseOut.setAttributeNS(null, "begin",
> "mouseout");
> > el.appendChild(mouseOut);
> > }
>
> Are these changes being made in the UpdateManager’s
> thread?  If not,
> then it might explain the problem.  See:
>
>   http://xmlgraphics.apache.org/batik/faq.html#N10215
>
> --
> Cameron McCormack ≝ http://mcc.id.au/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> batik-users-unsubscribe@...
> For additional commands, e-mail:
> batik-users-help@...


      __________________________________________________________
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com

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


Re: Repainting a JSVGCanvas

by Cameron McCormack-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

aaaa aaaa:
> No, because this method is only called before the first rendering.

OK.  Are you able to provide me with an SVG document that (if used by a
simple program that just displays a JSVGScrollPane in a resizable
window) demonstrates the problem?

--
Cameron McCormack ≝ http://mcc.id.au/

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


Re: Repainting a JSVGCanvas

by thomas.deweese :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Cameron, scorefande,


Cameron McCormack <cam@...> wrote on 05/31/2008 07:28:00 AM:

> Are these changes being made in the UpdateManager’s thread?  If not,
> then it might explain the problem.  See:

   Actually I think it's the JSVGScrollPane that is interacting
with the graphics tree outside of the UpdateManager's thread.
In particular updateCompleted is called in the Swing thread not
the update manager's thread.  However I don't think this is
really the source of the problem, but it might be good to
move at least all of the graphics node stuff in getViewBoxRect
into a runnable that we dispatch to the UpdateManager thread.

aaaa aaaa <scorefande@...> wrote on 05/30/2008 07:03:47 AM:

> I found out that when the Exception occurs "bounds" in the
> getViewBoxRect method is null. That's why it returns null.
>
> Rectangle2D bounds = gn.getBounds();

   This happens when a rendering is interrupted.  We should
handle this more gracefully.  I think the simplest thing
would be to simply protect all the callers of getViewBoxRect()
against a null return.  I've put this in SVN.

> Maybe this is part of the problem? What does getBounds() do?

   'getBounds' calculates the smallest rectangle that encloses
the contents of the graphics node it is called on.  In this
case it's trying to get the bounds of the document because
you haven't provided a viewBox attribute.  So your simplest
fix would be to provide a viewBox attribute on the outermost
SVG element.  This is really a better solution anyway as the
geometric bounds of the document is rarely the truly correct
document bounds (often documents have oversized 'background rects'
or they may want white space around the content, etc...).

Re: Repainting a JSVGCanvas

by aaaa aaaa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

ok, I now use the viewBox attribute. Since the exception wasn't always reproduceable I'll now use it as it is now for the next days. I hope this is the solution!


--- thomas.deweese@... <thomas.deweese@...> schrieb am Sa, 31.5.2008:

> Von: thomas.deweese@... <thomas.deweese@...>
> Betreff: Re: Repainting a JSVGCanvas
> An: batik-users@...
> CC: batik-users@...
> Datum: Samstag, 31. Mai 2008, 14:24
> Hi Cameron, scorefande,
>
>
> Cameron McCormack <cam@...> wrote on 05/31/2008
> 07:28:00 AM:
>
> > Are these changes being made in the UpdateManager’s
> thread?  If not,
> > then it might explain the problem.  See:
>
>    Actually I think it's the JSVGScrollPane that is
> interacting
> with the graphics tree outside of the UpdateManager's
> thread.
> In particular updateCompleted is called in the Swing thread
> not
> the update manager's thread.  However I don't think
> this is
> really the source of the problem, but it might be good to
> move at least all of the graphics node stuff in
> getViewBoxRect
> into a runnable that we dispatch to the UpdateManager
> thread.
>
> aaaa aaaa <scorefande@...> wrote on 05/30/2008
> 07:03:47 AM:
>
> > I found out that when the Exception occurs
> "bounds" in the
> > getViewBoxRect method is null. That's why it
> returns null.
> >
> > Rectangle2D bounds = gn.getBounds();
>
>    This happens when a rendering is interrupted.  We
> should
> handle this more gracefully.  I think the simplest thing
> would be to simply protect all the callers of
> getViewBoxRect()
> against a null return.  I've put this in SVN.
>
> > Maybe this is part of the problem? What does
> getBounds() do?
>
>    'getBounds' calculates the smallest rectangle
> that encloses
> the contents of the graphics node it is called on.  In
> this
> case it's trying to get the bounds of the document
> because
> you haven't provided a viewBox attribute.  So your
> simplest
> fix would be to provide a viewBox attribute on the
> outermost
> SVG element.  This is really a better solution anyway as
> the
> geometric bounds of the document is rarely the truly
> correct
> document bounds (often documents have oversized
> 'background rects'
> or they may want white space around the content, etc...).


      __________________________________________________________
Gesendet von Yahoo! Mail.
Dem pfiffigeren Posteingang.
http://de.overview.mail.yahoo.com

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