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 Alvarez <jp...@genigraph.fr> on 2008/07/09 18:42:56 UTC
Problem with a JSVGCanvas and an Applet.
Hello,
Im trying to do an applet with a JSVGCanvas but I have a problem (of
course, if not I wouldnt be here ! ).
The trace of the java console give me this error (the same under Firefox and
IE) :
java.lang.NullPointerException
at
org.apache.batik.swing.svg.AbstractJSVGComponent.setGraphicsNode(AbstractJSV
GComponent.java:840)
at
org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener.gvtBuildFailed(
AbstractJSVGComponent.java:1605)
at
org.apache.batik.swing.svg.GVTTreeBuilder$4.dispatch(GVTTreeBuilder.java:179
)
at
org.apache.batik.util.EventDispatcher.dispatchEvent(EventDispatcher.java:103
)
at
org.apache.batik.util.EventDispatcher.fireEvent(EventDispatcher.java:87)
at
org.apache.batik.util.EventDispatcher$1.run(EventDispatcher.java:46)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
The code of my applet :
import javax.swing.JApplet;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.swing.JSVGCanvas;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class AppletSvg extends JApplet {
private static final long serialVersionUID = 1L;
protected JSVGCanvas canvas;
protected Document doc;
protected Element svgRoot;
/**
* Création du document svg
*/
public void init() {
//Objet permettant de manipuler un document SVG
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = "http://www.w3.org/2000/svg";
//Création du document SVG
doc = impl.createDocument(svgNS, "svg", null);
//get the root element (the svg element)
svgRoot = doc.getDocumentElement();
//set the width and height attribute on the svg root element
svgRoot.setAttributeNS(null, "width", getParameter("screenSizeX"));
svgRoot.setAttributeNS(null, "height", getParameter("screenSizeY"));
//Fond
Element rect = doc.createElementNS(svgNS, "rect");
rect.setAttributeNS(null, "x", "5%");
rect.setAttributeNS(null, "y", "5%");
rect.setAttributeNS(null, "width", "90%");
rect.setAttributeNS(null, "height", "90%");
rect.setAttributeNS(null, "style", "fill:#F5F5F5");
rect.setAttributeNS(null, "stroke-width",
getParameter("pixelSizeY1"));
svgRoot.appendChild(rect);
canvas = new JSVGCanvas();
getContentPane().add(canvas);
}
public void start() {
// Display the document.
canvas.setDocumentState(JSVGCanvas.ALWAYS_STATIC);
canvas.setDocument(doc);
}
public void stop() {
// Remove the document.
canvas.setDocument(null);
}
public void destroy() {
canvas.dispose();
}
}
And the way I call it from my jsp :
<jsp:plugin type="applet" archive="batik-anim.jar, batik-awt-util.jar,
batik-bridge.jar, batik-css.jar, batik-dom.jar, batik-ext.jar,
batik-gvt.jar, batik-parser.jar, batik-script.jar, batik-svg-dom.jar,
batik-swing.jar, batik-util.jar, batik-xml.jar, xml-apis.jar,
xml-apis-ext.jar"
code="AppletSvg.class" codebase="../applet-lib/"
jreversion="1.1" width="650" height="400" >
<jsp:params>
<jsp:param name="screenSizeX"
value="<bean:write name='gParams' property='screenSizeX'/>"/>
<jsp:param name="screenSizeY"
value="<bean:write name='gParams' property='screenSizeY'/>"/>
<jsp:param name="pixelSizeY1"
value="<bean:write name='gParams' property='pixelSizeY1'/>"/>
</jsp:params>
</jsp:plugin>
I have not found that error on the net and I cant understand why it occurs,
I have not found that error on the web and I cant understand why it occurs,
if someone have any idea to resolve it I will be very thankfull !
RE: Problem with a JSVGCanvas and an Applet.
Posted by Alvarez <jp...@genigraph.fr>.
Yes, Ive used something like that to correct my problem, now everything
works fine thanks.
Ive forgot half of the solution on my previous message sorry. ^^
_____
De : Guillaume Rosauro [mailto:g.rosauro@gmail.com]
Envoyé : jeudi 10 juillet 2008 17:43
À : batik-users@xmlgraphics.apache.org
Objet : Re: Problem with a JSVGCanvas and an Applet.
Hi
I am not a JSP expert, but you should change your code like this :
<jsp:useBean id="myBean" scope="session" type="??"/>
<%
String screenSizeX = myBean.getScreenSizeX();
String screenSizeY = myBean.getScreenSizeY();
%>
<jsp:plugin>
...
<jsp:param name="screenSizeX " value="<%= screenSizeX %>" />
<jsp:param name="screenSizeY " value="<%= screenSizeY %>" />
...
</jsp:plugin>
Guillaume
On Thu, Jul 10, 2008 at 5:35 PM, Alvarez <jp...@genigraph.fr> wrote:
Me again, I've found my mystake, in fact that line : <jsp:param
name="screenSizeX" value="<bean:write name='gParams'
property='screenSizeX'/>"/> give me the string "<bean:write name='gParams'
property='screenSizeX'/>" on my applet with getParamter("screenSizeX").
If it can help someone
_____
De : Alvarez [mailto:jpalvarez@genigraph.fr]
Envoyé : mercredi 9 juillet 2008 18:43
À : batik-users@xmlgraphics.apache.org
Objet : Problem with a JSVGCanvas and an Applet.
Hello,
I'm trying to do an applet with a JSVGCanvas but I have a problem (of
course, if not I wouldn't be here ! ).
The trace of the java console give me this error (the same under Firefox and
IE) :
java.lang.NullPointerException
at
org.apache.batik.swing.svg.AbstractJSVGComponent.setGraphicsNode(AbstractJSV
GComponent.java:840)
at
org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener.gvtBuildFailed(
AbstractJSVGComponent.java:1605)
at
org.apache.batik.swing.svg.GVTTreeBuilder$4.dispatch(GVTTreeBuilder.java:179
)
at
org.apache.batik.util.EventDispatcher.dispatchEvent(EventDispatcher.java:103
)
at
org.apache.batik.util.EventDispatcher.fireEvent(EventDispatcher.java:87)
at
org.apache.batik.util.EventDispatcher$1.run(EventDispatcher.java:46)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
The code of my applet :
import javax.swing.JApplet;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.swing.JSVGCanvas;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class AppletSvg extends JApplet {
private static final long serialVersionUID = 1L;
protected JSVGCanvas canvas;
protected Document doc;
protected Element svgRoot;
/**
* Création du document svg
*/
public void init() {
//Objet permettant de manipuler un document SVG
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = "http://www.w3.org/2000/svg";
//Création du document SVG
doc = impl.createDocument(svgNS, "svg", null);
//get the root element (the svg element)
svgRoot = doc.getDocumentElement();
//set the width and height attribute on the svg root element
svgRoot.setAttributeNS(null, "width", getParameter("screenSizeX"));
svgRoot.setAttributeNS(null, "height", getParameter("screenSizeY"));
//Fond
Element rect = doc.createElementNS(svgNS, "rect");
rect.setAttributeNS(null, "x", "5%");
rect.setAttributeNS(null, "y", "5%");
rect.setAttributeNS(null, "width", "90%");
rect.setAttributeNS(null, "height", "90%");
rect.setAttributeNS(null, "style", "fill:#F5F5F5");
rect.setAttributeNS(null, "stroke-width",
getParameter("pixelSizeY1"));
svgRoot.appendChild(rect);
canvas = new JSVGCanvas();
getContentPane().add(canvas);
}
public void start() {
// Display the document.
canvas.setDocumentState(JSVGCanvas.ALWAYS_STATIC);
canvas.setDocument(doc);
}
public void stop() {
// Remove the document.
canvas.setDocument(null);
}
public void destroy() {
canvas.dispose();
}
}
And the way I call it from my jsp :
<jsp:plugin type="applet" archive="batik-anim.jar, batik-awt-util.jar,
batik-bridge.jar, batik-css.jar, batik-dom.jar, batik-ext.jar,
batik-gvt.jar, batik-parser.jar, batik-script.jar, batik-svg-dom.jar,
batik-swing.jar, batik-util.jar, batik-xml.jar, xml-apis.jar,
xml-apis-ext.jar"
code="AppletSvg.class" codebase="../applet-lib/"
jreversion="1.1" width="650" height="400" >
<jsp:params>
<jsp:param name="screenSizeX"
value="<bean:write name='gParams' property='screenSizeX'/>"/>
<jsp:param name="screenSizeY"
value="<bean:write name='gParams' property='screenSizeY'/>"/>
<jsp:param name="pixelSizeY1"
value="<bean:write name='gParams' property='pixelSizeY1'/>"/>
</jsp:params>
</jsp:plugin>
I have not found that error on the net and I can't understand why it occurs,
I have not found that error on the web and I can't understand why it occurs,
if someone have any idea to resolve it I will be very thankfull !
Re: Problem with a JSVGCanvas and an Applet.
Posted by Guillaume Rosauro <g....@gmail.com>.
Hi
I am not a JSP expert, but you should change your code like this :
<jsp:useBean id="myBean" scope="session" type="??"/>
<%
String screenSizeX = myBean.getScreenSizeX();
String screenSizeY = myBean.getScreenSizeY();
%>
<jsp:plugin>
...
<jsp:param name="screenSizeX " value="<%= screenSizeX %>" />
<jsp:param name="screenSizeY " value="<%= screenSizeY %>" />
...
</jsp:plugin>
Guillaume
On Thu, Jul 10, 2008 at 5:35 PM, Alvarez <jp...@genigraph.fr> wrote:
> Me again, I've found my mystake, in fact that line : <jsp:param name="screenSizeX"
> value="<bean:write name='gParams' property='screenSizeX'/>"/> give me the
> string "<bean:write name='gParams' property='screenSizeX'/>" on my applet
> with getParamter("screenSizeX").
>
>
>
> If it can help someone…
>
>
>
>
> ------------------------------
>
> *De :* Alvarez [mailto:jpalvarez@genigraph.fr]
> *Envoyé :* mercredi 9 juillet 2008 18:43
> *À :* batik-users@xmlgraphics.apache.org
> *Objet :* Problem with a JSVGCanvas and an Applet.
>
>
>
> Hello,
>
>
>
> I'm trying to do an applet with a JSVGCanvas but I have a problem (of
> course, if not I wouldn't be here ! ).
>
>
>
> The trace of the java console give me this error (the same under Firefox
> and IE) :
>
>
>
> java.lang.NullPointerException
>
> at
> org.apache.batik.swing.svg.AbstractJSVGComponent.setGraphicsNode(AbstractJSVGComponent.java:840)
>
> at
> org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener.gvtBuildFailed(AbstractJSVGComponent.java:1605)
>
> at
> org.apache.batik.swing.svg.GVTTreeBuilder$4.dispatch(GVTTreeBuilder.java:179)
>
> at
> org.apache.batik.util.EventDispatcher.dispatchEvent(EventDispatcher.java:103)
>
> at
> org.apache.batik.util.EventDispatcher.fireEvent(EventDispatcher.java:87)
>
> at
> org.apache.batik.util.EventDispatcher$1.run(EventDispatcher.java:46)
>
> at java.awt.event.InvocationEvent.dispatch(Unknown Source)
>
> at java.awt.EventQueue.dispatchEvent(Unknown Source)
>
> at
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
>
> at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
> Source)
>
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>
> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>
> at java.awt.EventDispatchThread.run(Unknown Source)
>
>
>
>
>
>
>
> The code of my applet :
>
>
>
> *import* javax.swing.JApplet;
>
>
>
> *import* org.apache.batik.dom.svg.SVGDOMImplementation;
>
> *import* org.apache.batik.swing.JSVGCanvas;
>
> *import* org.w3c.dom.DOMImplementation;
>
> *import* org.w3c.dom.Document;
>
> *import* org.w3c.dom.Element;
>
>
>
> *public* *class* AppletSvg *extends* JApplet {
>
>
>
> *private* *static* *final* *long* *serialVersionUID* = 1L;
>
>
>
> *protected* JSVGCanvas canvas;
>
> *protected* Document doc;
>
> *protected* Element svgRoot;
>
>
>
> /**
>
> * Création du document svg
>
> */
>
> *public* *void* init() {
>
>
>
> //Objet permettant de manipuler un document SVG
>
> DOMImplementation impl = SVGDOMImplementation.*getDOMImplementation
> *();
>
> String svgNS = "http://www.w3.org/2000/svg";
>
>
>
> //Création du document SVG
>
> doc = impl.createDocument(svgNS, "svg", *null*);
>
>
>
> //get the root element (the svg element)
>
> svgRoot = doc.getDocumentElement();
>
>
>
> //set the width and height attribute on the svg root element
>
> svgRoot.setAttributeNS(*null*, "width", getParameter("screenSizeX"
> ));
>
> svgRoot.setAttributeNS(*null*, "height", getParameter("screenSizeY"
> ));
>
>
>
> //Fond
>
> Element rect = doc.createElementNS(svgNS, "rect");
>
> rect.setAttributeNS(*null*, "x", "5%");
>
> rect.setAttributeNS(*null*, "y", "5%");
>
> rect.setAttributeNS(*null*, "width", "90%");
>
> rect.setAttributeNS(*null*, "height", "90%");
>
> rect.setAttributeNS(*null*, "style", "fill:#F5F5F5");
>
> rect.setAttributeNS(*null*, "stroke-width", getParameter(
> "pixelSizeY1"));
>
> svgRoot.appendChild(rect);
>
>
>
> canvas = *new* JSVGCanvas();
>
> getContentPane().add(canvas);
>
>
>
> }
>
>
>
> *public* *void* start() {
>
> // Display the document.
>
> canvas.setDocumentState(JSVGCanvas.*ALWAYS_STATIC*);
>
> canvas.setDocument(doc);
>
> }
>
>
>
> *public* *void* stop() {
>
> // Remove the document.
>
> canvas.setDocument(*null*);
>
> }
>
>
>
> *public* *void* destroy() {
>
> canvas.dispose();
>
> }
>
>
>
> }
>
>
>
>
>
>
>
>
>
> And the way I call it from my jsp :
>
>
>
> <jsp:plugin type="applet" archive="batik-anim.jar, batik-awt-util.jar,
> batik-bridge.jar, batik-css.jar, batik-dom.jar, batik-ext.jar,
> batik-gvt.jar, batik-parser.jar, batik-script.jar, batik-svg-dom.jar,
> batik-swing.jar, batik-util.jar, batik-xml.jar, xml-apis.jar,
> xml-apis-ext.jar"
>
> code="AppletSvg.class" codebase="../applet-lib/"
>
> jreversion="1.1" width="650" height="400" >
>
>
>
> <jsp:params>
>
> <jsp:param name="screenSizeX" value="<
> bean:write name='gParams' property='screenSizeX'/>"/>
>
> <jsp:param name="screenSizeY" value="<
> bean:write name='gParams' property='screenSizeY'/>"/>
>
> <jsp:param name="pixelSizeY1" value="<
> bean:write name='gParams' property='pixelSizeY1'/>"/>
>
> </jsp:params>
>
> </jsp:plugin>
>
>
>
>
>
>
>
> I have not found that error on the net and I can't understand why it
> occurs,
>
>
>
>
>
> I have not found that error on the web and I can't understand why it
> occurs, if someone have any idea to resolve it I will be very thankfull !
>
RE: Problem with a JSVGCanvas and an Applet.
Posted by Alvarez <jp...@genigraph.fr>.
Me again, Ive found my mystake, in fact that line : <jsp:param
name="screenSizeX" value="<bean:write name='gParams'
property='screenSizeX'/>"/> give me the string "<bean:write name='gParams'
property='screenSizeX'/>" on my applet with getParamter("screenSizeX").
If it can help someone
_____
De : Alvarez [mailto:jpalvarez@genigraph.fr]
Envoyé : mercredi 9 juillet 2008 18:43
À : batik-users@xmlgraphics.apache.org
Objet : Problem with a JSVGCanvas and an Applet.
Hello,
Im trying to do an applet with a JSVGCanvas but I have a problem (of
course, if not I wouldnt be here ! ).
The trace of the java console give me this error (the same under Firefox and
IE) :
java.lang.NullPointerException
at
org.apache.batik.swing.svg.AbstractJSVGComponent.setGraphicsNode(AbstractJSV
GComponent.java:840)
at
org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener.gvtBuildFailed(
AbstractJSVGComponent.java:1605)
at
org.apache.batik.swing.svg.GVTTreeBuilder$4.dispatch(GVTTreeBuilder.java:179
)
at
org.apache.batik.util.EventDispatcher.dispatchEvent(EventDispatcher.java:103
)
at
org.apache.batik.util.EventDispatcher.fireEvent(EventDispatcher.java:87)
at
org.apache.batik.util.EventDispatcher$1.run(EventDispatcher.java:46)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
The code of my applet :
import javax.swing.JApplet;
import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.apache.batik.swing.JSVGCanvas;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class AppletSvg extends JApplet {
private static final long serialVersionUID = 1L;
protected JSVGCanvas canvas;
protected Document doc;
protected Element svgRoot;
/**
* Création du document svg
*/
public void init() {
//Objet permettant de manipuler un document SVG
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = "http://www.w3.org/2000/svg";
//Création du document SVG
doc = impl.createDocument(svgNS, "svg", null);
//get the root element (the svg element)
svgRoot = doc.getDocumentElement();
//set the width and height attribute on the svg root element
svgRoot.setAttributeNS(null, "width", getParameter("screenSizeX"));
svgRoot.setAttributeNS(null, "height", getParameter("screenSizeY"));
//Fond
Element rect = doc.createElementNS(svgNS, "rect");
rect.setAttributeNS(null, "x", "5%");
rect.setAttributeNS(null, "y", "5%");
rect.setAttributeNS(null, "width", "90%");
rect.setAttributeNS(null, "height", "90%");
rect.setAttributeNS(null, "style", "fill:#F5F5F5");
rect.setAttributeNS(null, "stroke-width",
getParameter("pixelSizeY1"));
svgRoot.appendChild(rect);
canvas = new JSVGCanvas();
getContentPane().add(canvas);
}
public void start() {
// Display the document.
canvas.setDocumentState(JSVGCanvas.ALWAYS_STATIC);
canvas.setDocument(doc);
}
public void stop() {
// Remove the document.
canvas.setDocument(null);
}
public void destroy() {
canvas.dispose();
}
}
And the way I call it from my jsp :
<jsp:plugin type="applet" archive="batik-anim.jar, batik-awt-util.jar,
batik-bridge.jar, batik-css.jar, batik-dom.jar, batik-ext.jar,
batik-gvt.jar, batik-parser.jar, batik-script.jar, batik-svg-dom.jar,
batik-swing.jar, batik-util.jar, batik-xml.jar, xml-apis.jar,
xml-apis-ext.jar"
code="AppletSvg.class" codebase="../applet-lib/"
jreversion="1.1" width="650" height="400" >
<jsp:params>
<jsp:param name="screenSizeX"
value="<bean:write name='gParams' property='screenSizeX'/>"/>
<jsp:param name="screenSizeY"
value="<bean:write name='gParams' property='screenSizeY'/>"/>
<jsp:param name="pixelSizeY1"
value="<bean:write name='gParams' property='pixelSizeY1'/>"/>
</jsp:params>
</jsp:plugin>
I have not found that error on the net and I cant understand why it occurs,
I have not found that error on the web and I cant understand why it occurs,
if someone have any idea to resolve it I will be very thankfull !