Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am having trouble drawing a circular spiral for this Java Program, please help me! The main parts i need is where it says student

I am having trouble drawing a circular spiral for this Java Program, please help me! The main parts i need is where it says student puts missing code! I am using Netbeans for my IDE if that makes a difference.

//--------------------------------------------------------------- // Figure727.java //--------------------------------------------------------------- package figure727;

import javafx.application.Application; import static javafx.application.Application.launch; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage;

public class Figure727 { public void start(Stage stage) throws Exception { Parent root = FXMLLoader.load(getClass().getResource("Figure727.fxml")); Scene scene = new Scene(root); stage.setTitle("Chapter #7, Figure 7.27"); stage.setScene(scene); stage.show(); } public static void main(String[] args) { launch(args); }

}

//--------------------------------------------------------------- // Figure727Controller.java //--------------------------------------------------------------- package figure727;

import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.paint.Color; import javafx.scene.shape.ArcType;

public class Figure727Controller {

@FXML private Canvas drawingCanvas;

@FXML void drawFigure727ButtonPressed(ActionEvent event) { GraphicsContext gc = drawingCanvas.getGraphicsContext2D(); final int W = (int) drawingCanvas.getWidth(); final int H = (int) drawingCanvas.getHeight(); final int D = (W <= H) ? W : H;

final int XC = W / 2; final int YC = H / 2; final int R = (int) Math.round(0.025 * D); final int DELTAR = (int) Math.round(R * 0.25); final int STEPS = (D / 2 - R) / DELTAR;

// Draw circular spiral centered at (XC,YC) for (int step = 1; step <= STEPS; step += 1) { int r = R + (step - 1) * DELTAR;

Student provides missing code to either draw odd-numbered steps as "top" semicircles (sweeping CW L-to-R) centered at (XC,YC) or draw even-numbered steps as "bottom" semicircles (sweeping CW R-to-L) centered at (XC-DELTAR,YC) } } }

Figure 7.27 XML

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

10. I am searching for meaning in my life.

Answered: 1 week ago