I've created a mediumly complex Processing application, using some 3D graphics, OpenGL, Minim, and ControlP5 libs.
I want to turn it into a commerical product, but it runs slowly, the user interface is poor, networking support is poor, etc. I am wondering if switching to Java will help with the speed issues very much, or if I need to go back to something like C++ ? Basically, the question is will I gain much speed by switching to pure Java? Will it be as much work as switching to something else such as C++? I am mostly a C programmer, so I still don't know full Java or C++ at this time.
I'm having a problem with listBox stealing mouse clicks from my program. I made a simple example to show this. I didn't have this problem when I was using the older scrollList, but it seems to exist in listBox...
I am attaching the controlP5 website example for using ListBox. I added a few lines to controlEvent() to set the label of the listbox after it is selected, and then automatically close it up. This part works fine, but then the next mouse click is always stolen, it doesn't re-open the listBox, or if you had any other controllers on the screen, it doesn't activate them. Wondering if this is a bug or there is something I'm doing wrong?
thanks!
/**
* ControlP5 ListBox
* listBox operates the same way as a scrollList, but
* is optimized for many items (1000+). using a listBox
* over a scrollList is recommended
* by andreas schlegel, 2009
*/
import controlP5.*;
ControlP5 controlP5;
ListBox l;
int cnt = 0;
void setup() {
size(400,400);
frameRate(30);
controlP5 = new ControlP5(this);
l = controlP5.addListBox("myList",100,100,120,120);
l.setItemHeight(15);
l.setBarHeight(15);
void keyPressed() {
if(key=='1') {
// set the height of a listBox should alwyays be a multiple of itemHeight
l.setHeight(210);
}
else if(key=='2') {
// set the height of a listBox should alwyays be a multiple of itemHeight
l.setHeight(120);
}
else if(key=='i') {
// set the height of a listBoxItem, should alwyays be a fraction of the listBox
l.setItemHeight(30);
}
else if(key=='u') {
// set the height of a listBoxItem, should alwyays be a fraction of the listBox
l.setItemHeight(10);
l.setBackgroundColor(color(100,0,0));
}
else if(key=='a') {
int n = (int)(random(100000));
l.addItem("item "+n, n);
}
else if(key=='d') {
l.removeItem("item "+cnt);
cnt++;
}
}
void controlEvent(ControlEvent theEvent) {
// ListBox is if type ControlGroup.
// 1 controlEvent will be executed, where the event
// originates from a ControlGroup. therefore
// you need to check the Event with
// if (theEvent.isGroup())
// to avoid an error message from controlP5.
if (theEvent.isGroup()) {
// an event from a group e.g. scrollList
println(theEvent.group().value()+" from "+theEvent.group());
l.setLabel("set to " + l.value());
l.close();
}
}
void draw() {
background(128);
// scroll the scroll List according to the mouseX position
// when holding down SPACE.
if(keyPressed && key==' ') {
//l.scroll(mouseX/((float)width)); // scroll taks values between 0 and 1
}
if(keyPressed && key==' ') {
l.setWidth(mouseX);
}
}