You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Julien Beghin <mi...@hotmail.com> on 2010/07/13 12:05:14 UTC

Partial Refresh

Hello all,

 

I still experience some refresh  "bugs" in my application.

 

I have a (quite big) SVG, that I am trying to update in my application.

The modification consists in setting all colored stuff in the SVG to black fill and stroke.

 

So (part of) what we are doing for now is : 

 

for (int j = 0; j < eltPattern.getChildNodes().getLength(); j++) {
     Node temp = eltPattern.getChildNodes().item(j);
     if(temp instanceof Element){
           String strokeAttribute = ((Element)temp).getAttribute(SVGConstants.SVG_STROKE_ATTRIBUTE);
          if(strokeAttribute.equals(refColor)){
               ((Element)temp).setAttribute(SVGConstants.SVG_STROKE_ATTRIBUTE, colorsPattern.get(i));
          }
          String fillAttribute = ((Element)temp).getAttribute(SVGConstants.SVG_FILL_ATTRIBUTE);
          if(fillAttribute.equals(refColor)){
               ((Element)temp).setAttribute(SVGConstants.SVG_FILL_ATTRIBUTE, colorsPattern.get(i));
          }
     }
}

 

 

 

We added a refresh at the end :

svgPanel.getSvgCanvas().setRenderingTransform(svgPanel.getSvgCanvas().getRenderingTransform());

 

 

The modification is not correctly displayed in our canvas, but when I look at the exported SVG, via Squiggle, the result is OK.

 

Do someone know where my problem can come from

 

(I am using batik 1.8pre and I just added xmlgraphic 1.4, just in case...)

 

I Joined pictures of what is see too....

 

 

This is going to run my brain out :'(

 
 		 	   		  
_________________________________________________________________
Exclu : Téléchargez la nouvelle version de Messenger !
http://clk.atdmt.com/FRM/go/244627952/direct/01/

RE: Partial Refresh

Posted by th...@kodak.com.
Hi Julien,

Julien Beghin <mi...@hotmail.com> wrote on 07/26/2010 08:59:56 AM:

> Just to tell that I managed to solve my problem.
> 
> Setting an initial viewbox to the SVG seemed to be our solution.

    Just so you know why this works.  It works because changes  to
the viewbox cause the entire graphics tree to be rebuilt (due to
the fact that any element using percentages might change). 

        You could get the same effect by removing the root SVG element 
from the Document and adding it back, this is essentially what we do 
under the hood.  I suggest this because we don't always rebuild the
graphics tree and at some point in the future we might handle changes
to the viewbox in a more elegant way (of course we might handle changes
to patterns more elegantly by then as well...).

Thomas DeWeese | CDG Advanced Development | 
Eastman Kodak Company | 343 State Street | Rochester, NY 14650-0128 | 
Thomas.DeWeese@Kodak.com | 585 724-0294 | 
www.kodak.com 


> 
> Thanks all for your help !
> 
> From: minimoi1234@hotmail.com
> To: batik-users@xmlgraphics.apache.org
> Subject: RE: Partial Refresh
> Date: Fri, 23 Jul 2010 11:44:32 +0000
> 
> Hi Thomas, and thanks for your confirmation.
> 
> I found a bug in the list, that should explain that : https://
> issues.apache.org/bugzilla/show_bug.cgi?id=23443
> 
> I know that it is possible to see the correct result by setting 
> attributes to node using the pattern but I still have some display 
problem.
> I'll now be looking at the viewbox of our SVG... modifying this 
> attribute in a test cases allowed me to display what I wanted...
> Maybe I'll manage to do what I need one day ^^
> 
> Regards !
> 
> 
> To: batik-users@xmlgraphics.apache.org
> CC: batik-users@xmlgraphics.apache.org
> Subject: RE: Partial Refresh
> From: thomas.deweese@kodak.com
> Date: Wed, 21 Jul 2010 07:59:52 -0400
> 
> Hi Julien, 
> 
> Julien Beghin <mi...@hotmail.com> wrote on 07/19/2010 09:14:23 AM:
> 
> > I simply create a pattern and use it in the fill attribute of a 
<rect>...
> 
>    This is the problem.  Batik doesn't do a good job of tracking 
> complex dependencies like patterns.  The only solution is to twiddle 
> all of the pattern references (set them to nothing then back to the 
> pattern). 
> 
> > The application consists in changing the pattern color when pressing 
space.
> > 
> > The SVG is also displayed in the console for information...
> > 
> > Do someone on the mailing list have this application working correctly 
?
> > 
> > Nota : I have a color modification when zooming with the CTRL key 
> > and the mouse after having pressed space.
> > 
> > 
> > 
> > //////////////////////////////////////////////////////////
> > 
> > Here is the source code, same as the attached file
> > 
> > /////////////////////////////////////////////////////////
> > 
> > package com.test;
> > import java.awt.event.KeyAdapter;
> > import java.awt.event.KeyEvent;
> > import java.awt.event.WindowAdapter;
> > import java.awt.event.WindowEvent;
> > import java.io.StringReader;
> > import javax.swing.JFrame;
> > import javax.swing.SwingUtilities;
> > import javax.xml.transform.OutputKeys;
> > import javax.xml.transform.Result;
> > import javax.xml.transform.Source;
> > import javax.xml.transform.Transformer;
> > import javax.xml.transform.TransformerFactory;
> > import javax.xml.transform.dom.DOMSource;
> > import javax.xml.transform.stream.StreamResult;
> > import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
> > import org.apache.batik.swing.JSVGCanvas;
> > import org.apache.batik.swing.gvt.GVTTreeRendererEvent;
> > import org.apache.batik.swing.gvt.GVTTreeRendererListener;
> > import org.apache.batik.util.RunnableQueue;
> > import org.apache.batik.util.SVGConstants;
> > import org.apache.batik.util.XMLResourceDescriptor;
> > import org.w3c.dom.Element;
> > import org.w3c.dom.NodeList;
> > import org.w3c.dom.svg.SVGDocument;
> > import org.w3c.dom.svg.SVGSVGElement;
> > 
> > 
> > 
> > public class TestPattern extends JFrame {
> > 
> >  private static final long serialVersionUID = 5778700446793083700L;
> > 
> >  Canvas canvas;
> >  SVGDocument document;
> >  RunnableQueue runQ = null;
> > 
> >  String svg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
> >  +"<svg viewbox=\"0 0 50 50\" xmlns=\"http://www.w3.org/2000/svg\" 
> > xmlns:xlink=\"http://www.w3.org/1999/xlink\" contentScriptType=
> > \"text/ecmascript\" width=\"50\" zoomAndPan=\"magnify\" 
> > contentStyleType=\"text/css\" height=\"50\" preserveAspectRatio=
> > \"xMidYMid meet\" version=\"1.1\">"
> >  +"<pattern width=\"25\" xmlns:xlink=\"http://www.w3.org/1999/xlink\
> > " patternUnits=\"userSpaceOnUse\" xlink:type=\"simple\" 
> > xlink:actuate=\"none\" height=\"25\"  id=\"myPattern\" 
> > preserveAspectRatio=\"xMidYMid meet\" xlink:show=\"other\" overflow=
> > \"hidden\">"
> >  +" <path fill=\"red\" d=\"M 1 1 L 24 1 L 24 24 L 1 24z\" stroke-
> > width=\"1\" stroke=\"green\"/>"
> >  +"</pattern>"
> >  +"<rect overflow=\"visible\" fill=\"url(#myPattern)\" width=\"50.
> > 0000\" height=\"50\"/>"
> >  +"</svg>";
> > 
> >  private boolean invert = false;
> > 
> > 
> > 
> >  public TestPattern() {
> >   super("");
> >   canvas = new Canvas();
> >   setContentPane(canvas);
> >   WindowAdapter windowAdapter = new WindowAdapter() {
> >    public void windowOpened(WindowEvent we) {
> >     SVGDocument doc = null;
> >     try {
> >      String parser = XMLResourceDescriptor
> >        .getXMLParserClassName();
> >      SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
> >      StringReader reader = new StringReader(svg);
> >      doc = f.createSVGDocument(null, reader);
> >     } catch (Exception ex) {
> >     }
> >     canvas.setSVGDocument(doc);
> >     try {
> >      Source source = new DOMSource(doc);
> >      Result result = new StreamResult(System.out);
> >      Transformer xformer = TransformerFactory.newInstance()
> >        .newTransformer();
> >      xformer.setOutputProperty(OutputKeys.INDENT, "yes");
> >      xformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
> >      xformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
> >        "no");
> >      xformer.transform(source, result);
> >     } catch (Exception ex) {
> >      ex.printStackTrace();
> >     }
> >    }
> >   };
> >   addWindowListener(windowAdapter);
> >   setDefaultCloseOperation(EXIT_ON_CLOSE);
> >   setSize(100, 100);
> >   setVisible(true);
> >  }
> >  public class Canvas extends JSVGCanvas implements 
GVTTreeRendererListener {
> >   private static final long serialVersionUID = 1L;
> >   public Canvas() {
> >    canvas = this;
> >    setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
> >    addGVTTreeRendererListener(this);
> >    KeyAdapter keyAdapter = new KeyAdapter() {
> >     public void keyPressed(KeyEvent e) {
> > 
> >      if(e.getKeyCode() != KeyEvent.VK_SPACE )
> >       return;
> > 
> > 
> >      if (runQ == null)
> >       return;
> >      runQ.invokeLater(new Runnable() {
> >       public void run() {
> >        changeColor();
> >        try {
> >         Source source = new DOMSource(document);
> >         Result result = new StreamResult(System.out);
> >         Transformer xformer = TransformerFactory
> >           .newInstance().newTransformer();
> >         xformer.setOutputProperty(OutputKeys.INDENT,
> >           "yes");
> >         xformer.setOutputProperty(OutputKeys.ENCODING,
> >           "UTF-8");
> >         xformer.setOutputProperty(
> >           OutputKeys.OMIT_XML_DECLARATION, "no");
> >         xformer.transform(source, result);
> >        } catch (Exception ex) {
> >         ex.printStackTrace();
> >        }
> >       }
> >      });
> >     }
> >    };
> >    addKeyListener(keyAdapter);
> >   }
> >   public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
> >   }
> >   public void gvtRenderingStarted(GVTTreeRendererEvent e) {
> >   }
> >   public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
> >    document = canvas.getSVGDocument();
> >    runQ = canvas.getUpdateManager().getUpdateRunnableQueue();
> >   }
> >   public void gvtRenderingCancelled(GVTTreeRendererEvent e) {
> >   }
> >   public void gvtRenderingFailed(GVTTreeRendererEvent e) {
> >   }
> >  }
> >  private void changeColor() {
> >   SVGSVGElement root = document.getRootElement();
> >   NodeList liste = 
document.getElementsByTagName(SVGConstants.SVG_PATH_TAG);
> >   Element path = (Element)liste.item(0);
> >   if(invert == false){
> >    path.setAttributeNS(null, SVGConstants.SVG_FILL_ATTRIBUTE, "blue");
> >    path.setAttributeNS(null, SVGConstants.SVG_STROKE_ATTRIBUTE, 
"yellow");
> >   }else{
> >    path.setAttributeNS(null, SVGConstants.SVG_FILL_ATTRIBUTE, "red");
> >    path.setAttributeNS(null, SVGConstants.SVG_STROKE_ATTRIBUTE, 
"green"); 
> >   }
> >   invert = !invert;
> >  }
> > 
> >  public static void main(String[] args) {
> >   SwingUtilities.invokeLater(new Runnable() {
> >    public void run() {
> >     new TestPattern();
> >    }
> >   });
> >  }
> > }
> > 
> > 
> > De nouvelles Emoticones sur Messenger ? Téléchargez gratuitement les
> > émoticônes Summer ![attachment "TestPattern.java" deleted by Thomas 
> > E. DeWeese/449433/EKC] 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> 
> De nouvelles Emoticones sur Messenger ? Téléchargez gratuitement les
> émoticônes Summer ! 
> Votre vie privée l'est-elle vraiment ? Internet Explorer 8 vous 
> protège gratuitement

RE: Partial Refresh

Posted by Julien Beghin <mi...@hotmail.com>.
Just to tell that I managed to solve my problem.

 

Setting an initial viewbox to the SVG seemed to be our solution.

 

Thanks all for your help !
 


From: minimoi1234@hotmail.com
To: batik-users@xmlgraphics.apache.org
Subject: RE: Partial Refresh
Date: Fri, 23 Jul 2010 11:44:32 +0000



Hi Thomas, and thanks for your confirmation.
 
I found a bug in the list, that should explain that : https://issues.apache.org/bugzilla/show_bug.cgi?id=23443
 
I know that it is possible to see the correct result by setting attributes to node using the pattern but I still have some display problem.
I'll now be looking at the viewbox of our SVG... modifying this attribute in a test cases allowed me to display what I wanted...
Maybe I'll manage to do what I need one day ^^
 
Regards !
 
 


To: batik-users@xmlgraphics.apache.org
CC: batik-users@xmlgraphics.apache.org
Subject: RE: Partial Refresh
From: thomas.deweese@kodak.com
Date: Wed, 21 Jul 2010 07:59:52 -0400

Hi Julien, 

Julien Beghin <mi...@hotmail.com> wrote on 07/19/2010 09:14:23 AM:

> I simply create a pattern and use it in the fill attribute of a <rect>...

   This is the problem.  Batik doesn't do a good job of tracking 
