Java 字段组件.x不可见
我正在尝试运行以下代码:Java 字段组件.x不可见,java,processing,Java,Processing,我正在尝试运行以下代码: import TUIO.*; TuioProcessing tuioClient; // Grid int cols = 6, rows = 6; boolean[][] states = new boolean[cols][rows]; int videoScale = 100; // these are some helper variables which are used // to create scalable graphical feedback
import TUIO.*;
TuioProcessing tuioClient;
// Grid
int cols = 6, rows = 6;
boolean[][] states = new boolean[cols][rows];
int videoScale = 100;
// these are some helper variables which are used
// to create scalable graphical feedback
float cursor_size = 15;
float object_size = 60;
float table_size = 760;
float scale_factor = 1;
PFont font;
boolean verbose = false; // print console debug messages
boolean callback = true; // updates only after callbacks
void setup(){
size(600,600);
noCursor();
noStroke();
fill(0);
// periodic updates
if (!callback) {
frameRate(60); //<>//
loop();
} else noLoop(); // or callback updates
font = createFont("Arial", 18);
scale_factor = height/table_size;
// finally we create an instance of the TuioProcessing client
// since we add "this" class as an argument the TuioProcessing class expects
// an implementation of the TUIO callback methods in this class (see below)
tuioClient = new TuioProcessing(this);
}
void draw()
{
// Begin loop for columns
for (int i = 0; i < cols; i++) {
// Begin loop for rows
for (int j = 0; j < rows; j++) {
// Scaling up to draw a rectangle at (x,y)
int x = i*videoScale;
int y = j*videoScale;
fill(255);
stroke(0);
//check if coordinates are within a box (these are mouse x,y but could be fiducial x,y)
//simply look for bounds (left,right,top,bottom)
rect(x,y,videoScale,videoScale);
}
}
textFont(font,18*scale_factor);
float obj_size = object_size*scale_factor;
float cur_size = cursor_size*scale_factor;
ArrayList<TuioObject> tuioObjectList = tuioClient.getTuioObjectList();
for (int i=0;i<tuioObjectList.size();i++) {
TuioObject tobj = tuioObjectList.get(i);
stroke(0);
fill(0,0,0);
pushMatrix();
translate(tobj.getScreenX(width),tobj.getScreenY(height));
rotate(tobj.getAngle());
rect(-obj_size/2,-obj_size/2,obj_size,obj_size);
popMatrix();
fill(255);
text(""+tobj.getSymbolID(), tobj.getScreenX(width), tobj.getScreenY(height));
}
ArrayList<TuioCursor> tuioCursorList = tuioClient.getTuioCursorList();
for (int i=0;i<tuioCursorList.size();i++) {
TuioCursor tcur = tuioCursorList.get(i);
ArrayList<TuioPoint> pointList = tcur.getPath();
if (pointList.size()>0) {
stroke(0,0,255);
TuioPoint start_point = pointList.get(0);
for (int j=0;j<pointList.size();j++) {
TuioPoint end_point = pointList.get(j);
line(start_point.getScreenX(width),start_point.getScreenY(height),end_point.getScreenX(width),end_point.getScreenY(height));
start_point = end_point;
}
stroke(192,192,192);
fill(192,192,192);
ellipse( tcur.getScreenX(width), tcur.getScreenY(height),cur_size,cur_size);
fill(0);
text(""+ tcur.getCursorID(), tcur.getScreenX(width)-5, tcur.getScreenY(height)+5);
}
}
ArrayList<TuioBlob> tuioBlobList = tuioClient.getTuioBlobList();
for (int i=0;i<tuioBlobList.size();i++) {
TuioBlob tblb = tuioBlobList.get(i);
stroke(0);
fill(0);
pushMatrix();
translate(tblb.getScreenX(width),tblb.getScreenY(height));
rotate(tblb.getAngle());
ellipse(-1*tblb.getScreenWidth(width)/2,-1*tblb.getScreenHeight(height)/2, tblb.getScreenWidth(width), tblb.getScreenWidth(width));
popMatrix();
fill(255);
text(""+tblb.getBlobID(), tblb.getScreenX(width), tblb.getScreenX(width));
}
}
// --------------------------------------------------------------
// these callback methods are called whenever a TUIO event occurs
// there are three callbacks for add/set/del events for each object/cursor/blob type
// the final refresh callback marks the end of each TUIO frame
// called when an object is added to the scene
void addTuioObject(TuioObject tobj) {
if (verbose) println("add obj "+tobj.getSymbolID()+" ("+tobj.getSessionID()+") "+tobj.getX()+" "+tobj.getY()+" "+tobj.getAngle());
double fx = tobj.getX();
double fy = tobj.getY();
println (fx + " " + fy);
if( (fx >= x && fx <= x + videoScale) && //check horzontal
(fy >= y && fy <= y + videoScale)){
//coordinates are within a box, do something about it
fill(0);
stroke(255);
//you can keep track of the boxes states (contains x,y or not)
states[i][j] = true;
}
}
导入TUIO.*;
TuioProcessing tuioClient;
//网格
int cols=6,rows=6;
布尔[][]状态=新的布尔[cols][rows];
int videoScale=100;
//这些是使用的一些辅助变量
//创建可伸缩的图形反馈
浮动光标_size=15;
浮动对象大小=60;
浮动台_尺寸=760;
浮动比例系数=1;
字体;
布尔详细值=false;//打印控制台调试消息
布尔回调=true;//仅在回调后更新
无效设置(){
尺寸(600600);
noCursor();
仰泳();
填充(0);
//定期更新
如果(!回调){
帧率(60)////
loop();
}else noLoop();//或回调更新
font=createFont(“Arial”,18);
比例系数=高度/桌子尺寸;
//最后,我们创建一个TuioProcessing客户机的实例
//由于我们将“this”类添加为TuioProcessing类所期望的参数
//此类中TUIO回调方法的实现(请参见下文)
tuioClient=新的TuioProcessing(this);
}
作废提款()
{
//开始列的循环
for(int i=0;i 对于(int i=0;i您从不在draw()
方法之外声明x
和y
,因此它们对addTuioObject()
不可见。如果您需要draw方法内部的值,您可以像使用cursor\u size
或object\u size
那样声明类字段。使用
int x, y;
在任何方法之外,然后相应地赋值,或向addTuioObject()方法添加参数:
您从不在draw()
方法之外声明x
和y
,因此它们对addTuioObject()
不可见。如果您需要draw方法内部的值,您可以像使用cursor\u size
或object\u size
那样声明类字段。使用
int x, y;
在任何方法之外,然后相应地赋值,或向addTuioObject()方法添加参数:
您从不在draw()
方法之外声明x
和y
,因此它们对addTuioObject()
不可见。如果您需要draw方法内部的值,您可以像使用cursor\u size
或object\u size
那样声明类字段。使用
int x, y;
在任何方法之外,然后相应地赋值,或向addTuioObject()方法添加参数:
您从不在draw()
方法之外声明x
和y
,因此它们对addTuioObject()
不可见。如果您需要draw方法内部的值,您可以像使用cursor\u size
或object\u size
那样声明类字段。使用
int x, y;
在任何方法之外,然后相应地赋值,或向addTuioObject()方法添加参数: