Skip to content

Commit 0a205e1

Browse files
Brandon LumBrandon Lum
Brandon Lum
authored and
Brandon Lum
committed
Updated graph stream
1 parent 3bfb0f3 commit 0a205e1

12 files changed

+144
-219
lines changed

.DS_Store

0 Bytes
Binary file not shown.

GraphStreamTest/.classpath

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22
<classpath>
33
<classpathentry kind="src" path="src"/>
44
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
5-
<classpathentry kind="lib" path="GraphStream/gs-core-1.2/gs-core-1.2.jar"/>
6-
<classpathentry kind="lib" path="GraphStream/gs-algo-1.2/gs-algo-1.2.jar"/>
7-
<classpathentry kind="lib" path="GraphStream/gs-ui-1.2/gs-ui-1.2.jar"/>
8-
<classpathentry kind="lib" path="GraphStream/gs-core-1.2/gs-core-1.2-javadoc.jar"/>
5+
<classpathentry kind="lib" path="GraphStream/gs-core-1.2/gs-core-1.2.jar">
6+
<attributes>
7+
<attribute name="javadoc_location" value="jar:file:/Users/brandon/Documents/workspace/GraphStreamTest/GraphStream/gs-core-1.2/gs-core-1.2-javadoc.jar!/"/>
8+
</attributes>
9+
</classpathentry>
10+
<classpathentry kind="lib" path="GraphStream/gs-algo-1.2/gs-algo-1.2.jar">
11+
<attributes>
12+
<attribute name="javadoc_location" value="jar:file:/Users/brandon/Documents/workspace/GraphStreamTest/GraphStream/gs-algo-1.2/gs-algo-1.2-javadoc.jar!/"/>
13+
</attributes>
14+
</classpathentry>
15+
<classpathentry kind="lib" path="GraphStream/gs-ui-1.2/gs-ui-1.2.jar">
16+
<attributes>
17+
<attribute name="javadoc_location" value="jar:file:/Users/brandon/Documents/workspace/GraphStreamTest/GraphStream/gs-ui-1.2/gs-ui-1.2-javadoc.jar!/"/>
18+
</attributes>
19+
</classpathentry>
920
<classpathentry kind="output" path="bin"/>
1021
</classpath>
-25 Bytes
Binary file not shown.

GraphStreamTest/bin/main/Clicks.class

-2.42 KB
Binary file not shown.
858 Bytes
Binary file not shown.
-100 Bytes
Binary file not shown.
-187 Bytes
Binary file not shown.