complex dependencies like patterns.  The only solution is to twiddle 
all of the pattern references (set them to nothing then back to the 
pattern). 

> The application consists in changing the pattern color when pressing space.
>  
> The SVG is also displayed in the console for information...
>  
> Do someone on the mailing list have this application working correctly ?
>  
> Nota : I have a color modification when zooming with the CTRL key 
> and the mouse after having pressed space.
>  
>  
>  
> //////////////////////////////////////////////////////////
>  
> Here is the source code, same as the attached file
>  
> /////////////////////////////////////////////////////////
>  
> package com.test;
> import java.awt.event.KeyAdapter;
> import java.awt.event.KeyEvent;
> import java.awt.event.WindowAdapter;
> import java.awt.event.WindowEvent;
> import java.io.StringReader;
> import javax.swing.JFrame;
> import javax.swing.SwingUtilities;
> import javax.xml.transform.OutputKeys;
> import javax.xml.transform.Result;
> import javax.xml.transform.Source;
> import javax.xml.transform.Transformer;
> import javax.xml.transform.TransformerFactory;
> import javax.xml.transform.dom.DOMSource;
> import javax.xml.transform.stream.StreamResult;
> import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
> import org.apache.batik.swing.JSVGCanvas;
> import org.apache.batik.swing.gvt.GVTTreeRendererEvent;
> import org.apache.batik.swing.gvt.GVTTreeRendererListener;
> import org.apache.batik.util.RunnableQueue;
> import org.apache.batik.util.SVGConstants;
> import org.apache.batik.util.XMLResourceDescriptor;
> import org.w3c.dom.Element;
> import org.w3c.dom.NodeList;
> import org.w3c.dom.svg.SVGDocument;
> import org.w3c.dom.svg.SVGSVGElement;
>  
>  
>  
> public class TestPattern extends JFrame {
>  
>  private static final long serialVersionUID = 5778700446793083700L;
>  
>  Canvas canvas;
>  SVGDocument document;
>  RunnableQueue runQ = null;
>  
>  String svg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
>  +"<svg viewbox=\"0 0 50 50\" xmlns=\"http://www.w3.org/2000/svg\" 
> xmlns:xlink=\"http://www.w3.org/1999/xlink\" contentScriptType=
> \"text/ecmascript\" width=\"50\" zoomAndPan=\"magnify\" 
> contentStyleType=\"text/css\" height=\"50\" preserveAspectRatio=
> \"xMidYMid meet\" version=\"1.1\">"
>  +"<pattern width=\"25\" xmlns:xlink=\"http://www.w3.org/1999/xlink\
> " patternUnits=\"userSpaceOnUse\" xlink:type=\"simple\" 
> xlink:actuate=\"none\" height=\"25\"  id=\"myPattern\" 
> preserveAspectRatio=\"xMidYMid meet\" xlink:show=\"other\" overflow=
> \"hidden\">"
>  +" <path fill=\"red\" d=\"M 1 1 L 24 1 L 24 24 L 1 24z\" stroke-
> width=\"1\" stroke=\"green\"/>"
>  +"</pattern>"
>  +"<rect overflow=\"visible\" fill=\"url(#myPattern)\" width=\"50.
> 0000\" height=\"50\"/>"
>  +"</svg>";
>  
>  private boolean invert = false;
>  
>  
>  
>  public TestPattern() {
>   super("");
>   canvas = new Canvas();
>   setContentPane(canvas);
>   WindowAdapter windowAdapter = new WindowAdapter() {
>    public void windowOpened(WindowEvent we) {
>     SVGDocument doc = null;
>     try {
>      String parser = XMLResourceDescriptor
>        .getXMLParserClassName();
>      SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
>      StringReader reader = new StringReader(svg);
>      doc = f.createSVGDocument(null, reader);
>     } catch (Exception ex) {
>     }
>     canvas.setSVGDocument(doc);
>     try {
>      Source source = new DOMSource(doc);
>      Result result = new StreamResult(System.out);
>      Transformer xformer = TransformerFactory.newInstance()
>        .newTransformer();
>      xformer.setOutputProperty(OutputKeys.INDENT, "yes");
>      xformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
>      xformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
>        "no");
>      xformer.transform(source, result);
>     } catch (Exception ex) {
>      ex.printStackTrace();
>     }
>    }
>   };
>   addWindowListener(windowAdapter);
>   setDefaultCloseOperation(EXIT_ON_CLOSE);
>   setSize(100, 100);
>   setVisible(true);
>  }
>  public class Canvas extends JSVGCanvas implements GVTTreeRendererListener {
>   private static final long serialVersionUID = 1L;
>   public Canvas() {
>    canvas = this;
>    setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>    addGVTTreeRendererListener(this);
>    KeyAdapter keyAdapter = new KeyAdapter() {
>     public void keyPressed(KeyEvent e) {
>      
>      if(e.getKeyCode() != KeyEvent.VK_SPACE )
>       return;
>      
>      
>      if (runQ == null)
>       return;
>      runQ.invokeLater(new Runnable() {
>       public void run() {
>        changeColor();
>        try {
>         Source source = new DOMSource(document);
>         Result result = new StreamResult(System.out);
>         Transformer xformer = TransformerFactory
>           .newInstance().newTransformer();
>         xformer.setOutputProperty(OutputKeys.INDENT,
>           "yes");
>         xformer.setOutputProperty(OutputKeys.ENCODING,
>           "UTF-8");
>         xformer.setOutputProperty(
>           OutputKeys.OMIT_XML_DECLARATION, "no");
>         xformer.transform(source, result);
>        } catch (Exception ex) {
>         ex.printStackTrace();
>        }
>       }
>      });
>     }
>    };
>    addKeyListener(keyAdapter);
>   }
>   public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
>   }
>   public void gvtRenderingStarted(GVTTreeRendererEvent e) {
>   }
>   public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
>    document = canvas.getSVGDocument();
>    runQ = canvas.getUpdateManager().getUpdateRunnableQueue();
>   }
>   public void gvtRenderingCancelled(GVTTreeRendererEvent e) {
>   }
>   public void gvtRenderingFailed(GVTTreeRendererEvent e) {
>   }
>  }
>  private void changeColor() {
>   SVGSVGElement root = document.getRootElement();
>   NodeList liste = document.getElementsByTagName(SVGConstants.SVG_PATH_TAG);
>   Element path = (Element)liste.item(0);
>   if(invert == false){
>    path.setAttributeNS(null, SVGConstants.SVG_FILL_ATTRIBUTE, "blue");
>    path.setAttributeNS(null, SVGConstants.SVG_STROKE_ATTRIBUTE, "yellow");
>   }else{
>    path.setAttributeNS(null, SVGConstants.SVG_FILL_ATTRIBUTE, "red");
>    path.setAttributeNS(null, SVGConstants.SVG_STROKE_ATTRIBUTE, "green");   
>   }
>   invert = !invert;
>  }
>  
>  public static void main(String[] args) {
>   SwingUtilities.invokeLater(new Runnable() {
>    public void run() {
>     new TestPattern();
>    }
>   });
>  }
> }
> 
> 
> De nouvelles Emoticones sur Messenger ? Téléchargez gratuitement les
> émoticônes Summer ![attachment "TestPattern.java" deleted by Thomas 
> E. DeWeese/449433/EKC] 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org



De nouvelles Emoticones sur Messenger ? Téléchargez gratuitement les émoticônes Summer ! 		 	   		  
_________________________________________________________________
Exclu : Téléchargez la nouvelle version de Messenger !
http://clk.atdmt.com/FRM/go/244627952/direct/01/

RE: Partial Refresh

Posted by Julien Beghin <mi...@hotmail.com>.
Hi Thomas, and thanks for your confirmation.

 

I found a bug in the list, that should explain that : https://issues.apache.org/bugzilla/show_bug.cgi?id=23443

 

I know that it is possible to see the correct result by setting attributes to node using the pattern but I still have some display problem.

I'll now be looking at the viewbox of our SVG... modifying this attribute in a test cases allowed me to display what I wanted...

Maybe I'll manage to do what I need one day ^^

 

Regards !

 
 


To: batik-users@xmlgraphics.apache.org
CC: batik-users@xmlgraphics.apache.org
Subject: RE: Partial Refresh
From: thomas.deweese@kodak.com
Date: Wed, 21 Jul 2010 07:59:52 -0400

Hi Julien, 

Julien Beghin <mi...@hotmail.com> wrote on 07/19/2010 09:14:23 AM:

> I simply create a pattern and use it in the fill attribute of a <rect>...

   This is the problem.  Batik doesn't do a good job of tracking 
complex dependencies like patterns.  The only solution is to twiddle 
all of the pattern references (set them to nothing then back to the 
pattern). 

> The application consists in changing the pattern color when pressing space.
>  
> The SVG is also displayed in the console for information...
>  
> Do someone on the mailing list have this application working correctly ?
>  
> Nota : I have a color modification when zooming with the CTRL key 
> and the mouse after having pressed space.
>  
>  
>  
> //////////////////////////////////////////////////////////
>  
> Here is the source code, same as the attached file
>  
> /////////////////////////////////////////////////////////
>  
> package com.test;
> import java.awt.event.KeyAdapter;
> import java.awt.event.KeyEvent;
> import java.awt.event.WindowAdapter;
> import java.awt.event.WindowEvent;
> import java.io.StringReader;
> import javax.swing.JFrame;
> import javax.swing.SwingUtilities;
> import javax.xml.transform.OutputKeys;
> import javax.xml.transform.Result;
> import javax.xml.transform.Source;
> import javax.xml.transform.Transformer;
> import javax.xml.transform.TransformerFactory;
> import javax.xml.transform.dom.DOMSource;
> import javax.xml.transform.stream.StreamResult;
> import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
> import org.apache.batik.swing.JSVGCanvas;
> import org.apache.batik.swing.gvt.GVTTreeRendererEvent;
> import org.apache.batik.swing.gvt.GVTTreeRendererListener;
> import org.apache.batik.util.RunnableQueue;
> import org.apache.batik.util.SVGConstants;
> import org.apache.batik.util.XMLResourceDescriptor;
> import org.w3c.dom.Element;
> import org.w3c.dom.NodeList;
> import org.w3c.dom.svg.SVGDocument;
> import org.w3c.dom.svg.SVGSVGElement;
>  
>  
>  
> public class TestPattern extends JFrame {
>  
>  private static final long serialVersionUID = 5778700446793083700L;
>  
>  Canvas canvas;
>  SVGDocument document;
>  RunnableQueue runQ = null;
>  
>  String svg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
>  +"<svg viewbox=\"0 0 50 50\" xmlns=\"http://www.w3.org/2000/svg\" 
> xmlns:xlink=\"http://www.w3.org/1999/xlink\" contentScriptType=
> \"text/ecmascript\" width=\"50\" zoomAndPan=\"magnify\" 
> contentStyleType=\"text/css\" height=\"50\" preserveAspectRatio=
> \"xMidYMid meet\" version=\"1.1\">"
>  +"<pattern width=\"25\" xmlns:xlink=\"http://www.w3.org/1999/xlink\
> " patternUnits=\"userSpaceOnUse\" xlink:type=\"simple\" 
> xlink:actuate=\"none\" height=\"25\"  id=\"myPattern\" 
> preserveAspectRatio=\"xMidYMid meet\" xlink:show=\"other\" overflow=
> \"hidden\">"
>  +" <path fill=\"red\" d=\"M 1 1 L 24 1 L 24 24 L 1 24z\" stroke-
> width=\"1\" stroke=\"green\"/>"
>  +"</pattern>"
>  +"<rect overflow=\"visible\" fill=\"url(#myPattern)\" width=\"50.
> 0000\" height=\"50\"/>"
>  +"</svg>";
>  
>  private boolean invert = false;
>  
>  
>  
>  public TestPattern() {
>   super("");
>   canvas = new Canvas();
>   setContentPane(canvas);
>   WindowAdapter windowAdapter = new WindowAdapter() {
>    public void windowOpened(WindowEvent we) {
>     SVGDocument doc = null;
>     try {
>      String parser = XMLResourceDescriptor
>        .getXMLParserClassName();
>      SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
>      StringReader reader = new StringReader(svg);
>      doc = f.createSVGDocument(null, reader);
>     } catch (Exception ex) {
>     }
>     canvas.setSVGDocument(doc);
>     try {
>      Source source = new DOMSource(doc);
>      Result result = new StreamResult(System.out);
>      Transformer xformer = TransformerFactory.newInstance()
>        .newTransformer();
>      xformer.setOutputProperty(OutputKeys.INDENT, "yes");
>      xformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
>      xformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
>        "no");
>      xformer.transform(source, result);
>     } catch (Exception ex) {
>      ex.printStackTrace();
>     }
>    }
>   };
>   addWindowListener(windowAdapter);
>   setDefaultCloseOperation(EXIT_ON_CLOSE);
>   setSize(100, 100);
>   setVisible(true);
>  }
>  public class Canvas extends JSVGCanvas implements GVTTreeRendererListener {
>   private static final long serialVersionUID = 1L;
>   public Canvas() {
>    canvas = this;
>    setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>    addGVTTreeRendererListener(this);
>    KeyAdapter keyAdapter = new KeyAdapter() {
>     public void keyPressed(KeyEvent e) {
>      
>      if(e.getKeyCode() != KeyEvent.VK_SPACE )
>       return;
>      
>      
>      if (runQ == null)
>       return;
>      runQ.invokeLater(new Runnable() {
>       public void run() {
>        changeColor();
>        try {
>         Source source = new DOMSource(document);
>         Result result = new StreamResult(System.out);
>         Transformer xformer = TransformerFactory
>           .newInstance().newTransformer();
>         xformer.setOutputProperty(OutputKeys.INDENT,
>           "yes");
>         xformer.setOutputProperty(OutputKeys.ENCODING,
>           "UTF-8");
>         xformer.setOutputProperty(
>           OutputKeys.OMIT_XML_DECLARATION, "no");
>         xformer.transform(source, result);
>        } catch (Exception ex) {
>         ex.printStackTrace();
>        }
>       }
>      });
>     }
>    };
>    addKeyListener(keyAdapter);
>   }
>   public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
>   }
>   public void gvtRenderingStarted(GVTTreeRendererEvent e) {
>   }
>   public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
>    document = canvas.getSVGDocument();
>    runQ = canvas.getUpdateManager().getUpdateRunnableQueue();
>   }
>   public void gvtRenderingCancelled(GVTTreeRendererEvent e) {
>   }
>   public void gvtRenderingFailed(GVTTreeRendererEvent e) {
>   }
>  }
>  private void changeColor() {
>   SVGSVGElement root = document.getRootElement();
>   NodeList liste = document.getElementsByTagName(SVGConstants.SVG_PATH_TAG);
>   Element path = (Element)liste.item(0);
>   if(invert == false){
>    path.setAttributeNS(null, SVGConstants.SVG_FILL_ATTRIBUTE, "blue");
>    path.setAttributeNS(null, SVGConstants.SVG_STROKE_ATTRIBUTE, "yellow");
>   }else{
>    path.setAttributeNS(null, SVGConstants.SVG_FILL_ATTRIBUTE, "red");
>    path.setAttributeNS(null, SVGConstants.SVG_STROKE_ATTRIBUTE, "green");   
>   }
>   invert = !invert;
>  }
>  
>  public static void main(String[] args) {
>   SwingUtilities.invokeLater(new Runnable() {
>    public void run() {
>     new TestPattern();
>    }
>   });
>  }
> }
> 
> 
> De nouvelles Emoticones sur Messenger ? Téléchargez gratuitement les
> émoticônes Summer ![attachment "TestPattern.java" deleted by Thomas 
> E. DeWeese/449433/EKC] 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
 		 	   		  
