A rudak pozicionálása és az első rúdon lévő korongok kirajzolása.

This commit is contained in:
pp 2021-11-04 12:58:28 +01:00
parent 1b14e32589
commit f34737bd30
2 changed files with 38 additions and 2 deletions

View File

@ -69,7 +69,8 @@ public class HanoiFormController {
for (int i = 0; i < korongokSzama; i++) {
Korong k = new Korong(szinek[i], korongSzelMax-i*KDIFF, korongMag);
/*
* Rectangle tlap = k.getTlap(); tlap.setLayoutX(0);
* Rectangle tlap = k.getTlap();
* tlap.setLayoutX(0);
* tlap.setLayoutY(i*30+100);
* jatekTerulet.getChildren().add(tlap);
*/
@ -79,7 +80,37 @@ public class HanoiFormController {
}
private void rudRajzolas() {
double x = jatekTerulet.getWidth();
double y = jatekTerulet.getHeight();
double w = x*0.02;
double rx1 = x/4-w/2;
double ry1 = y/3;
double rx2 = rx1+x/4;
double ry2 = ry1;
double rx3 = rx2+x/4;
double ry3 = ry1;
double rh = y-15-ry1;
elsoRudRect.setLayoutX(rx1);
elsoRudRect.setLayoutY(ry1);
elsoRudRect.setWidth(w);
elsoRudRect.setHeight(rh);
masodikRudRect.setLayoutX(rx2);
masodikRudRect.setLayoutY(ry2);
masodikRudRect.setWidth(w);
masodikRudRect.setHeight(rh);
harmadikRudRect.setLayoutX(rx3);
harmadikRudRect.setLayoutY(ry3);
harmadikRudRect.setWidth(w);
harmadikRudRect.setHeight(rh);
for (int kix=0; kix < r1.getKorongok().size(); kix++) {
Korong k = r1.getKorongok().get(kix);
double kx = rx1-(k.getSzelesseg()/2-w/2);
double ky = (y-15)-((kix+1)*k.getMagassag());
Rectangle tlap = k.getTlap();
tlap.setLayoutX(kx);
tlap.setLayoutY(ky);
jatekTerulet.getChildren().add(tlap);
}
}

View File

@ -68,6 +68,11 @@ public class Rud {
this.tlap = tlap;
}
public ArrayList<Korong> getKorongok() {
return korongok;
}
}