Menu

[r70]: / GraphScript / trunk / ls / graph / GraphController.java  Maximize  Restore  History

Download this file

63 lines (51 with data), 1.7 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
package ls.graph;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import ls.graph.script.AlgorithmListener;
import ls.graph.script.GraphScriptEngine;
import ls.graph.script.ScriptableGraph;
import ls.graph.ui.GraphInternalFrame;
public class GraphController implements ControlListener
{
private GraphInternalFrame graphFrame = null;
private GraphScriptEngine scriptEngine = null;
private List<ControlListener> localControlListeners = new LinkedList<ControlListener>();
GraphController(GraphInternalFrame gf)
{
super();
if (gf == null)
throw new IllegalArgumentException("GraphController: Graph frame is null");
this.graphFrame = gf;
gf.setGraphController(this);
this.scriptEngine = new GraphScriptEngine(this);
}
public GraphInternalFrame frame() { return graphFrame; }
public ScriptableGraph graph() { return frame().getGraph(); }
public void addControlListener(ControlListener l)
{
if (l != null) this.localControlListeners.add(l);
}
GraphScriptEngine scriptEngine() { return this.scriptEngine; }
public void addAlgorithmListener(AlgorithmListener l)
{
if (l != null)
this.frame().addAlgorithmListener(l);
}
public void graphChanged(ScriptableGraph sg)
{
for (ControlListener l : localControlListeners)
l.graphChanged(sg);
}
public void graphLoaded(File graphFile)
{
this.frame().setTitle(graphFile.getName());
for (ControlListener l : localControlListeners)
l.graphLoaded(graphFile);
}
public void scriptLoaded(File scriptFile, String scriptText)
{
for (ControlListener l : localControlListeners)
l.scriptLoaded(scriptFile, scriptText);
}
} //end of GraphController class
MongoDB Logo MongoDB