Skip to content

Commit

Permalink
Added WebSocket code for Euler Diagram creation
Browse files Browse the repository at this point in the history
Although this will be moved to an external location at some point
  • Loading branch information
robbaker292 committed Oct 31, 2013
1 parent aa23ff8 commit f6748d8
Show file tree
Hide file tree
Showing 484 changed files with 205,371 additions and 30 deletions.
9 changes: 3 additions & 6 deletions visualizations/high/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
To run the offline high level visualization, there are several requirements:
Navigate to regions.html in your HTML5 compliant browser. You must be connected to the web.

All files need to be stored in a webserver, specifically one that can run PHP.
The webserver also needs Java 1.6 or greater.
Currently, you will need to run ws/bin/ws-server.php from the command line for the Euler diagram creation to be run. Soon, this will be stored externally so only a web connection will be required.

Once these requirements are met, navigate to regions.html in your HTML5 compliant browser.

It requires three files in various formats, and these formats must be exact.
The visualization requires three files in various formats, and these formats must be exact.

Example of sgroup format (see sgroup.txt):
```
Expand Down
49 changes: 25 additions & 24 deletions visualizations/high/regions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ var currentTime = 0;
var svg;
var times = [];

var conn = new WebSocket('ws://localhost:8081');
//var conn = new WebSocket('ws://cs.kent.ac.uk/~rb440/:8081');
conn.onopen = function(e) {
console.log("Connection established!");
};

conn.onmessage = function(e) {
parseCircles(e.data);
};

/** A labelled circle */
function Circle(label,r,x,y) {
this.label = label;
Expand Down Expand Up @@ -167,7 +177,8 @@ function readFile(fileType){
if (fileType == "sGroup"){
sGroupsRead = true;

parseCircles(output);
//parseCircles(output);
conn.send(output);

$(sGroupUpload).hide();
$(nodesBox).show();
Expand Down Expand Up @@ -252,30 +263,20 @@ function parseNodes(nodesFile) {

function parseCircles(input){

console.log(input);

//var url = "http://www.cs.kent.ac.uk/people/rpg/rb440/Release/runJava.php?input="+input;
var url = "runJava.php?input="+input;

var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);

xhr.onload = function() {
//decodeCsv(xhr.responseText.split("\n"));
console.log(xhr.responseText);
//console.log(circles,zones);
//testRegion(zones);

//console.log(circleFile);

circleFile = xhr.responseText.split("\n")
//use 1 as first row of input are labels
for (var i = 1; i < circleFile.length-1; i++){
var result = circleFile[i].split(",");
//console.log(result);
var c = new Circle(result[0].trim(), parseInt(result[3]), parseInt(result[1]), parseInt(result[2]));
circles.push(c);
}
};
xhr.send();
//var url = "runJava.php?input="+input;

circleFile = input.split("\n")
//use 1 as first row of input are labels
for (var i = 1; i < circleFile.length-1; i++){
var result = circleFile[i].split(",");
//console.log(result);
var c = new Circle(result[0].trim(), parseInt(result[3]), parseInt(result[1]), parseInt(result[2]));
circles.push(c);
}


}

Expand Down
28 changes: 28 additions & 0 deletions visualizations/high/ws/bin/ws-server.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use HighVis\HVWebSocket;

//require '/../autoload.php';
require dirname(__DIR__) . '/vendor/autoload.php';

//require '/vendor/autoload.php';
/*
$server = IoServer::factory(
new WsServer(
new HVWebSocket()
)
, 8081
);
/*/
$server = IoServer::factory(
new HttpServer(
new WsServer(
new HVWebSocket()
)
),
8081
);

$server->run();
10 changes: 10 additions & 0 deletions visualizations/high/ws/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"autoload": {
"psr-0": {
"HighVis": "src"
}
},
"require": {
"cboden/Ratchet": "0.3.*"
}
}
Loading

0 comments on commit f6748d8

Please sign in to comment.