Hi guys! Im Niko, new here
I am trying to make an application where I mix together images of different lamps and lighting conditions. The way I imagined it, is that each there is one channel with the natural light, and slider01 controls its intensity, and then on top of that we get different lighting options that are I can turn on by pressing either of the three buttons. A button then brings up a slider where I can control intensity of that image. Finally, pressing other buttons brings up another slider in place of previous, and resets value from the previous, so we start with the clear ‘‘canvas’’ of only the image from the first channel (the one that is independent of the buttons).
It is kinda working, but I am getting a bunch of errors coming from the buttons - do you have any idea what is the issue here? Also, the app is kinda heavy on the computer… I am not sure but maybe there is a way to make it run more smooth? Any help would be greatly appreciated!
The errors:
sty 02, 2020 12:41:41 PM controlP5.ControlBroadcaster printMethodError
SEVERE: An error occured while forwarding a Controller event, please check your code at CCT4000K
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at controlP5.ControlBroadcaster.invokeMethod(Unknown Source)
at controlP5.ControlBroadcaster.callTarget(Unknown Source)
at controlP5.ControlBroadcaster.broadcast(Unknown Source)
at controlP5.Controller.broadcast(Unknown Source)
at controlP5.Button.setValue(Unknown Source)
at LIGHTCONTROL.setup(LIGHTCONTROL.java:72)
at processing.core.PApplet.handleDraw(PApplet.java:2425)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)
Caused by: java.lang.NullPointerException
at LIGHTCONTROL.CCT4000K(LIGHTCONTROL.java:223)
... 13 more
sty 02, 2020 12:41:41 PM controlP5.ControlBroadcaster printMethodError
SEVERE: An error occured while forwarding a Controller event, please check your code at CCT5000K
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at controlP5.ControlBroadcaster.invokeMethod(Unknown Source)
at controlP5.ControlBroadcaster.callTarget(Unknown Source)
at controlP5.ControlBroadcaster.broadcast(Unknown Source)
at controlP5.Controller.broadcast(Unknown Source)
at controlP5.Button.setValue(Unknown Source)
at LIGHTCONTROL.setup(LIGHTCONTROL.java:83)
at processing.core.PApplet.handleDraw(PApplet.java:2425)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:313)
Caused by: java.lang.NullPointerException
at LIGHTCONTROL.CCT5000K(LIGHTCONTROL.java:234)
... 13 more
Code:
//In case of any questions - contact the author via: derengowski.nikodem@gmail.com
import controlP5.*;
ControlP5 cp5;
ControlP5 OPT1;
ControlP5 OPT2;
ControlP5 OPT3;
PImage img1;
PImage img2;
PImage img3;
PImage img4;
PImage img5;
int Daylight = 0;
int Tasklamp = 0;
int Ceiling3000K = 0;
int Ceiling4000K = 0;
int Ceiling5000K = 0;
boolean display3K = false;
boolean display4K = false;
boolean display5K = false;
void setup() {
//size(960, 680);
fullScreen();
OPT1 = new ControlP5(this);
OPT2 = new ControlP5(this);
OPT3 = new ControlP5(this);
cp5 = new ControlP5(this);
PFont p = createFont("Calibri bold",10);
ControlFont font = new ControlFont(p);
cp5.setFont(font);
OPT1.setFont(font);
OPT2.setFont(font);
OPT3.setFont(font);
cp5.addButton("CCT3000K")
.setPosition(20,height-90)
.setSize(80,50)
.setValue(0)
.setColorValue(color(200))
.setColorActive(color(155))
.setColorForeground(color(100))
.setColorBackground(color(255, 214, 170, 230))
.activateBy(ControlP5.PRESS);
;
cp5.addButton("CCT4000K")
.setPosition(120,height-90)
.setSize(80,50)
.setValue(0)
.setColorValue(color(200))
.setColorActive(color(155))
.setColorForeground(color(100))
.setColorBackground(color(244, 255, 250, 230))
.activateBy(ControlP5.PRESS);
;
cp5.addButton("CCT5000K")
.setPosition(220,height-90)
.setSize(80,50)
.setValue(0)
.setColorValue(color(200))
.setColorActive(color(155))
.setColorForeground(color(100))
.setColorBackground(color(212, 235, 255, 230))
.activateBy(ControlP5.PRESS);
;
cp5.addSlider("Daylight")
.setRange(0, 255)
.setValue(0)
.setPosition(20, height - 140)
.setSize(width - 200, 20)
.setColorValue(color(200))
.setColorActive(color(155))
.setColorForeground(color(100))
.setColorBackground(color(150, 150, 150));
cp5.addSlider("Tasklamp")
.setRange(0, 210)
.setPosition(320, height-60)
.setSize(width - 500, 20)
.setColorValue(color(200))
.setColorActive(color(155))
.setColorForeground(color(100))
.setColorBackground(color(150, 150, 150));
OPT1.addSlider("Ceiling3000K")
.setRange(0, 230)
.setPosition(320, height - 100)
.setSize(width-500, 20)
.setColorValue(color(200))
.setColorActive(color(155))
.setColorForeground(color(100))
.setColorBackground(color(150, 150, 150));
OPT2.addSlider("Ceiling4000K")
.setRange(0, 230)
.setPosition(320, height - 100)
.setSize(width - 500, 20)
.setColorValue(color(200))
.setColorActive(color(155))
.setColorForeground(color(100))
.setColorBackground(color(150, 150, 150));
OPT3.addSlider("Ceiling5000K")
.setRange(0, 230)
.setPosition(320, height - 100)
.setSize(width - 500, 20)
.setColorValue(color(200))
.setColorActive(color(155))
.setColorForeground(color(100))
.setColorBackground(color(150, 150, 150));
img1 = loadImage("2GDLx.png");
img1.resize(0, height-150);
img2 = loadImage("2GTx.png");
img2.resize(0, height-150);
img3 = loadImage("2G3Kx.png");
img3.resize(0, height-150);
img4 = loadImage("2G4K.png");
img4.resize(0, height-150);
img5 = loadImage("2G5K.png");
img5.resize(0, height-150);
}
void draw() {
background(0);
fill(255);
textSize(14);
text("CCT OF CEILING LUMINARIES", 20, height - 100);
blendMode(SCREEN);
int imgw = 20;
int imgh = 0;
tint(255, 255-Daylight);
image(img1,imgw,imgh);
tint(255, Tasklamp);
image(img2, imgw,imgh);
tint(255, Ceiling3000K);
image(img3, imgw,imgh);
tint(255, Ceiling4000K);
image(img4, imgw,imgh);
tint(255, Ceiling5000K);
image(img5, imgw,imgh);
hideSlider3K();
hideSlider4K();
hideSlider5K();
}
void hideSlider3K() {
if (display3K == false) {
OPT1.hide();
}
else {
OPT1.show();
}
}
void hideSlider4K() {
if (display4K == false) {
OPT2.hide();
}
else {
OPT2.show();
}
}
void hideSlider5K() {
if (display5K == false) {
OPT3.hide();
}
else {
OPT3.show();
}
}
public void CCT3000K(){
display3K = true;
display4K = false;
display5K = false;
OPT2.getController("Ceiling4000K").getValue();;
OPT2.getController("Ceiling4000K").setValue(0);
OPT3.getController("Ceiling5000K").getValue();;
OPT3.getController("Ceiling5000K").setValue(0);
println("3K");
}
public void CCT4000K(){
display3K = false;
display4K = true;
display5K = false;
OPT1.getController("Ceiling3000K").getValue();;
OPT1.getController("Ceiling3000K").setValue(0);
OPT3.getController("Ceiling5000K").getValue();;
OPT3.getController("Ceiling5000K").setValue(0);
println("4K");
}
public void CCT5000K(){
display3K = false;
display4K = false;
display5K = true;
OPT1.getController("Ceiling3000K").getValue();;
OPT1.getController("Ceiling3000K").setValue(0);
OPT2.getController("Ceiling4000K").getValue();;
OPT2.getController("Ceiling4000K").setValue(0);
println("5K");
}