_________________________________________________________________
Allumez et éteignez votre PC en un instant avec Windows 7 !
http://clk.atdmt.com/FRM/go/238030931/direct/01/

RE: Partial Refresh

Posted by th...@kodak.com.
Hi Julien,

Julien Beghin <mi...@hotmail.com> wrote on 07/19/2010 09:14:23 AM:

> I simply create a pattern and use it in the fill attribute of a 
<rect>...

   This is the problem.  Batik doesn't do a good job of tracking 
complex dependencies like patterns.  The only solution is to twiddle
all of the pattern references (set them to nothing then back to the
pattern).

> The application consists in changing the pattern color when pressing 
space.
> 
> The SVG is also displayed in the console for information...
> 
> Do someone on the mailing list have this application working correctly ?
> 
> Nota : I have a color modification when zooming with the CTRL key 
> and the mouse after having pressed space.
> 
> 
> 
> //////////////////////////////////////////////////////////
> 
> Here is the source code, same as the attached file
> 
> /////////////////////////////////////////////////////////
> 
> package com.test;
> import java.awt.event.KeyAdapter;
> import java.awt.event.KeyEvent;
> import java.awt.event.WindowAdapter;
> import java.awt.event.WindowEvent;
> import java.io.StringReader;
> import javax.swing.JFrame;
> import javax.swing.SwingUtilities;
> import javax.xml.transform.OutputKeys;
> import javax.xml.transform.Result;
> import javax.xml.transform.Source;
> import javax.xml.transform.Transformer;
> import javax.xml.transform.TransformerFactory;
> import javax.xml.transform.dom.DOMSource;
> import javax.xml.transform.stream.StreamResult;
> import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
> import org.apache.batik.swing.JSVGCanvas;
> import org.apache.batik.swing.gvt.GVTTreeRendererEvent;
> import org.apache.batik.swing.gvt.GVTTreeRendererListener;
> import org.apache.batik.util.RunnableQueue;
> import org.apache.batik.util.SVGConstants;
> import org.apache.batik.util.XMLResourceDescriptor;
> import org.w3c.dom.Element;
> import org.w3c.dom.NodeList;
> import org.w3c.dom.svg.SVGDocument;
> import org.w3c.dom.svg.SVGSVGElement;
> 
> 
> 
> public class TestPattern extends JFrame {
> 
>  private static final long serialVersionUID = 5778700446793083700L;
> 
>  Canvas canvas;
>  SVGDocument document;
>  RunnableQueue runQ = null;
> 
>  String svg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
>  +"<svg viewbox=\"0 0 50 50\" xmlns=\"http://www.w3.org/2000/svg\" 
> xmlns:xlink=\"http://www.w3.org/1999/xlink\" contentScriptType=
> \"text/ecmascript\" width=\"50\" zoomAndPan=\"magnify\" 
> contentStyleType=\"text/css\" height=\"50\" preserveAspectRatio=
> \"xMidYMid meet\" version=\"1.1\">"
>  +"<pattern width=\"25\" xmlns:xlink=\"http://www.w3.org/1999/xlink\
> " patternUnits=\"userSpaceOnUse\" xlink:type=\"simple\" 
> xlink:actuate=\"none\" height=\"25\"  id=\"myPattern\" 
> preserveAspectRatio=\"xMidYMid meet\" xlink:show=\"other\" overflow=
> \"hidden\">"
>  +" <path fill=\"red\" d=\"M 1 1 L 24 1 L 24 24 L 1 24z\" stroke-
> width=\"1\" stroke=\"green\"/>"
>  +"</pattern>"
>  +"<rect overflow=\"visible\" fill=\"url(#myPattern)\" width=\"50.
> 0000\" height=\"50\"/>"
>  +"</svg>";
> 
>  private boolean invert = false;
> 
> 
> 
>  public TestPattern() {
>   super("");
>   canvas = new Canvas();
>   setContentPane(canvas);
>   WindowAdapter windowAdapter = new WindowAdapter() {
>    public void windowOpened(WindowEvent we) {
>     SVGDocument doc = null;
>     try {
>      String parser = XMLResourceDescriptor
>        .getXMLParserClassName();
>      SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
>      StringReader reader = new StringReader(svg);
>      doc = f.createSVGDocument(null, reader);
>     } catch (Exception ex) {
>     }
>     canvas.setSVGDocument(doc);
>     try {
>      Source source = new DOMSource(doc);
>      Result result = new StreamResult(System.out);
>      Transformer xformer = TransformerFactory.newInstance()
>        .newTransformer();
>      xformer.setOutputProperty(OutputKeys.INDENT, "yes");
>      xformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
>      xformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
>        "no");
>      xformer.transform(source, result);
>     } catch (Exception ex) {
>      ex.printStackTrace();
>     }
>    }
>   };
>   addWindowListener(windowAdapter);
>   setDefaultCloseOperation(EXIT_ON_CLOSE);
>   setSize(100, 100);
>   setVisible(true);
>  }
>  public class Canvas extends JSVGCanvas implements 
GVTTreeRendererListener {
>   private static final long serialVersionUID = 1L;
>   public Canvas() {
>    canvas = this;
>    setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
>    addGVTTreeRendererListener(this);
>    KeyAdapter keyAdapter = new KeyAdapter() {
>     public void keyPressed(KeyEvent e) {
> 
>      if(e.getKeyCode() != KeyEvent.VK_SPACE )
>       return;
> 
> 
>      if (runQ == null)
>       return;
>      runQ.invokeLater(new Runnable() {
>       public void run() {
>        changeColor();
>        try {
>         Source source = new DOMSource(document);
>         Result result = new StreamResult(System.out);
>         Transformer xformer = TransformerFactory
>           .newInstance().newTransformer();
>         xformer.setOutputProperty(OutputKeys.INDENT,
>           "yes");
>         xformer.setOutputProperty(OutputKeys.ENCODING,
>           "UTF-8");
>         xformer.setOutputProperty(
>           OutputKeys.OMIT_XML_DECLARATION, "no");
>         xformer.transform(source, result);
>        } catch (Exception ex) {
>         ex.printStackTrace();
>        }
>       }
>      });
>     }
>    };
>    addKeyListener(keyAdapter);
>   }
>   public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
>   }
>   public void gvtRenderingStarted(GVTTreeRendererEvent e) {
>   }
>   public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
>    document = canvas.getSVGDocument();
>    runQ = canvas.getUpdateManager().getUpdateRunnableQueue();
>   }
>   public void gvtRenderingCancelled(GVTTreeRendererEvent e) {
>   }
>   public void gvtRenderingFailed(GVTTreeRendererEvent e) {
>   }
>  }
>  private void changeColor() {
>   SVGSVGElement root = document.getRootElement();
>   NodeList liste = 
document.getElementsByTagName(SVGConstants.SVG_PATH_TAG);
>   Element path = (Element)liste.item(0);
>   if(invert == false){
>    path.setAttributeNS(null, SVGConstants.SVG_FILL_ATTRIBUTE, "blue");
>    path.setAttributeNS(null, SVGConstants.SVG_STROKE_ATTRIBUTE, 
"yellow");
>   }else{
>    path.setAttributeNS(null, SVGConstants.SVG_FILL_ATTRIBUTE, "red");
>    path.setAttributeNS(null, SVGConstants.SVG_STROKE_ATTRIBUTE, 
"green"); 
>   }
>   invert = !invert;
>  }
> 
>  public static void main(String[] args) {
>   SwingUtilities.invokeLater(new Runnable() {
>    public void run() {
>     new TestPattern();
>    }
>   });
>  }
> }
> 
> 
> De nouvelles Emoticones sur Messenger ? Téléchargez gratuitement les
> émoticônes Summer ![attachment "TestPattern.java" deleted by Thomas 
> E. DeWeese/449433/EKC] 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

RE: Partial Refresh

Posted by Julien Beghin <mi...@hotmail.com>.
Hi All,

 

As I can't give you the whole application, I created a sample of what I want to do.

 

I simply create a pattern and use it in the fill attribute of a <rect>...

 

The application consists in changing the pattern color when pressing space.

 

The SVG is also displayed in the console for information...

 

Do someone on the mailing list have this application working correctly ?

 

Nota : I have a color modification when zooming with the CTRL key and the mouse after having pressed space.

 

 

 

//////////////////////////////////////////////////////////

 

Here is the source code, same as the attached file

 

/////////////////////////////////////////////////////////

 

package com.test;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.StringReader;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.swing.JSVGCanvas;
import org.apache.batik.swing.gvt.GVTTreeRendererEvent;
import org.apache.batik.swing.gvt.GVTTreeRendererListener;
import org.apache.batik.util.RunnableQueue;
import org.apache.batik.util.SVGConstants;
import org.apache.batik.util.XMLResourceDescriptor;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.svg.SVGDocument;
import org.w3c.dom.svg.SVGSVGElement;

 

 

 

public class TestPattern extends JFrame {
 
 private static final long serialVersionUID = 5778700446793083700L;
 
 Canvas canvas;
 SVGDocument document;
 RunnableQueue runQ = null;
 
 String svg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
 +"<svg viewbox=\"0 0 50 50\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" contentScriptType=\"text/ecmascript\" width=\"50\" zoomAndPan=\"magnify\" contentStyleType=\"text/css\" height=\"50\" preserveAspectRatio=\"xMidYMid meet\" version=\"1.1\">"
 +"<pattern width=\"25\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" patternUnits=\"userSpaceOnUse\" xlink:type=\"simple\" xlink:actuate=\"none\" height=\"25\"  id=\"myPattern\" preserveAspectRatio=\"xMidYMid meet\" xlink:show=\"other\" overflow=\"hidden\">"
 +" <path fill=\"red\" d=\"M 1 1 L 24 1 L 24 24 L 1 24z\" stroke-width=\"1\" stroke=\"green\"/>"
 +"</pattern>"
 +"<rect overflow=\"visible\" fill=\"url(#myPattern)\" width=\"50.0000\" height=\"50\"/>"
 +"</svg>";
 
 private boolean invert = false;
 
 
 
 public TestPattern() {
  super("");
  canvas = new Canvas();
  setContentPane(canvas);

  WindowAdapter windowAdapter = new WindowAdapter() {
   public void windowOpened(WindowEvent we) {
    SVGDocument doc = null;
    try {
     String parser = XMLResourceDescriptor
       .getXMLParserClassName();
     SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
     StringReader reader = new StringReader(svg);
     doc = f.createSVGDocument(null, reader);
    } catch (Exception ex) {
    }
    canvas.setSVGDocument(doc);
    try {
     Source source = new DOMSource(doc);
     Result result = new StreamResult(System.out);
     Transformer xformer = TransformerFactory.newInstance()
       .newTransformer();
     xformer.setOutputProperty(OutputKeys.INDENT, "yes");
     xformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
     xformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
       "no");
     xformer.transform(source, result);
    } catch (Exception ex) {
     ex.printStackTrace();
    }
   }
  };
  addWindowListener(windowAdapter);

