mirror of
https://github.com/sojamo/controlp5
synced 2024-11-22 14:07:55 +01:00
402 lines
12 KiB
HTML
402 lines
12 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<!-- NewPage -->
|
|
<html lang="en">
|
|
<head>
|
|
<!-- Generated by javadoc (version 1.7.0_51) on Sun Apr 27 21:39:47 SGT 2014 -->
|
|
<title>ControllerPlug (Javadocs: controlP5)</title>
|
|
<meta name="date" content="2014-04-27">
|
|
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript"><!--
|
|
if (location.href.indexOf('is-external=true') == -1) {
|
|
parent.document.title="ControllerPlug (Javadocs: controlP5)";
|
|
}
|
|
//-->
|
|
</script>
|
|
<noscript>
|
|
<div>JavaScript is disabled on your browser.</div>
|
|
</noscript>
|
|
<!-- ========= START OF TOP NAVBAR ======= -->
|
|
<div class="topNav"><a name="navbar_top">
|
|
<!-- -->
|
|
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="navList" title="Navigation">
|
|
<li><a href="../controlP5/package-summary.html">Package</a></li>
|
|
<li class="navBarCell1Rev">Class</li>
|
|
<li><a href="package-tree.html">Tree</a></li>
|
|
<li><a href="../index-all.html">Index</a></li>
|
|
<li><a href="../help-doc.html">Help</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="subNav">
|
|
<ul class="navList">
|
|
<li><a href="../controlP5/ControllerList.html" title="class in controlP5"><span class="strong">Prev Class</span></a></li>
|
|
<li><a href="../controlP5/ControllerProperties.html" title="class in controlP5"><span class="strong">Next Class</span></a></li>
|
|
</ul>
|
|
<ul class="navList">
|
|
<li><a href="../index.html?controlP5/ControllerPlug.html" target="_top">Frames</a></li>
|
|
<li><a href="ControllerPlug.html" target="_top">No Frames</a></li>
|
|
</ul>
|
|
<ul class="navList" id="allclasses_navbar_top">
|
|
<li><a href="../allclasses-noframe.html">All Classes</a></li>
|
|
</ul>
|
|
<div>
|
|
<script type="text/javascript"><!--
|
|
allClassesLink = document.getElementById("allclasses_navbar_top");
|
|
if(window==top) {
|
|
allClassesLink.style.display = "block";
|
|
}
|
|
else {
|
|
allClassesLink.style.display = "none";
|
|
}
|
|
//-->
|
|
</script>
|
|
</div>
|
|
<div>
|
|
<ul class="subNavList">
|
|
<li>Summary: </li>
|
|
<li>Nested | </li>
|
|
<li>Field | </li>
|
|
<li><a href="#constructor_summary">Constr</a> | </li>
|
|
<li><a href="#method_summary">Method</a></li>
|
|
</ul>
|
|
<ul class="subNavList">
|
|
<li>Detail: </li>
|
|
<li>Field | </li>
|
|
<li><a href="#constructor_detail">Constr</a> | </li>
|
|
<li><a href="#method_detail">Method</a></li>
|
|
</ul>
|
|
</div>
|
|
<a name="skip-navbar_top">
|
|
<!-- -->
|
|
</a></div>
|
|
<!-- ========= END OF TOP NAVBAR ========= -->
|
|
<!-- ======== START OF CLASS DATA ======== -->
|
|
<div class="header">
|
|
<div class="subTitle">controlP5</div>
|
|
<h2 title="Class ControllerPlug" class="title">Class ControllerPlug</h2>
|
|
</div>
|
|
<div class="contentContainer">
|
|
<ul class="inheritance">
|
|
<li>java.lang.Object</li>
|
|
<li>
|
|
<ul class="inheritance">
|
|
<li>controlP5.ControllerPlug</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<div class="description">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<hr>
|
|
<br>
|
|
<pre>public class <span class="strong">ControllerPlug</span>
|
|
extends java.lang.Object</pre>
|
|
<div class="block">The ControllerPlug is used to do all the reflection procedures to link a controller to a variable
|
|
or function inside your main application.</div>
|
|
<dl><script type="text/javascript">
|
|
<!--
|
|
document.getElementsByTagName('html')[0].className = 'isjs';function toggle(dt) { var display, dd=dt; do{ dd = dd.nextSibling } while(dd.tagName!='DD'); toOpen =!dd.style.display;dd.style.display = toOpen? 'block':''; dt.getElementsByTagName('span')[0].innerHTML = toOpen? '-':'+' ; }
|
|
-->
|
|
</script>
|
|
<div id="test" class="toggleList"><dl><dt onclick="toggle(this);"><span>+</span>Example</dt><dd><code><pre>/**
|
|
* ControlP5 plugTo
|
|
*
|
|
* This example demonstrate how to use the plugTo method to
|
|
* connect a controller to a field or method of a particular object.
|
|
*
|
|
*
|
|
* find a list of public methods available for the ControlP5 Controller
|
|
* at the bottom of this sketch.
|
|
*
|
|
* by Andreas Schlegel, 2011
|
|
* www.sojamo.de/libraries/controlp5
|
|
*
|
|
*/
|
|
|
|
import controlP5.*;
|
|
import processing.opengl.*;
|
|
|
|
ControlP5 controlP5;
|
|
|
|
Test[] testarray;
|
|
|
|
Test test;
|
|
|
|
Button b;
|
|
|
|
int cnt;
|
|
|
|
void setup() {
|
|
size(600,400);
|
|
smooth();
|
|
test = new Test(50);
|
|
testarray = new Test[10];
|
|
for(int i=0;i<10;i++) {
|
|
testarray[i] = new Test(200 + i*20);
|
|
}
|
|
|
|
controlP5 = new ControlP5(this);
|
|
|
|
controlP5.begin(100,20);
|
|
|
|
b = controlP5.addButton("trigger",1);
|
|
b.setColorBackground(ControlP5.RED);
|
|
|
|
controlP5.addButton("plug",2);
|
|
controlP5.addButton("unplug",3);
|
|
|
|
// b is a button previously added to controlP5 with name 'trigger'
|
|
// controlP5 no tries to find a field or method inside object test
|
|
// in order to connect controller 'trigger' with test.trigger()
|
|
b.plugTo(test);
|
|
controlP5.end();
|
|
}
|
|
|
|
// connects controller 'trigger' with objects of type Test contained
|
|
// inside arrat testarray
|
|
void plug(int theValue) {
|
|
b.plugTo(testarray);
|
|
b.setColorBackground(ControlP5.GREEN);
|
|
println("plugging controller b1 to array 'testarray' and variable 'test'.");
|
|
}
|
|
|
|
// disconnects controller 'trigger' from objects of type Test stored
|
|
// inside array testarray
|
|
void unplug(int theValue) {
|
|
b.unplugFrom(testarray);
|
|
b.setColorBackground(ControlP5.RED);
|
|
println("removing array 'testarray' and variable 'test' from controller b1.");
|
|
}
|
|
|
|
|
|
void draw() {
|
|
background(0);
|
|
fill(255);
|
|
for(int i=0;i<10;i++) {
|
|
testarray[i].display();
|
|
}
|
|
test.display();
|
|
cnt++;
|
|
if(cnt%30 == 0) {
|
|
controlP5.getController("trigger").update();
|
|
}
|
|
}
|
|
|
|
|
|
class Test {
|
|
float n0 = 0;
|
|
float n1 = 1;
|
|
float x;
|
|
|
|
Test(float theX) {
|
|
x = theX;
|
|
}
|
|
|
|
void trigger(int theValue) {
|
|
n1 = random(100);
|
|
}
|
|
|
|
void display() {
|
|
n0 += (n1-n0) * 0.1;
|
|
rect(x,200,10,n0);
|
|
}
|
|
|
|
void controlEvent(ControlEvent theEvent) {
|
|
//println("\t\t b1 event sub \n\n");
|
|
}
|
|
}
|
|
|
|
|
|
</pre></code></dd></dl></div></dl>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="summary">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="constructor_summary">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Constructor Summary</h3>
|
|
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
|
|
<caption><span>Constructors</span><span class="tabEnd"> </span></caption>
|
|
<tr>
|
|
<th class="colOne" scope="col">Constructor and Description</th>
|
|
</tr>
|
|
<tr class="altColor">
|
|
<td class="colOne"><code><strong><a href="../controlP5/ControllerPlug.html#ControllerPlug(java.lang.Object, java.lang.String, int, int, java.lang.Class[])">ControllerPlug</a></strong>(java.lang.Object theObject,
|
|
java.lang.String theName,
|
|
int theType,
|
|
int theParameterType,
|
|
java.lang.Class<?>[] theAcceptClassList)</code> </td>
|
|
</tr>
|
|
</table>
|
|
</li>
|
|
</ul>
|
|
<!-- ========== METHOD SUMMARY =========== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="method_summary">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Method Summary</h3>
|
|
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
|
|
<caption><span>Methods</span><span class="tabEnd"> </span></caption>
|
|
<tr>
|
|
<th class="colFirst" scope="col">Modifier and Type</th>
|
|
<th class="colLast" scope="col">Method and Description</th>
|
|
</tr>
|
|
<tr class="altColor">
|
|
<td class="colFirst"><code>static boolean</code></td>
|
|
<td class="colLast"><code><strong><a href="../controlP5/ControllerPlug.html#checkPlug(java.lang.Object, java.lang.String, java.lang.Class[])">checkPlug</a></strong>(java.lang.Object theObject,
|
|
java.lang.String thePlugName,
|
|
java.lang.Class<?>[] theArgs)</code> </td>
|
|
</tr>
|
|
<tr class="rowColor">
|
|
<td class="colFirst"><code>void</code></td>
|
|
<td class="colLast"><code><strong><a href="../controlP5/ControllerPlug.html#set(java.lang.Object, java.lang.String, int, int, java.lang.Class[])">set</a></strong>(java.lang.Object theObject,
|
|
java.lang.String theName,
|
|
int theType,
|
|
int theParameterType,
|
|
java.lang.Class<?>[] theAcceptClassList)</code> </td>
|
|
</tr>
|
|
</table>
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Methods inherited from class java.lang.Object</h3>
|
|
<code>equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="details">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<!-- ========= CONSTRUCTOR DETAIL ======== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="constructor_detail">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Constructor Detail</h3>
|
|
<a name="ControllerPlug(java.lang.Object, java.lang.String, int, int, java.lang.Class[])">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>ControllerPlug</h4>
|
|
<pre>public ControllerPlug(java.lang.Object theObject,
|
|
java.lang.String theName,
|
|
int theType,
|
|
int theParameterType,
|
|
java.lang.Class<?>[] theAcceptClassList)</pre>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<!-- ============ METHOD DETAIL ========== -->
|
|
<ul class="blockList">
|
|
<li class="blockList"><a name="method_detail">
|
|
<!-- -->
|
|
</a>
|
|
<h3>Method Detail</h3>
|
|
<a name="checkPlug(java.lang.Object, java.lang.String, java.lang.Class[])">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<h4>checkPlug</h4>
|
|
<pre>public static boolean checkPlug(java.lang.Object theObject,
|
|
java.lang.String thePlugName,
|
|
java.lang.Class<?>[] theArgs)</pre>
|
|
</li>
|
|
</ul>
|
|
<a name="set(java.lang.Object, java.lang.String, int, int, java.lang.Class[])">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="blockListLast">
|
|
<li class="blockList">
|
|
<h4>set</h4>
|
|
<pre>public void set(java.lang.Object theObject,
|
|
java.lang.String theName,
|
|
int theType,
|
|
int theParameterType,
|
|
java.lang.Class<?>[] theAcceptClassList)</pre>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<!-- ========= END OF CLASS DATA ========= -->
|
|
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
|
<div class="bottomNav"><a name="navbar_bottom">
|
|
<!-- -->
|
|
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="navList" title="Navigation">
|
|
<li><a href="../controlP5/package-summary.html">Package</a></li>
|
|
<li class="navBarCell1Rev">Class</li>
|
|
<li><a href="package-tree.html">Tree</a></li>
|
|
<li><a href="../index-all.html">Index</a></li>
|
|
<li><a href="../help-doc.html">Help</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="subNav">
|
|
<ul class="navList">
|
|
<li><a href="../controlP5/ControllerList.html" title="class in controlP5"><span class="strong">Prev Class</span></a></li>
|
|
<li><a href="../controlP5/ControllerProperties.html" title="class in controlP5"><span class="strong">Next Class</span></a></li>
|
|
</ul>
|
|
<ul class="navList">
|
|
<li><a href="../index.html?controlP5/ControllerPlug.html" target="_top">Frames</a></li>
|
|
<li><a href="ControllerPlug.html" target="_top">No Frames</a></li>
|
|
</ul>
|
|
<ul class="navList" id="allclasses_navbar_bottom">
|
|
<li><a href="../allclasses-noframe.html">All Classes</a></li>
|
|
</ul>
|
|
<div>
|
|
<script type="text/javascript"><!--
|
|
allClassesLink = document.getElementById("allclasses_navbar_bottom");
|
|
if(window==top) {
|
|
allClassesLink.style.display = "block";
|
|
}
|
|
else {
|
|
allClassesLink.style.display = "none";
|
|
}
|
|
//-->
|
|
</script>
|
|
</div>
|
|
<div>
|
|
<ul class="subNavList">
|
|
<li>Summary: </li>
|
|
<li>Nested | </li>
|
|
<li>Field | </li>
|
|
<li><a href="#constructor_summary">Constr</a> | </li>
|
|
<li><a href="#method_summary">Method</a></li>
|
|
</ul>
|
|
<ul class="subNavList">
|
|
<li>Detail: </li>
|
|
<li>Field | </li>
|
|
<li><a href="#constructor_detail">Constr</a> | </li>
|
|
<li><a href="#method_detail">Method</a></li>
|
|
</ul>
|
|
</div>
|
|
<a name="skip-navbar_bottom">
|
|
<!-- -->
|
|
</a></div>
|
|
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
|
<p class="legalCopy"><small>processing library controlP5 by Andreas Schlegel. (c) 2006-2014</small></p>
|
|
</body>
|
|
</html>
|