Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Figure 6.13 Consider the GUI in Figure 7.27 (page 307) then write code to satisfy the requirements using the JavaFX library (plus Scene Builder) to

Figure 6.13 Consider the GUI in Figure 7.27 (page 307) then write code to satisfy the requirements using the JavaFX library (plus Scene Builder) to display your version of Figure 7.27. See exercise 7.2 in the section entitled GUI and Graphics Case Study Exercises for details.

Hints

(1) See https://docs.oracle.com/javase/8/javafx/api/toc.htm for help using the class GraphicsContext method strokeArc(). Strokes an arc using the current stroke paint. This method will be affected by any of the global common or stroke attributes as specified in the Rendering Attributes Table.

public void strokeArc(double x, double y,double w,double h,

double startAngle,double arcExtent,ArcType closure);

where (x,y) = the (X,Y) coordinate of the upper-left corner of the arcs bounding rectangle; w = the width of the arcs bounding rectangle; h = the height of the arcs bounding rectangle; startAngle = the starting angle of the arc (measured in degrees); arcExtent = the angular extent of the arc (measured in degrees); and closure = type of closure-of-arc (ArcType.Round, ArcType.Chord, ArcType.Open) or null.

//---------------------------------------------------------------

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;

The details associated with the highlighted code are subject to the programmers aesthetic sensibility!

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)

}

}

}

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions