This lab will give you an introduction to Java 8, including lambda expressions, streams, and basic JavaFX.

When complete, your program should behave like the one shown in the VIDEO accompanying this lab.

Below is a snapshot. Each time the user clicks the Circles button, randomly colored circles flow into the display from the lower right and continuously change their shapes.

This section includes the relevant Oracle APIs.
This exercise walks you through the process of adding behavior when the Circles button is clicked. Note:
This exercise walks you through the process of adding behavior when the Circles button is clicked. Note:
After this step, running the project produces this display:

Take a look at the Java8.java file: Add to the body of the configure method in the following ways:
After this step, when the button is clicked a single black circle will be added to the display as shown below. Note: You will write a new method that accepts a circle and adds it to the canvas.

This method will be tested by calling it from the handler for the button.

Write a private addToCanvas method that:

Your addToCanvas method will be tested in the next step.

In the body of the addButtonHandler method, give the starter button a handler by calling its setOnAction method.
After this step, when the button is clicked a row of circles will be added to the display as shown below.

While it would be straightforward to accomplish this with standard iteration techniques, in this step you will practice working with streams.

Write a method called makeRow that: The Stream.generate method expects an object implementing the Supplier<T> functional interface. Use a lambda expression of the form:

Test makeRow by putting the following at the end of the Circles constructor:

When CirclesTest.java is tested, you should see the following in the Output window:

	Circle[centerX=0.0, centerY=0.0, radius=25.0, fill=0x000000ff]
	Circle[centerX=0.0, centerY=0.0, radius=25.0, fill=0x000000ff]
	Circle[centerX=0.0, centerY=0.0, radius=25.0, fill=0x000000ff]
	Circle[centerX=0.0, centerY=0.0, radius=25.0, fill=0x000000ff]
	Circle[centerX=0.0, centerY=0.0, radius=25.0, fill=0x000000ff]	
      
Add private int instance fields row and col that will be used to index the circles within the display. Currently addToCanvas arbitrarily places its argument circle in the upper left corner of the display.

Modify addToCanvas so that it uses the row and col indexes to calculate the location of the circle's center.

Test addToCanvas by initializing various values of row and col. For example:

should result in the circle being placed in the bottom right position of the display.

Write a method called addRowToCanvas that: addRowToCanvas will be tested in the next step.
Change the lambda expression given to setOnAction in addButtonHandler to the following:

Now the top row of circles should be inserted into the display.

After this step, when the button is clicked all circles will be added to the display as shown here.

Write a method called makeAllRows that generates a stream of streams of circles representing all elements of the display. This method: The lambda expression given to Stream.generate should be:

Test makeAllRows by putting the following at the end of the Circle's constructor (replacing the previous test code):

When CirclesTest.java is tested, the Output window should show printed representations of 20 circles.

Write a method called addAllRowsToCanvas that: addRowToCanvas will be tested in the next step.
Change the lambda expression given to setOnAction in addButtonHandler to the following:

Now all rows of circles should be inserted into the display.

After this step, when the button is clicked colored circles will be added to the display as shown below. Note:
You can give a circle a random color with a single line of code at the beginning of addToCanvas:
The animation effects will be produced using "transition" classes in the javafx.animation package: Both animations are added in the addToCanvas method.
addToCanvas currently places each circle in its destination location.

Modify addToCanvas so that each circle is initially placed in the lower right corner.

A TranslateTransition object makes a scene node appear to move by continuously "translating" the location of the node by an incremental amount and repainting it.

The amount of time taken to complete the movement is given to the TranslateTransition constructor as a Duration object. For example:

will create a transition that takes half a second.

Here are the TranslateTransition methods you will use. Suppose that the TranslateTransition object is named tt:

Here is an outline of the code needed to move the circles:

When correctly implemented, clicking the button will cause the desired behavior.
The button can be clicked repeatedly to animate new colored circles into position.

The animation is more distinct if the circles in the display before clicking are cleared before new ones are moved in.

This can be accomplished by changing the lambda expression given to setOnAction in addButtonHandler to the following:

A ScaleTransition object makes a scene node appear to expand or shrink in size by continuously changing its width and/or height by an incremental amount and repainting it.

The amount of time taken to complete the expansion or shrinking is given to the ScaleTransition constructor as a Duration object. For example:

will create a scale transition that takes half a second.

Here are the ScaleTransition methods you will use. Suppose that the ScaleTransition object is named st:

Here is an outline of the code needed to continuously resize the circles:

When correctly implemented, clicking the button will cause the desired behavior.
When your program is working correctly: Note the general Submission Policy in the menu at left.
Successful completion of: