-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
77 lines (65 loc) · 1.57 KB
/
Copy pathMain.java
File metadata and controls
77 lines (65 loc) · 1.57 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
/*
* file: Main.java
* desc: Takes in a file and uses classes to turn it into a compatible LED grid
* Author: AJ Nagashima
* email: ajn3687@g.rit.edu
*/
//ImageIO imports
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
//Swing GUI imports
import javax.swing.JFrame;
import javax.swing.BorderFactory;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JTextField;
//Misc imports
import java.awt.Color;
public class Main extends JFrame{
BufferedImage base;
OpeningFrame oFrame;
EditorFrame eFrame;
Color[][] pixels;
public Main() {
oFrame = new OpeningFrame();
while( true )
{
if(oFrame.confirmPressed()){
oFrame.confirmChecked();
if(oFrame.getPath().equals(""))
break;
if(open(oFrame.getPath()))
break;
}
try{Thread.sleep(10);}
catch (Exception e){}
}
oFrame.dispose();
makeGrid();
eFrame = new EditorFrame(pixels, oFrame.isRGB());
}
void makeGrid(){
pixels = new Color[oFrame.getDims()[0]][oFrame.getDims()[1]];
if(base == null){
for(int r = 0; r < pixels.length; r++)
for(int c = 0; c < pixels[0].length; c++)
pixels[r][c] = new Color(255,255,255);
}
}
boolean open(String path) {
try {
base = ImageIO.read(new File(path));
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
public static void main(String args[]) {
new Main();
}
}