160k views
1 vote
your goal is to implement a gui application in java using javafx 17 that displays a gallery of images based on the results of a search query to the itunes search api. this will require you to lookup things in javadoc and apply your knowledge of things like inheritance, polymorphism, and interfaces. the functional and non-functional requirements for this project are outlined later in this document. here is an example of what your program might look like:

User AdSR
by
7.2k points

1 Answer

3 votes

The code snippet shows how to parse the JSON response from the API call above:

ObjectMapper mapper = new ObjectMapper();

JsonNode root = mapper.readTree(response);

JsonNode results = root.get("results");

for (JsonNode result : results) {

String artistName = result.get("artistName").asText();

String songName = result.get("songName").asText();

System.out.println("Artist: " + artistName);

System.out.println("Song: " + songName);

}

What is the java code?

The iTunes Search API is one that is seen as a RESTful API that allows you to search for and retrieve information about music, movies, books, and more.

So, To use the API, one will need to create a developer account on Apple's Developer Portal and obtain an API key. Once one have an API key, you can make requests to the API using your web browser or a programming language such as Java. The API returns JSON-formatted responses that one can parse to extract the information one need.

See full text below

Your goal is to implement a GUI application in Java using JavaFX 8 that displays a gallery of images based on the results of a search query to the iTunes Search API. This will require you to lookup things in Javadoc and apply your knowledge of things like inheritance, polymorphism, and interfaces. The functional and non-functional requirements for this project are outlined later in this document. Here is an example of what your program might look like:

student submitted image, transcription available below

Here are links to an animated version: gifv, gif.

Part of software development is being given a goal but not necessarily being given instruction on all of the details needed to accomplish that goal. For example, even though working with things like images, threads, JSON, and the iTunes Search API haven't been covered in class, you are going to need to lookup how to do these things in order to complete this project. Starter code and a generously helpful FAQ are provided.

This project is also designed to help you better understand the usefulness of good class design. While you can technically write your entire JavaFX-based GUI application entirely in the start method, this will make your code messy, hard to read, possibly redundant, and likely more prone to errors. Before you write any code, you should plan out your application's scene graph (i.e., the containment hierarchy), and design custom components as needed. If you find that you are writing a lot of code related to a specific component (e.g., setting styling, adding event handlers, etc.), then it's probably a good idea to make a custom version of that component in order to reduce clutter.

Toolbar (50 points): The application needs to have a toolbar that contains the following components:

Play/Pause Button (10 points): This button should allow the user to pause and resume the random image replacement described for the main content of the application. The button text should change, as needed, to reflect the current application mode (i.e., play vs. pause).

Query Text Field (10 points): This component should allow the user to enter in a search query for the iTunes Search API. Its initial contents should correspond to some default query.

Update Images Button (30 points): This button should cause the application to execute the search query specified in the query text field, gather the images associated with the query response, and update the images in the main content area of the application accordingly. If less than twenty (20) images are gathered, then a dialog should be displayed to the user with an appropriate error message, and the main content area should not be updated. If twenty (20) or more images are gathered, then the images not chosen for display in the main content area of the application should be remembered in order to facilitate the random replacement described for the main content of the application.

Progress Bar (10 points): The application needs to have a progress bar that indicates the progress of querying the iTunes Search API, loading the images into memory, and updating the main content area of the application. Notably, the progress bar will be seen to progress when the application first starts (as images are gathered from the response to the default query) and when the "Update Images" button is pressed. Please note that this progress bar is not merely aesthetic. It should actually show the progress of gathering individual images from the query response.

User HChen
by
8.2k points