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;
103 BufferedReader br =
new BufferedReader(
new FileReader(file));
104 String line = br.readLine();
106 while (line != null) {
107 String[] parts = line.split(
";");
108 if(parts[0].equals(
"node")){
109 canvasPanel.
addNode(Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
111 else if(parts[0].equals(
"edge")){
112 canvasPanel.
addEdge(Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
114 line = br.readLine();
117 canvasPanel.paint(canvasPanel.getGraphics());
118 }
catch (Exception e) {
119 JOptionPane.showMessageDialog(frame,
"Could not load file.");
129 if (!file.getName().endsWith(
".gdf"))
130 file =
new File(file.getAbsolutePath() +
".gdf");
131 BufferedWriter bw =
new BufferedWriter(
new FileWriter(file));
133 bw.write(
"node;" + node.getXInt() +
";" + node.getYInt() +
"\n");
135 bw.write(
"edge;" + canvasPanel.
getNodes().indexOf(edge.getStartNode()) +
";"
136 + canvasPanel.
getNodes().indexOf(edge.getEndNode()) +
"\n");
139 }
catch (Exception e) {
140 JOptionPane.showMessageDialog(frame,
"Could not save file.");
165 frame =
new JFrame(
"Force-Directed Edge Bundling");
166 frame.setBounds(100, 100, 700, 400);
167 frame.setMinimumSize(
new Dimension(700,400));
168 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
169 frame.getContentPane().setLayout(
new MigLayout(
"",
"[grow]",
"[grow]"));
172 frame.getContentPane().add(drawPanel,
"cell 0 0, aligny top");
174 canvasPanel.setMinimumSize(
new Dimension(700-drawPanel.getWidth(), 400));
175 frame.getContentPane().add(canvasPanel,
"cell 1 0,alignx left,grow");