  setDefaultCloseOperation(EXIT_ON_CLOSE);
  setSize(100, 100);
  setVisible(true);
 }

 public class Canvas extends JSVGCanvas implements GVTTreeRendererListener {

  private static final long serialVersionUID = 1L;

  public Canvas() {
   canvas = this;
   setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
   addGVTTreeRendererListener(this);

   KeyAdapter keyAdapter = new KeyAdapter() {
    public void keyPressed(KeyEvent e) {
     
     if(e.getKeyCode() != KeyEvent.VK_SPACE )
      return;
     
     
     if (runQ == null)
      return;
     runQ.invokeLater(new Runnable() {
      public void run() {
       changeColor();
       try {
        Source source = new DOMSource(document);
        Result result = new StreamResult(System.out);
        Transformer xformer = TransformerFactory
          .newInstance().newTransformer();
        xformer.setOutputProperty(OutputKeys.INDENT,
          "yes");
        xformer.setOutputProperty(OutputKeys.ENCODING,
          "UTF-8");
        xformer.setOutputProperty(
          OutputKeys.OMIT_XML_DECLARATION, "no");
        xformer.transform(source, result);
       } catch (Exception ex) {
        ex.printStackTrace();
       }
      }
     });
    }
   };
   addKeyListener(keyAdapter);
  }

  public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
  }

  public void gvtRenderingStarted(GVTTreeRendererEvent e) {
  }

  public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
   document = canvas.getSVGDocument();
   runQ = canvas.getUpdateManager().getUpdateRunnableQueue();
  }

  public void gvtRenderingCancelled(GVTTreeRendererEvent e) {
  }

  public void gvtRenderingFailed(GVTTreeRendererEvent e) {
  }
 }

 private void changeColor() {
  SVGSVGElement root = document.getRootElement();

  NodeList liste = document.getElementsByTagName(SVGConstants.SVG_PATH_TAG);
  Element path = (Element)liste.item(0);
  if(invert == false){
   path.setAttributeNS(null, SVGConstants.SVG_FILL_ATTRIBUTE, "blue");
   path.setAttributeNS(null, SVGConstants.SVG_STROKE_ATTRIBUTE, "yellow");
  }else{
   path.setAttributeNS(null, SVGConstants.SVG_FILL_ATTRIBUTE, "red");
   path.setAttributeNS(null, SVGConstants.SVG_STROKE_ATTRIBUTE, "green");   
  }
  invert = !invert;
 }

 

 public static void main(String[] args) {
  SwingUtilities.invokeLater(new Runnable() {
   public void run() {
    new TestPattern();
   }
  });
 }

}

 		 	   		  
_________________________________________________________________
Allumez et éteignez votre PC en un instant avec Windows 7 !
http://clk.atdmt.com/FRM/go/238030931/direct/01/

RE: Partial Refresh

Posted by Julien Beghin <mi...@hotmail.com>.
Hi Dao, and thanks for reading about my problems.

 

I tried to change this by setting setAttribute("xlink:actuate","none") and setAttribute("xlink:actuate","onRequest") but nothing more happens...

 

Couldn't this come from the fact that the pattern is identifed by its url for other elements of the SVG ?

 

I mean maybe the pattern is changed when I modify its attributes, but what about the elements using it ? Are they supposed to be refreshed by Batik ?

 

I thought we were respecting all Batik prescription when setting the canvas as Dynamic and using the runnable queue... but I must have missed a thing ...


 


Date: Fri, 16 Jul 2010 16:19:05 +0200
Subject: Re: Partial Refresh
From: dao.hodac@gmail.com
To: batik-users@xmlgraphics.apache.org

perhaps it is because you specified xlink:actuate="onLoad" in the pattern attributes...


On Fri, Jul 16, 2010 at 3:09 PM, Julien Beghin <mi...@hotmail.com> wrote:


Hi Thomas,
 
I should be missing a thing...
I am using a SVGCanavas Class, extending "JSVGCanvas" that contains the following -> setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC); 
So I assume that it keep the always dynamic status during the execution.
 
All our graphic operations are done in updatemanager :
 

