Coder Social home page Coder Social logo

sojamo / controlp5 Goto Github PK

View Code? Open in Web Editor NEW
479.0 479.0 139.0 2.08 MB

A gui library for processing.org

License: GNU Lesser General Public License v2.1

Java 95.99% Shell 0.16% CSS 2.13% HTML 1.71%
controlp5 gui gui-library processing processing-library

controlp5's People

Contributors

amnonowed avatar sojamo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

controlp5's Issues

Hexadecimal values in controls: numberbox test

Hello, I am using Processing since too little time to have a deep understanding, but ControlP5 seems to me a great library.

Just wondering if it would be possible to have hexadecimal values displayed in labels for controllers.
My Java is a little rugged, but I think something like that:

HexBox.java

import controlP5.*;

import processing.core.PApplet;
import processing.core.PVector;

/**
 * 
 */
public class HexBox extends Numberbox {

  /**
   * 
   */
  public HexBox(ControlP5 theControlP5, String theName) {
    super(theControlP5, theName);
  }

  /**
   * 
   */
  public HexBox(ControlP5 theControlP5, Tab theParent, String theName, float theDefaultValue, int theX, int theY, int theWidth, int theHeight) {
    super(theControlP5, theParent, theName, theDefaultValue, theX, theY, theWidth, theHeight);
  }



  /**
   * set the value of the HexBox.
   * 
   * @param theValue float
   * @return HexBox
   */
  @Override
  public HexBox setValue(float theValue) {
    _myValue = theValue;
    _myValue = Math.max(_myMin, Math.min(_myMax, _myValue));
    broadcast(FLOAT);
    //_myValueLabel.set("gg" + adjustValue(_myValue));
    _myValueLabel.set(adjustHexValue(_myValue));
    return this;
  }

  private String adjustHexValue(float theValue){
    return String.format("%02X", (int) theValue);
  }

}

In the sketch use:

cp5 = new ControlP5(this);

HexBox hb = new HexBox(cp5, "hexbox");
hb.setRange(0,255);
hb.setDecimalPrecision(0);
hb.setScrollSensitivity(1);

Can it be a feature in the future?
Maybe adding some methods for the hex precision (number of digits).

Thanks a lot, I hope this little piece of code is helpful... now working for me.
Cheers

New JSON properties save and load not working

I have a Processing 2 project and trying to port it to Processing 3.
It heavily uses controlp5 for parameters adjustment. In Processing 2 it works perfectly, in Processing 3 it doesn't.

The project can be found here:
https://github.com/w4nderlust/SkolpTiles

the code for loading and saving the parameters is the following:

void load() {
  selectInput("Select a parameters file to load", "load_callback");
}

void load_callback(File selection) {
  if (selection != null) {
    cp5.loadProperties(selection.getAbsolutePath());
    generate();
  }
}

void save() {
  selectOutput("Select a parameters file to save to", "save_callback");
}

void save_callback(File selection) {
  if (selection != null) {
    cp5.saveProperties(selection.getAbsolutePath());
  }
}

Trigger callback after load

Hi,
I'm currently implementing ControlP5 into my apps and I like a lot the idea of the load/save functions.
One thing I don't understand though is why the callback functions of the controllers are not called when I load new settings. Since the new value is different I would like the callbacks to be triggered automatically.
Is there an option to do so ?
Thanks for your help !

controlp5 Missing 'author' from library

Hello There,

I hope you're well and may be able to help with an issue I'm having with the ControlP5 library. I've been playing around with an Adafruit Trinket and some Neopixels. But I can't actually ever seem to successfully upload a sketch to the microcontroller on the Trinket, to drive the Neopixels.

I keep getting the following error message, right before it is about to complete the upload.

"Documents\Arduino\libraries\controlP5: Missing 'author' from library"

I'm not sure why there would be a missing 'author' from the library or what that exactly means, but I was hoping someone could shed some light on this issue or know of a workaround/fix.

Kind Regards,

Michael B

Fork of Control P5 and rewrite

Hello,

I spend some time working on a fork of ControlP5 to extend it. I reworked the code architecture to understand how it works and handle the quantity of classes.
Obviously it is not as convenient now, as it requires multiple import lines in the Processing sketch.

There are a few new possibilities however :

  • Use another object than the PApplet object to handle the events.
  • Use another PGraphics than the usual PApplet.g .
  • Rewrite of the mouse / pointer events. There is now a generic "pointer" and the mouse is one of them. Users can add, and remove pointers.
  • Building using Maven.
  • Creation of the library with a Bash script.
  • First reached goal : it works with Ruby with JRubyArt (new name of Ruby-Processing). Almost like in Java, the controllers will link to a method, and a variable automatically.
  • Second reached goal : Multiple ControlP5 objects can be instanciated with different graphics contexts (not just different windows). Also, one object can have its own ControlP5 object.
  • Maybe possible : use ControlP5 in Python mode (like we do in Ruby).
  • To come : Extension of the controllers for multi-touch surfaces.

You can have a look. I kept the name ControlP5 for now. So we have two possibility, try to merge, or I could become real fork with another name.
Thanks for your great work ! 

Cheers,

Jeremy.

steps as integers on Range

Hi. Great library. Thanks. Quick question:

Using one of your examples, I found that the default behavior of range was to show and return floats but I simply wanted ints. In one other slider example, you made this step-wise motion in ints possible by writing int v1; // v1 is later cp5.addSlider("v1")

I did something similar in this example and it works but I'm sure this is not the correct / best way. What is the correct way?

import controlP5.*;

ControlP5 cp5;
int bandStart, bandEnd;
Range bandRange;

int bandRangeSlider; // makes range steps in integer and not float...

public void setup() {
    // canvas details
    size(500, 500, P3D);
    background(0);

    // controls
    cp5 = new ControlP5(this);
    bandRange = cp5.addRange("bandRangeSlider")
            .setBroadcast(false)
            .setPosition(40, 40)
            .setSize(200, 20)
            .setHandleSize(20)
            .setRange(0, 500)
            .setRangeValues(50, 100)
            .setBroadcast(true)
            .setColorForeground(color(255, 40))
            .setColorBackground(color(255, 40));
}

public void draw() {
    background(0);
}

public void controlEvent(ControlEvent theControlEvent) {
    if (theControlEvent.isFrom("bandRangeSlider")) {

        bandStart = (int)theControlEvent.getController().getArrayValue(0);
        bandEnd = (int)theControlEvent.getController().getArrayValue(1);
        System.out.println("range update, done.");
        System.out.print(bandStart);
        System.out.println(" to " + bandEnd);
    }
}

_myPaddingY missing in most cases in SinglelineLabel#align()?

class SinglelineLabel implements Labeltype {

        private void align( PGraphics theGraphics , int theAlignX , int theAlignY , int theW , int theH ) {
            int x = 0;
            int y = 0;
            switch ( theAlignX ) {
            case ( ControlP5.CENTER ):
                x = ( theW - _myFontLabel.getWidth( ) ) / 2;
                break;
            case ( ControlP5.LEFT ):
                x = _myPaddingX;
                break;
            case ( ControlP5.RIGHT ):
                x = theW - _myFontLabel.getWidth( ) - _myPaddingX;
                break;
            case ( ControlP5.LEFT_OUTSIDE ):
                x = -_myFontLabel.getWidth( ) - _myPaddingX;
                break;
            case ( ControlP5.RIGHT_OUTSIDE ):
                x = theW + _myPaddingX;
                break;
            }
            switch ( theAlignY ) {
            case ( ControlP5.CENTER ):
                y = theH / 2 + _myFontLabel.getTop( ) - _myFontLabel.getCenter( );
                break;
            case ( ControlP5.TOP ):
                y = 0;
                break;
            case ( ControlP5.BOTTOM ):
                y = theH - _myFontLabel.getHeight( ) - 1;
                break;
            case ( ControlP5.BASELINE ):
                y = theH + _myFontLabel.getTop( ) - 1;
                break;
            case ( ControlP5.BOTTOM_OUTSIDE ):
                y = theH + _myPaddingY;
                break;
            case ( ControlP5.TOP_OUTSIDE ):
                y = -_myFontLabel.getHeight( ) - _myPaddingY;
                break;
            }
            theGraphics.translate( x , y );
        }
}

Notice how _myPaddingY is only used in two cases for the Y alignment. But _myPaddingX is used by all X alignment cases except for CENTER.

Errors when using FX2D as renderer in Processing 3

In Processing 3.0.1 when I set the render to FX2D in my project using ControlP5 ( https://github.com/w4nderlust/SkolpTiles ) I get the following NullPointerException

ControlP5 2.2.5 infos, comments, questions at http://www.sojamo.de/libraries/controlP5
java.lang.NullPointerException
    at processing.javafx.PGraphicsFX2D$FontCache$Key.hashCode(PGraphicsFX2D.java:1423)
    at java.util.HashMap.hash(HashMap.java:338)
    at java.util.LinkedHashMap.get(LinkedHashMap.java:440)
    at processing.javafx.PGraphicsFX2D$FontCache.get(PGraphicsFX2D.java:1377)
    at processing.javafx.PGraphicsFX2D.handleTextFont(PGraphicsFX2D.java:1470)
    at processing.javafx.PGraphicsFX2D.textFontImpl(PGraphicsFX2D.java:1446)
    at processing.core.PGraphics.textFont(PGraphics.java:4232)
    at controlP5.ControlFont.adjust(Unknown Source)
    at controlP5.Label$SinglelineLabel.draw(Unknown Source)
    at controlP5.Label$SinglelineLabel.draw(Unknown Source)
    at controlP5.Label.draw(Unknown Source)
    at controlP5.Button$ButtonView.display(Unknown Source)
    at controlP5.Button$ButtonView.display(Unknown Source)
    at controlP5.Controller.draw(Unknown Source)
    at controlP5.ControllerGroup.drawControllers(Unknown Source)
    at controlP5.ControllerGroup.draw(Unknown Source)
    at controlP5.ControlWindow.draw(Unknown Source)
    at controlP5.ControlWindow.draw(Unknown Source)
    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:497)
    at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1395)
    at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1388)
    at processing.core.PApplet.handleMethods(PApplet.java:1582)
    at processing.core.PApplet.handleDraw(PApplet.java:2412)
    at processing.javafx.PSurfaceFX$1.handle(PSurfaceFX.java:75)
    at processing.javafx.PSurfaceFX$1.handle(PSurfaceFX.java:1)
    at com.sun.scenario.animation.shared.TimelineClipCore.visitKeyFrame(TimelineClipCore.java:226)
    at com.sun.scenario.animation.shared.TimelineClipCore.playTo(TimelineClipCore.java:184)
    at javafx.animation.Timeline.impl_playTo(Timeline.java:176)
    at javafx.animation.AnimationAccessorImpl.playTo(AnimationAccessorImpl.java:39)
    at com.sun.scenario.animation.shared.InfiniteClipEnvelope.timePulse(InfiniteClipEnvelope.java:110)
    at javafx.animation.Animation.impl_timePulse(Animation.java:1102)
    at javafx.animation.Animation$1.lambda$timePulse$26(Animation.java:186)
    at javafx.animation.Animation$1$$Lambda$98/1995405830.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at javafx.animation.Animation$1.timePulse(Animation.java:185)
    at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:344)
    at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:267)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:521)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:505)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$400(QuantumToolkit.java:334)
    at com.sun.javafx.tk.quantum.QuantumToolkit$$Lambda$56/1457741631.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
handleDraw() called before finishing
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help → Troubleshooting.

Deactivate ScrollableList item

Hi, I'm working with the amazing ControlP5 again for a creative coding project! :-)

I am using a ScrollableList of type LIST in ControlP5 2.2.5. Currently once you click on / activate an item, the only way to deactivate it is by clicking on / activating another item. I would like to manually deactivate an item, after it has been selected (or just deactivate all items). So that the appearance of the list is as it was before it was clicked on.

Thinking of methods like in the RadioButton class like this:

  • myScrollableList.deactivate(indexOfItem);
  • myScrollableList.deactivateAll();

Looking at the source it seemed that the map's 'state' key controls the active state (true or false). So I tried to achieve my goal through the map interface with myList.getItem(index).put("state", false); but I found that state was already set to false for all items, even the one that is active!?!?

My question is if there currently is a way to achieve what I would like to do? And if not, if this functionality could be added to the ScrollableList class.

Thanks!

ScollableList disable dropdown

Hi,
I am using the ScrollableList to make a COM port selection. Everything is working well however I would like to disable the dropdown function. i.e. if the user clicks the top bar I don't want the list to collapse.

I have tried setType(LIST) however this doesn't seem to change anything.?
and I can't do this with a controlEvent() because the dropdown activity doesn't seem to trigger an event.

Am I missing something or should I be using a different controller?

thanks, Scott

IndexOutOfBounds in ScrollableList and Listbox

When the ScrollableList and the Listbox do not have enough items to fill the entire height of the controller, clicking below the last item causes the following stacktrace:

java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
    at java.util.ArrayList.rangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at controlP5.ScrollableList.onRelease(Unknown Source)
    at controlP5.Controller.setMousePressed(Unknown Source)
    at controlP5.ControllerGroup.setMousePressed(Unknown Source)
    at controlP5.ControlWindow.mouseReleasedEvent(Unknown Source)
    at controlP5.ControlWindow.mouseEvent(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1236)
    at processing.core.PApplet.handleMethods(PApplet.java:1431)
    at processing.core.PApplet.handleMouseEvent(PApplet.java:2826)
    at processing.core.PApplet.dequeueEvents(PApplet.java:2725)
    at processing.core.PApplet.handleDraw(PApplet.java:2397)
    at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240)
    at processing.core.PApplet.run(PApplet.java:2256)
    at java.lang.Thread.run(Unknown Source)

This can be easily recreated by opening the ScrollableList example, deleting all items from the list except 'a', and clicking directly below item 'a' (where the following item would be). Problems experienced in version 2.2.4.

Easy fix would be to check the length of the list before accessing, I could change this myself but I'm not aware of the consequences this might have.

controlp5 2.2.5 not working with Processing 3.0.1 FX2D renderer

Windows 7, Processing 3.0.1

Taking a number of examples (e.g. button / slide / textfield), adding FX2D to the size() constructor consistently results in the following error which prevents the sketch from running:

ControlP5 2.2.5 infos, comments, questions at http://www.sojamo.de/libraries/controlP5
java.lang.NullPointerException
    at processing.javafx.PGraphicsFX2D$FontCache$Key.hashCode(PGraphicsFX2D.java:1423)
    at java.util.HashMap.hash(HashMap.java:338)
    at java.util.LinkedHashMap.get(LinkedHashMap.java:440)
    at processing.javafx.PGraphicsFX2D$FontCache.get(PGraphicsFX2D.java:1377)
    at processing.javafx.PGraphicsFX2D.handleTextFont(PGraphicsFX2D.java:1470)
    at processing.javafx.PGraphicsFX2D.textFontImpl(PGraphicsFX2D.java:1446)
    at processing.core.PGraphics.textFont(PGraphics.java:4232)
    at controlP5.ControlFont.adjust(Unknown Source)
    at controlP5.Label$SinglelineLabel.draw(Unknown Source)
    at controlP5.Label$SinglelineLabel.draw(Unknown Source)
    at controlP5.Label.draw(Unknown Source)
    at controlP5.Textfield.draw(Unknown Source)
    at controlP5.ControllerGroup.drawControllers(Unknown Source)
    at controlP5.ControllerGroup.draw(Unknown Source)
    at controlP5.ControlWindow.draw(Unknown Source)
    at controlP5.ControlWindow.draw(Unknown Source)
    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:497)
    at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1395)
    at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1388)
    at processing.core.PApplet.handleMethods(PApplet.java:1582)
    at processing.core.PApplet.handleDraw(PApplet.java:2412)
    at processing.javafx.PSurfaceFX$1.handle(PSurfaceFX.java:75)
    at processing.javafx.PSurfaceFX$1.handle(PSurfaceFX.java:1)
    at com.sun.scenario.animation.shared.TimelineClipCore.visitKeyFrame(TimelineClipCore.java:226)
    at com.sun.scenario.animation.shared.TimelineClipCore.playTo(TimelineClipCore.java:184)
    at javafx.animation.Timeline.impl_playTo(Timeline.java:176)
    at javafx.animation.AnimationAccessorImpl.playTo(AnimationAccessorImpl.java:39)
    at com.sun.scenario.animation.shared.InfiniteClipEnvelope.timePulse(InfiniteClipEnvelope.java:110)
    at javafx.animation.Animation.impl_timePulse(Animation.java:1102)
    at javafx.animation.Animation$1.lambda$timePulse$26(Animation.java:186)
    at javafx.animation.Animation$1$$Lambda$102/1585508389.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at javafx.animation.Animation$1.timePulse(Animation.java:185)
    at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:344)
    at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:267)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:521)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:505)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$400(QuantumToolkit.java:334)
    at com.sun.javafx.tk.quantum.QuantumToolkit$$Lambda$56/874026615.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
    at com.sun.glass.ui.win.WinApplication$$Lambda$52/1125138434.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
handleDraw() called before finishing
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.

Typing characters with accent marks in a textbox

The controlp5 library is amazing, and I just want to say thanks for putting it together.

Is there a way to write special characters in controlp5? Currently, I am trying to create a textbox that searches for names in a list. Some of the names include characters from the Spanish alphabet, such as 'ó' in López, but I am having trouble typing them as a single character. If I try to type the character 'ó' it appears as the two separate characters ' and o.

I have added a PFont that includes all characters, and I have changed my keyboard to Spanish. I am using a PC and Processing v. 2.2.1.

At the moment, I am only using the example textbox found in the documentation.

void setup() {
PFont font = loadFont("myarial.vlw");
cp5 = new ControlP5(this);

cp5.addTextfield("input")
.setPosition(20, 100)
.setSize(200, 40)
.setFont(font)
.setFocus(true)
.setColor(color(255, 0, 0))
;

cp5.addTextfield("textValue")
.setPosition(20, 170)
.setSize(200, 40)
.setFont(font)
.setAutoClear(false)
;

cp5.addBang("clear")
.setPosition(240, 170)
.setSize(80, 40)
.getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER)
;

cp5.addTextfield("default")
.setPosition(20, 350)
.setAutoClear(false)
;

textFont(font);

}

void draw() {
background(0);
rect(10, 100, 50, 50);
if (foo) {
background(0);
fill(255);
text(cp5.get(Textfield.class, "input").getText(), 360, 130);
text(textValue, 360, 180);
}
}

Resizing window and moving button to higher x position than the original window width

When a button is moved outside of the original window width it stops working (No hover effect, clicks doesnt register)

Here is a sketch to illustrate it:

import controlP5.*;

ControlP5 cp5;
Button button;

void setup() {
  size(400,600);
  surface.setResizable(true);

  cp5 = new ControlP5(this);

  button = cp5.addButton("testbtn")
     .setPosition(width-110,10)
     .setSize(100,20);

}

void testbtn(){
  println("clicked");
}

void draw() {
  button.setPosition(width-110,10);
}

Drag the window to a new size at least 100px wider than the original.

Result:
Button doesnt work

Expected result:
Button should be clickable, but it is not

controlP5.js

I read that it is on hold.. is there any kind of material online (repo or something else?)
I need a simple gui with p5.js and if there is something on hold I can try to use it anyway.. Maybe help to improve it?

cmd button crashes Processing3 pde

If I press the cmd button (Mac OS X 10.11) on my Processing3 application using controlP5 it creashes with the following error:

java.lang.ArrayIndexOutOfBoundsException: 768
    at controlP5.ControlWindow.keyEvent(Unknown Source)
    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:497)
    at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1395)
    at processing.core.PApplet.handleMethods(PApplet.java:1590)
    at processing.core.PApplet.handleKeyEvent(PApplet.java:2945)
    at processing.core.PApplet.dequeueEvents(PApplet.java:2602)
    at processing.core.PApplet.handleDraw(PApplet.java:2410)
    at processing.javafx.PSurfaceFX$1.handle(PSurfaceFX.java:75)
    at processing.javafx.PSurfaceFX$1.handle(PSurfaceFX.java:1)
    at com.sun.scenario.animation.shared.TimelineClipCore.visitKeyFrame(TimelineClipCore.java:226)
    at com.sun.scenario.animation.shared.TimelineClipCore.playTo(TimelineClipCore.java:184)
    at javafx.animation.Timeline.impl_playTo(Timeline.java:176)
    at javafx.animation.AnimationAccessorImpl.playTo(AnimationAccessorImpl.java:39)
    at com.sun.scenario.animation.shared.InfiniteClipEnvelope.timePulse(InfiniteClipEnvelope.java:110)
    at javafx.animation.Animation.impl_timePulse(Animation.java:1102)
    at javafx.animation.Animation$1.lambda$timePulse$26(Animation.java:186)
    at javafx.animation.Animation$1$$Lambda$101/60587559.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at javafx.animation.Animation$1.timePulse(Animation.java:185)
    at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:344)
    at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:267)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:521)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:505)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$400(QuantumToolkit.java:334)
    at com.sun.javafx.tk.quantum.QuantumToolkit$$Lambda$56/1178450398.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
handleDraw() called before finishing
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help → Troubleshooting.

Suggestion for ScrollableList: getItemHover()

Find out which list-item of a ScrollableList is currently hovered

In the old/deprecated DropdownList one could trigger stuff by just hovering individually list-items, because you could find out over which particular ListBoxItem you were currently hovering through the cp5.isMouseOver(ListBoxItem xy) respectively cp5.getWindow().getMouseOverList() functionality.

In the new ScrollableList this is not possible anymore, because list-items are implemented differently and are not of type Controller anymore.

Internally in ScrollableList there is the field protected int itemHover; which gets tracked throughout the enter/hover/leave-process to highlight the hovered list-entry.

So an easy solution would be to make this field visible from "outer space" through providing a getter for it:
public int getHoverIndex() or getItemHover()
(returns null if ScrollableList is currently not hovered) (internally itemHover is -1 when not hovered, so -1)

What do you think??
Wanted/Planned functionality?

Greetings, benjamin.

setPosition of a Tab

Hi Sojamo, I would like to change the position of a Tab controller from your library, Is this possible?.
By default the first Tab is put on (0,0) position, and the next tab on right the first and so on. Can I change this?. If I use .setPosition, it is changes the position of the objects inside the tab but not the position of the tab itself.

regards!

Processing 3 support

Hi @sojamo,

I was wondering if you could contribute in any way to add Processing 3 support.

I'm the creator of MusicBeam which highly depends on ControlP5. I could ask my users for contributions as well, if needed.

Cheers,
Joe

ControlP5.Range right value label does not receive any font changes from .getValueLabel().setFont(font)

The font of the rightvalueLable in a range slider can only be set by declaring
.setFont(font); before the range slider is created.

Changing the font with .getValueLabel().setFont(font); does only affect the left value label.
Meaning that ones it is created its font can never be changed.

Example(extended from the range example):

cp5 = new ControlP5(this); 
  PFont font = createFont("arial", 17);
  //cp5.setFont(font);
  range = cp5.addRange("rangeController")
    .setBroadcast(false) 
    .setPosition(50, 50)
    .setSize(400, 40)
    .setHandleSize(20)
    .setRange(0, 255)
    .setRangeValues(50, 100)
    .setBroadcast(true)
    .setColorForeground(color(255, 40))
    .setColorBackground(color(255, 40))  
    ;
  cp5.getController("rangeController").getValueLabel().setFont(font);
  cp5.getController("rangeController").getCaptionLabel().setFont(font);

produces:
disatisfying

This is not a pressing issue but it would be great to have fixed for the sake of consistency.

Scrolling Textarea is painfully slow

When adding text using Textarea.append, eventually scrolling becomes painfully slow. I'm talking of a few dozen lines, though some of them with a few thousand characters.

Is that expected behavior? Any workaround?

Cannot get Radiobutton from within a group with the getController() method

Hi,

Type off RadioButton is ControllerGroup and for this reason the widget cannot be retrieved by name from within a group with "getController(String name): Controller"

Retrieving a ControllerInterface object and then casting it to RadioButton results in getting a a null object when using the getController(String name) method on the group.

Hope this is clear enough

Processing 3 : pixelDensity(2) affecting Textfield appearance

All the Textfield input text was disappearing from my Processing 3 sketch.

I found this was being caused by the new Processing 3 function pixelDensity() when set to pixelDensity(2). pixelDensity(1) is fine, as expected.

pixelDensity(2) renders strangely large text at sizes 20+ or completely disappears at sizes 19 and below.

Hope this helps!

See example code below:

import controlP5.*;
ControlP5 cp5;

String textValue = "";

void setup(){
  size(700,400);
  pixelDensity(2);

  cp5 = new ControlP5(this);

  cp5.addTextfield("textValue")
        .setPosition(20,170)
        .setSize(200,40)
        .setFont(createFont("arial",20)); 
}

void draw(){
  background(0);
  fill(255);
  text(textValue, 360,180);
}

as can I use Textfield in android mode processing?

Hello, first thank sojamo the work done with the library.

I am using this code in Android:

import android.view.inputmethod.InputMethodManager;
import android.inputmethodservice.KeyboardView.OnKeyboardActionListener;
import android.content.Context;
import controlP5.*;

