We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Candy SVG library and Array
Page Index Toggle Pages: 1
Candy SVG library and Array (Read 451 times)
Candy SVG library and Array
Mar 6th, 2008, 3:32pm
 
greetings,

i am making a project and i need to use some SVG graphics (78 graphics * 3) the best way i can think of using these to fit my purpose is to create an array and load them all there. to do so, i've made the following array:

SVG[][] letras = new SVG[3][78];

then, in the void setup(){}, i wrote

for(int i = 0; i < 3; i++){
   for (int j = 0; j < 78; j++) {
     letras[i][j] = new SVG(this, "\""+"letra"+i+(j+33)+".svg"+"\"");

in order to load the SVG files called letra#*.svg where # is a number between 0 and 2 and * is a number between 33 and 90 (inclusive).

i get the following error:

"letra033.svg" does not exist or could not be read
java.lang.RuntimeException: java.lang.NullPointerException
at processing.opengl.PGraphicsOpenGL.requestDisplay(PGraphicsOpenGL.java:172)
at processing.core.PApplet.run(PApplet.java:1562)
at java.lang.Thread.run(Thread.java:552)
Caused by: java.lang.NullPointerException
at processing.xml.XMLElement.readChar(XMLElement.java:2517)
at processing.xml.XMLElement.scanWhitespace(XMLElement.java:2199)
at processing.xml.XMLElement.parseFromReader(XMLElement.java:1640)
at processing.xml.XMLElement.parseFromReader(XMLElement.java:1598)
at processing.xml.XMLElement.<init>(XMLElement.java:485)
at processing.candy.SVG.<init>(SVG.java:158)
at Temporary_6596_4593.setup(Temporary_6596_4593.java:63)
at processing.core.PApplet.handleDisplay(PApplet.java:1390)
at processing.opengl.PGraphicsOpenGL$1.display(PGraphicsOpenGL.java:227)
at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:281)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
at javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java
:298)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:179)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:478)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:2
34)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:184
)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:170)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)




yet, if i use this:

SVG a33;
a33 = new SVG(this, "letra033.svg");

i get no error.

how can i load the svg files to the array i described above?

or is it possible to load all the SVG files one by one like the second method i used and then link the position in the array to the file loaded?
Re: Candy SVG library and Array
Reply #1 - Mar 6th, 2008, 5:32pm
 
"\""+"letra"+i+(j+33)+".svg"+"\"" will give you this String "letra033.svg" but you need  the String letra033.svg without the "". So your string construction should look like this: "letra"+i+(j+33)+".svg"
Re: Candy SVG library and Array
Reply #2 - Mar 6th, 2008, 11:44pm
 
thanks for the quick reply.
since in the example we put the filename in "" i thought we needed to pass the filename with "" also as in the normal method.

Re: Candy SVG library and Array
Reply #3 - Mar 7th, 2008, 8:19pm
 
The "" are just the way to tell Processing that the literal value we are writing is to be interpreted as a String, rather than some other type.

The real contents of a String don't include (generally) the "".

You would only use \" if you really want the String contents to have the " symbol. In your case the filename must not have a " symbol so you can't put one in it.

jorge
Re: Candy SVG library and Array
Reply #4 - Mar 8th, 2008, 12:43am
 
Wink
Page Index Toggle Pages: 1