updateManager.getUpdateRunnableQueue().invokeLater(new Runnable() 
{
     public void run()    {
         // Code done here
   }
}
 
Basically we are getting org.w3c.dom.Element and we use setAttribute to modify SVG contents...
 
It seems OK for most of our application.
 
Also, our SVG contains patterns like this : 
<path xmlns:math="http://exslt.org/math" fill="none" d="M386.25,462.50 L386.25,457.50" stroke-width="0.20" stroke="rgb(0,0,0)"/>
<defs>
     <pattern width="12.5000" xmlns:xlink="http://www.w3.org/1999/xlink" patternUnits="userSpaceOnUse" xlink:type="simple" xlink:actuate="onLoad" id="Autres_fluides_04db74e9-a2aa-      46d1-ab9c-6684fed4a84d" viewBox="0.00000 -1.27500 25.0000 2.55000" height="2.55000" preserveAspectRatio="xMidYMid meet" xlink:show="other" overflow="hidden">
           <path fill="rgb(0,0,0)" d="M 10.0 -2.5 L 10.0 2.5 L 15.0 2.5 L 15.0 -2.5 z" stroke-width="0.100000" stroke="rgb(0,0,0)"/>
      </pattern>
</defs>
 
 
When this pattern is updated the result is not displayed ( if I do "getSvgCanvas().setSVGDocument(svgDoc);" result is OK, but that is not a good way to work... )
Node referencing the pattern with fill="url(#Autres_fluides_04db74e9...)" are not OK in the canvas...
 
 
Is there a specific way to implement the modification ?
 
 


To: batik-users@xmlgraphics.apache.org
CC: batik-users@xmlgraphics.apache.org
Subject: Re: Partial Refresh
From: thomas.deweese@kodak.com
Date: Fri, 16 Jul 2010 06:16:59 -0400




Hi Julien, 

Julien Beghin <mi...@hotmail.com> wrote on 07/13/2010 06:05:14 AM:

> I still experience some refresh  "bugs" in my application.

   This means that either your canvas is not set to 'dynamic' or 
that you are not making your modifications in the UpdateManager's 
runnable queue.  I'm betting on the latter. 

> We added a refresh at the end :
> svgPanel.getSvgCanvas().setRenderingTransform(svgPanel.getSvgCanvas
> ().getRenderingTransform());

   If you need to do this then you are modifying the document 
incorrectly.  Batik will update the canvas automatically if you 
follow the rules.




Le nouveau Messenger arrive ! Téléchargez-le gratuitement et découvrez ses nouvelles fonctionnalités

-- 
Dao Hodac
 		 	   		  
_________________________________________________________________
Découvrez Microsoft Security Essentials, l'antivirus gratuit par Microsoft
http://clk.atdmt.com/FRM/go/212688364/direct/01/

Re: Partial Refresh

Posted by dao <da...@gmail.com>.
perhaps it is because you specified xlink:actuate="onLoad" in the pattern
attributes...

On Fri, Jul 16, 2010 at 3:09 PM, Julien Beghin <mi...@hotmail.com>wrote:

>  Hi Thomas,
>
> I should be missing a thing...
> I am using a SVGCanavas Class, extending "JSVGCanvas" that contains the
> following -> setDocumentState(JSVGCanvas.*ALWAYS_DYNAMIC*);
> So I assume that it keep the always dynamic status during the execution.
>
> All our graphic operations are done in updatemanager :
>
>
> updateManager.getUpdateRunnableQueue().invokeLater(*new* Runnable()
>
> {
>
> *     public* *void* run()    {
>          // Code done here
>    }
> }
>
> Basically we are getting org.w3c.dom.Element and we use setAttribute to
> modify SVG contents...
>
> It seems OK for most of our application.
>
> Also, our SVG contains patterns like this :
> <path xmlns:math="http://exslt.org/math" fill="none" d="M386.25,462.50
> L386.25,457.50" stroke-width="0.20" stroke="rgb(0,0,0)"/>
> <defs>
>      <pattern width="12.5000" xmlns:xlink="http://www.w3.org/1999/xlink"
> patternUnits="userSpaceOnUse" xlink:type="simple" xlink:actuate="onLoad"
> id="Autres_fluides_04db74e9-a2aa-      46d1-ab9c-6684fed4a84d"
> viewBox="0.00000 -1.27500 25.0000 2.55000" height="2.55000"
> preserveAspectRatio="xMidYMid meet" xlink:show="other" overflow="hidden">
>            <path fill="rgb(0,0,0)" d="M 10.0 -2.5 L 10.0 2.5 L 15.0 2.5 L
> 15.0 -2.5 z" stroke-width="0.100000" stroke="rgb(0,0,0)"/>
>       </pattern>
> </defs>
>
>
> When this pattern is updated the result is not displayed ( if I do "getSvgCanvas().setSVGDocument(svgDoc);"
> result is OK, but that is not a good way to work... )
> Node referencing the pattern with fill="url(#Autres_fluides_04db74e9...)"
> are not OK in the canvas...
>
>
> Is there a specific way to implement the modification ?
>
>
> ------------------------------
> To: batik-users@xmlgraphics.apache.org
> CC: batik-users@xmlgraphics.apache.org
> Subject: Re: Partial Refresh
> From: thomas.deweese@kodak.com
> Date: Fri, 16 Jul 2010 06:16:59 -0400
>
>
> Hi Julien,
>
> Julien Beghin <mi...@hotmail.com> wrote on 07/13/2010 06:05:14 AM:
>
> > I still experience some refresh  "bugs" in my application.
>
>    This means that either your canvas is not set to 'dynamic' or
> that you are not making your modifications in the UpdateManager's
> runnable queue.  I'm betting on the latter.
>
> > We added a refresh at the end :
> > svgPanel.getSvgCanvas().setRenderingTransform(svgPanel.getSvgCanvas
> > ().getRenderingTransform());
>
>    If you need to do this then you are modifying the document
> incorrectly.  Batik will update the canvas automatically if you
> follow the rules.
>
>
> ------------------------------
> Le nouveau Messenger arrive ! Téléchargez-le gratuitement et découvrez ses
> nouvelles fonctionnalités<http://clk.atdmt.com/FRM/go/244627952/direct/01/>
>



-- 
Dao Hodac

RE: Partial Refresh

Posted by Julien Beghin <mi...@hotmail.com>.
Hi Thomas,

 

I should be missing a thing...

I am using a SVGCanavas Class, extending "JSVGCanvas" that contains the following -> setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC); 

So I assume that it keep the always dynamic status during the execution.

 

All our graphic operations are done in updatemanager :

 

updateManager.getUpdateRunnableQueue().invokeLater(new Runnable()
{
     public void run()
   {

         // Code done here

   }

}

 

Basically we are getting org.w3c.dom.Element and we use setAttribute to modify SVG contents...

 

It seems OK for most of our application.

 

Also, our SVG contains patterns like this : 

<path xmlns:math="http://exslt.org/math" fill="none" d="M386.25,462.50 L386.25,457.50" stroke-width="0.20" stroke="rgb(0,0,0)"/>
<defs>
     <pattern width="12.5000" xmlns:xlink="http://www.w3.org/1999/xlink" patternUnits="userSpaceOnUse" xlink:type="simple" xlink:actuate="onLoad" id="Autres_fluides_04db74e9-a2aa-      46d1-ab9c-6684fed4a84d" viewBox="0.00000 -1.27500 25.0000 2.55000" height="2.55000" preserveAspectRatio="xMidYMid meet" xlink:show="other" overflow="hidden">
           <path fill="rgb(0,0,0)" d="M 10.0 -2.5 L 10.0 2.5 L 15.0 2.5 L 15.0 -2.5 z" stroke-width="0.100000" stroke="rgb(0,0,0)"/>
      </pattern>
</defs>

 

 

When this pattern is updated the result is not displayed ( if I do "getSvgCanvas().setSVGDocument(svgDoc);" result is OK, but that is not a good way to work... )

Node referencing the pattern with fill="url(#Autres_fluides_04db74e9...)" are not OK in the canvas...

 

 

Is there a specific way to implement the modification ?

 

 



To: batik-users@xmlgraphics.apache.org
CC: batik-users@xmlgraphics.apache.org
Subject: Re: Partial Refresh
From: thomas.deweese@kodak.com
Date: Fri, 16 Jul 2010 06:16:59 -0400

Hi Julien, 

Julien Beghin <mi...@hotmail.com> wrote on 07/13/2010 06:05:14 AM:

> I still experience some refresh  "bugs" in my application.

   This means that either your canvas is not set to 'dynamic' or 
that you are not making your modifications in the UpdateManager's 
runnable queue.  I'm betting on the latter. 

> We added a refresh at the end :
> svgPanel.getSvgCanvas().setRenderingTransform(svgPanel.getSvgCanvas
> ().getRenderingTransform());

   If you need to do this then you are modifying the document 
incorrectly.  Batik will update the canvas automatically if you 
follow the rules.

 		 	   		  
_________________________________________________________________
Le nouveau Hotmail est presque arrivé, ne le manquez pas !
http://www.windowslive.fr/nouveau-hotmail/

Re: Partial Refresh

Posted by th...@kodak.com.
Hi Julien,

Julien Beghin <mi...@hotmail.com> wrote on 07/13/2010 06:05:14 AM:

> I still experience some refresh  "bugs" in my application.

   This means that either your canvas is not set to 'dynamic' or
that you are not making your modifications in the UpdateManager's 
runnable queue.  I'm betting on the latter. 

> We added a refresh at the end :
> svgPanel.getSvgCanvas().setRenderingTransform(svgPanel.getSvgCanvas
> ().getRenderingTransform());

   If you need to do this then you are modifying the document
incorrectly.  Batik will update the canvas automatically if you
follow the rules.