以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 SVG/GML/VRML/X3D/XAML 』  (http://bbs.xml.org.cn/list.asp?boardid=21)
----  Batik下的脚本问题  (http://bbs.xml.org.cn/dispbbs.asp?boardid=21&rootid=&id=58302)


--  作者:qiruiabc
--  发布时间:1/21/2008 2:35:00 PM

--  Batik下的脚本问题
用Batik在canvas下可以实现的类似javascript的交互功能,但通过如下代码转换的时候只能保存那些静态的SVG信息,而脚本无法保存。

  File file = new File("svgs/" + name + ".svg");
  PrintWriter pw = null;
  try {
   pw = new PrintWriter(new FileWriter(file));
   pw.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
   pw.write("<!DOCTYPE svg PUBLIC '");
   pw.write(SVGConstants.SVG_PUBLIC_ID);
   pw.write("' '");
   pw.write(SVGConstants.SVG_SYSTEM_ID);
   pw.write("'>\n\n");
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }

  Transcoder svgtranscoder = new SVGTranscoder();
  TranscoderInput input = new TranscoderInput(doc);
  TranscoderOutput output = new TranscoderOutput(pw);
  try {
   svgtranscoder.transcode(input, output);
   pw.close();
  } catch (TranscoderException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 
这样的话,如果单独打开生成后的SVG文件则无法具备动画交互功能了。
想问一下,该如何把那些动画的用JAVA写的代码转换成javascript。

难道只能手写吗,还是说,Batik下对SVG的事件处理只能局限在Swing下运用????

谢谢


--  作者:wdy9927
--  发布时间:1/22/2008 9:15:00 AM

--  
关注一下,我现在的做法是把javascript的函数在java程序里添加到script节点下.
这样做很麻烦,需要组成函数字符串,还好我的不是很麻烦,所以实现起来还可以.

W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
45.898ms