Menu

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

Download this file

114 lines (86 with data), 2.9 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
 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
111
112
113
package ls.graph;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;
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, InternalFrameListener
{
private GraphInternalFrame graphFrame = null;
private GraphScriptEngine scriptEngine = null;
private List<ControlListener> localControlListeners = new LinkedList<ControlListener>();
private Controller globalController = null;
GraphController(GraphInternalFrame gf,Controller controller)
{
super();
if (controller == null)
throw new IllegalArgumentException("GraphController: Controller cannot be null");
if (gf == null)
throw new IllegalArgumentException("GraphController: Internal frame cannot be null");
this.globalController = controller;
this.graphFrame = gf;
gf.setGraphController(this);
gf.addInternalFrameListener(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);
}
public void internalFrameActivated(InternalFrameEvent arg0)
{
this.globalController.fireGraphChanged(this.graph());
}
public void internalFrameClosed(InternalFrameEvent arg0)
{
// TODO Auto-generated method stub
}
public void internalFrameClosing(InternalFrameEvent arg0)
{
// TODO Auto-generated method stub
}
public void internalFrameDeactivated(InternalFrameEvent arg0)
{
// TODO Auto-generated method stub
}
public void internalFrameDeiconified(InternalFrameEvent arg0)
{
// TODO Auto-generated method stub
}
public void internalFrameIconified(InternalFrameEvent arg0)
{
// TODO Auto-generated method stub
}
public void internalFrameOpened(InternalFrameEvent arg0)
{
// TODO Auto-generated method stub
}
} //end of GraphController class
MongoDB Logo MongoDB