ControlP5 cp5;
String textValue = "";
Textfield myTextfield;

void setup() {
size(400, 600);
cp5 = new ControlP5(this);
myTextfield = cp5.addTextfield("textinput")
.setPosition(100, 200)
.setSize(200, 20)
.setFocus(true)
;

cp5.addTextfield("textValue")
.setPosition(100, 300)
.setSize(200, 20)
;

// use setAutoClear(true/false) to clear a textfield or keep text displayed in
// a textfield after pressing return.
myTextfield.setAutoClear(true).keepFocus(true);

cp5.addButton("clear", 0, 20, 200, 70, 20);
cp5.addButton("submit", 0, 310, 200, 60, 20);
cp5.addButton("performTextfieldActions", 0, 20, 100, 150, 20);
cp5.addToggle("toggleAutoClear", true, 180, 100, 90, 20).setCaptionLabel("Auto Clear");
cp5.addToggle("toggleKeepFocus", true, 280, 100, 90, 20).setCaptionLabel("Keep Focus");

}

void draw() {
background(0);
if(mousePressed == true){showVirtualKeyboard();delay(888);}

}

public void showVirtualKeyboard()
{
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}

void toggleAutoClear(boolean theFlag) {
myTextfield.setAutoClear(theFlag);
}

void toggleKeepFocus(boolean theFlag) {
myTextfield.keepFocus(theFlag);
}

void clear(int theValue) {
myTextfield.clear();
}

void submit(int theValue) {
myTextfield.submit();
}

void controlEvent(ControlEvent theEvent) {
if (theEvent.isAssignableFrom(Textfield.class)) {
Textfield t = (Textfield)theEvent.getController();

println("controlEvent: accessing a string from controller '"
  +t.getName()+"': "+t.getStringValue()
  );

// Textfield.isAutoClear() must be true
print("controlEvent: trying to setText, ");

t.setText("controlEvent: changing text.");
if (t.isAutoClear()==false) {
  println(" success!");
} 
else {
  println(" but Textfield.isAutoClear() is false, could not setText here.");
}

}
}

void performTextfieldActions() {
println("\n");
// Textfield.getText();
println("the current text of myTextfield: "+myTextfield.getText());
println("the current value of textValue: "+textValue);
// Textfield.setText();
myTextfield.setText("changed the text of a textfield");
println("changing text of myTextfield to: "+myTextfield.getText());
// Textfield.getTextList();
println("the textlist of myTextfield has "+myTextfield.getTextList().length+" items.");
for (int i=0;i<myTextfield.getTextList().length;i++) {
println("\t"+myTextfield.getTextList()[i]);
}
println("\n");
}

public void textinput(String theText) {
// receiving text from controller textinput
println("a textfield event for controller 'textinput': "+theText);
}

The problem is that the virtual keyboard is not connected to textfield and keystrokes are not recognized.

How I can fix that?

RadioButton.removeItem(String) doesn't work

I found that RadioButton's removeItem(String) method doesn't work:

  • When you remove the last item, the Toggle can still be seen and toggled. However, it seems to be partly removed, because it no longer sends out controlEvents.
  • When you remove any item, before the last item, you get an IndexOutOfBoundsException.

Code Example

import controlP5.*;
ControlP5 cp5;
RadioButton r1;

void setup() {
  size(400, 400);
  cp5 = new ControlP5(this);
  r1 = cp5.addRadioButton("radioButton")
         .setPosition(50, 50)
         .setSize(300, 50)
         .addItem("50", 1)
         .addItem("100", 2)
         .addItem("150", 3)
         .addItem("200", 4)
         .addItem("250", 5)
         ;
}


void draw() {
  background(0);
}

void radioButton(int a) {
  println("a radio Button event: " + a);
}

void keyPressed() {
  switch(key) {
    case('1'): r1.removeItem("50"); break;
    case('2'): r1.removeItem("100"); break;
    case('3'): r1.removeItem("150"); break;
    case('4'): r1.removeItem("200"); break;
    case('5'): r1.removeItem("250"); break;
  }
}

Dropdownlist doesn't work in Android mode

When I run the dropdown list example in Android mode it throws these warnings and errors:

1. WARNING in /private/var/folders/hg/mmm3m8ys4djd0r_ss4d6y4fc0000gn/T/android7074952142323453289sketch/src/processing/test/controlp5scrollablelist/ControlP5scrollableList.java (at line 43)
    List l = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h");
    ^^^^
List is a raw type. References to generic type List<E> should be parameterized
----------
2. WARNING in /private/var/folders/hg/mmm3m8ys4djd0r_ss4d6y4fc0000gn/T/android7074952142323453289sketch/src/processing/test/controlp5scrollablelist/ControlP5scrollableList.java (at line 50)
    .addItems(l)
              ^
Type safety: The expression of type List needs unchecked conversion to conform to List<String>
----------
3. ERROR in /private/var/folders/hg/mmm3m8ys4djd0r_ss4d6y4fc0000gn/T/android7074952142323453289sketch/src/processing/test/controlp5scrollablelist/ControlP5scrollableList.java (at line 63)
    println(n, cp5.get(ScrollableList.class, "dropdown").getItem(n));
    ^^^^^^^
The method println(int) in the type PApplet is not applicable for the arguments (int, Map<String,Object>)
----------
4. WARNING in /private/var/folders/hg/mmm3m8ys4djd0r_ss4d6y4fc0000gn/T/android7074952142323453289sketch/src/processing/test/controlp5scrollablelist/ControlP5scrollableList.java (at line 91)
    List l = Arrays.asList("a-1", "b-1", "c-1", "d-1", "e-1", "f-1", "g-1", "h-1", "i-1", "j-1", "k-1");
    ^^^^
List is a raw type. References to generic type List<E> should be parameterized
----------
5. WARNING in /private/var/folders/hg/mmm3m8ys4djd0r_ss4d6y4fc0000gn/T/android7074952142323453289sketch/src/processing/test/controlp5scrollablelist/ControlP5scrollableList.java (at line 92)
    cp5.get(ScrollableList.class, "dropdown").setItems(l);
                                                       ^
Type safety: The expression of type List needs unchecked conversion to conform to List<String>

Use Radio buttons and Sliders together to manipulate geometries

Hi sojamo,
I'm usign a ControlP5 interface to handle IGeo geometries and I'm trying to use buttons and sliders together to manipulate 3 curves. I have two sliders for each one, which allow me to move the curve in X and Y direction, and a button for each curve, to rotate it 180°. The sliders are working in the right way, but I'm having some troubles with the buttons. I'm trying to adapt the Button example to my sketch but if I press the button I'm able to rotate the curve just one time, after the first time the button is not working (I need to rotate it everytime I press).
Which is the right way to use this controllers together?
Thanks in advance!

ControlP5frame example doesn't work in Processing 3

I just installed Processing 3 and installed controlP5 library ( the newest version 2.2.5 ) . I tried to run the examples and I got error message by running examples -> extra -> ControlP5frame. The error message is :
The function "add()" expects parameters like: "add(Component)"
and the error line is the line 45:
f.add(p);

With Processing 2.2.1 everything works fine.
I'm on Mac Yosemite, x64.

Println.setMax() results in StringIndexOutOfBoundsException

When you use .setMax() to set the maximum number of lines on a Println console and you then add println()'s inside draw(), the result is a StringIndexOutOfBoundsException. Below is a small code example that replicates the bug.

Code Example

import controlP5.*;
ControlP5 cp5;

void setup() {
  size(400, 200);
  cp5 = new ControlP5(this);
  Textarea myTextarea = cp5.addTextarea("txt").setPosition(10, 10).setLineHeight(14).setColorBackground(color(0, 100));
  cp5.addConsole(myTextarea).setMax(3); // without .setMax() it runs fine
}

void draw() {
  background(128);
  println(frameCount);
}

Slider value is not int anymore

I had created my project using controlp5's slider and it worked until May 2015. I opened it September 2015 and my slider doesn't work anymore. I figured it out it is because the value of the slider, year , is float but integer now.

I'm not sure why it happened. Maybe software update? I'm sure the code was working before because I made a video at the time.

Does anyone know how I can fix it?

Here is my code

import controlP5.*;
ControlP5 cp5;
int year = 1990;
String [][] csvIco;
String [][] csvGrower;
int csvIcoWidth=0, csvGrowerWidth=0;
PShape mapImg, beanImg;
PFont font1, font2;

void setup() {
size(1000, 800);
font1 = loadFont("Akkurat-12.vlw");
font2 = loadFont("Akkurat-48.vlw");
cp5 = new ControlP5(this);
cp5.addSlider("year")
.setRange(1990, 2009)
.setPosition(30, 200)
.setSize(5, 450)
.setColorValue(color(89, 5, 220))
.setColorActive(color(89, 5, 220))
.setColorForeground(color(89, 5, 220))
.setColorBackground(color(1, 239, 224))
.setColorLabel(color(1, 239, 224))
;
String linesIco[] = loadStrings("dataIcoPrice.csv");
String linesGrower[] = loadStrings("dataGrowerPrice.csv");
//calculate max width of csv file
for (int i=0; i < linesIco.length; i++) {
String [] chars=split(linesIco[i], ',');
if (chars.length>csvIcoWidth) {
csvIcoWidth=chars.length;
}
}

//create csv array based on # of rows and columns in csv file
csvIco = new String [linesIco.length][csvIcoWidth];

//parse values into 2d array
for (int i=0; i < linesIco.length; i++) {
String [] temp = new String [linesIco.length];
temp= split(linesIco[i], ',');
for (int j=0; j < temp.length; j++) {
csvIco[i][j]=temp[j];
}
}

for (int i=0; i < linesGrower.length; i++) {
String [] chars=split(linesGrower[i], ',');
if (chars.length>csvGrowerWidth) {
csvGrowerWidth=chars.length;
}
}

//create csv array based on # of rows and columns in csv file
csvGrower = new String [linesGrower.length][csvGrowerWidth];

//parse values into 2d array
for (int i=0; i < linesGrower.length; i++) {
String [] temp = new String [linesGrower.length];
temp= split(linesGrower[i], ',');
for (int j=0; j < temp.length; j++) {
csvGrower[i][j]=temp[j];
}
}
}

void draw() {
background(20);
textFont(font2);
textSize(21);
fill(1, 239, 224, 180);
text("Coffee Trading Price 1990-2009", 10, 20, 300, 200);
textFont(font1);
stroke(1, 239, 224, 120);
strokeWeight(2);
noFill();
ellipse(width/2, height/2, 400, 400);
text("$1", width/2-6, 195);
fill(3, 208, 147, 180);
beanImg = loadShape("bean.svg");
beanImg.disableStyle();
shape(beanImg, 10, 140, 15, 15);
text(csvGrower[7][0], 30, 152 );
fill(89, 5, 220, 180);
shape(beanImg, 10, 120, 15, 15);
text(csvGrower[12][0], 30, 132 );
fill(8, 148, 255, 180);
shape(beanImg, 10, 100, 15, 15);
text(csvGrower[36][0], 30, 112 );
fill(144, 0, 246, 180);
shape(beanImg, 10, 80, 15, 15);
text(csvGrower[42][0], 30, 92);
if (dist(mouseX, mouseY, width/2, height/2)<=400) {
coffeeName(year);
} else {
coffeeData(year);
}
fill(1, 239, 224, 180);
textFont(font2);
textSize(18);
text("Indicator Price", 30, 750);
textSize(12);
text("International Coffee Organization", 30, 770);
if ((mouseX>30)&&(mouseX<300)&&(mouseY>750)&&(mouseX<770)) {
float rIco = Float.parseFloat(csvIco[year-1989][5]);
fill(1, 239, 224, 20);
ellipse(width/2, height/2, 4_rIco, 4_rIco);
}
}

void coffeeData(int year) {
for (int i=1; i < 4; i++) {
pushMatrix();
translate(width/2, height/2);
noStroke();
fill(3, 208, 147, 180);
rotate(-(i+1)_PI/30);
float r = Float.parseFloat(csvGrower[7+i][year-1988]);
arc(0, 0, 4_r, 4*r, 0, PI/100, PIE);
mapImg = loadShape(csvGrower[7+i][0] + ".svg");
shape(mapImg, 350, 0, 15, 15);
popMatrix();
}

for (int i=1; i < 20; i++) {
pushMatrix();
translate(width/2, height/2);
noStroke();
fill(89, 5, 220, 180);
rotate((i-1)_PI/30);
float r = Float.parseFloat(csvGrower[12+i][year-1988]);
arc(0, 0, 4_r, 4*r, 0, PI/100, PIE);
mapImg = loadShape(csvGrower[12+i][0] + ".svg");
shape(mapImg, 350, 0, 15, 15);
popMatrix();
}

for (int i=1; i < 5; i++) {
pushMatrix();
translate(width/2, height/2);
noStroke();
//fill(1, 239, 224, 180);
fill(8, 148, 255, 180);
rotate(20_PI/30+(i-1)_PI/30);
float r = Float.parseFloat(csvGrower[36+i][year-1988]);
arc(0, 0, 4_r, 4_r, 0, PI/100, PIE);
mapImg = loadShape(csvGrower[36+i][0] + ".svg");
mapImg.disableStyle();
shape(mapImg, 350, 0, 15, 15);
popMatrix();
}

for (int i=1; i < 15; i++) {
pushMatrix();
translate(width/2, height/2);
noStroke();
fill(144, 0, 246, 180);
rotate(25_PI/30+(i-1)_PI/30);
float r = Float.parseFloat(csvGrower[42+i][year-1988]);
arc(0, 0, 4_r, 4_r, 0, PI/100, PIE);
mapImg = loadShape(csvGrower[42+i][0] + ".svg");
mapImg.disableStyle();
shape(mapImg, 350, 0, 15, 15);
popMatrix();
}
}

void coffeeName(int year) {
for (int i=1; i < 4; i++) {
pushMatrix();
translate(width/2, height/2);
noStroke();
fill(3, 208, 147, 120);
rotate(-(i+1)_PI/30);
float r = Float.parseFloat(csvGrower[7+i][year-1988]);
arc(0, 0, 4_r, 4*r, 0, PI/100, PIE);
mapImg = loadShape(csvGrower[7+i][0] + ".svg");
fill(3, 208, 147, 180);
shape(mapImg, 250, 0, 15, 15);
text(csvGrower[7+i][0], 280, 10);
popMatrix();
}

for (int i=1; i < 20; i++) {
pushMatrix();
translate(width/2, height/2);
noStroke();
fill(89, 5, 220, 120);
rotate((i-1)_PI/30);
float r = Float.parseFloat(csvGrower[12+i][year-1988]);
arc(0, 0, 4_r, 4*r, 0, PI/100, PIE);
mapImg = loadShape(csvGrower[12+i][0] + ".svg");
fill(89, 5, 220, 180);
shape(mapImg, 250, 0, 15, 15);
text(csvGrower[12+i][0], 280, 10);
popMatrix();
}

for (int i=1; i < 5; i++) {
pushMatrix();
translate(width/2, height/2);
noStroke();
//fill(1, 239, 224, 180);
fill(8, 148, 255, 120);
rotate(20_PI/30+(i-1)_PI/30);
float r = Float.parseFloat(csvGrower[36+i][year-1988]);
arc(0, 0, 4_r, 4_r, 0, PI/100, PIE);
mapImg = loadShape(csvGrower[36+i][0] + ".svg");
mapImg.disableStyle();
fill(8, 148, 255, 180);
shape(mapImg, 250, 0, 15, 15);
text(csvGrower[36+i][0], 280, 10);
popMatrix();
}

for (int i=1; i < 15; i++) {
pushMatrix();
translate(width/2, height/2);
noStroke();
fill(144, 0, 246, 120);
rotate(25_PI/30+(i-1)_PI/30);
float r = Float.parseFloat(csvGrower[42+i][year-1988]);
arc(0, 0, 4_r, 4_r, 0, PI/100, PIE);
mapImg = loadShape(csvGrower[42+i][0] + ".svg");
mapImg.disableStyle();
fill(144, 0, 246, 180);
shape(mapImg, 250, 0, 15, 15);
text(csvGrower[42+i][0], 280, 10);
popMatrix();
}
}

no drag for ColorWheel in Android mode

Hi,

I develop an App with your great library on Android.
Click and Drag doesn't work for the ColorWheel controller in Android Mode.

I can only use click point in this mode so it's not very intuitive.

I haven't drag issue with sliders or other color selector, like ControlP5 Color picker in Android.
No drag issue to with the colorWheel controller in desktop mode.

Is there a simple way to solve that?

Test with ControlP5 ColorWheel exemple
Processing 3.0 in Android mode
OS 10.10.4 with java build 1.8.0_73-b02 (last update)

Android 5.1.1

Best regards

cp5.getProperties().load() expect .json file in Processing 3

Attempting to upgrade to Processing 3.0.1 from 2.X

I have a sketch that loads serialized snapshot files:
cp5.getProperties().load("state.ser");

it is now returning this error:
state.ser.json does not exist or could not be read NullPointerException

I had saved those snapshots like this:
cp5.getProperties().saveSnapshotAs("state","state");

Did the default format change?

Jan 04, 2016 9:42:03 PM controlP5.ControlBroadcaster printMethodErro

Jan 04, 2016 9:42:03 PM controlP5.ControlBroadcaster printMethodError
SEVERE: An error occured while forwarding a Controller event, please check your code at Toggle_AM
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:497)
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 PID_FrontEnd_v03.setup(PID_FrontEnd_v03.java:133)
at processing.core.PApplet.handleDraw(PApplet.java:2374)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1527)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
Caused by: java.lang.NullPointerException
at PID_FrontEnd_v03.Toggle_AM(PID_FrontEnd_v03.java:386)
... 13 more
PID_FrontEnd_v03.zip

ColorWheel - modifying certain colors

controlp5 2.2.5, processing 2.2.1

Not sure if this is a bug or feature, but for certain (not all) hex RGB values, getRGB returns a different color value from what was set (similar, but different color value).

import controlP5.*;

ControlP5 cp5;
color col = #f8931f;

void setup() {
  size(800, 400);
  cp5 = new ControlP5( this );
  cp5.addColorWheel("c" , 250 , 10 , 200 ).setRGB(col);
  noStroke();
}

int c = color(100);

void draw() {  
  background(50);
  fill( c );
  rect(0,240,width,200);

  // these values should be the same
  println(col);
  // but are not
  println(cp5.get(ColorWheel.class,"c").getRGB()); 
}

When I run this, I get -486625 for the value of col and -552161 from getRGB

Not compatible with Processing 3.0a10

OSX 10.9 / iMac 2012
CP5 prettyVersion=2.0.4
With the new version of Processing the library is down

import controlP5.*;
ControlP5 cp5;

void setup() {
  cp5 = new ControlP5(this);
}

The consol return: NoSuchMethodError: You may be using a library that's incompatible with this version of Processing

Scrollbar missing from Textarea with few very long lines

Example:

import controlP5.*;

void setup() {
  Textarea ta = new ControlP5(this).addTextarea("");

  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 100; j++) {
      ta.append("" + i);
    }
    ta.append("\n");
  }
}

void draw() {
  background(0);
}

What I get (Windows 7 x64, Processing 3.0.1):

Screenshot of Processing window

Scrolling with the mouse wheel also doesn’t work.

Save/Load properties of ScrollableList - Bug

Trying to save and load properties of a ScrollableList results in "java.lang.NoSuchMethodException" (caught ones = no program-termination)

Saving ScrollableList-Properties (to json) actually works, but following debug-message appears:

SEVERE: java.lang.NoSuchMethodException: controlP5.ScrollableList.getListBoxItems()

Loading back this property won`t either set the (internal) value of the ScrollableList, nor change the corresponding item visually. Following debug-message appears:

java.lang.NoSuchMethodException: controlP5.ScrollableList.setValue(float)

Code Example

Press 1 to print current value, 2 to save properties, 3 to load back saved properties.

import controlP5.*;
import java.util.*;

ControlP5 cp5;

void setup() {
  size(400, 400);
  cp5 = new ControlP5(this);
  List l = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h");

  cp5.addScrollableList("dropdown")
     .setPosition(100, 100)
     .setSize(200, 100)
     .setBarHeight(20)
     .setItemHeight(20)
     .addItems(l)
     .setType(ScrollableList.LIST) // or DROPDOWN
     ;
}

void draw() {
  background(240);
}

void keyPressed() {
  switch(key) {
    case('1'):
        println("currentValue: " +cp5.get(ScrollableList.class, "dropdown").getValue());
    break;
    case('2'):
        cp5.saveProperties("hello.json");
    break;
    case('3'):
        cp5.loadProperties("hello.json");
    break;
  }
}

controlP5 german keyboard layout

With my keyboard layout, a standard German one, the keycode for Alt-Gr is 65406.
It is necessary to resize the boolean-array: keys, in the file ControlWindow.java
to 65407 or higher.
Two lines musst be changed, the first line is 116: private boolean[] keys = new boolean[65500]; and the second change is in the function public void clearKeys().

Thanks

Changing Tab by code bug (invisible controllers still work)

When you change to a different Tab by code - via bringToFront() or activateTab() - instead of by mouse click, it visually changes the Tab, but the old Tab still works. In my current application, this is a pretty crippling bug, because it relies on changing-tab-by-code. However currently the consequence is that there are invisible controllers that keep on working. I hope this issue can be resolved. Or for the short term there is a workaround I can use.

A code example that displays the faulty behavior is included below. Change the tab by pressing SPACE. Then notice the invisible controller is still working.

Code Example:

/*
 * To reproduce the problem:
 * 1. Run sketch.
 * 2. Press SPACE to go to the tab named 'extra' and SEE the Button disappear.
 * 3. Now either:
 *    - 3a. Click OUTSIDE the Button area: it works ONCE.
 *    - 3b. Click INSIDE the Button area: it works CONTINUOUSLY.
 *    In both cases it generates an event and changes the background color,
 *    where of course the invisible controller should not be working at all.
 */

import controlP5.*;
ControlP5 cp5;

int myColorBackground = 0;

void setup() {
  size(600, 600);
  noStroke();
  cp5 = new ControlP5(this);
  cp5.addTab("extra");     
  cp5.addButton("button")
    .setPosition(50, 50)
    .setSize(width-100, height-100)
    .getCaptionLabel().align(CENTER, CENTER);
}

void draw() {
  background(myColorBackground);
}

void button() {
  myColorBackground = 255 - myColorBackground;
  println("Button pressed! Setting background to: " + myColorBackground);
}

void keyPressed() {
  if (key == ' ') {
    // PROBLEM: changing the tab by code, only VISUALLY changes the tab,
    // but all the controllers from the previous tab still work!
    //cp5.getTab("extra").bringToFront(); // method 1 to change a tab
    cp5.controlWindow.activateTab("extra"); // method 2 to change a tab
  }
}

ControlP5frame example code does not compile

I am using processing-3.0.2 on Linux.
When I click: File > examples > contributed libraries > ControlP5 > extra > ControlP5frame,
there are 2 errors:
Line 45: f.add(p): The function "add()" expects parameters like: "add(Component)"
Line 46: p.init(): The function "init()" does not exist

Multiple consecutive line breaks in Textarea don't work under Processing3.0b4

The following code worked fine under 3.0b3, but with 3.0b4 everything is truncated after the '\n':

ControlP5 cp5;
Textarea myTextarea;

void setup() {
  size(200, 200);
  background(0);
  cp5 = new ControlP5(this);

  myTextarea = cp5.addTextarea("txt")
    ;
  myTextarea.setText("Line1\n\nLine3");
}

screenshot from 2015-08-26 13 48 27

ControlP5 2.2.5, tested on OSX, Windows7, and Ubuntu Linux (64 and 32 bit).

ControlP5pointer example not working

Hi All, I'm trying to get the pointer example to work.

I'm assuming that the code should allow me to use the slider control by using the pointer as opposed to the mouse. The code seems to compile and load OK, although it does throw up quite a few errors (included at the end of this post).

At the moment the "+" symbol shows up in the correct place (i.e. opposite where my finger is relative to the centre of the screen) however I can only manipulate the slider when I press the slider with my finger and move it (when the "+" is on the opposite side of the screen). When I control the slider with my finger the bar slides and colour changes as it should. When I put the "+" over the slider nothing happens.

I'm using the code as stated in the example (with a minor modification for screen size and slider size - I assume that wouldn't be an issue) using Processing 3.0.2 (on Mac OS X) running on a Galaxy S5 with Android 5.0.

Many thanks for your help

Errors (Can't copy and paste, so I've picked the ones that seem most relevant):

  • The type processing.core.PApplet cannot be resolved. It is indirectly referenced from required .class files.
  • The class "PApplet" does not exist
  • The constructor ControlP5(PApplet) refers to the missing type PApplet
  • After this a whole load of the errors are stating that variables or functions don't exist.

bad value in Color picker

controlp5 2.2.5,
Processing 3.0.2

I wonder if it's due to my recent Processing update but in colorPicker exemple
controlEvent and picker don't return the same value.
the issue is with picker.

In extrem situation, one say 255 and the other 0 :/

capture d ecran 2016-02-20 a 14 42 28

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.