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.
Page Index Toggle Pages: 1
Text issues (Read 642 times)
Text issues
Jul 12th, 2007, 11:17pm
 
Hey there,
So, I'm kind of a Java/Processing noob, so this is going to be a kind of basic issue.  But I have been playing with the Switchboard library, and want to display the results to an applet window, and have been having a hell of a time with that.  The problem seems to be with the text() function, the string and array.  

Specifically, the error I get is:

"No applicable overload for a method with signature "text(java.lang.String[], int, int, int, int)" was found in type "processing.core.PApplet". Perhaps you wanted the overloaded version "void text(java.lang.String $1, float $2, float $3, float $4, float $5);" instead?"

Anyone got any ideas?

Code:

import processing.opengl.*;
import org.switchboard.*;


Switchboard board;
ArrayList words = new ArrayList();

void setup() {
size(300, 300, OPENGL);
background(0);
frameRate(10);

board = new Switchboard(this);
board.setYahooKey("xxxxxxx");

board.yahooWeb("self");
}

void resultReceived() {

words.add(board.yahooWeb.getSummary());
}



void draw() {
String word[] = (String[]) words.toArray (new String [words.size ()]);
println(word); //Check to make sure that the service is working
PFont font = loadFont("HelveticaNeue-BoldItalic-48.vlw");
textFont(font, 24);
fill(255);
text(word, 10, 10, 300, 300);
}
Re: Text issues
Reply #1 - Jul 12th, 2007, 11:36pm
 
What you have is an array of words, what the function expects is a single string, you have 2 optioned, either write all the words individually, or join all the words together into a single string.
The single string is the easiest way I think:

Code:
 void draw() {
String word[] = (String[]) words.toArray (new String [words.size ()]);
println(word); //Check to make sure that the service is working
PFont font = loadFont("HelveticaNeue-BoldItalic-48.vlw");
textFont(font, 24);
fill(255);
String joinedwords=join(word," "); //converts an array of individual words
//into a single string of them all
text(joinedword, 10, 10, 300, 300);
}
Re: Text issues
Reply #2 - Jul 12th, 2007, 11:42pm
 
You just made my week.  Thank you so much!
Re: Text issues
Reply #3 - Jul 13th, 2007, 12:01am
 
I can probbaly make things even better.. you're loading the font every frame.. it'd be better to load it in setup only.

Code:

PFont font;

void setup()
{
.. other stuff...
PFont font = loadFont("HelveticaNeue-BoldItalic-48.vlw");
textFont(font, 24);
}

void draw()
{
.. stuff .. no loadFont or textFont
text(...);
}
Re: Text issues
Reply #4 - Jul 13th, 2007, 12:06am
 
Aha!  Nice, thank you.
Page Index Toggle Pages: 1