1 import java.awt.Dimension;
2 import java.awt.EventQueue;
4 import javax.swing.JFrame;
5 import javax.swing.JOptionPane;
7 import java.io.BufferedReader;
8 import java.io.BufferedWriter;
10 import java.io.FileReader;
11 import java.io.FileWriter;
13 import net.miginfocom.swing.MigLayout;
30 public static void main(String[] args) {
31 EventQueue.invokeLater(
new Runnable() {
35 window.frame.setVisible(
true);
36 }
catch (Exception e) {
71 this.mouseMode = mouseMode;
125 BufferedReader br =
new BufferedReader(
new FileReader(file));
126 String line = br.readLine();
128 while (line != null) {
129 String[] parts = line.split(
";");
130 if(parts[0].equals(
"node")){
131 canvasPanel.
addNode(Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
133 else if(parts[0].equals(
"edge")){
134 canvasPanel.
addEdge(Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
136 line = br.readLine();
139 canvasPanel.paintComponent(canvasPanel.getGraphics());
140 }
catch (Exception e) {
141 JOptionPane.showMessageDialog(frame,
"Could not load file.");
149 canvasPanel.paintComponent(canvasPanel.getGraphics());
158 if (!file.getName().endsWith(
".gdf"))
159 file =
new File(file.getAbsolutePath() +
".gdf");
160 BufferedWriter bw =
new BufferedWriter(
new FileWriter(file));
162 bw.write(
"node;" + node.getXInt() +
";" + node.getYInt() +
"\n");
164 bw.write(
"edge;" + canvasPanel.
getNodes().indexOf(edge.getStartNode()) +
";"
165 + canvasPanel.
getNodes().indexOf(edge.getEndNode()) +
"\n");
168 }
catch (Exception e) {
169 JOptionPane.showMessageDialog(frame,
"Could not save file.");
186 frame =
new JFrame(
"Geometry-Based Edge Clustering");
187 frame.setBounds(100, 100, 700, 400);
188 frame.setMinimumSize(
new Dimension(700,400));
189 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
190 frame.getContentPane().setLayout(
new MigLayout(
"",
"[grow]",
"[grow]"));
193 frame.getContentPane().add(drawPanel,
"cell 0 0, aligny top");
195 canvasPanel.setMinimumSize(
new Dimension(700-drawPanel.getWidth(), 400));
196 frame.getContentPane().add(canvasPanel,
"cell 1 0,alignx left,grow");