Skip to content

Commit

Permalink
Added a top level Springy namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Hotson committed Mar 14, 2013
1 parent 9e4b8b0 commit 484ec31
Show file tree
Hide file tree
Showing 6 changed files with 608 additions and 596 deletions.
2 changes: 1 addition & 1 deletion demo-json.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
};

jQuery(function(){
var graph = new Graph();
var graph = new Springy.Graph();
graph.loadJSON(graphJSON);

var springy = jQuery('#springydemo').springy({
Expand Down
14 changes: 7 additions & 7 deletions demo-raphael.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
</script>

<script>
var graph = new Graph();
var graph = new Springy.Graph();

var dennis = graph.newNode({label: 'Dennis'});
var michael = graph.newNode({label: 'Michael'});
Expand Down Expand Up @@ -166,16 +166,16 @@
}

function doit() {
var layout = new Layout.ForceDirected(graph, 640, 480.0, 0.5);
var layout = new Springy.Layout.ForceDirected(graph, 640, 480.0, 0.5);

var r = Raphael("holder", 640, 480);

// calculate bounding box of graph layout.. with ease-in
var currentBB = layout.getBoundingBox();
var targetBB = {bottomleft: new Vector(-2, -2), topright: new Vector(2, 2)};
var targetBB = {bottomleft: new Springy.Vector(-2, -2), topright: new Springy.Vector(2, 2)};

// auto adjusting bounding box
Layout.requestAnimationFrame(function adjust() {
Springy.requestAnimationFrame(function adjust() {
targetBB = layout.getBoundingBox();
// current gets 20% closer to target every iteration
currentBB = {
Expand All @@ -185,19 +185,19 @@
.divide(10))
};

Layout.requestAnimationFrame(adjust);
Springy.requestAnimationFrame(adjust);
});

// convert to/from screen coordinates
toScreen = function(p) {
var size = currentBB.topright.subtract(currentBB.bottomleft);
var sx = p.subtract(currentBB.bottomleft).divide(size.x).x * r.width;
var sy = p.subtract(currentBB.bottomleft).divide(size.y).y * r.height;
return new Vector(sx, sy);
return new Springy.Vector(sx, sy);
};


var renderer = new Renderer(layout,
var renderer = new Springy.Renderer(layout,
function clear() {
// code to clear screen
},
Expand Down
2 changes: 1 addition & 1 deletion demo-simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<script src="springy.js"></script>
<script src="springyui.js"></script>
<script>
var graph = new Graph();
var graph = new Springy.Graph();
graph.addNodes('Dennis', 'Michael', 'Jessica', 'Timothy', 'Barbara')
graph.addNodes('Amphitryon', 'Alcmene', 'Iphicles', 'Heracles');

Expand Down
2 changes: 1 addition & 1 deletion demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<script src="springy.js"></script>
<script src="springyui.js"></script>
<script>
var graph = new Graph();
var graph = new Springy.Graph();

var dennis = graph.newNode({
label: 'Dennis',
Expand Down
Loading

0 comments on commit 484ec31

Please sign in to comment.