向列表中添加元素:错误 "Constructor undefined "

Adding elements to a list: error "Constructor undefined "

我想将具有 3 个参数(iD 及其 x y 位置)的元素添加到我的 activList 中,使用:activList.add(new Fiducial(iD, x, y ));

import TUIO.*;
TuioProcessing tuioClient;

// Grid variables
int cols = 10, rows = 10;
int rectangleWidth = 100;
int rectangleHeight = 60;

// these are some helper variables which are used
// to create scalable graphical feedback
int k, l, iD;
float cursor_size = 15;
float object_size = 60;
float table_size = 760;
float scale_factor = 1;
float x, y;

ArrayList<Fiducial> activList;


public class Fiducial {

  public int iD; 
  public float x;
  public float y;
}

void draw() {
  // Begin loop for columns
  for ( k = 0; k < cols; k++) {
    // Begin loop for rows
    for ( l = 0; l < rows; l++) {
      fill(255);
      stroke(0);
      rect(k*rectangleWidth, l*rectangleHeight, rectangleWidth, rectangleHeight);
    }
  }


  // This part detects the fiducial markers 
  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(-80, -40, 80, 40);
    popMatrix();
    fill(255);
    x = round(10*tobj.getX ());
    y = round(10*tobj.getY ());
    iD = tobj.getSymbolID();
    activList.add(new Fiducial(iD, x, y ));
  }
}

当 运行 时,我在这一行收到错误 "The constructor FiducialDetection.Fiducial(int,float,float) is undefined":

activList.add(new Fiducial(iD, x, y ));

我不明白,我是这样定义的:

public class Fiducial {

  public int iD; 
  public float x;
  public float y;
}

为什么我仍然收到此错误?

您必须添加带参数的构造函数。

public class Fiducial {

    public int iD;
    public float x;
    public float y;

    public Fiducial(int iD, float x, float y) {
        this.iD = iD;
        this.x = x;
        this.y = y;
    }
}