Question about controlP5 abilities???
in
Contributed Library Questions
•
1 month ago
I have jst started playing with controlP5 library and what a fantastic library... However I might be asking to much from the library. I am not sure. Using the following sample sketch I have two questions.
1. How do you position the multiple Frames/Windows created by controlP5?
2. How does one setup separate processing applets for the three Frames/Windows created by controlP5?
Any help would be greatly apreciated as I am very new to this library...
Thanks
Ron
Sample Code:
- // Library Files Installed ================================
- // For controlP5 function==========>
- import java.awt.Frame;
- import java.awt.BorderLayout;
- import controlP5.*;
- //End Libraries //=========================================
- // Inialization Files and what they are used for.==========
- //private ControlP5 cp5;
- private ControlP5 cp5;
- ControlFrame cf1, cf2, cf3;
- // Variables Used and what they are used for.===============
- // End of Variable List.
- // Main Frame Setup applications.===========================
- void setup() {
- size(1900, 500);
- cp5 = new ControlP5(this);
- cf1 = addControlFrame("GPS Position", 600,480);
- cf2 = addControlFrame("Flight Camera", 600,480);
- cf3 = addControlFrame("Flight Data", 600,480);
- }
- // End Main Setup //
- void draw() {
- background(40);
- }
- //=============================================================
- 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(1300, 5);
- f.setResizable(false);
- f.setVisible(true);
- return p;
- }
- //==================================================================
- public class ControlFrame extends PApplet {
- int w, h;
- int zoom = 30000;
- public void setup() {
- size(w, h);
- frameRate(25);
- // Slider control for Map Zoom. ===========>
- cp5 = new ControlP5(this);
- cp5.addSlider("zoom")
- .setRange(30000, 4000000)
- .setPosition(10,420)
- .setSize(500,25)
- .setWidth(550);
- }
- public void draw() {
- background(40);
- // Sample script for applet...
- fill(100, 255, 100);
- ellipse(300, 240, 100, 100);
- }
- private ControlFrame() {
- }
- public ControlFrame(Object theParent, int theWidth, int theHeight) {
- parent = theParent;
- w = theWidth;
- h = theHeight;
- }
- public ControlP5 control() {
- return cp5;
- }
- ControlP5 cp5;
- Object parent;
- }
1