Displaying Links


#1

Hi i am just getting started with JGO … I have a very basic doubt…
How do i display a link programatically on the screen?
this is the simple code that i wrote…is this ok?
the nodes are being displayed but the link is not getting displayed
public void makeGraph()
{
JGoDocument doc = myView.getDocument();

JGoBasicNode node1 = new JGoBasicNode(“first”);
node1.setLocation(100,200);
node1.setBrush(JGoBrush.makeStockBrush(Color.blue));
doc.addObjectAtTail(node1);

JGoBasicNode node2 = new JGoBasicNode(“first”);
node2.setLocation(300,200);
node2.setBrush(JGoBrush.makeStockBrush(Color.RED));
doc.addObjectAtTail(node2);

JGoPort port1 = node1.createPort();
JGoPort port2 = node2.createPort();

JGoLink myLink = new JGoLink(port1,port2);
doc.addObjectAtTail(myLink);
}

public static void main(String args[])
{
JFrame myGraph = new ApplicationAnalysisGraph();
myGraph.setSize(400,400);
myGraph.setVisible(true);
}


#2

When you call the JGoBasicNode constructor with a string argument, it automatically creates and adds all of the standard parts of a JGoBasicNode. So each node already has a port.
Just replace your calls to createPort() with calls to getPort().


#3

Thanks i actually found that out myself Thanks anyway…i’l be back with more questions