Skip to content

Commit

Permalink
fixed domain graph applet (visible in Terminal)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5946 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed May 11, 2009
1 parent 04ec42e commit d3ca038
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 16 deletions.
Binary file modified htroot/processing/domaingraph/applet/domaingraph.jar
Binary file not shown.
34 changes: 28 additions & 6 deletions htroot/processing/domaingraph/applet/domaingraph.java
@@ -1,4 +1,4 @@
import processing.core.*; import traer.physics.*; import traer.animation.*; import processing.net.*; import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; import javax.sound.midi.*; import javax.sound.midi.spi.*; import javax.sound.sampled.*; import javax.sound.sampled.spi.*; import java.util.regex.*; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.sax.*; import javax.xml.transform.stream.*; import org.xml.sax.*; import org.xml.sax.ext.*; import org.xml.sax.helpers.*; public class domaingraph extends PApplet {// Domain visualization graph for YaCy
import processing.core.*; import traer.physics.*; import traer.animation.*; import processing.net.*; import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; public class domaingraph extends PApplet {// Domain visualization graph for YaCy
// by Michael Christen
//
// this applet uses code and the physics engine from
Expand Down Expand Up @@ -96,7 +96,7 @@ public void draw() {

public void initRequest(boolean update) {
myClient = new Client(this, host, port);
myClient.write((update) ? "GET /xml/webstructure.xml?latest= HTTP/1.1\n" : "GET /xml/webstructure.xml HTTP/1.1\n");
myClient.write((update) ? "GET /api/webstructure.xml?latest= HTTP/1.1\n" : "GET /xml/webstructure.xml HTTP/1.1\n");
myClient.write("Host: localhost\n\n");
}

Expand All @@ -111,8 +111,31 @@ public void processRequestResponse(int steps) {
String line = myClient.readStringUntil((byte) 10);
//println("Line: " + line);
if (line == null) line = ""; else line = line.trim();
if (line.startsWith("<domain")) processDomain(parseProps(line.substring(7, line.length() - 1).trim()));
if (line.startsWith("<citation")) processCitation(parseProps(line.substring(9, line.length() - 2).trim()));
/*
<domain host="www.oreilly.com" id="-1po3Y" date="20090510">
<reference id="uU2r5Q" count="2">www.catb.org</reference>
<reference id="zG43kY" count="516">oreilly.com</reference>
<reference id="QEf_LZ" count="44">www.oreillynet.com</reference>
</domain>
*/
int p = line.indexOf("<domain");
if (p >= 0) {
//println("domain :" + line.substring(p + 8, line.length() - 1).trim());
processDomain(parseProps(line.substring(p + 8, line.length() - 1).trim()));
}
p = line.indexOf("<reference");
if (p >= 0) {
int q = line.indexOf("</reference>");
if (q > 0) {
int r = line.lastIndexOf('>', q);
if (r > 0) {
String refhost = line.substring(r, q);
//println("reference:" + line.substring(p + 11, r).trim());
processCitation(refhost, parseProps(line.substring(p + 11, r).trim()));
}
}
}
lastUpdate = System.currentTimeMillis();
} else {
initTime = false;
Expand All @@ -135,9 +158,8 @@ public void processDomain(HashMap props) {
addAttraction(h.node);
}

public void processCitation(HashMap props) {
public void processCitation(String host, HashMap props) {
//println("Citation: " + props.toString());
String host = (String) props.get("host"); if (host == null) host = "";
String id = (String) props.get("id"); if (id == null) id = "";
int count = 0;
try {
Expand Down
32 changes: 27 additions & 5 deletions htroot/processing/domaingraph/applet/domaingraph.pde
Expand Up @@ -96,7 +96,7 @@ void draw() {

void initRequest(boolean update) {
myClient = new Client(this, host, port);
myClient.write((update) ? "GET /xml/webstructure.xml?latest= HTTP/1.1\n" : "GET /xml/webstructure.xml HTTP/1.1\n");
myClient.write((update) ? "GET /api/webstructure.xml?latest= HTTP/1.1\n" : "GET /xml/webstructure.xml HTTP/1.1\n");
myClient.write("Host: localhost\n\n");
}

Expand All @@ -111,8 +111,31 @@ void processRequestResponse(int steps) {
String line = myClient.readStringUntil((byte) 10);
//println("Line: " + line);
if (line == null) line = ""; else line = line.trim();
if (line.startsWith("<domain")) processDomain(parseProps(line.substring(7, line.length() - 1).trim()));
if (line.startsWith("<citation")) processCitation(parseProps(line.substring(9, line.length() - 2).trim()));
/*
<domain host="www.oreilly.com" id="-1po3Y" date="20090510">
<reference id="uU2r5Q" count="2">www.catb.org</reference>
<reference id="zG43kY" count="516">oreilly.com</reference>
<reference id="QEf_LZ" count="44">www.oreillynet.com</reference>
</domain>
*/
int p = line.indexOf("<domain");
if (p >= 0) {
//println("domain :" + line.substring(p + 8, line.length() - 1).trim());
processDomain(parseProps(line.substring(p + 8, line.length() - 1).trim()));
}
p = line.indexOf("<reference");
if (p >= 0) {
int q = line.indexOf("</reference>");
if (q > 0) {
int r = line.lastIndexOf('>', q);
if (r > 0) {
String refhost = line.substring(r, q);
//println("reference:" + line.substring(p + 11, r).trim());
processCitation(refhost, parseProps(line.substring(p + 11, r).trim()));
}
}
}
lastUpdate = System.currentTimeMillis();
} else {
initTime = false;
Expand All @@ -135,9 +158,8 @@ void processDomain(HashMap props) {
addAttraction(h.node);
}

void processCitation(HashMap props) {
void processCitation(String host, HashMap props) {
//println("Citation: " + props.toString());
String host = (String) props.get("host"); if (host == null) host = "";
String id = (String) props.get("id"); if (id == null) id = "";
int count = 0;
try {
Expand Down
32 changes: 27 additions & 5 deletions htroot/processing/domaingraph/domaingraph.pde
Expand Up @@ -96,7 +96,7 @@ void draw() {

void initRequest(boolean update) {
myClient = new Client(this, host, port);
myClient.write((update) ? "GET /xml/webstructure.xml?latest= HTTP/1.1\n" : "GET /xml/webstructure.xml HTTP/1.1\n");
myClient.write((update) ? "GET /api/webstructure.xml?latest= HTTP/1.1\n" : "GET /xml/webstructure.xml HTTP/1.1\n");
myClient.write("Host: localhost\n\n");
}

Expand All @@ -111,8 +111,31 @@ void processRequestResponse(int steps) {
String line = myClient.readStringUntil((byte) 10);
//println("Line: " + line);
if (line == null) line = ""; else line = line.trim();
if (line.startsWith("<domain")) processDomain(parseProps(line.substring(7, line.length() - 1).trim()));
if (line.startsWith("<citation")) processCitation(parseProps(line.substring(9, line.length() - 2).trim()));
/*
<domain host="www.oreilly.com" id="-1po3Y" date="20090510">
<reference id="uU2r5Q" count="2">www.catb.org</reference>
<reference id="zG43kY" count="516">oreilly.com</reference>
<reference id="QEf_LZ" count="44">www.oreillynet.com</reference>
</domain>
*/
int p = line.indexOf("<domain");
if (p >= 0) {
//println("domain :" + line.substring(p + 8, line.length() - 1).trim());
processDomain(parseProps(line.substring(p + 8, line.length() - 1).trim()));
}
p = line.indexOf("<reference");
if (p >= 0) {
int q = line.indexOf("</reference>");
if (q > 0) {
int r = line.lastIndexOf('>', q);
if (r > 0) {
String refhost = line.substring(r, q);
//println("reference:" + line.substring(p + 11, r).trim());
processCitation(refhost, parseProps(line.substring(p + 11, r).trim()));
}
}
}
lastUpdate = System.currentTimeMillis();
} else {
initTime = false;
Expand All @@ -135,9 +158,8 @@ void processDomain(HashMap props) {
addAttraction(h.node);
}

void processCitation(HashMap props) {
void processCitation(String host, HashMap props) {
//println("Citation: " + props.toString());
String host = (String) props.get("host"); if (host == null) host = "";
String id = (String) props.get("id"); if (id == null) id = "";
int count = 0;
try {
Expand Down

0 comments on commit d3ca038

Please sign in to comment.