i want to draw the topology of the network which can display the hierachy relation, which means that when i click on the vertex( subnet or node) i want it to display the topology in that subnet( if it is a subnet).
so i need to redraw the the graph, when i click the node.
but when i implement the graphClicked method of GraphMouseListener
code like this :
public class TopHierachy {
static Graph graph;
VisualizationViewer vv;
public TopHierachy() {
super();
graph = getGraph("I:\\ljt\\workplace\\jungTest\\samples\\datasets\\my.net");
JFrame jf = new JFrame();
vv = new VisualizationViewer(new KKLayout(graph), new PluggableRenderer());
vv.addGraphMouseListener(new MySimpleGraphMouse(vv));
jf.getContentPane().add(vv);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.pack();
jf.setVisible(true);
}
public static Graph getGraph(String filename) {
Graph g = null;
try {
PajekNetReader pnr = new PajekNetReader();
g = pnr.load(filename);
} catch (IOException e) {
e.printStackTrace();
}
return g;
}
public static class MySimpleGraphMouse extends SimpleGraphMouse implements GraphMouseListener {
public MySimpleGraphMouse(VisualizationViewer vv) {
super(vv);
}
i want to draw the topology of the network which can display the hierachy relation, which means that when i click on the vertex( subnet or node) i want it to display the topology in that subnet( if it is a subnet).
so i need to redraw the the graph, when i click the node.
but when i implement the graphClicked method of GraphMouseListener
code like this :
public class TopHierachy {
static Graph graph;
VisualizationViewer vv;
public TopHierachy() {
super();
graph = getGraph("I:\\ljt\\workplace\\jungTest\\samples\\datasets\\my.net");
JFrame jf = new JFrame();
vv = new VisualizationViewer(new KKLayout(graph), new PluggableRenderer());
vv.addGraphMouseListener(new MySimpleGraphMouse(vv));
jf.getContentPane().add(vv);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.pack();
jf.setVisible(true);
}
public static Graph getGraph(String filename) {
Graph g = null;
try {
PajekNetReader pnr = new PajekNetReader();
g = pnr.load(filename);
} catch (IOException e) {
e.printStackTrace();
}
return g;
}
public static class MySimpleGraphMouse extends SimpleGraphMouse implements GraphMouseListener {
public MySimpleGraphMouse(VisualizationViewer vv) {
super(vv);
}
public void graphClicked(Vertex v, MouseEvent me) {
graph = getGraph("I:\\ljt\\workplace\\jungTest\\samples\\datasets\\my2.net");
graph.removeAllEdges();
vv.repaint();
}
public void graphPressed(Vertex v, MouseEvent me) {
}
public void graphReleased(Vertex v, MouseEvent me) {
}
}
public static void main(String[] args) {
TopHierachy t = new TopHierachy();
}
}
i wonder why the handler wasn't invoke when i click the mouse
in fact the click Event is invoked, but why the graph didn't change