Take-home (Individual) assignment Instruction:
1. The duration for this take-home assignment is 1.5 days (from 13 April 2020, 10:00 am to 14 April 2020, 10:00 pm).
2. Write your Name, ID and Programme on TOP of your code and comment it.
3. Rename your Java source code as “yourname_id” (e.g. ChanMeiTing_012345.java) and submit it to WBLE.
Please ensure you are submitting your file to the correct submission link which is according to your
respective programme.
4. The link will be CLOSED on 14th April 2020 by 10:00 pm. As such you are advised to submit it earlier.
Question: Write a JavaFX application for manipulating colors and locations:
Figure 1. Illustration of the JavaFX application.
Figure 1. When “Chart Color” button is clicked. Figure 3. When “Font Color” button is clicked. 3
Figure 4. When “Shift Right” button is clicked. 1
Figure 5. When “Shift Left” button is clicked. 00
Refer to the above figures, your objective is to develop a JavaFX application to do the following:
1. A pie chart to display the percentages of the electronic devices. Suppose that Smartphone takes 70 percent and is displayed in light blue, Laptop takes 15 percent and is displayed in light goldenrod yellow, Desktop takes 10 percent and is displayed in light coral and Tablet takes 5% and is displayed in light green as shown in Figure 1.
2. It has 4 buttons on the bottom for manipulating colors and locations of the pie chart:
a) 1st button uses to change the color of the pie chart. Display the button with ¡°Chart Color¡±. When the button is clicked, the color of the pie chart will be changed as shown in Figure 2. (color selection is
based on your own preferences)
b) 2nd button uses to change the font color. Display the button with ¡°Font Color¡±. When the button is
clicked, the font color will change from black to white as shown in Figure 3.
c) 3rd button uses to move the pie chart and fonts to the right side by 10 pixels when the button is clicked
as shown in Figure 4. Display the button with ¡°Shift Right¡±.
d) 4th button uses to move the pie chart and fonts to the left side by 10 pixels when the button is clicked as
shown in Figure 5. Display the button with ¡°Shift Left¡±
Hints:
1. Use the Arc class to display the pies. Represent each section with one Arc object. Set the arc type to ArcType.ROUND.
2. Set the centers of the arcs to (100, 100) and the radiuses to 80 for both x and y.
3. Set the scene dimension to 400 x 250.
4. Use Lambda expression to simplify the event-handling code in the program.
Following is the pseudocode for implementation of the program.
// Name, ID, Programme (e.g. Chan Mei Ting, 012345, CS)
// Import all necessary JavaFX packages for classes, GUI component classes & interfaces.
// Extends Application class
// //
// // //
// //
// //
Create a Pane and add the four arcs & texts to the pane.
Create a HBox and add the four buttons to the HBox.
Add the event-handling codes for the four buttons using Lambda expression. Perform the respective actions as mentioned above (refer to Fig. 2©¤4)
when these buttons are clicked.
Create a BorderPane and place the pane in the center region and HBox in the bottom region of the border pane.
Create a scene of size (400, 250) to host the BorderPane, place the scene into the stage and show the stage.
// Include main method for launching the JavaFX application
2