diff --git a/LICENSE.md b/LICENSE.md index aaf1dc3..a970635 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -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. 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 modify it under the terms of the GNU Lesser General Public diff --git a/examples/controllers/ControlP5colorPicker/ControlP5colorPicker.pde b/examples/controllers/ControlP5colorPicker/ControlP5colorPicker.pde index 5d3dc62..8545134 100644 --- a/examples/controllers/ControlP5colorPicker/ControlP5colorPicker.pde +++ b/examples/controllers/ControlP5colorPicker/ControlP5colorPicker.pde @@ -42,13 +42,13 @@ public void controlEvent(ControlEvent c) { int b = int(c.getArrayValue(2)); int a = int(c.getArrayValue(3)); 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 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); } @@ -183,6 +183,4 @@ java.lang.Object : boolean equals(Object) created: 2015/03/24 12:20:58 -*/ - - +*/ \ No newline at end of file diff --git a/examples/extra/ControlP5frame/ControlP5frame.pde b/examples/extra/ControlP5frame/ControlP5frame.pde index 0b597ac..4bc9a82 100644 --- a/examples/extra/ControlP5frame/ControlP5frame.pde +++ b/examples/extra/ControlP5frame/ControlP5frame.pde @@ -1,98 +1,112 @@ /** * 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 * */ -import java.awt.Frame; -import java.awt.BorderLayout; import controlP5.*; -private ControlP5 cp5; - ControlFrame cf; -int def; +float speed; +float pos; +float c0, c1, c2, c3; +boolean auto; + +void settings() { + size(400, 400, P3D); +} void setup() { - size(400, 400); - cp5 = new ControlP5(this); - - // 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. - - + cf = new ControlFrame(this, 400, 800, "Controls"); + surface.setLocation(420, 10); + noStroke(); } void draw() { - background(def); -} - -ControlFrame addControlFrame(String theName, int theWidth, int theHeight) { - Frame f = new Frame(theName); - ControlFrame p = new ControlFrame(this, theWidth, theHeight); - f.add(p); - p.init(); - f.setTitle(theName); - f.setSize(p.w, p.h); - f.setLocation(100, 100); - f.setResizable(false); - f.setVisible(true); - return p; + if (auto) pos += speed; + background(0); + translate(width/2, height/2); + rotateY(pos); + lights(); + fill(c0, c1, c2, c3); + box(100); } -// the ControlFrame class extends PApplet, so we -// are creating a new processing applet inside a -// new frame with a controlP5 object loaded -public class ControlFrame extends PApplet { + + +class ControlFrame extends PApplet { int w, h; - - 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; - } - - + PApplet parent; 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); + } +} \ No newline at end of file diff --git a/resources/build.xml b/resources/build.xml index 8ae31e8..eeffc46 100644 --- a/resources/build.xml +++ b/resources/build.xml @@ -1,102 +1,102 @@ - + ant build file for controlP5, a gui processing library. - + - + - + - - + + - + - + - + - - + + - + - + - + - + - + -------------------------------------------------------------------------------------------- ${date} compiling ${libraryName} ${versionNumber} -------------------------------------------------------------------------------------------- Properties initialized -------------------------------------------------------------------------------------------- - + src path ${src} bin path ${bin} libraryClasspath ${libraryClasspath} processing Libraries ${processing} java version ${javaVersion} - - + + -------------------------------------------------------------------------------------------- building library ... - - - - + + + + - + - + - - + + - + - - + + - + @@ -109,48 +109,48 @@ - - - + + + - + - - - + + + Generating JavaDoc Reference - - - - - + + - + - + @@ -165,7 +165,7 @@ - + @@ -178,64 +178,64 @@ basedir="${dist}/tmp" excludes="**/.DS_Store" /> - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - + -------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------- - + - - + + - + - + -------------------------------------------------------------------------------------------- done, finished compiling ${libraryName} ${versionNumber} -------------------------------------------------------------------------------------------- - - - + + + @@ -296,7 +296,7 @@ - + ${exampleDir} - - + + ${file} - diff --git a/resources/jar.sh b/resources/jar.sh index afb7616..1cd7b05 100755 --- a/resources/jar.sh +++ b/resources/jar.sh @@ -1,4 +1,4 @@ cd $HOME/Documents/workspace/controlp5/bin 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)" diff --git a/resources/library.properties b/resources/library.properties index 0166e0a..1479349 100644 --- a/resources/library.properties +++ b/resources/library.properties @@ -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 # check if an update is available. You should think of it as a # counter, counting the total number of releases you've had. -version = 84 # 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 -prettyVersion = 2.2.5 # This is treated as a String +prettyVersion = 2.2.6 # This is treated as a String diff --git a/src/controlP5/Accordion.java b/src/controlP5/Accordion.java index e599c9a..eb077c1 100755 --- a/src/controlP5/Accordion.java +++ b/src/controlP5/Accordion.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 * modify it under the terms of the GNU Lesser General Public License diff --git a/src/controlP5/Background.java b/src/controlP5/Background.java index 10deb74..a454509 100644 --- a/src/controlP5/Background.java +++ b/src/controlP5/Background.java @@ -1,5 +1,30 @@ 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 Background( ControlP5 theControlP5 , ControllerGroup< ? > theParent , String theName , int theX , int theY , int theW , int theH ) { diff --git a/src/controlP5/Bang.java b/src/controlP5/Bang.java index 75b55a2..ff8bfc1 100755 --- a/src/controlP5/Bang.java +++ b/src/controlP5/Bang.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 * modify it under the terms of the GNU Lesser General Public License diff --git a/src/controlP5/BitFont.java b/src/controlP5/BitFont.java index ee8e5b9..15bec01 100755 --- a/src/controlP5/BitFont.java +++ b/src/controlP5/BitFont.java @@ -2,9 +2,9 @@ package controlP5; /** * 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 * modify it under the terms of the GNU Lesser General Public License * 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 * 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## - * + * + * @author Andreas Schlegel (http://www.sojamo.de) + * @modified ##date## + * @version ##version## + * */ import java.lang.reflect.Constructor; diff --git a/src/controlP5/Button.java b/src/controlP5/Button.java index c257130..f67b1d1 100755 --- a/src/controlP5/Button.java +++ b/src/controlP5/Button.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 modify it under the terms of the GNU Lesser diff --git a/src/controlP5/ButtonBar.java b/src/controlP5/ButtonBar.java index 7ad1011..85c0973 100644 --- a/src/controlP5/ButtonBar.java +++ b/src/controlP5/ButtonBar.java @@ -1,5 +1,32 @@ 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 java.util.ArrayList; diff --git a/src/controlP5/CColor.java b/src/controlP5/CColor.java index ba2ff06..1720a14 100755 --- a/src/controlP5/CColor.java +++ b/src/controlP5/CColor.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 * the terms of the GNU Lesser General Public License as published by the Free diff --git a/src/controlP5/CDrawable.java b/src/controlP5/CDrawable.java index 3c65a5e..9fbe46a 100755 --- a/src/controlP5/CDrawable.java +++ b/src/controlP5/CDrawable.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/CP.java b/src/controlP5/CP.java index 9385df6..1a867ff 100755 --- a/src/controlP5/CP.java +++ b/src/controlP5/CP.java @@ -1,5 +1,30 @@ 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.lang.reflect.Array; import java.net.URLEncoder; @@ -7,8 +32,6 @@ import java.text.CharacterIterator; import java.text.StringCharacterIterator; import java.util.List; -import processing.core.PVector; - public class CP { /** @@ -224,10 +247,7 @@ public class CP { 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 ) { if ( theRect.length == 4 ) { return ( theX > theRect[ 0 ] && theX < theRect[ 2 ] && theY > theRect[ 1 ] && theY < theRect[ 3 ] ); diff --git a/src/controlP5/CallbackEvent.java b/src/controlP5/CallbackEvent.java index 7e90079..7fde0b1 100755 --- a/src/controlP5/CallbackEvent.java +++ b/src/controlP5/CallbackEvent.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 * modify it under the terms of the GNU Lesser General Public License diff --git a/src/controlP5/CallbackListener.java b/src/controlP5/CallbackListener.java index 7d43cf9..f1399ef 100755 --- a/src/controlP5/CallbackListener.java +++ b/src/controlP5/CallbackListener.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/Canvas.java b/src/controlP5/Canvas.java index 78d3ee5..0533214 100755 --- a/src/controlP5/Canvas.java +++ b/src/controlP5/Canvas.java @@ -1,5 +1,30 @@ 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.PGraphics; diff --git a/src/controlP5/Chart.java b/src/controlP5/Chart.java index 3999247..7b77ee6 100755 --- a/src/controlP5/Chart.java +++ b/src/controlP5/Chart.java @@ -1,5 +1,30 @@ 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.LinkedHashMap; diff --git a/src/controlP5/ChartData.java b/src/controlP5/ChartData.java index e102325..45dfafd 100755 --- a/src/controlP5/ChartData.java +++ b/src/controlP5/ChartData.java @@ -1,5 +1,30 @@ 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. */ diff --git a/src/controlP5/ChartDataSet.java b/src/controlP5/ChartDataSet.java index dd6edd0..323ab33 100755 --- a/src/controlP5/ChartDataSet.java +++ b/src/controlP5/ChartDataSet.java @@ -1,5 +1,30 @@ 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.ListIterator; diff --git a/src/controlP5/CheckBox.java b/src/controlP5/CheckBox.java index a29736e..1d9accd 100755 --- a/src/controlP5/CheckBox.java +++ b/src/controlP5/CheckBox.java @@ -1,16 +1,9 @@ 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. * - * 2006-2012 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 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 * columns. items of a checkBox are of type Toggle. diff --git a/src/controlP5/ColorPalette.java b/src/controlP5/ColorPalette.java index b454c44..05fd20e 100644 --- a/src/controlP5/ColorPalette.java +++ b/src/controlP5/ColorPalette.java @@ -1,5 +1,30 @@ 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 > { protected ColorPalette( ControlP5 theControlP5 , ControllerGroup< ? > theParent , String theName , int theX , int theY , int theWidth , int theHeight ) { diff --git a/src/controlP5/ColorPicker.java b/src/controlP5/ColorPicker.java index d6e39b3..468c127 100755 --- a/src/controlP5/ColorPicker.java +++ b/src/controlP5/ColorPicker.java @@ -3,19 +3,21 @@ package controlP5; /** * 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 - * 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. + * 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 + * 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## @@ -169,7 +171,7 @@ public class ColorPicker extends ControlGroup< ColorPicker > { if ( _myPlug != null ) { try { Method method = _myPlug.getClass( ).getMethod( _myPlugName , int.class ); - method.invoke( _myPlug , ( int ) _myValue ); + method.invoke( _myPlug , ( int ) getColorValue( ) ); } catch ( SecurityException ex ) { ex.printStackTrace( ); } catch ( NoSuchMethodException ex ) { diff --git a/src/controlP5/ColorWheel.java b/src/controlP5/ColorWheel.java index 96b3311..c7d1dee 100644 --- a/src/controlP5/ColorWheel.java +++ b/src/controlP5/ColorWheel.java @@ -1,5 +1,30 @@ 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.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 ); 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++ ) { - int dx = ( int ) ( x(center) - x ); + int dx = ( int ) ( x( center ) - x ); double dist = Math.sqrt( dx * dx + dy * dy ); if ( dist >= inner_radius && dist <= outer_radius ) { 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; set( _myCursor , x , y ); setSaturation( t[ 1 ] ); + // TODO resolve rounding error issue as reported here https://github.com/sojamo/controlp5/issues/21 _myColorValue = HSLtoRGB( hsl ); setValue( _myColorValue ); - return this; } diff --git a/src/controlP5/ControlBehavior.java b/src/controlP5/ControlBehavior.java index ac77bf0..25b5c5f 100755 --- a/src/controlP5/ControlBehavior.java +++ b/src/controlP5/ControlBehavior.java @@ -2,9 +2,9 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License * 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 * 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## - * + * + * @author Andreas Schlegel (http://www.sojamo.de) + * @modified ##date## + * @version ##version## + * */ /** diff --git a/src/controlP5/ControlBroadcaster.java b/src/controlP5/ControlBroadcaster.java index dc9d364..04da3ee 100755 --- a/src/controlP5/ControlBroadcaster.java +++ b/src/controlP5/ControlBroadcaster.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/ControlElement.java b/src/controlP5/ControlElement.java index 40ac235..7da0d48 100755 --- a/src/controlP5/ControlElement.java +++ b/src/controlP5/ControlElement.java @@ -1,5 +1,30 @@ 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.RetentionPolicy; diff --git a/src/controlP5/ControlEvent.java b/src/controlP5/ControlEvent.java index 06bd7ff..4f4f16b 100755 --- a/src/controlP5/ControlEvent.java +++ b/src/controlP5/ControlEvent.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/ControlFont.java b/src/controlP5/ControlFont.java index 2864b7f..53d553b 100755 --- a/src/controlP5/ControlFont.java +++ b/src/controlP5/ControlFont.java @@ -2,9 +2,9 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License * 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 * 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## - * + * + * @author Andreas Schlegel (http://www.sojamo.de) + * @modified ##date## + * @version ##version## + * */ import java.util.ArrayList; diff --git a/src/controlP5/ControlGroup.java b/src/controlP5/ControlGroup.java index d1fe3ba..1d77774 100755 --- a/src/controlP5/ControlGroup.java +++ b/src/controlP5/ControlGroup.java @@ -3,23 +3,21 @@ package controlP5; /** * 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 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. + * 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 + * 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## diff --git a/src/controlP5/ControlKey.java b/src/controlP5/ControlKey.java index 176570b..81f930e 100755 --- a/src/controlP5/ControlKey.java +++ b/src/controlP5/ControlKey.java @@ -1,5 +1,30 @@ 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 void keyEvent(); diff --git a/src/controlP5/ControlListener.java b/src/controlP5/ControlListener.java index 940460f..ffc622e 100755 --- a/src/controlP5/ControlListener.java +++ b/src/controlP5/ControlListener.java @@ -2,9 +2,9 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License * 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 * 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## - * + * + * @author Andreas Schlegel (http://www.sojamo.de) + * @modified ##date## + * @version ##version## + * */ /** diff --git a/src/controlP5/ControlP5.java b/src/controlP5/ControlP5.java index 5ba4747..5f6ed0f 100755 --- a/src/controlP5/ControlP5.java +++ b/src/controlP5/ControlP5.java @@ -3,23 +3,21 @@ package controlP5; /** * 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 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. + * 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 + * 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## @@ -98,7 +96,7 @@ public class ControlP5 extends ControlP5Base { /** * @exclude */ - @ControlP5.Invisible public static final String VERSION = "2.2.5";// "##version##"; + @ControlP5.Invisible public static final String VERSION = "2.2.6";// "##version##"; /** * @exclude @@ -954,7 +952,8 @@ public class ControlP5 extends ControlP5Base { public boolean loadProperties( final String theFilePath ) { String path = theFilePath.endsWith( _myProperties.format.getExtension( ) ) ? theFilePath : theFilePath + "." + _myProperties.format.getExtension( ); path = checkPropertiesPath( path ); - File f = new File( path ); + File f = new File( path); + if ( f.exists( ) ) { return _myProperties.load( path ); } @@ -1226,8 +1225,14 @@ public class ControlP5 extends ControlP5Base { /* static helper functions including Object-to-Type * 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 ]; for ( int i = 0 ; i < theParams.length ; i++ ) { @@ -1235,7 +1240,7 @@ public class ControlP5 extends ControlP5Base { cs[ i ] = classmap.containsKey( c ) ? classmap.get( c ) : c; } try { - final Field f = theObject.getClass( ).getDeclaredField( theMember ); + final Field f = theClass.getDeclaredField( theMember ); /* TODO check super */ f.setAccessible( true ); Object o = theParams[ 0 ]; @@ -1257,8 +1262,7 @@ public class ControlP5 extends ControlP5Base { } } catch ( NoSuchFieldException e1 ) { try { - final Method m = theObject.getClass( ).getDeclaredMethod( theMember , cs ); - /* TODO check super */ + final Method m = theClass.getDeclaredMethod( theMember , cs ); m.setAccessible( true ); try { return m.invoke( theObject , theParams ); @@ -1273,7 +1277,7 @@ public class ControlP5 extends ControlP5Base { } catch ( SecurityException e ) { System.err.println( e ); } catch ( NoSuchMethodException e ) { - System.err.println( e ); + invoke( theObject , theClass.getSuperclass( ) , theMember , theParams ); } } catch ( IllegalArgumentException e ) { System.err.println( e ); diff --git a/src/controlP5/ControlP5Base.java b/src/controlP5/ControlP5Base.java index b2f36cf..f2caed7 100755 --- a/src/controlP5/ControlP5Base.java +++ b/src/controlP5/ControlP5Base.java @@ -3,23 +3,21 @@ package controlP5; /** * 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 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. + * 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 + * 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## @@ -39,7 +37,6 @@ import java.util.Set; import java.util.TreeSet; import processing.core.PApplet; -import processing.core.PVector; import processing.event.Event; import static controlP5.Controller.*; diff --git a/src/controlP5/ControlP5Constants.java b/src/controlP5/ControlP5Constants.java index 5414d92..e4f93d9 100755 --- a/src/controlP5/ControlP5Constants.java +++ b/src/controlP5/ControlP5Constants.java @@ -3,29 +3,28 @@ package controlP5; /** * 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 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. + * 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 + * 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; /** diff --git a/src/controlP5/ControlP5Legacy.java b/src/controlP5/ControlP5Legacy.java index e91d186..63ecaa0 100644 --- a/src/controlP5/ControlP5Legacy.java +++ b/src/controlP5/ControlP5Legacy.java @@ -1,5 +1,30 @@ 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 processing.core.PApplet; diff --git a/src/controlP5/ControlTimer.java b/src/controlP5/ControlTimer.java index cba5d05..5a93fb4 100755 --- a/src/controlP5/ControlTimer.java +++ b/src/controlP5/ControlTimer.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/ControlWindow.java b/src/controlP5/ControlWindow.java index 5c329ca..968d172 100755 --- a/src/controlP5/ControlWindow.java +++ b/src/controlP5/ControlWindow.java @@ -2,9 +2,9 @@ package controlP5; /** * 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 modify it under the terms of the GNU Lesser * General Public License as published by the Free Software @@ -15,16 +15,16 @@ package controlP5; * 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; @@ -34,7 +34,6 @@ import java.util.concurrent.CopyOnWriteArrayList; import processing.core.PApplet; import processing.core.PConstants; import processing.core.PGraphics; -import processing.core.PVector; import processing.event.KeyEvent; import processing.event.MouseEvent; import controlP5.ControlP5Base.KeyCode; @@ -62,10 +61,10 @@ public final class ControlWindow { protected List< Canvas > _myCanvas; protected boolean isDrawBackground = true; 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 boolean rendererNotification = false; - protected PVector positionOfTabs = new PVector( 0 , 0 , 0 ); + protected float[] positionOfTabs = new float[]{ 0 , 0 , 0 }; private int _myFrameCount = 0; private boolean isMouse = true; private Pointer _myPointer; @@ -82,7 +81,8 @@ public final class ControlWindow { protected boolean mouselock; protected char key; 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 boolean focused = true; @@ -195,29 +195,18 @@ public final class ControlWindow { /** * Sets the position of the tab bar which is set to 0,0 * by default. to move the tabs to y-position 100, use - * cp5.getWindow().setPositionOfTabs(new PVector(0,100,0)); - * - * @param thePVector + * cp5.getWindow().setPositionOfTabs(0,100); + * */ - public ControlWindow setPositionOfTabs( PVector thePVector ) { - positionOfTabs.set( thePVector ); - return this; - } public ControlWindow setPositionOfTabs( int theX , int theY ) { - positionOfTabs.set( theX , theY , positionOfTabs.z ); + positionOfTabs[0] = theX; + positionOfTabs[1] = theY; return this; } - /** - * Returns the position of the tab bar as PVector. to - * 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( ) { + + public float[] getPositionOfTabs( ) { return positionOfTabs; } @@ -341,7 +330,7 @@ public final class ControlWindow { /** * updates all controllers inside the control window if * update is enabled. - * + * * @exclude */ public void update( ) { @@ -508,7 +497,7 @@ public final class ControlWindow { } public void clearKeys( ) { - keys = new boolean[ 525 ]; + keys = new boolean[ numKeys ]; numOfActiveKeys = 0; } @@ -566,8 +555,8 @@ public final class ControlWindow { pg.noStroke( ); pg.noFill( ); - int myOffsetX = ( int ) getPositionOfTabs( ).x; - int myOffsetY = ( int ) getPositionOfTabs( ).y; + int myOffsetX = ( int ) getPositionOfTabs( )[0]; + int myOffsetY = ( int ) getPositionOfTabs( )[1]; int myHeight = 0; if ( _myTabs.size( ) > 0 ) { @@ -632,7 +621,7 @@ public final class ControlWindow { /** * Adds a custom context to a ControlWindow. Use a * custom class which implements the CDrawable interface - * + * * @see controlP5.CDrawable * @param theDrawable CDrawable */ @@ -795,7 +784,7 @@ public final class ControlWindow { /** * sets the frame rate of the control window. - * + * * @param theFrameRate * @return ControlWindow */ @@ -814,7 +803,7 @@ public final class ControlWindow { * filled with a background color every frame. to enable * or disable the background from drawing, use * setDrawBackgorund(true/false). - * + * * @param theFlag * @return ControlWindow */ diff --git a/src/controlP5/ControlWindowCanvas.java b/src/controlP5/ControlWindowCanvas.java index 45c2924..2a322aa 100755 --- a/src/controlP5/ControlWindowCanvas.java +++ b/src/controlP5/ControlWindowCanvas.java @@ -4,7 +4,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/Controller.java b/src/controlP5/Controller.java index 05f1762..78ffc0c 100755 --- a/src/controlP5/Controller.java +++ b/src/controlP5/Controller.java @@ -1,17 +1,23 @@ 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 - * 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. + * 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 + * 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## @@ -26,9 +32,9 @@ import java.util.List; import java.util.Map; import processing.core.PApplet; +import processing.core.PFont; import processing.core.PGraphics; import processing.core.PImage; -import processing.core.PVector; import processing.event.KeyEvent; /** @@ -270,8 +276,7 @@ public abstract class Controller< T > implements ControllerInterface< T > , CDra } protected void updateFont( ControlFont theControlFont ) { - _myCaptionLabel.updateFont( theControlFont ); - _myValueLabel.updateFont( theControlFont ); + setFont( theControlFont ); } /** @@ -413,15 +418,7 @@ public abstract class Controller< T > implements ControllerInterface< T > , CDra return me; } - /** - * @return {@link PVector} - */ 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; } @@ -2213,4 +2210,16 @@ public abstract class Controller< T > implements ControllerInterface< T > , CDra 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; + } + } diff --git a/src/controlP5/ControllerAutomator.java b/src/controlP5/ControllerAutomator.java index 297d4e6..25b0863 100755 --- a/src/controlP5/ControllerAutomator.java +++ b/src/controlP5/ControllerAutomator.java @@ -2,9 +2,9 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License * 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 * 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## - * + * + * @author Andreas Schlegel (http://www.sojamo.de) + * @modified ##date## + * @version ##version## + * */ import java.lang.reflect.Field; @@ -104,16 +104,16 @@ class ControllerAutomator { * */ void addControllersFor( final String theAddressSpace , final Object t ) { - + System.out.println("OKOK"); if ( t instanceof List< ? > ) { return; } 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 >( ); diff --git a/src/controlP5/ControllerDisplay.java b/src/controlP5/ControllerDisplay.java index ec82be0..768ace2 100755 --- a/src/controlP5/ControllerDisplay.java +++ b/src/controlP5/ControllerDisplay.java @@ -2,9 +2,9 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License * 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 * 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## - * + * + * @author Andreas Schlegel (http://www.sojamo.de) + * @modified ##date## + * @version ##version## + * */ import processing.core.PApplet; diff --git a/src/controlP5/ControllerGroup.java b/src/controlP5/ControllerGroup.java index 6c1a5af..86bafed 100755 --- a/src/controlP5/ControllerGroup.java +++ b/src/controlP5/ControllerGroup.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.List; import processing.core.PApplet; +import processing.core.PFont; import processing.core.PGraphics; import processing.event.KeyEvent; @@ -260,8 +261,8 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > , return me; } - public T setPosition( float[] thePVector ) { - setPosition( x( thePVector ) , y( thePVector ) ); + public T setPosition( float[] thePosition ) { + setPosition( x( thePosition ) , y( thePosition ) ); return me; } @@ -954,4 +955,16 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > , 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; + } + } diff --git a/src/controlP5/ControllerInterface.java b/src/controlP5/ControllerInterface.java index 9c7bf5b..6a4a355 100755 --- a/src/controlP5/ControllerInterface.java +++ b/src/controlP5/ControllerInterface.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License @@ -26,6 +26,7 @@ package controlP5; */ import processing.core.PApplet; +import processing.core.PFont; import processing.core.PGraphics; 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[] thePVector ); + @ControlP5.Invisible public T setPosition( float[] thePosition ); public float[] getAbsolutePosition( ); - public T setAbsolutePosition( float[] thePVector ); + public T setAbsolutePosition( float[] thePosition ); public T updateAbsolutePosition( ); @@ -163,7 +164,11 @@ public interface ControllerInterface< T > { public boolean isMouseOver( ); public T setMouseOver( boolean theFlag ); - + + public T setFont( PFont theFont ); + + public T setFont( ControlFont theFont ); + public T addListener( ControlListener theListener ); public T setCaptionLabel( String theValue ); diff --git a/src/controlP5/ControllerLayout.java b/src/controlP5/ControllerLayout.java index c25e0e1..cc757f4 100755 --- a/src/controlP5/ControllerLayout.java +++ b/src/controlP5/ControllerLayout.java @@ -1,5 +1,30 @@ 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.FileOutputStream; import java.io.ObjectInputStream; @@ -11,7 +36,6 @@ import java.util.HashSet; import java.util.Map; import java.util.logging.Logger; -import processing.core.PVector; class ControllerLayout { @@ -28,7 +52,6 @@ class ControllerLayout { datatypes.put( Long.class , long.class ); datatypes.put( Double.class , double.class ); datatypes.put( Byte.class , byte.class ); - datatypes.put( PVector.class , PVector.class ); datatypes.put( CColor.class , CColor.class ); } diff --git a/src/controlP5/ControllerLayoutElement.java b/src/controlP5/ControllerLayoutElement.java index 35c8690..d59b07f 100755 --- a/src/controlP5/ControllerLayoutElement.java +++ b/src/controlP5/ControllerLayoutElement.java @@ -1,5 +1,30 @@ 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.util.HashMap; import java.util.Map; diff --git a/src/controlP5/ControllerList.java b/src/controlP5/ControllerList.java index c0305af..ddc9f78 100755 --- a/src/controlP5/ControllerList.java +++ b/src/controlP5/ControllerList.java @@ -2,9 +2,9 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License * 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 * 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## - * + * + * @author Andreas Schlegel (http://www.sojamo.de) + * @modified ##date## + * @version ##version## + * */ import java.util.List; diff --git a/src/controlP5/ControllerPlug.java b/src/controlP5/ControllerPlug.java index 2bd66be..9c350b1 100755 --- a/src/controlP5/ControllerPlug.java +++ b/src/controlP5/ControllerPlug.java @@ -2,9 +2,9 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License * 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 * 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## - * + * + * @author Andreas Schlegel (http://www.sojamo.de) + * @modified ##date## + * @version ##version## + * */ import java.lang.reflect.Method; diff --git a/src/controlP5/ControllerProperties.java b/src/controlP5/ControllerProperties.java index 7dcd86d..bd80412 100755 --- a/src/controlP5/ControllerProperties.java +++ b/src/controlP5/ControllerProperties.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License @@ -35,6 +35,7 @@ import java.io.ObjectOutputStream; import java.io.StringReader; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -70,6 +71,8 @@ public class ControllerProperties { public final static int OPEN = 0; public final static int CLOSE = 1; public static String defaultName = "controlP5"; + + PropertiesStorageFormat format; /** @@ -420,14 +423,7 @@ public class ControllerProperties { for ( ControllerProperty cp : l ) { ControllerInterface< ? > ci = controlP5.getController( cp.getAddress( ) ); ci = ( ci == null ) ? controlP5.getGroup( cp.getAddress( ) ) : ci; - Method method; - 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( ) ); - } + ControlP5.invoke( ( Controller ) ci , cp.getSetter( ) , cp.getValue( ) ); } } return this; @@ -451,7 +447,7 @@ public class ControllerProperties { public boolean load( String thePropertiesPath ) { return format.load( getPathWithExtension( format , controlP5.checkPropertiesPath( thePropertiesPath ) ) ); } - + /** * 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. */ 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 ) ) ); 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 ) { long t = System.currentTimeMillis( ); JSONObject json = new JSONObject( ); for ( ControllerProperty cp : theProperties ) { + if ( cp.isActive( ) ) { if ( updatePropertyValue( cp ) ) { cp.setId( cp.getController( ).getId( ) ); @@ -714,7 +712,22 @@ public class ControllerProperties { } else if ( cp.getValue( ) instanceof Boolean ) { item.setBoolean( key , ControlP5.b( cp.getValue( ) ) ); } 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( ) ) ); } else if ( i1 instanceof String ) { ControlP5.invoke( c , member , ControlP5.s( value.getValue( ) ) ); + } else if ( i1 instanceof float[] ) { + ControlP5.invoke( c , member , (float[])i1 ); } 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 ) { try { diff --git a/src/controlP5/ControllerProperty.java b/src/controlP5/ControllerProperty.java index fd94f8a..f068fe6 100755 --- a/src/controlP5/ControllerProperty.java +++ b/src/controlP5/ControllerProperty.java @@ -1,5 +1,30 @@ 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; /** @@ -11,21 +36,13 @@ import java.io.Serializable; public class ControllerProperty implements Serializable , Cloneable { private static final long serialVersionUID = 4506431150330867327L; - private String setter; - private String getter; - private Class< ? > type; - private Object value; - private String address; - private int id; - private transient boolean active; - private transient ControllerInterface< ? > controller; ControllerProperty( ControllerInterface< ? > theController , String theSetter , String theGetter ) { @@ -37,8 +54,7 @@ public class ControllerProperty implements Serializable , Cloneable { setId( theController.getId( ) ); } - @Override - protected Object clone( ) throws CloneNotSupportedException { + @Override protected Object clone( ) throws CloneNotSupportedException { ControllerProperty clone = ( ControllerProperty ) super.clone( ); clone.setSetter( getSetter( ) ); clone.setGetter( getGetter( ) ); @@ -54,8 +70,7 @@ public class ControllerProperty implements Serializable , Cloneable { /** * @exclude {@inheritDoc} */ - @Override - public boolean equals( Object o ) { + @Override public boolean equals( Object o ) { if ( this == o ) { return true; @@ -74,8 +89,7 @@ public class ControllerProperty implements Serializable , Cloneable { /** * @exclude {@inheritDoc} */ - @Override - public int hashCode( ) { + @Override public int hashCode( ) { int result = 17; result = 37 * result + ( address != null ? address.hashCode( ) : 0 ); result = 37 * result + ( setter != null ? setter.hashCode( ) : 0 ); @@ -91,8 +105,7 @@ public class ControllerProperty implements Serializable , Cloneable { active = true; } - @Override - public String toString( ) { + @Override public String toString( ) { return address + " " + setter + ", " + getter; } diff --git a/src/controlP5/ControllerStyle.java b/src/controlP5/ControllerStyle.java index 671d636..b4b85f7 100755 --- a/src/controlP5/ControllerStyle.java +++ b/src/controlP5/ControllerStyle.java @@ -1,23 +1,23 @@ package controlP5; -import java.io.Serializable; - /** * 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 - * 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. + * 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 + * 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## @@ -25,6 +25,9 @@ import java.io.Serializable; * */ +import java.io.Serializable; + + /** * Labels use the ControllerStyle class to store margin and padding information. * diff --git a/src/controlP5/ControllerView.java b/src/controlP5/ControllerView.java index 5693e28..ca0f9d7 100755 --- a/src/controlP5/ControllerView.java +++ b/src/controlP5/ControllerView.java @@ -2,9 +2,9 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License * 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 * 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## - * + * + * @author Andreas Schlegel (http://www.sojamo.de) + * @modified ##date## + * @version ##version## + * */ import processing.core.PGraphics; diff --git a/src/controlP5/DropdownList.java b/src/controlP5/DropdownList.java index 4276467..9e276bf 100755 --- a/src/controlP5/DropdownList.java +++ b/src/controlP5/DropdownList.java @@ -16,7 +16,7 @@ import processing.event.KeyEvent; /** * 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 the terms of the GNU Lesser General Public License @@ -127,24 +127,26 @@ public class DropdownList extends Controller< DropdownList > implements ControlL // n += itemRange; /* UP */ int index = ( int ) n + itemIndexOffset; - Map m = items.get( index ); - - switch ( _myType ) { - case ( LIST ): - setValue( index ); - for ( Object o : items ) { - ( ( Map ) o ).put( "state" , false ); + if (index < items.size()) { + Map m = items.get( index ); + + switch ( _myType ) { + case ( LIST ): + setValue( index ); + 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; } } @@ -461,4 +463,4 @@ public class DropdownList extends Controller< DropdownList > implements ControlL } /* TODO keycontrol: arrows, return dragging moving items * sorting custom view custom event types */ -} +} \ No newline at end of file diff --git a/src/controlP5/FieldChangedListener.java b/src/controlP5/FieldChangedListener.java index 8ab2252..1ba3663 100755 --- a/src/controlP5/FieldChangedListener.java +++ b/src/controlP5/FieldChangedListener.java @@ -1,5 +1,30 @@ 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; /** diff --git a/src/controlP5/FrameRate.java b/src/controlP5/FrameRate.java index 4610f2e..b816618 100755 --- a/src/controlP5/FrameRate.java +++ b/src/controlP5/FrameRate.java @@ -1,5 +1,30 @@ 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.PGraphics; diff --git a/src/controlP5/Group.java b/src/controlP5/Group.java index fdcff46..fb661d1 100755 --- a/src/controlP5/Group.java +++ b/src/controlP5/Group.java @@ -1,5 +1,29 @@ 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 > { /** diff --git a/src/controlP5/Icon.java b/src/controlP5/Icon.java index c754728..efb8781 100644 --- a/src/controlP5/Icon.java +++ b/src/controlP5/Icon.java @@ -1,5 +1,30 @@ 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.PFont; import processing.core.PGraphics; diff --git a/src/controlP5/Knob.java b/src/controlP5/Knob.java index 2bf536a..880f1fe 100755 --- a/src/controlP5/Knob.java +++ b/src/controlP5/Knob.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/Label.java b/src/controlP5/Label.java index 1e756d6..a7f75b8 100755 --- a/src/controlP5/Label.java +++ b/src/controlP5/Label.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser @@ -41,6 +41,7 @@ import processing.core.PGraphics; */ public class Label implements CDrawable { + public static boolean isToUpperCaseDefault = true; protected int _myLetterSpacing = 0; protected boolean isMultiline; protected boolean isFixedSize; @@ -48,7 +49,7 @@ public class Label implements CDrawable { protected boolean isVisible = true; protected int _myColor = 0xffffffff; protected boolean isColorBackground; - protected boolean isToUpperCase = true; + protected boolean isToUpperCase = isToUpperCaseDefault; protected boolean changed; protected int _myColorBackground = 0xffffffff; protected int _myHeight = -1; @@ -407,13 +408,23 @@ public class Label implements CDrawable { return new Label( this ); } + + public static void setUpperCaseDefault( boolean theValue ) { + isToUpperCaseDefault = theValue; + } + 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 , int theW , int theH ); + public int getWidth( ); + public int getHeight( ); + public int getOverflow( ); + public String getTextFormatted( ); } diff --git a/src/controlP5/ListBox.java b/src/controlP5/ListBox.java index 2612e9a..57c8a05 100755 --- a/src/controlP5/ListBox.java +++ b/src/controlP5/ListBox.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/Matrix.java b/src/controlP5/Matrix.java index 593bdf4..57e58b4 100755 --- a/src/controlP5/Matrix.java +++ b/src/controlP5/Matrix.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/MultiList.java b/src/controlP5/MultiList.java index 2dc24d7..e9c3237 100755 --- a/src/controlP5/MultiList.java +++ b/src/controlP5/MultiList.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/MultiListButton.java b/src/controlP5/MultiListButton.java index bf6ff8d..852189a 100755 --- a/src/controlP5/MultiListButton.java +++ b/src/controlP5/MultiListButton.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/MultiListInterface.java b/src/controlP5/MultiListInterface.java index 23cf605..3509731 100755 --- a/src/controlP5/MultiListInterface.java +++ b/src/controlP5/MultiListInterface.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/Numberbox.java b/src/controlP5/Numberbox.java index 3069014..313580b 100755 --- a/src/controlP5/Numberbox.java +++ b/src/controlP5/Numberbox.java @@ -2,9 +2,9 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License * 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 * 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## - * + * + * @author Andreas Schlegel (http://www.sojamo.de) + * @modified ##date## + * @version ##version## + * */ import processing.core.PApplet; diff --git a/src/controlP5/Pad.java b/src/controlP5/Pad.java index 30b3028..382cd3d 100755 --- a/src/controlP5/Pad.java +++ b/src/controlP5/Pad.java @@ -1,5 +1,30 @@ 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 Pad { // pad for placing controllers, like matrix but without the grid // a sequencer diff --git a/src/controlP5/Pointer.java b/src/controlP5/Pointer.java index 9620923..c8ba02b 100755 --- a/src/controlP5/Pointer.java +++ b/src/controlP5/Pointer.java @@ -1,5 +1,30 @@ 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 Pointer { public int x(); diff --git a/src/controlP5/Println.java b/src/controlP5/Println.java index 183495d..787866e 100755 --- a/src/controlP5/Println.java +++ b/src/controlP5/Println.java @@ -1,6 +1,31 @@ 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.IOException; import java.io.PipedInputStream; import java.io.PipedOutputStream; diff --git a/src/controlP5/Radio.java b/src/controlP5/Radio.java index 12e0b34..31c1c91 100755 --- a/src/controlP5/Radio.java +++ b/src/controlP5/Radio.java @@ -1,5 +1,30 @@ 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## + * + */ + /* * Backwards compatibility, cp5magic for example uses it. * But if possible, upgrade to RadioButton diff --git a/src/controlP5/RadioButton.java b/src/controlP5/RadioButton.java index 6857b65..e2aff5a 100755 --- a/src/controlP5/RadioButton.java +++ b/src/controlP5/RadioButton.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/Range.java b/src/controlP5/Range.java index 606e8f0..255e28c 100755 --- a/src/controlP5/Range.java +++ b/src/controlP5/Range.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License @@ -29,8 +29,8 @@ import java.util.ArrayList; import java.util.logging.Level; import processing.core.PApplet; +import processing.core.PFont; import processing.core.PGraphics; -import processing.core.PVector; import controlP5.ControlP5.Invisible; /** @@ -66,7 +66,7 @@ public class Range extends Controller< Range > { protected boolean isSnapToTickMarks; public static int autoWidth = 99; public static int autoHeight = 9; - public static PVector autoSpacing = new PVector( 0 , 5 , 0 ); + public static float[] autoSpacing = new float[]{ 0 , 5 , 0 }; public int alignValueLabel = CENTER; protected int _myColorTickMark = 0xffffffff; private int mode = -1; @@ -489,7 +489,17 @@ public class Range extends Controller< Range > { } } + + @Override public Range setFont( PFont thePFont ) { + _myHighValueLabel.setFont( thePFont ); + return super.setFont( thePFont ); + } + @Override public Range setFont( ControlFont theFont ) { + _myHighValueLabel.setFont( theFont ); + return super.setFont( theFont ); + } + @Override @ControlP5.Invisible public String toString( ) { return "type:\tRange\n" + super.toString( ); } diff --git a/src/controlP5/ScrollableList.java b/src/controlP5/ScrollableList.java index 54fe575..eba6931 100644 --- a/src/controlP5/ScrollableList.java +++ b/src/controlP5/ScrollableList.java @@ -1,5 +1,30 @@ 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 java.util.ArrayList; @@ -13,33 +38,6 @@ import processing.core.PApplet; import processing.core.PGraphics; import processing.event.KeyEvent; -/** - * controlP5 is a processing gui library. - * - * 2006-2012 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## - * - */ - /** * A ScrollableList is a list of vertically aligned items * which can be scrolled if required. diff --git a/src/controlP5/Slider.java b/src/controlP5/Slider.java index 36ce80d..4a55331 100755 --- a/src/controlP5/Slider.java +++ b/src/controlP5/Slider.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/Slider2D.java b/src/controlP5/Slider2D.java index fa661c9..6980bc7 100755 --- a/src/controlP5/Slider2D.java +++ b/src/controlP5/Slider2D.java @@ -1,5 +1,30 @@ 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.PGraphics; diff --git a/src/controlP5/Spacer.java b/src/controlP5/Spacer.java index 93457bc..f7b384a 100644 --- a/src/controlP5/Spacer.java +++ b/src/controlP5/Spacer.java @@ -1,5 +1,30 @@ 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.PGraphics; public class Spacer extends Controller< Spacer > { diff --git a/src/controlP5/Tab.java b/src/controlP5/Tab.java index 58acd1f..9309e14 100755 --- a/src/controlP5/Tab.java +++ b/src/controlP5/Tab.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/Textarea.java b/src/controlP5/Textarea.java index 260b8db..fb01036 100755 --- a/src/controlP5/Textarea.java +++ b/src/controlP5/Textarea.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/Textfield.java b/src/controlP5/Textfield.java index b71e983..b42957c 100755 --- a/src/controlP5/Textfield.java +++ b/src/controlP5/Textfield.java @@ -1,21 +1,9 @@ package controlP5; -import java.util.Arrays; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import processing.core.PApplet; -import processing.core.PFont; -import processing.core.PGraphics; -import processing.event.Event; -import processing.event.KeyEvent; - /** * 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 the terms of the GNU Lesser General Public License @@ -37,6 +25,19 @@ import processing.event.KeyEvent; * */ +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import processing.core.PApplet; +import processing.core.PFont; +import processing.core.PGraphics; +import processing.event.Event; +import processing.event.KeyEvent; + + /** * A singleline input textfield, use arrow keys to go back and forth, use backspace to delete * characters. Using the up and down arrows lets you cycle through the history of the textfield. @@ -109,7 +110,7 @@ public class Textfield extends Controller< Textfield > { public Textfield( ControlP5 theControlP5 , ControllerGroup< ? > theParent , String theName , String theDefaultValue , int theX , int theY , int theWidth , int theHeight ) { super( theControlP5 , theParent , theName , theX , theY , theWidth , theHeight ); - _myCaptionLabel = new Label( cp5 , theName.toUpperCase( ) , 0 , 0 , color.getCaptionLabel( ) ); + _myCaptionLabel = new Label( cp5 , theName , 0 , 0 , color.getCaptionLabel( ) ); _myValueLabel.setFont( cp5.controlFont == cp5.defaultFont ? cp5.defaultFontForText : cp5.controlFont ); _myCaptionLabel.align( ControlP5.LEFT , ControlP5.BOTTOM_OUTSIDE ); _myCaptionLabel.setPaddingX( 0 ); @@ -183,15 +184,15 @@ public class Textfield extends Controller< Textfield > { return this; } - public Textfield setFont( PFont thePFont ) { - getValueLabel( ).setFont( thePFont ); - return this; - } - - public Textfield setFont( ControlFont theFont ) { - getValueLabel( ).setFont( theFont ); - return this; - } +// public Textfield setFont( PFont thePFont ) { +// getValueLabel( ).setFont( thePFont ); +// return this; +// } +// +// public Textfield setFont( ControlFont theFont ) { +// getValueLabel( ).setFont( theFont ); +// return this; +// } public Textfield setFont( int theFont ) { getValueLabel( ).setFont( theFont ); diff --git a/src/controlP5/Textlabel.java b/src/controlP5/Textlabel.java index e0adec1..f0742ba 100755 --- a/src/controlP5/Textlabel.java +++ b/src/controlP5/Textlabel.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/TickMark.java b/src/controlP5/TickMark.java index 7691071..2ff66fb 100755 --- a/src/controlP5/TickMark.java +++ b/src/controlP5/TickMark.java @@ -2,9 +2,9 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 @@ -13,18 +13,17 @@ package controlP5; * 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## - * + * + * @author Andreas Schlegel (http://www.sojamo.de) + * @modified ##date## + * @version ##version## + * */ - import processing.core.PApplet; import processing.core.PGraphics; diff --git a/src/controlP5/Toggle.java b/src/controlP5/Toggle.java index 11bf4f4..490791d 100755 --- a/src/controlP5/Toggle.java +++ b/src/controlP5/Toggle.java @@ -3,7 +3,7 @@ package controlP5; /** * 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 the terms of the GNU Lesser General Public License diff --git a/src/controlP5/Tooltip.java b/src/controlP5/Tooltip.java index 3fac96d..041d2a1 100755 --- a/src/controlP5/Tooltip.java +++ b/src/controlP5/Tooltip.java @@ -1,11 +1,35 @@ 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.Map; import processing.core.PApplet; import processing.core.PGraphics; -import processing.core.PVector; /** * A tooltip can be registered for individual controllers @@ -17,10 +41,10 @@ import processing.core.PVector; public class Tooltip { private ControllerView< ? > _myView; - private PVector position = new PVector( ); - private PVector currentPosition = new PVector( ); - private PVector previousPosition = new PVector( ); - private PVector offset = new PVector( ); + private float[] position = new float[3]; + private float[] currentPosition = new float[3]; + private float[] previousPosition = new float[3]; + private float[] offset = new float[3]; private Controller< ? > _myController; private long startTime = 0; private long _myDelayInMillis = 500; @@ -39,10 +63,11 @@ public class Tooltip { Tooltip( ControlP5 theControlP5 ) { cp5 = theControlP5; - position = new PVector( -1000 , -1000 ); - currentPosition = new PVector( ); - previousPosition = new PVector( ); - offset = new PVector( 0 , 24 , 0 ); + position[0] = -1000; + position[1] = -1000; + currentPosition = new float[3]; + previousPosition = new float[3]; + offset = new float[] { 0 , 24 , 0 }; map = new HashMap< Controller< ? > , String >( ); _myLabel = new Label( cp5 , "tooltip" ); _myLabel.setColor( _myColor ); @@ -103,83 +128,11 @@ public class Tooltip { * @param theWindow */ void draw( ControlWindow theWindow ) { - /* - if ( enabled ) { - - if ( _myMode >= ControlP5.WAIT ) { - - previousPosition.set( currentPosition ); - currentPosition.set( theWindow.mouseX , theWindow.mouseY , 0 ); - - if ( _myController != null ) { - if ( _myController.getControlWindow( ).equals( theWindow ) ) { - switch ( _myMode ) { - case ( ControlP5.WAIT ): - if ( moved( ) ) { - startTime = System.nanoTime( ); - } - - if ( System.nanoTime( ) > startTime + ( _myDelayInMillis * 1000000 ) ) { - - position.set( currentPosition ); - _myAlignH = ControlP5.RIGHT; - if ( position.x > ( _myController.getControlWindow( ).papplet( ).width - ( getWidth( ) + 20 ) ) ) { - position.sub( new PVector( getWidth( ) , 0 , 0 ) ); - _myAlignH = ControlP5.LEFT; - } - _myMode = ControlP5.FADEIN; - startTime = System.nanoTime( ); - _myAlpha = 0; - } - break; - case ( ControlP5.FADEIN ): - float t1 = System.nanoTime( ) - startTime; - _myAlpha = ( int ) PApplet.map( t1 , 0 , 200 * 1000000 , 0 , _myMaxAlpha ); - if ( _myAlpha >= 250 ) { - _myMode = ControlP5.IDLE; - _myAlpha = 255; - } - break; - case ( ControlP5.IDLE ): - break; - case ( ControlP5.FADEOUT ): - float t2 = System.nanoTime( ) - startTime; - _myAlpha = ( int ) PApplet.map( t2 , 0 , 200 * 1000000 , _myMaxAlpha , 0 ); - if ( _myAlpha <= 0 ) { - _myMode = ControlP5.DONE; - } - break; - case ( ControlP5.DONE ): - _myController = null; - _myMode = ControlP5.INACTIVE; - position.set( -1000 , -1000 , 0 ); - } - - _myAlpha = PApplet.max( 0 , PApplet.min( _myAlpha , _myMaxAlpha ) ); - - if ( _myMode >= ControlP5.WAIT ) { - _myAlpha = ( _myMode == ControlP5.WAIT ) ? 0 : _myAlpha; - theWindow.papplet( ).pushMatrix( ); - theWindow.papplet( ).translate( position.x , position.y ); - theWindow.papplet( ).translate( offset.x , offset.y ); - // TODO should request the current PGraphics element, not only the PApplet context. What if we render into a PGraphics buffer? - _myView.display( theWindow.papplet( ).g , null ); - theWindow.papplet( ).popMatrix( ); - } - if ( _myMode < ControlP5.FADEOUT ) { - if ( moved( ) ) { - deactivate( 0 ); - } - } - } - } - } - } - */ + // TODO re-implement Tooltip } private boolean moved( ) { - return PApplet.abs( PApplet.dist( previousPosition.x , previousPosition.y , currentPosition.x , currentPosition.y ) ) > 1; + return PApplet.abs( PApplet.dist( previousPosition[0] , previousPosition[1] , currentPosition[0] , currentPosition[1] ) ) > 1; } /** @@ -206,7 +159,8 @@ public class Tooltip { if ( map.containsKey( theController ) ) { startTime = System.nanoTime( ); _myController = theController; - currentPosition.set( theController.getControlWindow( ).mouseX , theController.getControlWindow( ).mouseY , 0 ); + currentPosition[0] = theController.getControlWindow( ).mouseX; + currentPosition[1] = theController.getControlWindow( ).mouseY; updateText( map.get( _myController ) ); _myMode = ControlP5.WAIT; } @@ -329,8 +283,8 @@ public class Tooltip { * @return Tooltip */ public Tooltip setPositionOffset( float theX , float theY ) { - offset.x = theX; - offset.y = theY; + offset[0] = theX; + offset[1] = theY; return this; } diff --git a/src/controlP5/changeLog.txt b/src/controlP5/changeLog.txt index f61d134..5b318b4 100755 --- a/src/controlP5/changeLog.txt +++ b/src/controlP5/changeLog.txt @@ -1,3 +1,12 @@ +2016-14-04 Andreas Schlegel + + mostly bug fixes, see github issues + removed all PVector references, variables, and functions using processing.core.PVector + +2015-08-02 Andreas Schlegel + + changes see github change log + 2015-03-29 Andreas Schlegel * src controlP5.ScrollabelList: