Cloud Stack Ninja

I need to create an image using instructions from a text file. I have almost finished, but 2 of my shapes are not showing up. https://imgur.com/a/KptnvOD The top pic is what I have, and the bottom is what I need. As you can see, one of the circles in the top right is not showing and the rectangle building the base of the rocket isn't either. this is the relevant code:

public class Graphic extends Application {
    /**
     * The start method. Required by Application
     *
     * @param stage
     */
    public void start(Stage stage) {
        Group root = new Group();
        try {
            Scanner obj = new Scanner(new File("scene.txt"));
            while(obj.hasNextLine()){
                String[] strArray = obj.nextLine().split(" ");
                switch(strArray[0]){
                    case "CIRCLE":
                        System.out.println('a');
                        cx = Integer.parseInt(strArray[1]);
                        cy = Integer.parseInt(strArray[2]);
                        cr = Integer.parseInt(strArray[3]);
                        Circle circle = new Circle(cx,cy,cr);
                        circle.setFill(null);
                        circle.setStyle("-fx-stroke:rgb(127,244,16)");
                        root.getChildren().add(circle);
                        break;
                    case "RECTANGLE":
                        rx = Integer.parseInt(strArray[1]);
                        ry = Integer.parseInt(strArray[2]);
                        rw = Integer.parseInt(strArray[3]);
                        rh = Integer.parseInt(strArray[4]);
                        Rectangle rect = new Rectangle(rx,ry,rw,rh);
                        rect.setFill(null);
                        rect.setStyle("-fx-stroke:rgb(127,244,16)");
                        root.getChildren().add(rect);
                        break;
            Scene scene = new Scene(root, fwidth, fheight, Color.BLACK);
            stage.setTitle("poop");
            stage.setScene(scene);
            stage.show();
        }
catch (FileNotFoundException fileNotFoundException) {
            fileNotFoundException.printStackTrace();
        }
        }

        /**
         * The main method
         * @param args
         */

        public static void main(String[] args) {
            launch(args);
        }
    }

I can't figure out why only one of the circles are missing and the rectangle doesn't work at all. Any help is appreciated.



Read more here: https://stackoverflow.com/questions/64396638/javafx-shapes-not-appearing

Content Attribution

This content was originally published by Alex at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: