Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design two JavaFX applications named PictureIterative and PictureRecursive that

ID: 3720986 • Letter: D

Question

Design two JavaFX applications named PictureIterative and PictureRecursive that produce the same picture. Must use objects from Circle, Ellypse, and Arc classes. In addition, must have one or more objects from Line and/or Rectangle classes. Must use at least three colors (two colors should be static constants from class Color, and third color should be an object instantiated from Color class by providing three RGB values). Finally, use one Text object to write your first and last name in the upper right corner of the drawing.


First application one should contain iterative method drawPicture to draw shapes, and second one should contain recursive method drawPictureRec to draw the same. Formal parameter list should include parameter group of Group type. Other possible parameters should be used as needed. Both pictures should use three colors to alternate colors of shapes.


Creativity is encouraged and will be graded too.


Explanation / Answer

Application 1

    package application;
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.layout.VBox;
    import javafx.scene.paint.Color;
    import javafx.scene.paint.CycleMethod;
    import javafx.scene.paint.LinearGradient;
    import javafx.scene.paint.Stop;
    import javafx.scene.shape.Rectangle;
    import javafx.stage.Stage;
    public class Shape_Example extends Application {
    
        @Override
        public void start(Stage primaryStage) {
            VBox root = new VBox();
            final Scene scene = new Scene(root,300, 250);
            Stop[] stops = new Stop[] { new Stop(0, Color.GREEN), new Stop(1, Color.BLUE)};
            LinearGradient linear = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);
            Group group=new Group();
            Image img = new Image("https://www.javatpoint.com/jogl/images/jogl-3d-triangle.gif");
            ImageInput imginput = new ImageInput();
            Rectangle rect = new Rectangle(0, 0, 100, 100);
            Rectangle rect=new Rectangle(); //instantiating Rectangle
            rect.setX(20); //setting the X coordinate of upper left //corner of rectangle
            rect.setY(20); //setting the Y coordinate of upper left //corner of rectangle
            rect.setWidth(100); //setting the width of rectangle
            rect.setHeight(100); // setting the height of rectangle
            group.getChildren().addAll(rect); //adding rectangle to the //group
            Ellipse elipse = new Ellipse();
            elipse.setCenterX(100);
            elipse.setCenterY(100);
            elipse.setRadiusX(50);
            elipse.setRadiusY(80);
            group.getChildren().addAll(elipse);
            Arc arc = new Arc();
            arc.setCenterX(100);
            arc.setCenterY(100);
            arc.setRadiusX(50);
            arc.setRadiusY(80);
            arc.setStartAngle(30);
            arc.setLength(70);
            arc.setType(ArcType.ROUND);
            arc.setFill(Color.RED);
            group.getChildren().addAll(arc);
            Circle circle = new Circle();
            circle.setCenterX(200);
            circle.setCenterY(200);
            circle.setRadius(100);
            circle.setFill(Color.RED);
            group.getChildren().addAll(circle);
                 Text text = new Text();
            text.setText("Hello !! manikanta mendi");
            StackPane root = new StackPane();
            Scene scene = new Scene(root,300,400);
           root.getChildren().add(text);
  
            Scene scene = new Scene(group,200,300,Color.GRAY);

            
            root.getChildren().add(rect);
            
            primaryStage.setScene(scene);
            primaryStage.setTitle("PictureIterative ");
            primaryStage.show();
        }
    
        public static void main(String[] args) {
            launch(args);
        }
        }

Application 2

    package application;
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.layout.VBox;
    import javafx.scene.paint.Color;
    import javafx.scene.paint.CycleMethod;
    import javafx.scene.paint.LinearGradient;
    import javafx.scene.paint.Stop;
    import javafx.scene.shape.Rectangle;
    import javafx.stage.Stage;
    public class Shape_Example extends Application {
    
        @Override
        public void start(Stage primaryStage) {
            VBox root = new VBox();
            final Scene scene = new Scene(root,300, 250);
            Stop[] stops = new Stop[] { new Stop(0, Color.GREEN), new Stop(1, Color.BLUE)};
            LinearGradient linear = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);
            Group group=new Group();
            Image img = new Image("https://www.javatpoint.com/jogl/images/jogl-3d-triangle.gif");
            ImageInput imginput = new ImageInput();
            Rectangle rect = new Rectangle(0, 0, 100, 100);
            Rectangle rect=new Rectangle(); //instantiating Rectangle
            rect.setX(20); //setting the X coordinate of upper left //corner of rectangle
            rect.setY(20); //setting the Y coordinate of upper left //corner of rectangle
            rect.setWidth(100); //setting the width of rectangle
            rect.setHeight(100); // setting the height of rectangle
            group.getChildren().addAll(rect); //adding rectangle to the //group
            Ellipse elipse = new Ellipse();
            elipse.setCenterX(100);
            elipse.setCenterY(100);
            elipse.setRadiusX(50);
            elipse.setRadiusY(80);
            group.getChildren().addAll(elipse);
            Arc arc = new Arc();
            arc.setCenterX(100);
            arc.setCenterY(100);
            arc.setRadiusX(50);
            arc.setRadiusY(80);
            arc.setStartAngle(30);
            arc.setLength(70);
            arc.setType(ArcType.ROUND);
            arc.setFill(Color.RED);
            group.getChildren().addAll(arc);
            Circle circle = new Circle();
            circle.setCenterX(200);
            circle.setCenterY(200);
            circle.setRadius(100);
            circle.setFill(Color.RED);
            group.getChildren().addAll(circle);
                 Text text = new Text();
            text.setText("Hello !! manikanta mendi");
            StackPane root = new StackPane();
            Scene scene = new Scene(root,300,400);
           root.getChildren().add(text);
  
            Scene scene = new Scene(group,200,300,Color.GRAY);

            
            root.getChildren().add(rect);
            
            primaryStage.setScene(scene);
            primaryStage.setTitle("PictureRecursive ");
            primaryStage.show();
        }
    
        public static void main(String[] args) {
            launch(args);
        }
        }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote