0

「VisualST」という名前のEclipseの処理クラスがあり、タイプVisualSTの「ツリー」というオブジェクトを作成しました。これで、メイン関数 (クラス GUI にあります) で以下の行を使用してクラス VisualST を実行できることがわかりました。

PApplet.main(new String[] {"VisualST" });

問題は、データを VisualST クラス (したがってオブジェクト) に格納していて、その特定の VisualST を実行する方法、またはプログラムの実行中にフィールドを編集できる VisualST を実行する方法が必要なことです。PApplet のメイン関数を実行したところ、ウィンドウが表示されましたが、ウィンドウの作成方法を変更するフィールドにアクセスする方法がありませんでした。

処理インポートのない Java であるクラス GUI でボタンをクリックすると、フィールドを編集する必要があります。

 public class ButtonListener implements ActionListener
{
    public void actionPerformed (ActionEvent e){

        if(isInteger(BInput.getText())) 
            val = Integer.parseInt(BInput.getText());

         tree.setstval(val);//edits tree! a specific VisualST object
        }

    }








VisualST クラスの要点は次のとおりです。

    import processing.core.PApplet;

public class VisualST extends PApplet {

int stbranch;
int lvls;
//the branch class takes PApplet, length, value (that will be display), and rgb
public branch rt;
public int stval;//start value that should be changed when button is pressed


public void setup() {
    size(360, 640);
    stbranch = 120;
    lvls = 5;
}



public void draw() {
    background(150);
    //start at the top of screen and start drawing
    translate(width/2,0);
    //stval is passed through the constructor and then drawn as the value
    rt = new branch(this, stbranch, stval, 0, 0, 0);
    translate(0, stbranch);
    makeBranch(lvls, stbranch*2/3, 0);
}


void makeBranch(int lvls, double stlength, float y)
{
     //this makes the tree
}

        }

ブランチ コンストラクタは次のとおりです。

    import processing.core.PApplet;

public class branch {


double y;
public int value;
PApplet parent;

int r;
int g;
int b;

private branch left;
private branch right;
int opacity; //0-255



branch(PApplet p, double fy, int v, int ir, int ig, int ib){
parent = p;
y = fy;
value = v;
opacity = 200;
parent.stroke(ir, ig, ib, opacity);
parent.line(0, 0, 0, (float)y);
parent.noFill();
parent.stroke(ir, ig, ib, opacity);
parent.ellipse(0, (float)(10+y), 20, 20); 
parent.fill(ir, ig, ib, opacity+25);
parent.text(value, -5,(float)(10+5+y));
} 
4

0 に答える 0