Compare commits

...

11 Commits

Author SHA1 Message Date
sojamo 1f7cb64986 2.2.6 release 2016-04-14 18:39:16 +08:00
sojamo 665b0c1aa5 readme typo fix 2015-09-04 15:12:40 +08:00
sojamo a4a4824bfe adjustments to fix issue #12 2015-07-30 17:38:55 +08:00
sojamo 12235cb462 fix for issue #12 2015-07-30 11:01:15 +08:00
andreas schlegel 096c553452 Merge pull request #8 from AmnonOwed/FixRadioButton.removeItem
Fix RadioButton.removeItem(String)
2015-07-30 10:34:19 +08:00
AmnonOwed c3bdd53a3c Fix RadioButton.removeItem(String) 2015-05-05 09:13:10 +02:00
sojamo 8ade1d493b adding DOI to the readme 2015-03-29 22:05:16 +08:00
sojamo 3ef6bdf244 fix, see issue 3, release 2.2.4 updated 2015-03-29 21:59:13 +08:00
sojamo d5c22c4be7 release for DOI 2015-03-24 12:43:40 +08:00
sojamo 388b13569b 2.2.3 release 2015-03-24 12:27:05 +08:00
sojamo e2b6800bd3 wip 2014-09-08 15:58:00 +08:00
120 changed files with 1469 additions and 759 deletions

1
.gitignore vendored
View File

@ -9,4 +9,3 @@
.buildpath .buildpath
.classpath .classpath
.project .project

View File

@ -471,7 +471,7 @@ convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found. "copyright" line and a pointer to where the full notice is found.
controlP5 is a processing gui library. controlP5 is a processing gui library.
Copyright (C) 2006-2014 andreas schlegel Copyright (C) 2006-2015 andreas schlegel
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public

View File

@ -18,13 +18,14 @@ The range of available controllers includes Slider, Button, Toggle, Knob, Textfi
* [Javascript](#javascript) * [Javascript](#javascript)
* [Problems and Issues](#issues) * [Problems and Issues](#issues)
* [Help](#help) * [Help](#help)
* [Digital Object Identifiers ](#doi)
## <a name"install"></a>Installation ## <a name"install"></a>Installation
To install the library from inside the Processing IDE, use the Library Manager from the menu under Sketch &rarr; Import Library &rarr; Add Library and search for ControlP5. To install the library from inside the Processing IDE, use the Library Manager from the menu under Sketch &rarr; Import Library &rarr; Add Library and search for ControlP5.
If you want to install ControlP5 manually, download (the latest) version from the [releases](releases) directory. Inside the downloaded .zip file you will find [install_instructions](resources/install_instructions.txt) that guide you through the installation details and tell you where the controlP5 folder needs to be put. In case you are looking for an earlier release, please check the [archive on google code](https://code.google.com/p/controlp5/downloads/list?can=1&q=&colspec=Filename+Summary+Uploaded+ReleaseDate+Size+DownloadCount). If you want to install ControlP5 manually, download (the latest) version from the [releases](https://github.com/sojamo/controlp5/releases) directory. Inside the downloaded .zip file you will find [install_instructions](resources/install_instructions.txt) that guide you through the installation details and tell you where the controlP5 folder needs to be put. In case you are looking for an earlier release, please check the [archive on google code](https://code.google.com/p/controlp5/downloads/list?can=1&q=&colspec=Filename+Summary+Uploaded+ReleaseDate+Size+DownloadCount).
After you have installed ControlP5, restart the Processing IDE to make the library available. After you have installed ControlP5, restart the Processing IDE to make the library available.
@ -34,7 +35,7 @@ To get started, here a simple example that demonstrates how to create a slider a
![example 1](resources/images/cp5-example-1_s.png) ![example 1](./resources/images/cp5-example-1_s.png)
_example 1, see code below_ _example 1, see code below_
@ -124,8 +125,8 @@ Alternatively, ControlP5 can be instantiated from other places as well for examp
class GUI { class GUI {
ControlP5 cp5; ControlP5 cp5;
GUI(ControlP5 theControlP5) { GUI(PApplet thePApplet) {
cp5 = new ControlP5(theControlP5); cp5 = new ControlP5(thePApplet);
} }
} }
``` ```
@ -364,5 +365,12 @@ In case you run into problems and issues, please use ControlP5's issues section
If you want to help improve ControlP5, the first place for me to do so would be the source code documentation where supporting comments are desperately needed to create a concise and comprehensive javadoc. If you want to help improve ControlP5, the first place for me to do so would be the source code documentation where supporting comments are desperately needed to create a concise and comprehensive javadoc.
If you have used ControlP5 in any of your projects, let me know, send me details, send me links, send me screeshots.
Copyright 2006-2014 Andreas Schlegel ## <a name="doi"></a>Digital Object Identifiers
Digital Object Identifiers (DOI) are the backbone of the academic reference and metrics system which allows researchers writing software to make their work they share on GitHub citable by archiving one of their GitHub repositories and assigning a DOI with the data archiving tool Zenodo [(link)](https://guides.github.com/activities/citable-code/).
[![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.16290.svg)](http://dx.doi.org/10.5281/zenodo.16290)
Copyright 2006-2015 Andreas Schlegel

View File

@ -200,7 +200,7 @@ controlP5.Controller : void setView(ControllerView, int)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:39 created: 2015/03/24 12:20:51
*/ */

View File

@ -196,7 +196,7 @@ controlP5.Controller : void setView(ControllerView, int)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:40 created: 2015/03/24 12:21:00
*/ */

View File

@ -279,7 +279,7 @@ controlP5.ControllerGroup : void remove()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:42 created: 2015/03/24 12:25:32
*/ */

View File

@ -181,7 +181,7 @@ controlP5.ControllerGroup : void remove()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:44 created: 2015/03/24 12:25:35
*/ */

View File

@ -224,7 +224,7 @@ controlP5.Controller : void setView(ControllerView, int)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:45 created: 2015/03/24 12:25:36
*/ */

View File

@ -260,7 +260,7 @@ controlP5.Controller : void setView(ControllerView, int)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:47 created: 2015/03/24 12:20:49
*/ */

View File

@ -82,7 +82,7 @@ controlP5.Canvas : void update(PApplet)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:48 created: 2015/03/24 12:20:53
*/ */

View File

@ -236,7 +236,7 @@ controlP5.Controller : void setView(ControllerView, int)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:50 created: 2015/03/24 12:20:54
*/ */

View File

@ -235,7 +235,7 @@ controlP5.ControllerGroup : void remove()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:51 created: 2015/03/24 12:20:56
*/ */

View File

@ -42,13 +42,13 @@ public void controlEvent(ControlEvent c) {
int b = int(c.getArrayValue(2)); int b = int(c.getArrayValue(2));
int a = int(c.getArrayValue(3)); int a = int(c.getArrayValue(3));
color col = color(r,g,b,a); color col = color(r,g,b,a);
println("event\talpha:"+a+"\tred:"+r+"\tgreen:"+g+"\tblue:"+b+"\tcol"+col); println("event \talpha:"+a+"\tred:"+r+"\tgreen:"+g+"\tblue:"+b+"\tcol"+col);
} }
} }
// color information from ColorPicker 'picker' are forwarded to the picker(int) function // color information from ColorPicker 'picker' are forwarded to the picker(int) function
void picker(int col) { void picker(int col) {
println("picker\talpha:"+alpha(col)+"\tred:"+red(col)+"\tgreen:"+green(col)+"\tblue:"+blue(col)+"\tcol"+col); println("picker\talpha:"+int(alpha(col))+"\tred:"+int(red(col))+"\tgreen:"+int(green(col))+"\tblue:"+int(blue(col))+"\tcol"+col);
} }
@ -181,8 +181,6 @@ controlP5.ControllerGroup : void remove()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:53 created: 2015/03/24 12:20:58
*/
*/

View File

@ -56,7 +56,7 @@ controlP5.ControlTimer : void update()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:55 created: 2015/03/24 12:21:02
*/ */

View File

@ -158,7 +158,7 @@ controlP5.ControllerProperties : void setFormat(String)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:56 created: 2015/03/24 12:21:03
*/ */

View File

@ -304,7 +304,7 @@ controlP5.DropdownList : void updateItemIndexOffset()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:18:58 created: 2015/03/24 12:21:05
*/ */

View File

@ -228,7 +228,7 @@ controlP5.ControllerGroup : void remove()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:00 created: 2015/03/24 12:21:07
*/ */

View File

@ -211,7 +211,7 @@ controlP5.Icon : int getFontIcon(int)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:01 created: 2015/03/24 12:21:09
*/ */

View File

@ -253,7 +253,7 @@ controlP5.Knob : int getViewStyle()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:02 created: 2015/03/24 12:21:10
*/ */

View File

@ -312,7 +312,7 @@ controlP5.ListBox : void updateItemIndexOffset()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:04 created: 2015/03/24 12:21:12
*/ */

View File

@ -289,7 +289,7 @@ controlP5.Matrix : void remove()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:06 created: 2015/03/24 12:21:14
*/ */

View File

@ -207,7 +207,7 @@ controlP5.Numberbox : float getMultiplier()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:09 created: 2015/03/24 12:25:44
*/ */

View File

@ -231,7 +231,7 @@ controlP5.RadioButton : void updateLayout()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:11 created: 2015/03/24 12:21:19
*/ */

View File

@ -237,7 +237,7 @@ controlP5.Range : float[] getArrayValue()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:12 created: 2015/03/24 12:21:20
*/ */

View File

@ -254,7 +254,7 @@ controlP5.ScrollableList : void updateItemIndexOffset()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:14 created: 2015/03/24 12:21:22
*/ */

View File

@ -290,7 +290,7 @@ controlP5.Slider : int getTriggerEvent()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:16 created: 2015/03/24 12:25:46
*/ */

View File

@ -231,7 +231,7 @@ controlP5.Slider2D : void setValueLabelSeparator(String)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:18 created: 2015/03/24 12:25:47
*/ */

View File

@ -229,7 +229,7 @@ controlP5.Tab : float getValue()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:19 created: 2015/03/24 12:25:49
*/ */

View File

@ -222,7 +222,7 @@ controlP5.Textarea : void controlEvent(ControlEvent)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:21 created: 2015/03/24 12:21:29
*/ */

View File

@ -250,7 +250,7 @@ controlP5.Textfield : void keyEvent(KeyEvent)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:23 created: 2015/03/24 12:21:31
*/ */

View File

@ -204,7 +204,7 @@ controlP5.Textlabel : void draw(int, int)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:24 created: 2015/03/24 12:21:33
*/ */

View File

@ -228,10 +228,11 @@ controlP5.Toggle : Toggle toggle()
controlP5.Toggle : Toggle update() controlP5.Toggle : Toggle update()
controlP5.Toggle : boolean getBooleanValue() controlP5.Toggle : boolean getBooleanValue()
controlP5.Toggle : boolean getState() controlP5.Toggle : boolean getState()
controlP5.Toggle : int getMode()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:26 created: 2015/03/24 12:21:35
*/ */

View File

@ -109,7 +109,7 @@ controlP5.Tooltip : int getWidth()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:27 created: 2015/03/24 12:21:36
*/ */

View File

@ -1,98 +1,112 @@
/** /**
* ControlP5 Controlframe * ControlP5 Controlframe
* with controlP5 2.0 all java.awt dependencies have been removed
* as a consequence the option to display controllers in a separate
* window had to be removed as well.
* this example shows you how to create a java.awt.frame and use controlP5
* *
* by Andreas Schlegel, 2012 * this example shows you how to create separate window to
* display and use controllers with processing 3
*
* by Andreas Schlegel, 2016
* www.sojamo.de/libraries/controlp5 * www.sojamo.de/libraries/controlp5
* *
*/ */
import java.awt.Frame;
import java.awt.BorderLayout;
import controlP5.*; import controlP5.*;
private ControlP5 cp5;
ControlFrame cf; ControlFrame cf;
int def; float speed;
float pos;
float c0, c1, c2, c3;
boolean auto;
void settings() {
size(400, 400, P3D);
}
void setup() { void setup() {
size(400, 400); cf = new ControlFrame(this, 400, 800, "Controls");
cp5 = new ControlP5(this); surface.setLocation(420, 10);
noStroke();
// by calling function addControlFrame() a
// new frame is created and an instance of class
// ControlFrame is instanziated.
cf = addControlFrame("extra", 200,200);
// add Controllers to the 'extra' Frame inside
// the ControlFrame class setup() method below.
} }
void draw() { void draw() {
background(def); if (auto) pos += speed;
} background(0);
translate(width/2, height/2);
ControlFrame addControlFrame(String theName, int theWidth, int theHeight) { rotateY(pos);
Frame f = new Frame(theName); lights();
ControlFrame p = new ControlFrame(this, theWidth, theHeight); fill(c0, c1, c2, c3);
f.add(p); box(100);
p.init();
f.setTitle(theName);
f.setSize(p.w, p.h);
f.setLocation(100, 100);
f.setResizable(false);
f.setVisible(true);
return p;
} }
// the ControlFrame class extends PApplet, so we
// are creating a new processing applet inside a
// new frame with a controlP5 object loaded class ControlFrame extends PApplet {
public class ControlFrame extends PApplet {
int w, h; int w, h;
PApplet parent;
int abc = 100;
public void setup() {
size(w, h);
frameRate(25);
cp5 = new ControlP5(this);
cp5.addSlider("abc").setRange(0, 255).setPosition(10,10);
cp5.addSlider("def").plugTo(parent,"def").setRange(0, 255).setPosition(10,30);
}
public void draw() {
background(abc);
}
private ControlFrame() {
}
public ControlFrame(Object theParent, int theWidth, int theHeight) {
parent = theParent;
w = theWidth;
h = theHeight;
}
public ControlP5 control() {
return cp5;
}
ControlP5 cp5; ControlP5 cp5;
Object parent; public ControlFrame(PApplet _parent, int _w, int _h, String _name) {
super();
parent = _parent;
w=_w;
h=_h;
PApplet.runSketch(new String[]{this.getClass().getName()}, this);
}
public void settings() {
} size(w, h);
}
public void setup() {
surface.setLocation(10, 10);
cp5 = new ControlP5(this);
cp5.addToggle("auto")
.plugTo(parent, "auto")
.setPosition(10, 70)
.setSize(50, 50)
.setValue(true);
cp5.addKnob("blend")
.plugTo(parent, "c3")
.setPosition(100, 300)
.setSize(200, 200)
.setRange(0, 255)
.setValue(200);
cp5.addNumberbox("color-red")
.plugTo(parent, "c0")
.setRange(0, 255)
.setValue(255)
.setPosition(100, 10)
.setSize(100, 20);
cp5.addNumberbox("color-green")
.plugTo(parent, "c1")
.setRange(0, 255)
.setValue(128)
.setPosition(100, 70)
.setSize(100, 20);
cp5.addNumberbox("color-blue")
.plugTo(parent, "c2")
.setRange(0, 255)
.setValue(0)
.setPosition(100, 130)
.setSize(100, 20);
cp5.addSlider("speed")
.plugTo(parent, "speed")
.setRange(0, 0.1)
.setValue(0.01)
.setPosition(100, 240)
.setSize(200, 30);
}
void draw() {
background(190);
}
}

View File

@ -192,7 +192,7 @@ controlP5.Textlabel : void draw(int, int)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:19:51 created: 2015/03/24 12:22:02
*/ */

View File

@ -68,7 +68,7 @@ ClassName : returnType methodName(parameter type)
created: 2014/09/08 01:20:02 created: 2015/03/24 12:22:14
*/ */

View File

@ -112,7 +112,7 @@ controlP5.ControlEvent : int getType()
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:20:21 created: 2015/03/24 12:22:35
*/ */

View File

@ -127,7 +127,7 @@ controlP5.ControlFont : void setSize(int)
java.lang.Object : String toString() java.lang.Object : String toString()
java.lang.Object : boolean equals(Object) java.lang.Object : boolean equals(Object)
created: 2014/09/08 01:20:23 created: 2015/03/24 12:22:36
*/ */

View File

@ -1,102 +1,102 @@
<project name="controlP5" default="build" basedir="../"> <project name="controlP5" default="build" basedir="../">
<description> <description>
ant build file for controlP5, a gui processing library. ant build file for controlP5, a gui processing library.
</description> </description>
<property name="processing" location="${user.home}/Documents/Processing/libraries"/> <property name="processing" location="${user.home}/Documents/Processing/libraries"/>
<property name="libraryClasspath" location="../libs"/> <property name="libraryClasspath" location="../libs"/>
<path id="library-classpath"> <path id="library-classpath">
<fileset dir="${libraryClasspath}" > <fileset dir="${libraryClasspath}" >
<include name="core.jar"/> <include name="core.jar"/>
</fileset> </fileset>
</path> </path>
<property name="javaVersion" value="1.6"/> <property name="javaVersion" value="1.6"/>
<property name="author" value="Andreas Schlegel"/> <property name="author" value="Andreas Schlegel"/>
<property name="copyright" value="(c) 2006-2014"/> <property name="copyright" value="(c) 2006-2016"/>
<property name="libraryName" value="controlP5"/> <property name="libraryName" value="controlP5"/>
<property name="versionNumber" value="2.2.2"/> <property name="versionNumber" value="2.2.6"/>
<property name="yourLink" value="http://www.sojamo.de" /> <property name="yourLink" value="http://www.sojamo.de" />
<property name="keywords" value="gui, ui, controller, interface, user interface" /> <property name="keywords" value="gui, ui, controller, interface, user interface" />
<property name="tested:platform" value="osx, windows, linux" /> <property name="tested:platform" value="osx, windows, linux" />
<property name="tested:processingVersion" value="2.2.1" /> <property name="tested:processingVersion" value="3.0.2" />
<property name="tested:dependencies" value="none" /> <property name="tested:dependencies" value="none" />
<property name="source:host" value="github" /> <property name="source:host" value="github" />
<property name="source:url" value="https://github.com/sojamo/controlp5" /> <property name="source:url" value="https://github.com/sojamo/controlp5" />
<property name="source:repository" value="https://github.com/sojamo/controlp5/tree/master/src" /> <property name="source:repository" value="https://github.com/sojamo/controlp5/tree/master/src" />
<!-- no changes or adjustments required below --> <!-- no changes or adjustments required below -->
<!-- Create the time stamp --> <!-- Create the time stamp -->
<tstamp> <tstamp>
<format property="date" pattern="MM/dd/yyyy" offset="0" unit="hour"/> <format property="date" pattern="MM/dd/yyyy" offset="0" unit="hour"/>
</tstamp> </tstamp>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"> <taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath> <classpath>
<pathelement location="./resources/code/ant-contrib-1.0b3.jar"/> <pathelement location="./resources/code/ant-contrib-1.0b3.jar"/>
</classpath> </classpath>
</taskdef> </taskdef>
<property name="jarFile" value="${libraryName}.jar"/> <property name="jarFile" value="${libraryName}.jar"/>
<property name="src" location="src"/> <property name="src" location="src"/>
<property name="bin" location="bin"/> <property name="bin" location="bin"/>
<property name="reference" location="reference"/> <property name="reference" location="reference"/>
<property name="dist" location="distribution"/> <property name="dist" location="distribution"/>
<property name="resources" location="resources"/> <property name="resources" location="resources"/>
<target name="init"> <target name="init">
<echo> <echo>
-------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------
${date} compiling ${libraryName} ${versionNumber} ${date} compiling ${libraryName} ${versionNumber}
-------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------
Properties initialized Properties initialized
-------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------
src path ${src} src path ${src}
bin path ${bin} bin path ${bin}
libraryClasspath ${libraryClasspath} libraryClasspath ${libraryClasspath}
processing Libraries ${processing} processing Libraries ${processing}
java version ${javaVersion} java version ${javaVersion}
</echo> </echo>
<echo> <echo>
-------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------
building library ... building library ...
</echo> </echo>
<delete dir="${bin}"/> <delete dir="${bin}"/>
<mkdir dir="${bin}"/> <mkdir dir="${bin}"/>
<delete dir="${dist}"/> <delete dir="${dist}"/>
<mkdir dir="${dist}"/> <mkdir dir="${dist}"/>
</target> </target>
<!-- compile the library --> <!-- compile the library -->
<target name="compile" depends="init" description="compile the source" > <target name="compile" depends="init" description="compile the source" >
<javac srcdir="${src}" destdir="${bin}" source="${javaVersion}" target="${javaVersion}"> <javac srcdir="${src}" destdir="${bin}" source="${javaVersion}" target="${javaVersion}">
<classpath> <classpath>
<path refid="library-classpath"/> <path refid="library-classpath"/>
</classpath> </classpath>
</javac> </javac>
</target> </target>
<!-- build the distribution of the library --> <!-- build the distribution of the library -->
<target name="prepare" depends="compile" description="generate the distribution" > <target name="prepare" depends="compile" description="generate the distribution" >
<!-- delete the previous content of the ${dist} folder --> <!-- delete the previous content of the ${dist} folder -->
<delete dir="${dist}" /> <delete dir="${dist}" />
<!-- build the structure for ${dist} --> <!-- build the structure for ${dist} -->
<mkdir dir="${dist}" /> <mkdir dir="${dist}" />
<mkdir dir="${dist}/library" /> <mkdir dir="${dist}/library" />
@ -109,48 +109,48 @@
</copy> </copy>
<copy todir="${dist}/src"> <copy todir="${dist}/src">
<fileset dir="src"/> <fileset dir="src"/>
</copy> </copy>
<path id="src.contents"><fileset dir="${dist}/src" includes="**/*.java" /></path> <path id="src.contents"><fileset dir="${dist}/src" includes="**/*.java" /></path>
<property name="src.list" refid="src.contents" /> <property name="src.list" refid="src.contents" />
<foreach list="${src.list}" param="file" target="versionSourcefile" delimiter=":" /> <foreach list="${src.list}" param="file" target="versionSourcefile" delimiter=":" />
</target> </target>
<target name="build" depends="prepare" description="generate the reference" > <target name="build" depends="prepare" description="generate the reference" >
<!-- create the java reference of the library --> <!-- create the java reference of the library -->
<echo>Generating JavaDoc Reference</echo> <echo>Generating JavaDoc Reference</echo>
<mkdir dir="${reference}" /> <mkdir dir="${reference}" />
<javadoc bottom="processing library ${libraryName} by ${author}. ${copyright}" <javadoc bottom="processing library ${libraryName} by ${author}. ${copyright}"
classpath="${libraryClasspath}/core.jar" classpath="${libraryClasspath}/core.jar"
destdir="${reference}" destdir="${reference}"
verbose="false" verbose="false"
nodeprecated="true" nodeprecated="true"
stylesheetfile="resources/stylesheet.css" stylesheetfile="resources/stylesheet.css"
doctitle="Javadocs: ${libraryName}" doctitle="Javadocs: ${libraryName}"
public="true" version="false" public="true" version="false"
windowtitle="Javadocs: ${libraryName}"> windowtitle="Javadocs: ${libraryName}">
<taglet name="ExampleTaglet" path="resources/code" /> <taglet name="ExampleTaglet" path="resources/code" />
<fileset dir="${src}" defaultexcludes="yes"> <fileset dir="${src}" defaultexcludes="yes">
<include name="**/*.java"/> <include name="**/*.java"/>
</fileset> </fileset>
</javadoc> </javadoc>
<copy todir="${dist}/reference"> <copy todir="${dist}/reference">
<fileset dir="${reference}" /> <fileset dir="${reference}" />
</copy> </copy>
<!-- copy the jar file to processing's libraries --> <!-- copy the jar file to processing's libraries -->
<mkdir dir="${processing}/${libraryName}" /> <mkdir dir="${processing}/${libraryName}" />
<copy todir="${processing}/${libraryName}"> <copy todir="${processing}/${libraryName}">
<fileset dir="${dist}"/> <fileset dir="${dist}"/>
</copy> </copy>
<mkdir dir="${dist}/${libraryName}-${versionNumber}" /> <mkdir dir="${dist}/${libraryName}-${versionNumber}" />
<mkdir dir="${dist}/${libraryName}-${versionNumber}/controlP5" /> <mkdir dir="${dist}/${libraryName}-${versionNumber}/controlP5" />
@ -165,7 +165,7 @@
<copy todir="${dist}/${libraryName}-${versionNumber}/controlP5/examples"><fileset dir="${dist}/examples"/></copy> <copy todir="${dist}/${libraryName}-${versionNumber}/controlP5/examples"><fileset dir="${dist}/examples"/></copy>
<copy todir="${dist}/${libraryName}-${versionNumber}/controlP5/reference"><fileset dir="${dist}/reference"/></copy> <copy todir="${dist}/${libraryName}-${versionNumber}/controlP5/reference"><fileset dir="${dist}/reference"/></copy>
<copy todir="${dist}/${libraryName}-${versionNumber}/controlP5/library"><fileset dir="${dist}/library"/></copy> <copy todir="${dist}/${libraryName}-${versionNumber}/controlP5/library"><fileset dir="${dist}/library"/></copy>
<copyfile src="${resources}/install_instructions.txt" dest="${dist}/tmp/install_instructions.txt"/> <copyfile src="${resources}/install_instructions.txt" dest="${dist}/tmp/install_instructions.txt"/>
<copyfile src="${resources}/library.properties" dest="${dist}/tmp/controlP5/library.properties"/> <copyfile src="${resources}/library.properties" dest="${dist}/tmp/controlP5/library.properties"/>
@ -178,64 +178,64 @@
basedir="${dist}/tmp" basedir="${dist}/tmp"
excludes="**/.DS_Store" excludes="**/.DS_Store"
/> />
<!-- <rename src="${dist}/${libraryName}.zip" dest="${dist}/${libraryName}_${versionNumber}.zip" /> --> <!-- <rename src="${dist}/${libraryName}.zip" dest="${dist}/${libraryName}_${versionNumber}.zip" /> -->
<!-- organize the ${dist} folder --> <!-- organize the ${dist} folder -->
<mkdir dir="${dist}/web" /> <mkdir dir="${dist}/web" />
<move todir="${dist}/web/reference"> <move todir="${dist}/web/reference">
<fileset dir="${dist}/reference" /> <fileset dir="${dist}/reference" />
</move> </move>
<move todir="${dist}/web/examples"> <move todir="${dist}/web/examples">
<fileset dir="${dist}/examples" /> <fileset dir="${dist}/examples" />
</move> </move>
<delete dir="${dist}/library" /> <delete dir="${dist}/library" />
<copy todir="${dist}/web"> <copy todir="${dist}/web">
<fileset dir="web" /> <fileset dir="web" />
</copy> </copy>
<!-- <!--
format the index.html file. format the index.html file.
regular expressions are used to parse the web index.html file. regular expressions are used to parse the web index.html file.
key words starting and ending with ## are replaced by values key words starting and ending with ## are replaced by values
defined earlier in the beginning of this build file. defined earlier in the beginning of this build file.
--> -->
<replaceregexp file="${dist}/web/index.html" <replaceregexp file="${dist}/web/index.html"
match="##yourLibrary##" match="##yourLibrary##"
replace="${libraryName}" replace="${libraryName}"
flags="g" /> flags="g" />
<replaceregexp file="${dist}/web/index.html" <replaceregexp file="${dist}/web/index.html"
match="##author##" match="##author##"
replace="${author}" replace="${author}"
flags="g" /> flags="g" />
<replaceregexp file="${dist}/web/index.html" <replaceregexp file="${dist}/web/index.html"
match="##versionNumber##" match="##versionNumber##"
replace="${versionNumber}" replace="${versionNumber}"
flags="g" /> flags="g" />
<replaceregexp file="${dist}/web/index.html" <replaceregexp file="${dist}/web/index.html"
match="##yourLink##" match="##yourLink##"
replace="${yourLink}" replace="${yourLink}"
flags="g" /> flags="g" />
<replaceregexp file="${dist}/web/index.html" <replaceregexp file="${dist}/web/index.html"
match="##date##" match="##date##"
replace="${date}" replace="${date}"
flags="g" /> flags="g" />
<replaceregexp file="${dist}/web/index.html" <replaceregexp file="${dist}/web/index.html"
match="##keywords##" match="##keywords##"
replace="${keywords}" replace="${keywords}"
flags="g" /> flags="g" />
<replaceregexp file="${dist}/web/index.html" <replaceregexp file="${dist}/web/index.html"
match="##tested:platform##" match="##tested:platform##"
replace="${tested:platform}" replace="${tested:platform}"
@ -261,34 +261,34 @@
replace="${source:repository}" replace="${source:repository}"
flags="g" /> flags="g" />
<echo>--------------------------------------------------------------------------------------------</echo> <echo>--------------------------------------------------------------------------------------------</echo>
<antcall target="processExamples" /> <antcall target="processExamples" />
<echo>--------------------------------------------------------------------------------------------</echo> <echo>--------------------------------------------------------------------------------------------</echo>
<replaceregexp file="${dist}/web/index.html" <replaceregexp file="${dist}/web/index.html"
match="##examples##" match="##examples##"
replace="" replace=""
flags="g" /> flags="g" />
<!-- finish organizing library's distribution --> <!-- finish organizing library's distribution -->
<mkdir dir="${dist}/web/download" /> <mkdir dir="${dist}/web/download" />
<copy file="${dist}/${libraryName}-${versionNumber}.zip" todir="${dist}/web/download" /> <copy file="${dist}/${libraryName}-${versionNumber}.zip" todir="${dist}/web/download" />
<copy todir="${processing}/${libraryName}/reference"> <copy todir="${processing}/${libraryName}/reference">
<fileset dir="${reference}" /> <fileset dir="${reference}" />
</copy> </copy>
<!-- done, finished. --> <!-- done, finished. -->
<echo>-------------------------------------------------------------------------------------------- <echo>--------------------------------------------------------------------------------------------
done, finished compiling ${libraryName} ${versionNumber} done, finished compiling ${libraryName} ${versionNumber}
-------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------
</echo> </echo>
</target> </target>
<!-- parsing the examples folder --> <!-- parsing the examples folder -->
<target name="processExamples"> <target name="processExamples">
<dirset id="examples.contents" dir="examples" /> <dirset id="examples.contents" dir="examples" />
@ -296,7 +296,7 @@
<foreach list="${examples.list}" target="addExamples" param="exampleDir" delimiter=";"> <foreach list="${examples.list}" target="addExamples" param="exampleDir" delimiter=";">
</foreach> </foreach>
</target> </target>
<target name="addExamples"> <target name="addExamples">
<echo>${exampleDir}</echo> <echo>${exampleDir}</echo>
<propertyregex property="pde" <propertyregex property="pde"
@ -326,12 +326,11 @@
</else> </else>
</if> </if>
</target> </target>
<target name="versionSourcefile"> <target name="versionSourcefile">
<echo>${file}</echo> <echo>${file}</echo>
<replaceregexp file="${file}" match="##version##" replace="${versionNumber}" flags="g" /> <replaceregexp file="${file}" match="##version##" replace="${versionNumber}" flags="g" />
<replaceregexp file="${file}" match="##date##" replace="${date}" flags="g" /> <replaceregexp file="${file}" match="##date##" replace="${date}" flags="g" />
</target> </target>
</project> </project>

View File

@ -1,4 +1,4 @@
cd $HOME/Documents/workspace/controlp5/bin cd $HOME/Documents/workspace/controlp5/bin
jar cf ../test/controlP5.jar . jar cf ../test/controlP5.jar .
cp ../test/controlP5.jar $HOME/Documents/Processing/libraries/controlP5/library cp ../test/controlP5.jar $HOME/Documents/Processing3/libraries/controlP5/library
echo "controlP5 compiled on $(date)" echo "controlP5 compiled on $(date)"

View File

@ -22,7 +22,7 @@ category = GUI
# shown from inside the PDE when the library is being installed. Avoid repeating # shown from inside the PDE when the library is being installed. Avoid repeating
# the name of your library here. Also, avoid saying anything redundant like # the name of your library here. Also, avoid saying anything redundant like
# mentioning that its a library. # mentioning that its a library.
sentence = A GUI library with a range of controllers to build custom user interfaces for desktop and android mode. sentence = A GUI library to build custom user interfaces for desktop and android mode.
# Additional information suitable for the Processing website. The value of # Additional information suitable for the Processing website. The value of
# 'sentence' always will be prepended, so you should start by writing the # 'sentence' always will be prepended, so you should start by writing the
@ -38,7 +38,7 @@ paragraph = Includes interface elements such as slider, button, knob, toggle, te
# is used to compare different versions of the same library, and # is used to compare different versions of the same library, and
# check if an update is available. You should think of it as a # check if an update is available. You should think of it as a
# counter, counting the total number of releases you've had. # counter, counting the total number of releases you've had.
version = 81 # This must be parsable as an int version = 85 # This must be parsable as an int
# The version as the user will see it. If blank, the version attribute will be used here # The version as the user will see it. If blank, the version attribute will be used here
prettyVersion = 2.2.2 # This is treated as a String prettyVersion = 2.2.6 # This is treated as a String

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2014 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
public class Background extends ControlGroup< Background > { public class Background extends ControlGroup< Background > {
public Background( ControlP5 theControlP5 , ControllerGroup< ? > theParent , String theName , int theX , int theY , int theW , int theH ) { public Background( ControlP5 theControlP5 , ControllerGroup< ? > theParent , String theName , int theX , int theY , int theW , int theH ) {

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2014 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -2,9 +2,9 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2014 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 * as published by the Free Software Foundation; either version 2.1
@ -13,16 +13,16 @@ package controlP5;
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the * Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
* @version ##version## * @version ##version##
* *
*/ */
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2014 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it * This library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser * and/or modify it under the terms of the GNU Lesser
@ -124,7 +124,6 @@ public class Button extends Controller< Button > {
isActive = false; isActive = false;
isOn = !isOn; isOn = !isOn;
setValue( _myValue ); setValue( _myValue );
} }
} }

View File

@ -1,5 +1,32 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import static controlP5.ControlP5.b; import static controlP5.ControlP5.b;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or modify it under * This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free * the terms of the GNU Lesser General Public License as published by the Free
@ -34,33 +34,20 @@ import java.io.Serializable;
public class CColor implements Serializable { public class CColor implements Serializable {
private int colorBackground = 0xff003652; private int colorBackground = 0xff003652;
private int colorForeground = 0xff00698c; private int colorForeground = 0xff00698c;
private int colorActive = 0xff08a2cf; // 0699C4; private int colorActive = 0xff08a2cf; // 0699C4;
private int colorCaptionLabel = 0xffffffff; private int colorCaptionLabel = 0xffffffff;
private int colorValueLabel = 0xffffffff; private int colorValueLabel = 0xffffffff;
private int colorBackgroundAlpha = 0xff; private int colorBackgroundAlpha = 0xff;
private int colorForegroundAlpha = 0xff; private int colorForegroundAlpha = 0xff;
private int colorActiveAlpha = 0xff; // 0699C4; private int colorActiveAlpha = 0xff; // 0699C4;
private int colorCaptionLabelAlpha = 0xff; private int colorCaptionLabelAlpha = 0xff;
private int colorValueLabelAlpha = 0xff; private int colorValueLabelAlpha = 0xff;
private int alpha = 0xff; private int alpha = 0xff;
private int maskA = 0x00ffffff; private int maskA = 0x00ffffff;
int maskR = 0xff00ffff; int maskR = 0xff00ffff;
int maskG = 0xffff00ff; int maskG = 0xffff00ff;
int maskB = 0xffffff00; int maskB = 0xffffff00;
protected CColor set( CColor theColor ) { protected CColor set( CColor theColor ) {

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -7,8 +32,6 @@ import java.text.CharacterIterator;
import java.text.StringCharacterIterator; import java.text.StringCharacterIterator;
import java.util.List; import java.util.List;
import processing.core.PVector;
public class CP { public class CP {
/** /**
@ -224,10 +247,7 @@ public class CP {
return c.toString( ).startsWith( pattern ) ? c.toString( ).substring( pattern.length( ) ) : c.toString( ); return c.toString( ).startsWith( pattern ) ? c.toString( ).substring( pattern.length( ) ) : c.toString( );
} }
static public boolean inside( int[] theRect , PVector theVector ) {
return inside( theRect , theVector.x , theVector.y );
}
static public boolean inside( int[] theRect , float theX , float theY ) { static public boolean inside( int[] theRect , float theX , float theY ) {
if ( theRect.length == 4 ) { if ( theRect.length == 4 ) {
return ( theX > theRect[ 0 ] && theX < theRect[ 2 ] && theY > theRect[ 1 ] && theY < theRect[ 3 ] ); return ( theX > theRect[ 0 ] && theX < theRect[ 2 ] && theY > theRect[ 1 ] && theY < theRect[ 3 ] );

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2014 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import processing.core.PApplet; import processing.core.PApplet;
import processing.core.PGraphics; import processing.core.PGraphics;

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
/** /**
* Used by Chart, single chart data is stored here including value, (label) text, and color. * Used by Chart, single chart data is stored here including value, (label) text, and color.
*/ */

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import java.util.ArrayList; import java.util.ArrayList;
import java.util.ListIterator; import java.util.ListIterator;

View File

@ -1,16 +1,9 @@
package controlP5; package controlP5;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import processing.core.PImage;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -32,6 +25,13 @@ import processing.core.PImage;
* *
*/ */
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import processing.core.PImage;
/** /**
* A multiple-choice radioButton. items are added to a checkBox and can be organized in rows and * A multiple-choice radioButton. items are added to a checkBox and can be organized in rows and
* columns. items of a checkBox are of type Toggle. * columns. items of a checkBox are of type Toggle.

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
class ColorPalette extends ControlGroup< ColorPalette > { class ColorPalette extends ControlGroup< ColorPalette > {
protected ColorPalette( ControlP5 theControlP5 , ControllerGroup< ? > theParent , String theName , int theX , int theY , int theWidth , int theHeight ) { protected ColorPalette( ControlP5 theControlP5 , ControllerGroup< ? > theParent , String theName , int theX , int theY , int theWidth , int theHeight ) {

View File

@ -3,19 +3,21 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or modify it under * This library is free software; you can redistribute it and/or
* the terms of the GNU Lesser General Public License as published by the Free * modify it under the terms of the GNU Lesser General Public License
* Software Foundation; either version 2.1 of the License, or (at your option) * as published by the Free Software Foundation; either version 2.1
* any later version. This library is distributed in the hope that it will be * of the License, or (at your option) any later version.
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * This library is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * but WITHOUT ANY WARRANTY; without even the implied warranty of
* General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General
* along with this library; if not, write to the Free Software Foundation, Inc., * Public License along with this library; if not, write to the
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
@ -169,7 +171,7 @@ public class ColorPicker extends ControlGroup< ColorPicker > {
if ( _myPlug != null ) { if ( _myPlug != null ) {
try { try {
Method method = _myPlug.getClass( ).getMethod( _myPlugName , int.class ); Method method = _myPlug.getClass( ).getMethod( _myPlugName , int.class );
method.invoke( _myPlug , ( int ) _myValue ); method.invoke( _myPlug , ( int ) getColorValue( ) );
} catch ( SecurityException ex ) { } catch ( SecurityException ex ) {
ex.printStackTrace( ); ex.printStackTrace( );
} catch ( NoSuchMethodException ex ) { } catch ( NoSuchMethodException ex ) {

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -175,9 +200,9 @@ public class ColorWheel extends Controller< ColorWheel > {
buffer.ellipse( buffer.width / 2 , buffer.height / 2 , ( inner_radius + 1 ) * 2 , ( inner_radius + 1 ) * 2 ); buffer.ellipse( buffer.width / 2 , buffer.height / 2 , ( inner_radius + 1 ) * 2 , ( inner_radius + 1 ) * 2 );
for ( int y = 0 ; y < h ; y++ ) { for ( int y = 0 ; y < h ; y++ ) {
int dy = ( int ) ( y(center) - y ); int dy = ( int ) ( y( center ) - y );
for ( int x = 0 ; x < w ; x++ ) { for ( int x = 0 ; x < w ; x++ ) {
int dx = ( int ) ( x(center) - x ); int dx = ( int ) ( x( center ) - x );
double dist = Math.sqrt( dx * dx + dy * dy ); double dist = Math.sqrt( dx * dx + dy * dy );
if ( dist >= inner_radius && dist <= outer_radius ) { if ( dist >= inner_radius && dist <= outer_radius ) {
double theta = Math.atan2( dy , dx ); double theta = Math.atan2( dy , dx );
@ -234,9 +259,9 @@ public class ColorWheel extends Controller< ColorWheel > {
float y = _myColorResources.get( "default" ).height / 2 - ( float ) Math.sin( theta ) * s; float y = _myColorResources.get( "default" ).height / 2 - ( float ) Math.sin( theta ) * s;
set( _myCursor , x , y ); set( _myCursor , x , y );
setSaturation( t[ 1 ] ); setSaturation( t[ 1 ] );
// TODO resolve rounding error issue as reported here https://github.com/sojamo/controlp5/issues/21
_myColorValue = HSLtoRGB( hsl ); _myColorValue = HSLtoRGB( hsl );
setValue( _myColorValue ); setValue( _myColorValue );
return this; return this;
} }

View File

@ -2,9 +2,9 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 * as published by the Free Software Foundation; either version 2.1
@ -13,16 +13,16 @@ package controlP5;
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the * Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
* @version ##version## * @version ##version##
* *
*/ */
/** /**

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -47,29 +47,17 @@ import java.util.Set;
public class ControlBroadcaster { public class ControlBroadcaster {
private int _myControlEventType = ControlP5Constants.INVALID; private int _myControlEventType = ControlP5Constants.INVALID;
private ControllerPlug _myControlEventPlug = null; private ControllerPlug _myControlEventPlug = null;
private ControllerPlug _myControllerCallbackEventPlug = null; private ControllerPlug _myControllerCallbackEventPlug = null;
private ControlP5 cp5; private ControlP5 cp5;
private String _myEventMethod = "controlEvent"; private String _myEventMethod = "controlEvent";
private String _myControllerCallbackEventMethod = "controlEvent"; private String _myControllerCallbackEventMethod = "controlEvent";
private ArrayList< ControlListener > _myControlListeners; private ArrayList< ControlListener > _myControlListeners;
private Set< Entry< CallbackListener , Controller< ? >>> _myControllerCallbackListeners; private Set< Entry< CallbackListener , Controller< ? >>> _myControllerCallbackListeners;
private static boolean setPrintStackTrace = true; private static boolean setPrintStackTrace = true;
private static boolean ignoreErrorMessage = false; private static boolean ignoreErrorMessage = false;
private static Map< Class< ? > , Field[] > fieldcache = new HashMap< Class< ? > , Field[] >( ); private static Map< Class< ? > , Field[] > fieldcache = new HashMap< Class< ? > , Field[] >( );
private static Map< Class< ? > , Method[] > methodcache = new HashMap< Class< ? > , Method[] >( ); private static Map< Class< ? > , Method[] > methodcache = new HashMap< Class< ? > , Method[] >( );
boolean broadcast = true; boolean broadcast = true;
protected ControlBroadcaster( ControlP5 theControlP5 ) { protected ControlBroadcaster( ControlP5 theControlP5 ) {

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -2,9 +2,9 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 * as published by the Free Software Foundation; either version 2.1
@ -13,16 +13,16 @@ package controlP5;
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the * Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
* @version ##version## * @version ##version##
* *
*/ */
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -3,23 +3,21 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it * This library is free software; you can redistribute it and/or
* and/or modify it under the terms of the GNU Lesser * modify it under the terms of the GNU Lesser General Public License
* General Public License as published by the Free Software * as published by the Free Software Foundation; either version 2.1
* Foundation; either version 2.1 of the License, or (at * of the License, or (at your option) any later version.
* your option) any later version. This library is * This library is distributed in the hope that it will be useful,
* distributed in the hope that it will be useful, but * but WITHOUT ANY WARRANTY; without even the implied warranty of
* WITHOUT ANY WARRANTY; without even the implied warranty * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * Lesser General Public License for more details.
* See the GNU Lesser General Public License for more
* details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to * Public License along with this library; if not, write to the
* the Free Software Foundation, Inc., 59 Temple Place, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Suite 330, Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
public interface ControlKey { public interface ControlKey {
public void keyEvent(); public void keyEvent();

View File

@ -2,9 +2,9 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 * as published by the Free Software Foundation; either version 2.1
@ -13,16 +13,16 @@ package controlP5;
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the * Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
* @version ##version## * @version ##version##
* *
*/ */
/** /**

View File

@ -3,23 +3,21 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it * This library is free software; you can redistribute it and/or
* and/or modify it under the terms of the GNU Lesser * modify it under the terms of the GNU Lesser General Public License
* General Public License as published by the Free Software * as published by the Free Software Foundation; either version 2.1
* Foundation; either version 2.1 of the License, or (at * of the License, or (at your option) any later version.
* your option) any later version. This library is * This library is distributed in the hope that it will be useful,
* distributed in the hope that it will be useful, but * but WITHOUT ANY WARRANTY; without even the implied warranty of
* WITHOUT ANY WARRANTY; without even the implied warranty * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * Lesser General Public License for more details.
* See the GNU Lesser General Public License for more
* details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to * Public License along with this library; if not, write to the
* the Free Software Foundation, Inc., 59 Temple Place, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Suite 330, Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
@ -33,11 +31,14 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -87,12 +88,15 @@ public class ControlP5 extends ControlP5Base {
*/ */
@ControlP5.Invisible PGraphics pg; @ControlP5.Invisible PGraphics pg;
int pgx = 0 , pgy = 0 , pgw = 0 , pgh = 0; int pgx = 0 , pgy = 0 , pgw = 0 , pgh = 0;
int ox = 0;
int oy = 0;
boolean isGraphics = false; boolean isGraphics = false;
/** /**
* @exclude * @exclude
*/ */
@ControlP5.Invisible public static final String VERSION = "2.2.2";// "##version##"; @ControlP5.Invisible public static final String VERSION = "2.2.6";// "##version##";
/** /**
* @exclude * @exclude
@ -256,6 +260,12 @@ public class ControlP5 extends ControlP5Base {
return this; return this;
} }
public ControlP5 setPosition( int theX , int theY ) {
ox = theX;
oy = theY;
return this;
}
/** /**
* By default event originating from tabs are disabled, * By default event originating from tabs are disabled,
* use setTabEventsActive(true) to receive controlEvents * use setTabEventsActive(true) to receive controlEvents
@ -942,7 +952,8 @@ public class ControlP5 extends ControlP5Base {
public boolean loadProperties( final String theFilePath ) { public boolean loadProperties( final String theFilePath ) {
String path = theFilePath.endsWith( _myProperties.format.getExtension( ) ) ? theFilePath : theFilePath + "." + _myProperties.format.getExtension( ); String path = theFilePath.endsWith( _myProperties.format.getExtension( ) ) ? theFilePath : theFilePath + "." + _myProperties.format.getExtension( );
path = checkPropertiesPath( path ); path = checkPropertiesPath( path );
File f = new File( path ); File f = new File( path);
if ( f.exists( ) ) { if ( f.exists( ) ) {
return _myProperties.load( path ); return _myProperties.load( path );
} }
@ -1214,8 +1225,14 @@ public class ControlP5 extends ControlP5Base {
/* static helper functions including Object-to-Type /* static helper functions including Object-to-Type
* conversions, invokes */ * conversions, invokes */
static public Object invoke( Object theObject , String theMember , Object ... theParams ) { static public Object invoke( final Object theObject , final String theMember , final Object ... theParams ) {
return invoke( theObject , theObject.getClass( ) , theMember , theParams );
}
static public Object invoke( final Object theObject , final Class< ? > theClass , final String theMember , final Object ... theParams ) {
if ( theClass == null ) {
return null;
}
Class[] cs = new Class[ theParams.length ]; Class[] cs = new Class[ theParams.length ];
for ( int i = 0 ; i < theParams.length ; i++ ) { for ( int i = 0 ; i < theParams.length ; i++ ) {
@ -1223,7 +1240,7 @@ public class ControlP5 extends ControlP5Base {
cs[ i ] = classmap.containsKey( c ) ? classmap.get( c ) : c; cs[ i ] = classmap.containsKey( c ) ? classmap.get( c ) : c;
} }
try { try {
final Field f = theObject.getClass( ).getDeclaredField( theMember ); final Field f = theClass.getDeclaredField( theMember );
/* TODO check super */ /* TODO check super */
f.setAccessible( true ); f.setAccessible( true );
Object o = theParams[ 0 ]; Object o = theParams[ 0 ];
@ -1245,8 +1262,7 @@ public class ControlP5 extends ControlP5Base {
} }
} catch ( NoSuchFieldException e1 ) { } catch ( NoSuchFieldException e1 ) {
try { try {
final Method m = theObject.getClass( ).getDeclaredMethod( theMember , cs ); final Method m = theClass.getDeclaredMethod( theMember , cs );
/* TODO check super */
m.setAccessible( true ); m.setAccessible( true );
try { try {
return m.invoke( theObject , theParams ); return m.invoke( theObject , theParams );
@ -1261,7 +1277,7 @@ public class ControlP5 extends ControlP5Base {
} catch ( SecurityException e ) { } catch ( SecurityException e ) {
System.err.println( e ); System.err.println( e );
} catch ( NoSuchMethodException e ) { } catch ( NoSuchMethodException e ) {
System.err.println( e ); invoke( theObject , theClass.getSuperclass( ) , theMember , theParams );
} }
} catch ( IllegalArgumentException e ) { } catch ( IllegalArgumentException e ) {
System.err.println( e ); System.err.println( e );
@ -1359,14 +1375,44 @@ public class ControlP5 extends ControlP5Base {
return str.matches( "(-|\\+)?\\d+(\\.\\d+)?" ); return str.matches( "(-|\\+)?\\d+(\\.\\d+)?" );
} }
static public List toList( final Object ... args ) {
List l = new ArrayList( );
Collections.addAll( l , args );
return l;
}
static public List toList( Object o ) { static public List toList( Object o ) {
return o != null ? ( o instanceof List ) ? ( List ) o : ( o instanceof String ) ? toList( o.toString( ) ) : Collections.EMPTY_LIST : Collections.EMPTY_LIST; return o != null ? ( o instanceof List ) ? ( List ) o : ( o instanceof String ) ? toList( o.toString( ) ) : Collections.EMPTY_LIST : Collections.EMPTY_LIST;
} }
static public Map toMap( final String s ) {
/* similar to mapFrom(Object ... args) but with type
* (Number,String) sensitivity */
String[] arr = s.trim( ).split( delimiter );
Map m = new LinkedHashMap( );
if ( arr.length % 2 == 0 ) {
for ( int i = 0 ; i < arr.length ; i += 2 ) {
String s1 = arr[ i + 1 ];
m.put( arr[ i ] , isNumeric( s1 ) ? s1.indexOf( "." ) == -1 ? i( s1 ) : f( s1 ) : s1 );
}
}
return m;
}
static public Map toMap( Object o ) { static public Map toMap( Object o ) {
return o != null ? ( o instanceof Map ) ? ( Map ) o : Collections.EMPTY_MAP : Collections.EMPTY_MAP; return o != null ? ( o instanceof Map ) ? ( Map ) o : Collections.EMPTY_MAP : Collections.EMPTY_MAP;
} }
static public Map toMap( final Object ... args ) {
Map m = new LinkedHashMap( );
if ( args.length % 2 == 0 ) {
for ( int i = 0 ; i < args.length ; i += 2 ) {
m.put( args[ i ] , args[ i + 1 ] );
}
}
return m;
}
static public String s( String o ) { static public String s( String o ) {
return ( o != null ) ? o : ""; return ( o != null ) ? o : "";
} }
@ -1382,6 +1428,18 @@ public class ControlP5 extends ControlP5Base {
} }
}; };
static public void sleep( long theMillis ) {
try {
Thread.sleep( theMillis );
} catch ( Exception e ) {
}
}
static public String timestamp( ) {
return new SimpleDateFormat( "yyyyMMdd-HHmmss" ).format( new Date( ) );
}
/* add Objects with Annotation */ /* add Objects with Annotation */
public static Logger logger( ) { public static Logger logger( ) {

View File

@ -3,23 +3,21 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it * This library is free software; you can redistribute it and/or
* and/or modify it under the terms of the GNU Lesser * modify it under the terms of the GNU Lesser General Public License
* General Public License as published by the Free Software * as published by the Free Software Foundation; either version 2.1
* Foundation; either version 2.1 of the License, or (at * of the License, or (at your option) any later version.
* your option) any later version. This library is * This library is distributed in the hope that it will be useful,
* distributed in the hope that it will be useful, but * but WITHOUT ANY WARRANTY; without even the implied warranty of
* WITHOUT ANY WARRANTY; without even the implied warranty * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * Lesser General Public License for more details.
* See the GNU Lesser General Public License for more
* details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to * Public License along with this library; if not, write to the
* the Free Software Foundation, Inc., 59 Temple Place, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Suite 330, Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
@ -39,7 +37,6 @@ import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import processing.core.PApplet; import processing.core.PApplet;
import processing.core.PVector;
import processing.event.Event; import processing.event.Event;
import static controlP5.Controller.*; import static controlP5.Controller.*;

View File

@ -3,29 +3,28 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it * This library is free software; you can redistribute it and/or
* and/or modify it under the terms of the GNU Lesser * modify it under the terms of the GNU Lesser General Public License
* General Public License as published by the Free Software * as published by the Free Software Foundation; either version 2.1
* Foundation; either version 2.1 of the License, or (at * of the License, or (at your option) any later version.
* your option) any later version. This library is * This library is distributed in the hope that it will be useful,
* distributed in the hope that it will be useful, but * but WITHOUT ANY WARRANTY; without even the implied warranty of
* WITHOUT ANY WARRANTY; without even the implied warranty * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * Lesser General Public License for more details.
* See the GNU Lesser General Public License for more
* details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to * Public License along with this library; if not, write to the
* the Free Software Foundation, Inc., 59 Temple Place, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Suite 330, Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
* @version ##version## * @version ##version##
* *
*/ */
import processing.core.PApplet; import processing.core.PApplet;
/** /**
@ -169,6 +168,8 @@ public interface ControlP5Constants {
public final static CColor THEME_GREY = new CColor( 0xffeeeeee, 0xffbbbbbb , 0xffffffff , 0xff555555 , 0xff555555 ); public final static CColor THEME_GREY = new CColor( 0xffeeeeee, 0xffbbbbbb , 0xffffffff , 0xff555555 , 0xff555555 );
public final static CColor THEME_A = new CColor( 0xff00FFC8 , 0xff00D7FF , 0xffffff00 , 0xff00B0FF , 0xff00B0FF ); public final static CColor THEME_A = new CColor( 0xff00FFC8 , 0xff00D7FF , 0xffffff00 , 0xff00B0FF , 0xff00B0FF );
// other colors: #ff3838 red-salmon; #08ffb4 turquoise; #40afff light-blue; #f3eddb beige;
public static final int standard58 = 0; public static final int standard58 = 0;
public static final int standard56 = 1; public static final int standard56 = 1;
public static final int synt24 = 2; public static final int synt24 = 2;
@ -180,4 +181,7 @@ public interface ControlP5Constants {
public final static String JSON = "JSON"; public final static String JSON = "JSON";
public final static String SERIALIZED = "SERIALIZED"; public final static String SERIALIZED = "SERIALIZED";
static public final String delimiter = " ";
static public final String pathdelimiter = "/";
} }

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import java.util.ArrayList; import java.util.ArrayList;
import processing.core.PApplet; import processing.core.PApplet;
@ -294,7 +319,7 @@ public class ControlP5Legacy {
public ScrollableList addScrollableList( final Object theObject , String theIndex , final String theName , final int theX , final int theY , final int theW , final int theH ) { public ScrollableList addScrollableList( final Object theObject , String theIndex , final String theName , final int theX , final int theY , final int theW , final int theH ) {
ScrollableList myController = new ScrollableList( base.cp5 , ( Tab ) base.cp5.controlWindow.getTabs( ).get( 1 ) , theName , theX , theY , theW , theH ); ScrollableList myController = new ScrollableList( base.cp5 , ( Tab ) base.cp5.controlWindow.getTabs( ).get( 1 ) , theName , theX , theY , theW , theH );
base.cp5.register( theObject , theIndex , myController ); base.cp5.register( theObject , theIndex , myController );
myController.registerProperty( "listBoxItems" ).registerProperty( "value" ); myController.registerProperty( "value" );
return myController; return myController;
} }

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -2,9 +2,9 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2014 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it * This library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser * and/or modify it under the terms of the GNU Lesser
* General Public License as published by the Free Software * General Public License as published by the Free Software
@ -15,16 +15,16 @@ package controlP5;
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more * See the GNU Lesser General Public License for more
* details. * details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to * Public License along with this library; if not, write to
* the Free Software Foundation, Inc., 59 Temple Place, * the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA * Suite 330, Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
* @version ##version## * @version ##version##
* *
*/ */
import java.util.ArrayList; import java.util.ArrayList;
@ -34,7 +34,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
import processing.core.PApplet; import processing.core.PApplet;
import processing.core.PConstants; import processing.core.PConstants;
import processing.core.PGraphics; import processing.core.PGraphics;
import processing.core.PVector;
import processing.event.KeyEvent; import processing.event.KeyEvent;
import processing.event.MouseEvent; import processing.event.MouseEvent;
import controlP5.ControlP5Base.KeyCode; import controlP5.ControlP5Base.KeyCode;
@ -62,10 +61,10 @@ public final class ControlWindow {
protected List< Canvas > _myCanvas; protected List< Canvas > _myCanvas;
protected boolean isDrawBackground = true; protected boolean isDrawBackground = true;
protected boolean isUndecorated = false; protected boolean isUndecorated = false;
protected PVector autoPosition = new PVector( 10 , 30 , 0 ); protected float[] autoPosition = new float[]{ 10 , 30 , 0 };
protected float tempAutoPositionHeight = 0; protected float tempAutoPositionHeight = 0;
protected boolean rendererNotification = false; protected boolean rendererNotification = false;
protected PVector positionOfTabs = new PVector( 0 , 0 , 0 ); protected float[] positionOfTabs = new float[]{ 0 , 0 , 0 };
private int _myFrameCount = 0; private int _myFrameCount = 0;
private boolean isMouse = true; private boolean isMouse = true;
private Pointer _myPointer; private Pointer _myPointer;
@ -82,7 +81,8 @@ public final class ControlWindow {
protected boolean mouselock; protected boolean mouselock;
protected char key; protected char key;
protected int keyCode; protected int keyCode;
private boolean[] keys = new boolean[ 525 ]; private final int numKeys = 1024;
private boolean[] keys = new boolean[ numKeys ];
private int numOfActiveKeys = 0; private int numOfActiveKeys = 0;
private boolean focused = true; private boolean focused = true;
@ -195,29 +195,18 @@ public final class ControlWindow {
/** /**
* Sets the position of the tab bar which is set to 0,0 * Sets the position of the tab bar which is set to 0,0
* by default. to move the tabs to y-position 100, use * by default. to move the tabs to y-position 100, use
* cp5.window().setPositionOfTabs(new PVector(0,100,0)); * cp5.getWindow().setPositionOfTabs(0,100);
* *
* @param thePVector
*/ */
public ControlWindow setPositionOfTabs( PVector thePVector ) {
positionOfTabs.set( thePVector );
return this;
}
public ControlWindow setPositionOfTabs( int theX , int theY ) { public ControlWindow setPositionOfTabs( int theX , int theY ) {
positionOfTabs.set( theX , theY , positionOfTabs.z ); positionOfTabs[0] = theX;
positionOfTabs[1] = theY;
return this; return this;
} }
/**
* Returns the position of the tab bar as PVector. to public float[] getPositionOfTabs( ) {
* move the tabs to y-position 100, use
* cp5.window().getPositionOfTabs().y = 100; or
* cp5.window().setPositionOfTabs(new PVector(0,100,0));
*
* @return PVector
*/
public PVector getPositionOfTabs( ) {
return positionOfTabs; return positionOfTabs;
} }
@ -341,7 +330,7 @@ public final class ControlWindow {
/** /**
* updates all controllers inside the control window if * updates all controllers inside the control window if
* update is enabled. * update is enabled.
* *
* @exclude * @exclude
*/ */
public void update( ) { public void update( ) {
@ -413,8 +402,8 @@ public final class ControlWindow {
*/ */
public void mouseEvent( int theX , int theY , boolean pressed ) { public void mouseEvent( int theX , int theY , boolean pressed ) {
mouseX = theX - cp5.pgx; mouseX = theX - cp5.pgx - cp5.ox;
mouseY = theY - cp5.pgy; mouseY = theY - cp5.pgy - cp5.oy;
if ( pressed && !pmousePressed ) { if ( pressed && !pmousePressed ) {
updateEvents( ); updateEvents( );
@ -451,8 +440,8 @@ public final class ControlWindow {
*/ */
public void mouseEvent( MouseEvent theMouseEvent ) { public void mouseEvent( MouseEvent theMouseEvent ) {
if ( isMouse ) { if ( isMouse ) {
mouseX = theMouseEvent.getX( ) - cp5.pgx; mouseX = theMouseEvent.getX( ) - cp5.pgx - cp5.ox;
mouseY = theMouseEvent.getY( ) - cp5.pgy; mouseY = theMouseEvent.getY( ) - cp5.pgy - cp5.oy;
if ( theMouseEvent.getAction( ) == MouseEvent.PRESS ) { if ( theMouseEvent.getAction( ) == MouseEvent.PRESS ) {
mousePressedEvent( ); mousePressedEvent( );
} }
@ -508,7 +497,7 @@ public final class ControlWindow {
} }
public void clearKeys( ) { public void clearKeys( ) {
keys = new boolean[ 525 ]; keys = new boolean[ numKeys ];
numOfActiveKeys = 0; numOfActiveKeys = 0;
} }
@ -526,7 +515,8 @@ public final class ControlWindow {
} }
public void draw( PGraphics pg ) { public void draw( PGraphics pg ) {
pg.pushMatrix( );
pg.translate( cp5.ox , cp5.oy );
if ( cp5.blockDraw == false ) { if ( cp5.blockDraw == false ) {
if ( cp5.isAndroid ) { if ( cp5.isAndroid ) {
mouseEvent( cp5.papplet.mouseX , cp5.papplet.mouseY , cp5.papplet.mousePressed ); mouseEvent( cp5.papplet.mouseX , cp5.papplet.mouseY , cp5.papplet.mousePressed );
@ -565,8 +555,8 @@ public final class ControlWindow {
pg.noStroke( ); pg.noStroke( );
pg.noFill( ); pg.noFill( );
int myOffsetX = ( int ) getPositionOfTabs( ).x; int myOffsetX = ( int ) getPositionOfTabs( )[0];
int myOffsetY = ( int ) getPositionOfTabs( ).y; int myOffsetY = ( int ) getPositionOfTabs( )[1];
int myHeight = 0; int myHeight = 0;
if ( _myTabs.size( ) > 0 ) { if ( _myTabs.size( ) > 0 ) {
@ -625,13 +615,13 @@ public final class ControlWindow {
} }
} }
} }
pg.popMatrix( );
} }
/** /**
* Adds a custom context to a ControlWindow. Use a * Adds a custom context to a ControlWindow. Use a
* custom class which implements the CDrawable interface * custom class which implements the CDrawable interface
* *
* @see controlP5.CDrawable * @see controlP5.CDrawable
* @param theDrawable CDrawable * @param theDrawable CDrawable
*/ */
@ -794,7 +784,7 @@ public final class ControlWindow {
/** /**
* sets the frame rate of the control window. * sets the frame rate of the control window.
* *
* @param theFrameRate * @param theFrameRate
* @return ControlWindow * @return ControlWindow
*/ */
@ -813,7 +803,7 @@ public final class ControlWindow {
* filled with a background color every frame. to enable * filled with a background color every frame. to enable
* or disable the background from drawing, use * or disable the background from drawing, use
* setDrawBackgorund(true/false). * setDrawBackgorund(true/false).
* *
* @param theFlag * @param theFlag
* @return ControlWindow * @return ControlWindow
*/ */

View File

@ -4,7 +4,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -1,17 +1,23 @@
package controlP5; package controlP5;
/** /**
* controlP5 is a processing gui library.
* *
* 2006-2013 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General * This library is free software; you can redistribute it and/or
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) * modify it under the terms of the GNU Lesser General Public License
* any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * as published by the Free Software Foundation; either version 2.1
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * of the License, or (at your option) any later version.
* License for more details. * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to * You should have received a copy of the GNU Lesser General
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
@ -26,9 +32,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import processing.core.PApplet; import processing.core.PApplet;
import processing.core.PFont;
import processing.core.PGraphics; import processing.core.PGraphics;
import processing.core.PImage; import processing.core.PImage;
import processing.core.PVector;
import processing.event.KeyEvent; import processing.event.KeyEvent;
/** /**
@ -270,8 +276,7 @@ public abstract class Controller< T > implements ControllerInterface< T > , CDra
} }
protected void updateFont( ControlFont theControlFont ) { protected void updateFont( ControlFont theControlFont ) {
_myCaptionLabel.updateFont( theControlFont ); setFont( theControlFont );
_myValueLabel.updateFont( theControlFont );
} }
/** /**
@ -413,15 +418,7 @@ public abstract class Controller< T > implements ControllerInterface< T > , CDra
return me; return me;
} }
/**
* @return {@link PVector}
*/
public float[] getAbsolutePosition( ) { public float[] getAbsolutePosition( ) {
// should return a mutable object of absolutePostion
// in a new PVector object to prevent
// absolutePosition from being
// modified by changing its field values. PVector
// should have getter and setters for x,y,z
return absolutePosition; return absolutePosition;
} }
@ -695,6 +692,7 @@ public abstract class Controller< T > implements ControllerInterface< T > , CDra
cp5.getControlBroadcaster( ).invokeAction( new CallbackEvent( this , ACTION_LEAVE ) ); cp5.getControlBroadcaster( ).invokeAction( new CallbackEvent( this , ACTION_LEAVE ) );
_myControlWindow.removeMouseOverFor( this ); _myControlWindow.removeMouseOverFor( this );
cp5.getTooltip( ).deactivate( ); cp5.getTooltip( ).deactivate( );
setIsInside( false ); /* added after issue 6 has been reported */
} }
return me; return me;
} }
@ -2212,4 +2210,16 @@ public abstract class Controller< T > implements ControllerInterface< T > , CDra
return me; return me;
} }
@Override public T setFont( PFont thePFont ) {
getValueLabel( ).setFont( thePFont );
getCaptionLabel( ).setFont( thePFont );
return me;
}
@Override public T setFont( ControlFont theFont ) {
getValueLabel( ).setFont( theFont );
getCaptionLabel( ).setFont( theFont );
return me;
}
} }

View File

@ -2,9 +2,9 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 * as published by the Free Software Foundation; either version 2.1
@ -13,16 +13,16 @@ package controlP5;
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the * Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
* @version ##version## * @version ##version##
* *
*/ */
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -104,16 +104,16 @@ class ControllerAutomator {
* *
*/ */
void addControllersFor( final String theAddressSpace , final Object t ) { void addControllersFor( final String theAddressSpace , final Object t ) {
System.out.println("OKOK");
if ( t instanceof List< ? > ) { if ( t instanceof List< ? > ) {
return; return;
} }
Class< ? > c = t.getClass( ); Class< ? > c = t.getClass( );
Field[] fs = c.getDeclaredFields( ); Field[] fs = c.getFields( );
Method[] ms = c.getDeclaredMethods( ); Method[] ms = c.getMethods( );
Map< ControllerInterface , Integer > controllersIndexed = new HashMap< ControllerInterface , Integer >( ); Map< ControllerInterface , Integer > controllersIndexed = new HashMap< ControllerInterface , Integer >( );

View File

@ -2,9 +2,9 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 * as published by the Free Software Foundation; either version 2.1
@ -13,16 +13,16 @@ package controlP5;
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the * Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
* @version ##version## * @version ##version##
* *
*/ */
import processing.core.PApplet; import processing.core.PApplet;

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import processing.core.PApplet; import processing.core.PApplet;
import processing.core.PFont;
import processing.core.PGraphics; import processing.core.PGraphics;
import processing.event.KeyEvent; import processing.event.KeyEvent;
@ -260,8 +261,8 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > ,
return me; return me;
} }
public T setPosition( float[] thePVector ) { public T setPosition( float[] thePosition ) {
setPosition( x( thePVector ) , y( thePVector ) ); setPosition( x( thePosition ) , y( thePosition ) );
return me; return me;
} }
@ -954,4 +955,16 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > ,
return 0; return 0;
} }
@Override public T setFont( PFont thePFont ) {
getValueLabel( ).setFont( thePFont );
getCaptionLabel( ).setFont( thePFont );
return me;
}
@Override public T setFont( ControlFont theFont ) {
getValueLabel( ).setFont( theFont );
getCaptionLabel( ).setFont( theFont );
return me;
}
} }

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -26,6 +26,7 @@ package controlP5;
*/ */
import processing.core.PApplet; import processing.core.PApplet;
import processing.core.PFont;
import processing.core.PGraphics; import processing.core.PGraphics;
import processing.event.KeyEvent; import processing.event.KeyEvent;
@ -64,11 +65,11 @@ public interface ControllerInterface< T > {
@ControlP5.Invisible public T setPosition( float theX , float theY ); @ControlP5.Invisible public T setPosition( float theX , float theY );
@ControlP5.Invisible public T setPosition( float[] thePVector ); @ControlP5.Invisible public T setPosition( float[] thePosition );
public float[] getAbsolutePosition( ); public float[] getAbsolutePosition( );
public T setAbsolutePosition( float[] thePVector ); public T setAbsolutePosition( float[] thePosition );
public T updateAbsolutePosition( ); public T updateAbsolutePosition( );
@ -163,7 +164,11 @@ public interface ControllerInterface< T > {
public boolean isMouseOver( ); public boolean isMouseOver( );
public T setMouseOver( boolean theFlag ); public T setMouseOver( boolean theFlag );
public T setFont( PFont theFont );
public T setFont( ControlFont theFont );
public T addListener( ControlListener theListener ); public T addListener( ControlListener theListener );
public T setCaptionLabel( String theValue ); public T setCaptionLabel( String theValue );

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
@ -11,7 +36,6 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import processing.core.PVector;
class ControllerLayout { class ControllerLayout {
@ -28,7 +52,6 @@ class ControllerLayout {
datatypes.put( Long.class , long.class ); datatypes.put( Long.class , long.class );
datatypes.put( Double.class , double.class ); datatypes.put( Double.class , double.class );
datatypes.put( Byte.class , byte.class ); datatypes.put( Byte.class , byte.class );
datatypes.put( PVector.class , PVector.class );
datatypes.put( CColor.class , CColor.class ); datatypes.put( CColor.class , CColor.class );
} }

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@ -2,9 +2,9 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 * as published by the Free Software Foundation; either version 2.1
@ -13,16 +13,16 @@ package controlP5;
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the * Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
* @version ##version## * @version ##version##
* *
*/ */
import java.util.List; import java.util.List;

View File

@ -2,9 +2,9 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 * as published by the Free Software Foundation; either version 2.1
@ -13,16 +13,16 @@ package controlP5;
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the * Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
* @version ##version## * @version ##version##
* *
*/ */
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -38,23 +38,14 @@ import java.security.AccessControlException;
public class ControllerPlug { public class ControllerPlug {
private Object _myObject; private Object _myObject;
private String _myName; private String _myName;
private Method _myMethod; private Method _myMethod;
private Field _myField; private Field _myField;
private int _myType = ControlP5Constants.INVALID; private int _myType = ControlP5Constants.INVALID;
private Class< ? > _myParameterClass; private Class< ? > _myParameterClass;
private int _myParameterType = -1; private int _myParameterType = -1;
private Object _myValue = null; private Object _myValue = null;
private Class< ? >[] _myAcceptClassList; private Class< ? >[] _myAcceptClassList;
private Class< ? > _myEventMethodParameter = ControlEvent.class; private Class< ? > _myEventMethodParameter = ControlEvent.class;
public ControllerPlug( final Object theObject , final String theName , final int theType , final int theParameterType , Class< ? >[] theAcceptClassList ) { public ControllerPlug( final Object theObject , final String theName , final int theType , final int theParameterType , Class< ? >[] theAcceptClassList ) {

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -35,6 +35,7 @@ import java.io.ObjectOutputStream;
import java.io.StringReader; import java.io.StringReader;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -70,6 +71,8 @@ public class ControllerProperties {
public final static int OPEN = 0; public final static int OPEN = 0;
public final static int CLOSE = 1; public final static int CLOSE = 1;
public static String defaultName = "controlP5"; public static String defaultName = "controlP5";
PropertiesStorageFormat format; PropertiesStorageFormat format;
/** /**
@ -420,14 +423,7 @@ public class ControllerProperties {
for ( ControllerProperty cp : l ) { for ( ControllerProperty cp : l ) {
ControllerInterface< ? > ci = controlP5.getController( cp.getAddress( ) ); ControllerInterface< ? > ci = controlP5.getController( cp.getAddress( ) );
ci = ( ci == null ) ? controlP5.getGroup( cp.getAddress( ) ) : ci; ci = ( ci == null ) ? controlP5.getGroup( cp.getAddress( ) ) : ci;
Method method; ControlP5.invoke( ( Controller ) ci , cp.getSetter( ) , cp.getValue( ) );
try {
method = ci.getClass( ).getMethod( cp.getSetter( ) , new Class[] { cp.getType( ) } );
method.setAccessible( true );
method.invoke( ci , new Object[] { cp.getValue( ) } );
} catch ( Exception e ) {
logger.severe( e.toString( ) );
}
} }
} }
return this; return this;
@ -451,7 +447,7 @@ public class ControllerProperties {
public boolean load( String thePropertiesPath ) { public boolean load( String thePropertiesPath ) {
return format.load( getPathWithExtension( format , controlP5.checkPropertiesPath( thePropertiesPath ) ) ); return format.load( getPathWithExtension( format , controlP5.checkPropertiesPath( thePropertiesPath ) ) );
} }
/** /**
* use ControllerProperties.SERIALIZED, ControllerProperties.XML or ControllerProperties.JSON as parameter. * use ControllerProperties.SERIALIZED, ControllerProperties.XML or ControllerProperties.JSON as parameter.
*/ */
@ -473,7 +469,7 @@ public class ControllerProperties {
* saves all registered properties into the default 'controlP5.properties' file into your sketch folder. * saves all registered properties into the default 'controlP5.properties' file into your sketch folder.
*/ */
public boolean save( ) { public boolean save( ) {
System.out.println( "saving with format " + format + " (" + format.getExtension( ) + ") " + controlP5.papplet.sketchPath( defaultName ) ); System.out.println( "save properties using format " + format + " (" + format.getExtension( ) + ") " + controlP5.papplet.sketchPath( defaultName ) );
format.compile( allProperties.keySet( ) , getPathWithExtension( format , controlP5.papplet.sketchPath( defaultName ) ) ); format.compile( allProperties.keySet( ) , getPathWithExtension( format , controlP5.papplet.sketchPath( defaultName ) ) );
return true; return true;
} }
@ -688,11 +684,13 @@ public class ControllerProperties {
} }
} }
class JSONFormat implements PropertiesStorageFormat { public class JSONFormat implements PropertiesStorageFormat {
public void compile( Set< ControllerProperty > theProperties , String thePropertiesPath ) { public void compile( Set< ControllerProperty > theProperties , String thePropertiesPath ) {
long t = System.currentTimeMillis( ); long t = System.currentTimeMillis( );
JSONObject json = new JSONObject( ); JSONObject json = new JSONObject( );
for ( ControllerProperty cp : theProperties ) { for ( ControllerProperty cp : theProperties ) {
if ( cp.isActive( ) ) { if ( cp.isActive( ) ) {
if ( updatePropertyValue( cp ) ) { if ( updatePropertyValue( cp ) ) {
cp.setId( cp.getController( ).getId( ) ); cp.setId( cp.getController( ).getId( ) );
@ -714,7 +712,22 @@ public class ControllerProperties {
} else if ( cp.getValue( ) instanceof Boolean ) { } else if ( cp.getValue( ) instanceof Boolean ) {
item.setBoolean( key , ControlP5.b( cp.getValue( ) ) ); item.setBoolean( key , ControlP5.b( cp.getValue( ) ) );
} else { } else {
item.setString( key , cp.getValue( ).toString( ) );
if ( cp.getValue( ).getClass( ).isArray( ) ) {
JSONArray arr = new JSONArray( );
if ( cp.getValue( ) instanceof int[] ) {
for ( Object o : ( int[] ) cp.getValue( ) ) {
arr.append( ControlP5.i( o ) );
}
} else if ( cp.getValue( ) instanceof float[] ) {
for ( Object o : ( float[] ) cp.getValue( ) ) {
arr.append( ControlP5.f( o ) );
}
}
item.setJSONArray( key , arr );
} else {
item.setString( key , cp.getValue( ).toString( ) );
}
} }
} }
} }
@ -741,8 +754,20 @@ public class ControllerProperties {
ControlP5.invoke( c , member , ControlP5.f( value.getValue( ) ) ); ControlP5.invoke( c , member , ControlP5.f( value.getValue( ) ) );
} else if ( i1 instanceof String ) { } else if ( i1 instanceof String ) {
ControlP5.invoke( c , member , ControlP5.s( value.getValue( ) ) ); ControlP5.invoke( c , member , ControlP5.s( value.getValue( ) ) );
} else if ( i1 instanceof float[] ) {
ControlP5.invoke( c , member , (float[])i1 );
} else { } else {
ControlP5.invoke( c , member , value.getValue( ) ); if ( i1 instanceof List ) {
List l = ( List ) i1;
float[] arr = new float[ l.size( ) ];
for ( int i = 0 ; i < l.size( ) ; i++ ) {
arr[ i ] = ControlP5.f( l.get( i ) );
}
ControlP5.invoke( c , member , arr );
} else {
ControlP5.invoke( c , member , value.getValue( ) );
}
} }
} }
} }
@ -818,7 +843,7 @@ public class ControllerProperties {
} }
class SerializedFormat implements PropertiesStorageFormat { public class SerializedFormat implements PropertiesStorageFormat {
public boolean load( String thePropertiesPath ) { public boolean load( String thePropertiesPath ) {
try { try {

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -11,21 +36,13 @@ import java.io.Serializable;
public class ControllerProperty implements Serializable , Cloneable { public class ControllerProperty implements Serializable , Cloneable {
private static final long serialVersionUID = 4506431150330867327L; private static final long serialVersionUID = 4506431150330867327L;
private String setter; private String setter;
private String getter; private String getter;
private Class< ? > type; private Class< ? > type;
private Object value; private Object value;
private String address; private String address;
private int id; private int id;
private transient boolean active; private transient boolean active;
private transient ControllerInterface< ? > controller; private transient ControllerInterface< ? > controller;
ControllerProperty( ControllerInterface< ? > theController , String theSetter , String theGetter ) { ControllerProperty( ControllerInterface< ? > theController , String theSetter , String theGetter ) {
@ -37,8 +54,7 @@ public class ControllerProperty implements Serializable , Cloneable {
setId( theController.getId( ) ); setId( theController.getId( ) );
} }
@Override @Override protected Object clone( ) throws CloneNotSupportedException {
protected Object clone( ) throws CloneNotSupportedException {
ControllerProperty clone = ( ControllerProperty ) super.clone( ); ControllerProperty clone = ( ControllerProperty ) super.clone( );
clone.setSetter( getSetter( ) ); clone.setSetter( getSetter( ) );
clone.setGetter( getGetter( ) ); clone.setGetter( getGetter( ) );
@ -54,8 +70,7 @@ public class ControllerProperty implements Serializable , Cloneable {
/** /**
* @exclude {@inheritDoc} * @exclude {@inheritDoc}
*/ */
@Override @Override public boolean equals( Object o ) {
public boolean equals( Object o ) {
if ( this == o ) { if ( this == o ) {
return true; return true;
@ -74,8 +89,7 @@ public class ControllerProperty implements Serializable , Cloneable {
/** /**
* @exclude {@inheritDoc} * @exclude {@inheritDoc}
*/ */
@Override @Override public int hashCode( ) {
public int hashCode( ) {
int result = 17; int result = 17;
result = 37 * result + ( address != null ? address.hashCode( ) : 0 ); result = 37 * result + ( address != null ? address.hashCode( ) : 0 );
result = 37 * result + ( setter != null ? setter.hashCode( ) : 0 ); result = 37 * result + ( setter != null ? setter.hashCode( ) : 0 );
@ -91,8 +105,7 @@ public class ControllerProperty implements Serializable , Cloneable {
active = true; active = true;
} }
@Override @Override public String toString( ) {
public String toString( ) {
return address + " " + setter + ", " + getter; return address + " " + setter + ", " + getter;
} }

View File

@ -1,23 +1,23 @@
package controlP5; package controlP5;
import java.io.Serializable;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or modify it under * This library is free software; you can redistribute it and/or
* the terms of the GNU Lesser General Public License as published by the Free * modify it under the terms of the GNU Lesser General Public License
* Software Foundation; either version 2.1 of the License, or (at your option) * as published by the Free Software Foundation; either version 2.1
* any later version. This library is distributed in the hope that it will be * of the License, or (at your option) any later version.
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * This library is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * but WITHOUT ANY WARRANTY; without even the implied warranty of
* General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General
* along with this library; if not, write to the Free Software Foundation, Inc., * Public License along with this library; if not, write to the
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
@ -25,6 +25,9 @@ import java.io.Serializable;
* *
*/ */
import java.io.Serializable;
/** /**
* Labels use the ControllerStyle class to store margin and padding information. * Labels use the ControllerStyle class to store margin and padding information.
* *

View File

@ -2,9 +2,9 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 * as published by the Free Software Foundation; either version 2.1
@ -13,16 +13,16 @@ package controlP5;
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General * You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the * Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA * Boston, MA 02111-1307 USA
* *
* @author Andreas Schlegel (http://www.sojamo.de) * @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date## * @modified ##date##
* @version ##version## * @version ##version##
* *
*/ */
import processing.core.PGraphics; import processing.core.PGraphics;

View File

@ -16,7 +16,7 @@ import processing.event.KeyEvent;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
@ -67,6 +67,7 @@ public class DropdownList extends Controller< DropdownList > implements ControlL
super( theControlP5 , theGroup , theName , theX , theY , theW , theH ); super( theControlP5 , theGroup , theName , theX , theY , theW , theH );
items = new ArrayList< Map< String , Object > >( ); items = new ArrayList< Map< String , Object > >( );
updateHeight( ); updateHeight( );
getValueLabel( ).align( PApplet.LEFT , PApplet.CENTER );
} }
public boolean isOpen( ) { public boolean isOpen( ) {
@ -126,24 +127,26 @@ public class DropdownList extends Controller< DropdownList > implements ControlL
// n += itemRange; /* UP */ // n += itemRange; /* UP */
int index = ( int ) n + itemIndexOffset; int index = ( int ) n + itemIndexOffset;
Map m = items.get( index ); if (index < items.size()) {
Map m = items.get( index );
switch ( _myType ) {
case ( LIST ): switch ( _myType ) {
setValue( index ); case ( LIST ):
for ( Object o : items ) { setValue( index );
( ( Map ) o ).put( "state" , false ); for ( Object o : items ) {
( ( Map ) o ).put( "state" , false );
}
m.put( "state" , !ControlP5.b( m.get( "state" ) ) );
break;
case ( DROPDOWN ):
setValue( index );
setOpen( false );
getCaptionLabel( ).setText( ( m.get( "text" ).toString( ) ) );
break;
case ( CHECKBOX ):
m.put( "state" , !ControlP5.b( m.get( "state" ) ) );
break;
} }
m.put( "state" , !ControlP5.b( m.get( "state" ) ) );
break;
case ( DROPDOWN ):
setValue( index );
setOpen( false );
getCaptionLabel( ).setText( ( m.get( "text" ).toString( ) ) );
break;
case ( CHECKBOX ):
m.put( "state" , !ControlP5.b( m.get( "state" ) ) );
break;
} }
} }
@ -389,7 +392,7 @@ public class DropdownList extends Controller< DropdownList > implements ControlL
} }
g.popMatrix( ); g.popMatrix( );
c.getCaptionLabel( ).align( PApplet.LEFT , PApplet.CENTER ).draw( g , 4 , c.barHeight / 2 ); c.getCaptionLabel( ).draw( g , 4 , c.barHeight / 2 );
} }
if ( c.isOpen( ) ) { if ( c.isOpen( ) ) {
@ -411,7 +414,7 @@ public class DropdownList extends Controller< DropdownList > implements ControlL
CColor color = ( CColor ) item.get( "color" ); CColor color = ( CColor ) item.get( "color" );
g.fill( ( b( item.get( "state" ) ) ) ? color.getActive( ) : ( i == c.itemHover ) ? ( c.isMousePressed ? color.getActive( ) : color.getForeground( ) ) : color.getBackground( ) ); g.fill( ( b( item.get( "state" ) ) ) ? color.getActive( ) : ( i == c.itemHover ) ? ( c.isMousePressed ? color.getActive( ) : color.getForeground( ) ) : color.getBackground( ) );
g.rect( 0 , 0 , c.getWidth( ) , c.itemHeight - 1 ); g.rect( 0 , 0 , c.getWidth( ) , c.itemHeight - 1 );
c.getValueLabel( ).align( PApplet.LEFT , PApplet.CENTER ).set( item.get( "text" ).toString( ) ).draw( g , 4 , c.itemHeight / 2 ); c.getValueLabel( ).set( item.get( "text" ).toString( ) ).draw( g , 4 , c.itemHeight / 2 );
g.translate( 0 , c.itemHeight ); g.translate( 0 , c.itemHeight );
} }
g.popMatrix( ); g.popMatrix( );
@ -460,4 +463,4 @@ public class DropdownList extends Controller< DropdownList > implements ControlL
} }
/* TODO keycontrol: arrows, return dragging moving items /* TODO keycontrol: arrows, return dragging moving items
* sorting custom view custom event types */ * sorting custom view custom event types */
} }

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import java.lang.reflect.Field; import java.lang.reflect.Field;
/** /**

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import processing.core.PApplet; import processing.core.PApplet;
import processing.core.PGraphics; import processing.core.PGraphics;

View File

@ -1,5 +1,29 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
public class Group extends ControlGroup< Group > { public class Group extends ControlGroup< Group > {
/** /**

View File

@ -1,5 +1,30 @@
package controlP5; package controlP5;
/**
* controlP5 is a processing gui library.
*
* 2006-2015 by Andreas Schlegel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* @author Andreas Schlegel (http://www.sojamo.de)
* @modified ##date##
* @version ##version##
*
*/
import processing.core.PApplet; import processing.core.PApplet;
import processing.core.PFont; import processing.core.PFont;
import processing.core.PGraphics; import processing.core.PGraphics;

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it * This library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser * and/or modify it under the terms of the GNU Lesser
@ -41,6 +41,7 @@ import processing.core.PGraphics;
*/ */
public class Label implements CDrawable { public class Label implements CDrawable {
public static boolean isToUpperCaseDefault = true;
protected int _myLetterSpacing = 0; protected int _myLetterSpacing = 0;
protected boolean isMultiline; protected boolean isMultiline;
protected boolean isFixedSize; protected boolean isFixedSize;
@ -48,7 +49,7 @@ public class Label implements CDrawable {
protected boolean isVisible = true; protected boolean isVisible = true;
protected int _myColor = 0xffffffff; protected int _myColor = 0xffffffff;
protected boolean isColorBackground; protected boolean isColorBackground;
protected boolean isToUpperCase = true; protected boolean isToUpperCase = isToUpperCaseDefault;
protected boolean changed; protected boolean changed;
protected int _myColorBackground = 0xffffffff; protected int _myColorBackground = 0xffffffff;
protected int _myHeight = -1; protected int _myHeight = -1;
@ -407,13 +408,23 @@ public class Label implements CDrawable {
return new Label( this ); return new Label( this );
} }
public static void setUpperCaseDefault( boolean theValue ) {
isToUpperCaseDefault = theValue;
}
interface Labeltype { interface Labeltype {
public void draw( Label theLabel , PGraphics theGraphics , int theX , int theY , ControllerInterface< ? > theController ); public void draw( Label theLabel , PGraphics theGraphics , int theX , int theY , ControllerInterface< ? > theController );
public void draw( Label theLabel , PGraphics theGraphics , int theX , int theY , int theW , int theH ); public void draw( Label theLabel , PGraphics theGraphics , int theX , int theY , int theW , int theH );
public int getWidth( ); public int getWidth( );
public int getHeight( ); public int getHeight( );
public int getOverflow( ); public int getOverflow( );
public String getTextFormatted( ); public String getTextFormatted( );
} }

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

View File

@ -3,7 +3,7 @@ package controlP5;
/** /**
* controlP5 is a processing gui library. * controlP5 is a processing gui library.
* *
* 2006-2012 by Andreas Schlegel * 2006-2015 by Andreas Schlegel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License

Some files were not shown because too many files have changed in this diff Show More