xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julien Beghin <minimoi1...@hotmail.com>
Subject RE: Partial Refresh
Date Mon, 26 Jul 2010 12:59:56 GMT

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 <minimoi1234@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/
Mime
View raw message