Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Using Java language and specifically JavaFX ONLY no swing or jpanel, netbeans I

ID: 3669256 • Letter: #

Question

(Using Java language and specifically JavaFX ONLY no swing or jpanel, netbeans IDE)

My Photos

create a photo album application. Your application will load a collection of images and display them in a photo album layout. The program will allow the user to tag an image with the following metadata:

- Title for the photo (limited to 20 characters)

- Description of the photo. Limited to 100 characters

- Date Taken

- Place Taken

Functional Specification

- Your album should allow sorting the pictures by Title, Date, and Place.

- When the user clicks on a photo, the metadata should be displayed

- The user should be able to add or remove photos from the album

Additional requirements

- Any test photos must be included with project source

- All photos should have maximum and minimum dimensions so that huge photos do not take up all the program’s viewing real estate and smaller photos are not so small that they’re indistinguishable.

- All paths should be relative paths or URL paths. No hard-coded file paths!

- All controls must be viewable without adjusting the parent Window

- Only javaFX GUI controls can be used. No Swing or AWT controls.

- No GUI designers may be used.

I would love this code as a reference, purhaps explain whats going on to me either with comments or seperate, because i know what im doing but only slightly i am a noobie afterall :D. thanks.

Explanation / Answer

ALBUM.java

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.scene.image.ImageView;
import java.util.*;

public class Album extends Observable{
private static List<ImageData> imageData = new ArrayList<>();

ObservableList<ImageData> observableList = FXCollections.observableList(imageData);
public ObservableList<ImageData> getObsList(){return observableList;}

private BooleanProperty changed = new SimpleBooleanProperty();
public final boolean getChanged(){return changed.get();}
public final void setChanged(boolean value){changed.set(value);}
public BooleanProperty changedProperty(){return changed;}

public Album(){}

public static List<ImageData> getImageData(){ return imageData; }

public void addImage(String image, String title, String desc, String loc) {
imageData.add(0, new ImageData(image, title, desc, loc));
}

public void removeImage(ImageView img){

List<ImageData> toRemove = new ArrayList<>();
for(ImageData a: imageData){
if(a.getImageView() == img){
toRemove.add(a);
//observableList.remove(a);
break;
}
}

imageData.removeAll(toRemove);
if (this.getChanged() == true)
this.setChanged(false);
else
this.setChanged(true);
}

public void sortAlbumTitle(Album album) {
System.out.println("Sort by Title");
Collections.sort(album.getImageData(), new Comparator<ImageData>() {
public int compare(ImageData img1, ImageData img2) {
return img1.getTitle().compareToIgnoreCase(img2.getTitle());
}
});
}

public void sortAlbumDate(Album album) {
System.out.println("Sort by Date");
Collections.sort(album.getImageData(), new Comparator<ImageData>() {
public int compare(ImageData img1, ImageData img2) {
return img1.getDate().compareTo(img2.getDate());
}
});
}

public void sortAlbumLoc(Album album) {
System.out.println("Sort by description");
Collections.sort(album.getImageData(), new Comparator<ImageData>() {
public int compare(ImageData img1, ImageData img2) {
return img1.getLocation().compareToIgnoreCase(img2.getLocation());
}
});
}
}