Skip to content

Commit

Permalink
a pass at cleaning up some errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
willscott committed Mar 12, 2012
1 parent 28b0d6d commit 8fe6b6f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 2 additions & 0 deletions build.xml
Expand Up @@ -15,6 +15,8 @@
<pathelement location="lib/core.jar" />
<pathelement location="lib/carnivore.jar" />
<pathelement location="lib/rsglib.jar" />
<pathelement location="lib/SQLibrary.jar" />
<pathelement location="lib/sqlitejdbc-v053-pure.jar" />
</path>


Expand Down
25 changes: 15 additions & 10 deletions src/com/p2pbr/netviz/NetViz.java
Expand Up @@ -58,6 +58,8 @@ public class NetViz extends PApplet {
int lastBG[] = new int[3];

private class Pin {
PApplet parent;

public int state;
public int animation;

Expand Down Expand Up @@ -86,7 +88,8 @@ private class Pin {
private int deadTimer = 1;
private boolean pulseUp = true;

public Pin(PImage mapImage, float lat, float lon, String country, String city) {
public Pin(PApplet p, PImage mapImage, float lat, float lon, String country, String city) {
this.parent = p;
this.mapImage = mapImage;
this.x = map(lon, -180, 180, mapX, mapX+mapImage.width);
this.y = map(lat, 90, -90, mapY, mapY+mapImage.height);
Expand All @@ -98,13 +101,15 @@ public Pin(PImage mapImage, float lat, float lon, String country, String city) {
this.state = STATE_ANIMATE;
this.animation = 1;
}

private int pulseStep() {
if (pulseUp) { pulse++; }
else { pulse--; }
if (pulse >= PULSE_MAX) { pulseUp = false; }
if (pulse <= PULSE_MAX * -1) { pulseUp = true; }
return pulse;
}

public boolean drawSelf() {
int rad = 8;
if (bytes > 0) {
Expand All @@ -118,7 +123,7 @@ public boolean drawSelf() {
if (state == STATE_STATIC) {
//println("static, rad="+rad);
if (bytes > 0) {
int variation = int(random(3));
int variation = (int)(parent.random(3));
//println("bytes >0");
fill(0x00, 0x00, 0x00, 0x00);
stroke(0xff, 0x00, 0xff);
Expand Down Expand Up @@ -193,10 +198,10 @@ void setup() {

// setup pins for local, loopback, autoconfig, broadcast.
//public Pin(PImage mapImage, float lat, float lon, String country, String city) {
localPin = new Pin(mapImage, -105, -160, null, null);
broadcastPin = new Pin(mapImage, -105, -120, null, null);
loopbackPin = new Pin(mapImage, -105, -80, null, null);
autoconfigPin = new Pin(mapImage, -105, -40, null, null);
localPin = new Pin(this, mapImage, -105, -160, null, null);
broadcastPin = new Pin(this, mapImage, -105, -120, null, null);
loopbackPin = new Pin(this, mapImage, -105, -80, null, null);
autoconfigPin = new Pin(this, mapImage, -105, -40, null, null);

//
size(WIDTH, HEIGHT);
Expand Down Expand Up @@ -270,8 +275,8 @@ private void drawPointsForNewPackets() {
// draw new packets
for (int i=0; i<this.newPackets/2; i++) {
stroke(0xFF, 0xFF, 0xFF);
int x = int(random(WIDTH-1));
int y = int(random(mapImage.height, HEIGHT-1));
int x = (int)(random(WIDTH-1));
int y = (int)(random(mapImage.height, HEIGHT-1));
point(x,y);
}
this.newPackets = this.newPackets/2;
Expand Down Expand Up @@ -299,7 +304,7 @@ int[] getBackgroundColorFromTrafficSpeed() {
if (absFraction > 1) {
absFraction = 1;
}
int r = int(Math.round(255 * absFraction));
int r = (int)(Math.round(255 * absFraction));
if (r > 255) {
r = 255;
}
Expand Down Expand Up @@ -462,7 +467,7 @@ synchronized void packetEvent(CarnivorePacket packet) {
float lat = latlon[0];
float lon = latlon[1];

p = new Pin(mapImage, lat, lon, country, city);
p = new Pin(this, mapImage, lat, lon, country, city);
pins.put(ip.toString(), p);
output.println(ip.toString());
output.flush();
Expand Down

0 comments on commit 8fe6b6f

Please sign in to comment.