//Extract links
//nodes.child[0] = parent node index
//nodes.child[+] = child nodes
//nodes.url[0] = name of node
//nodes.url[+] = address of resources
TextField inputLine = new TextField("input URL", 30);
Button sub = new Button("submit");
BFont metaBold;
linkMap [] nodes = new linkMap[1];
int stage = 1;
int c = 0;
void setup(){
size (400,400);
background (200);
smooth();
noStroke();
//framerate(4);
metaBold = loadFont("Meta-Bold.vlw.gz");
textFont(metaBold, 20);
add(inputLine);
add(sub);
sub.addActionListener(new ButtonListener());
}
void loop(){
if (stage == 2){
updateScreen();
}
}//loop;
class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
println(e.getActionCommand());
String iLine = inputLine.getText();
if (!iLine.substring(0,7).equals("http://") ){
iLine = "http://" + iLine;
} else if (!iLine.substring(0,7).equals("http://www.")){
iLine = "http://www." + iLine;
}
remove(inputLine);
remove(sub);
println("request: " + iLine);
nodes[0] = new linkMap(iLine, -1);
nodeChildren(0);
nodeResource(0);
stage = 2;
}
}
String getLinks (String name){
String returnThing = "bad link";
String lines[] = loadStrings(name);
if (lines == null){
return returnThing;
} else {
String docu = join(lines," ");
//link extraction
int mark = 0;
String type = "HREF";
if (stringNum(docu,"