GraphStreamTest/src/gsim/GraphSim.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public void ppr_go(String v) {
233233
public void importGraph(File f) {
234234

235235
String graphdata = getStringFromFile(f);
236-
System.out.println(graphdata);
236+
//System.out.println(graphdata);
237237
ImportEdgeDetails[] ied = getImportEdgeDetails(graphdata);
238238
addImportEdgeDetailsToGraph(ied);
239239
return;
@@ -318,7 +318,7 @@ private void addImportEdgeDetailsToGraph(ImportEdgeDetails[] ied)
318318
for (ImportEdgeDetails ed : ied)
319319
{
320320

321-
System.out.println(ed.toString());
321+
//System.out.println(ed.toString());
322322
String v1 = ed.v1;
323323
String v2 = ed.v2;
324324
String e = ed.e;
@@ -343,6 +343,10 @@ private void addImportEdgeDetailsToGraph(ImportEdgeDetails[] ied)
343343
}
344344
}
345345

346+
/**
347+
* Get the graph object of the current graph
348+
* @return graph object of the current graph
349+
*/
346350
public Graph getGraph()
347351
{
348352
return graph;

GraphStreamTest/src/main/Clicks.java

Lines changed: 0 additions & 77 deletions
This file was deleted.

GraphStreamTest/src/main/ControlUI.java

Lines changed: 45 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -31,50 +31,60 @@
3131
import org.graphstream.ui.swingViewer.ViewerPipe;
3232

3333

34-
34+
/**
35+
* UI Class that contains all the UI functions
36+
* @author brandon
37+
*
38+
*/
3539
public class ControlUI extends JFrame implements ActionListener {
3640

3741

3842
// Logic Variables
39-
MainLogic MLogic;
40-
File graph_file = null;
41-
File anim_file = null;
43+
private MainLogic MLogic;
44+
private File graph_file = null;
45+
private File anim_file = null;
4246

43-
GraphUIProperty gUIProp;
47+
private GraphUIProperty gUIProp;
4448

4549
// UI Components
4650

47-
int frm_width, frm_height;
48-
int ctrl_width, ctrl_height;
51+
private int frm_width, frm_height;
52+
private int ctrl_width, ctrl_height;
4953

50-
JFileChooser fc;
51-
JFrame jfrm;
54+
private JFileChooser fc;
55+
private JFrame jfrm;
5256

53-
JLabel lbl_header;
54-
JLabel lbl_graphPath;
55-
JButton btn_chooseGraph;
57+
private JLabel lbl_header;
58+
private JLabel lbl_graphPath;
59+
private JButton btn_chooseGraph;
5660

57-
JButton btn_loadGraph;
61+
private JButton btn_loadGraph;
5862

59-
JPanel ctrl_panel;
63+
private JPanel ctrl_panel;
6064

61-
JTextField txt_highlight;
62-
JButton btn_highlight;
65+
private JTextField txt_highlight;
66+
private JButton btn_highlight;
6367

64-
View vw=null;
68+
private View vw=null;
6569

6670
// Set % of span
67-
double btn_chooseGraph_h = .1;
68-
71+
private double btn_chooseGraph_h = .1;
6972

7073

74+
/**
75+
* Constructor, inits and starts UI
76+
*/
7177
public ControlUI ()
7278
{
7379
init ();
7480
startUI();
7581

7682
}
7783

84+
/**
85+
* initializes height, width variables, etc.
86+
* and creates main logic object for use by UI
87+
*/
7888
private void init ()
7989
{
8090

@@ -95,9 +105,12 @@ private void init ()
95105
gUIProp.posx = 0;
96106
gUIProp.posy = 0;
97107

98-
MLogic= new MainLogic(gUIProp);
108+
MLogic= new MainLogic();
99109
}
100110

111+
/**
112+
* Adds objects to UI, prepares UI window
113+
*/
101114
private void startUI(){
102115

103116
jfrm = new JFrame();
@@ -135,13 +148,11 @@ private void startUI(){
135148
ctrl_panel.add(btn_loadGraph);
136149
btn_loadGraph.addActionListener(this);
137150

138-
/* Features to add
151+
// Features to add
139152
// Block Label
140153
JLabel lbl_div1 = new JLabel("-----------------------------------");
141154
ctrl_panel.add(lbl_div1);
142155

143-
144-
145156
// Highlight filter Text Field and button
146157
txt_highlight = new JTextField();
147158
ctrl_panel.add(txt_highlight);
@@ -154,7 +165,7 @@ public void actionPerformed(ActionEvent e) {
154165
}
155166
});
156167
ctrl_panel.add(btn_highlight);
157-
*/
168+
158169

159170
jfrm.setVisible(true);
160171

@@ -168,102 +179,18 @@ public void actionPerformed(ActionEvent e) {
168179
//fromViewer.addViewerListener((ViewerListener) new NodeClickListener());
169180
//fromViewer.addSink(graph);
170181

171-
172-
/*
173-
174-
175-
// Initialize Frame + set default behaviors
176-
jfrm=new JFrame("VisualProPPR Control");
177-
jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
178-
jfrm.setLayout(new BorderLayout());
179-
180-
181-
// Set width height and location
182-
Dimension screen_dim = Toolkit.getDefaultToolkit().getScreenSize();
183-
184-
jfrm.setSize(frm_width,frm_height);
185-
186-
jfrm.setLocation(screen_dim.width - ctrl_width, 0);
187-
188-
189-
190-
191-
192-
193-
// Label
194-
lbl_header=new JLabel("Welcome to VisualProPPR");
195-
jfrm.add(lbl_header);
196-
197-
198-
// Choose graph button
199-
200-
//button dims
201-
int btn_width = (int)((double)ctrl_width * 0.8);
202-
int btn_height = (int)((double)ctrl_height * btn_chooseGraph_h);
203-
btn_chooseGraph = new JButton("Graph Button Chooser");
204-
btn_chooseGraph.setVerticalTextPosition(AbstractButton.CENTER);
205-
btn_chooseGraph.setHorizontalTextPosition(AbstractButton.LEADING); //aka LEFT, for left-to-right locales
206-
btn_chooseGraph.addActionListener(this);
207-
btn_chooseGraph.setLocation(frm_width-ctrl_width, 0);
208-
btn_chooseGraph.setSize(btn_width, btn_height);
209-
jfrm.add(btn_chooseGraph,BorderLayout.LINE_END);
210-
211-
// Chosen Graph Label
212-
lbl_graphPath =new JLabel("");
213-
lbl_graphPath.setText("< No Graph Chosen >");
214-
// Get location offset
215-
//btn_chooseGraph.getLocation() + btn_chooseGraph.getSize();
216-
lbl_graphPath.setLocation(frm_width - ctrl_width, 50);
217-
218-
jfrm.add(lbl_graphPath, BorderLayout.LINE_END);
219-
220-
221-
222-
223-
// File Chooser Component
224-
//Create a file chooser
225-
fc = new JFileChooser();
226-
//In response to a button click:
227-
//fc.showOpenDialog(jfrm);
228-
229-
230-
// Load graph button
231-
btn_width = (int)((double)ctrl_width * 0.8);
232-
btn_height = (int)((double)ctrl_height * btn_chooseGraph_h);
233-
btn_loadGraph = new JButton("Load Graph");
234-
btn_loadGraph.setVerticalTextPosition(AbstractButton.CENTER);
235-
btn_loadGraph.setHorizontalTextPosition(AbstractButton.LEADING); //aka LEFT, for left-to-right locales
236-
btn_loadGraph.addActionListener(this);
237-
btn_loadGraph.setLocation(frm_width-ctrl_width, 100);
238-
//btn_loadGraph.setSize(btn_width, btn_height);
239-
btn_loadGraph.setSize(100, 100);
240-
jfrm.add(btn_loadGraph,BorderLayout.LINE_END);
241-
242-
//int returnVal = fc.showOpenDialog(null);
243-
244-
245-
// Add components
246-
jfrm.setVisible(true);
247-
248-
*/
249-
/*
250-
* // Set it so program doesnt abort when close window
251-
vwr.setCloseFramePolicy(Viewer.CloseFramePolicy.CLOSE_VIEWER);
252-
org.graphstream.ui.swingViewer.View vw = vwr.getDefaultView();
253-
vw.setSize(width,height);
254-
vw.setLocation(posx, posy);
255-
256-
*/
182+
257183
}
258184

259185

260186

261187

262-
188+
/**
189+
* Action listener for click of buttons
190+
*/
263191
public void actionPerformed(ActionEvent e) {
264192
Object source = e.getSource();
265-
System.out.println("Event:" + e);
266-
System.out.println("Source:" + source);
193+
267194

268195
if (source == btn_chooseGraph)
269196
{
@@ -285,6 +212,9 @@ public void actionPerformed(ActionEvent e) {
285212
}
286213

287214

215+
/**
216+
* Function to laod graph and create graph listener
217+
*/
288218
NodeClickListener clisten=null;
289219
private void loadGraph()
290220
{
@@ -308,13 +238,11 @@ private void loadGraph()
308238
vw = vwr.addDefaultView(false);
309239

310240

311-
System.out.println(gUIProp.width);
312-
System.out.println(gUIProp.height);
313241
vw.setSize(gUIProp.width,gUIProp.height);
314242
vw.setLocation(gUIProp.posx, gUIProp.posy);
315243

316244

317-
/* Features to add
245+
// Features to add
318246
// We connect back the viewer to the graph,
319247
// the graph becomes a sink for the viewer.
320248
// We also install us as a viewer listener to
@@ -323,7 +251,7 @@ private void loadGraph()
323251
clisten = new NodeClickListener(fromViewer, vw, MLogic.getGraph());
324252
fromViewer.addViewerListener((ViewerListener) clisten);
325253

326-
*/
254+
327255

328256
// Add in frame
329257
jfrm.add(vw,BorderLayout.LINE_START);

0 commit comments

Comments
 (0)