-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
110 lines (93 loc) · 3.37 KB
/
Main.java
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
* @author ${Surajit Kundu}
*
* ${Provide the GUI to perform the DICOM Manipulation process}
*/
package skdcmManipulation;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import javax.swing.*;
import java.util.Arrays;
public class Main extends JFrame {
JFileChooser chooser = new JFileChooser("C://Work/Program/file/");
JButton button = new JButton("Choose Dicom file...");
JButton readButton = new JButton("Read");
JButton exportButton = new JButton("ExportJSON");
JButton defaultWButtton = new JButton("Auto Modify");
JLabel l = new JLabel("No file is choosen");
File dcmFile;
public Main() {
super("Dicom Reader");
Container dcmContainer = getContentPane();
dcmContainer.setLayout(new FlowLayout());
dcmContainer.add(button);
dcmContainer.add(readButton);
dcmContainer.add(exportButton);
dcmContainer.add(defaultWButtton);
dcmContainer.add(l);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int state = chooser.showOpenDialog(null);
dcmFile = chooser.getSelectedFile();
if(dcmFile != null && state == JFileChooser.APPROVE_OPTION) {
l.setText(dcmFile.getName());
}
else if(state == JFileChooser.CANCEL_OPTION) {
JOptionPane.showMessageDialog(null, "Canceled");
}
}
});
readButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame f=new JFrame();
String data[][] = new DicomRead().readDicom(dcmFile);
String column[]={"TAG","VM","VR","Attribute","Value"};
JTable jt=new JTable(data,column);
jt.setCellSelectionEnabled(true);
jt.getTableHeader().setFont(new Font("Serif", Font.BOLD, 16));
jt.setFont(new Font("Serif", Font.PLAIN, 16));
jt.setBounds(60,80,500,600);
JScrollPane sp=new JScrollPane(jt);
f.add(sp);
f.setSize(500,700);
f.setVisible(true);
//dcmContainer.revalidate();
}
});
exportButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showInputDialog( null,"Exported to : ",new DicomRead().WriteJSON(dcmFile));
}
});
defaultWButtton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame f=new JFrame();
String data[][] = new DicomModify().autoModifyDCMandRead(dcmFile);
String column[]={"TAG","VM","VR","Attribute","Value"};
JTable jt=new JTable(data,column);
jt.setCellSelectionEnabled(true);
jt.getTableHeader().setFont(new Font("Serif", Font.BOLD, 16));
jt.setFont(new Font("Serif", Font.PLAIN, 16));
jt.setBounds(60,80,500,600);
JScrollPane sp=new JScrollPane(jt);
f.add(sp);
f.setSize(500,700);
f.setVisible(true);
JOptionPane.showMessageDialog( null,"Exported to : "+new DicomModify().getPath());
}
});
}
public static void main(String args[]) {
JFrame f = new Main();
f.setBounds(300,300,450,300);
f.setVisible(true);
f.setDefaultCloseOperation(
WindowConstants.DISPOSE_ON_CLOSE);
f.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
System.exit(0);
}
});
}
}