-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
75 lines (66 loc) · 2.46 KB
/
Main.java
File metadata and controls
75 lines (66 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package Views;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import photomanager.Controllers.*;
import photomanager.Entry;
import photomanager.MasterLog;
import photomanager.Models.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.ArrayList;
public class Main extends Application {
/**
* Starts the PhotoManager
*
*/
public void start(Stage primaryStage) throws Exception{
final String dir = System.getProperty("user.dir");
File f = new File(dir+"//imagesAndTags.ser");
if(f.exists() && !f.isDirectory()) {
try {
FileInputStream fis=new FileInputStream(dir+"//imagesAndTags.ser");
ObjectInputStream ois=new ObjectInputStream(fis);
@SuppressWarnings("unchecked")
ArrayList<Object> woi= (ArrayList<Object>)ois.readObject();
@SuppressWarnings("unchecked")
ArrayList<ImageModel> savedImages = (ArrayList<ImageModel>) woi.get(0);
ImageController.getImageCollection().addAll(savedImages);
@SuppressWarnings("unchecked")
ArrayList<TagModel> savedTags = (ArrayList<TagModel>) woi.get(1);
TagController.getTagCollection().addAll(savedTags);
@SuppressWarnings("unchecked")
ArrayList<ImageModel> savedTrashItems = (ArrayList<ImageModel>) woi.get(2);
ImageController.getItemsInTrash().addAll(savedTrashItems);
@SuppressWarnings("unchecked")
ArrayList<Entry> savedMasterLog = (ArrayList<Entry>) woi.get(3);
MasterLog.getMasterLog().addAll(savedMasterLog);
}
catch (Exception e) {
e.printStackTrace();
}
}
Parent root = FXMLLoader.load(getClass().getResource("Home.fxml"));
primaryStage.setTitle("Photo Manager");
primaryStage.setScene(new Scene(root));
primaryStage.setResizable(false);
primaryStage.show();
}
/**
* Stops the PhotoManager
*/
public void stop(){
SaveObject saveFile = new SaveObject();
saveFile.run();
}
/**
* Launches the application
* @param args: Arguments that launch the application
*/
public static void main(String[] args) {
launch(args);
}
}