-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.java
More file actions
79 lines (56 loc) · 1.89 KB
/
GUI.java
File metadata and controls
79 lines (56 loc) · 1.89 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
76
77
78
79
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.FileNotFoundException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.text.JTextComponent;
public class GUI {
public GUI(){
}
public String chooseFile(){
JFileChooser fileChooser = new JFileChooser();
fileChooser.showOpenDialog(null);
String mediaUrl=null;
mediaUrl = fileChooser.getSelectedFile().toURI().toString().substring(5);
System.out.println(mediaUrl);
return(mediaUrl);
}
public void mainWindow(Parser ps, Solver slv){
JFrame mainW = new JFrame( "Tiling Solver" );
mainW.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
mainW.setPreferredSize(new Dimension(600, 600));
mainW.setMinimumSize(mainW.getPreferredSize());
mainW.add(new Tabbed(ps, slv), BorderLayout.CENTER);
mainW.pack();
mainW.setVisible(true);
}
public static void main(String[] args) throws FileNotFoundException{
System.out.println("Enable rotated tiles?");
Scanner myScanner = new Scanner(System.in);
boolean rotateFlag = (myScanner.nextLine().equals("yes"));
System.out.println("Enable reflected tiles?");
boolean reflectFlag = (myScanner.nextLine().equals("yes"));
GUI g = new GUI();
String fileN = g.chooseFile();
Parser p = new Parser();
p.parseFile(fileN);
p.setTiles();
p.updateTiles();
p.setMainBoard();
if(p.isValid()==false){
System.out.println("Input file is not a valid puzzle.");
}
final long startTime = System.currentTimeMillis();
Solver s = new Solver(p, rotateFlag, reflectFlag);
s.removeDuplicates();
final long endTime = System.currentTimeMillis();
System.out.println("Total execution time: " + (endTime - startTime) );
g.mainWindow(p, s);
}
}