vendredi 6 avril 2018

Java loop jumping

After looking through the debugger I have noticed that my loop resets if on the line after Table.size() == 3 where the Pixel is set on the WriteableImage even if I post extra code within the if statement it still jumps back to the beginning of the loop. Very interested as to why this would be happening.

while (Scan.hasNextLine() && !(XCount == XTotal)) {
    Scanner LineScan = new Scanner(Scan.nextLine());

    while (LineScan.hasNext()) {
        Table.add(LineScan.nextInt());
    }

    if (Table.size() == 3) {
        PixelWrite.setColor(XCount, YCount, new Color(Table.get(0), Table.get(1), Table.get(2), 255));
    } else {
        PixelWrite.setColor(XCount, YCount, new Color(0, 0, 0, 0));
    }

    Table.clear();
    YCount++;

    if (YCount == YTotal) {
        YCount = 0;
        XCount++;
        System.out.println(Math.floor(((double) XCount / XTotal) * 100));
    }
}

Aucun commentaire:

Enregistrer un commentaire