diff --git a/app/assets/javascripts/src/JIT.js b/app/assets/javascripts/src/JIT.js
index 843f1fa8..1cc4b8e1 100644
--- a/app/assets/javascripts/src/JIT.js
+++ b/app/assets/javascripts/src/JIT.js
@@ -2498,7 +2498,11 @@ Extras.Classes.Navigation = new Class({
if (!Metamaps.Mouse.boxStartCoordinates && (e.shiftKey || rightClick)) {
Metamaps.Mouse.boxStartCoordinates = eventInfo.getPos();
}
+
Metamaps.Mouse.didPan = false;
+
+
+
// END METAMAPS CODE
this.pos = eventInfo.getPos();
@@ -2570,6 +2574,8 @@ Extras.Classes.Navigation = new Class({
// START METAMAPS CODE
if (Metamaps.Mouse.didPan) Metamaps.JIT.SmoothPanning();
+
+
// END METAMAPS CODE
}
diff --git a/app/assets/javascripts/src/Metamaps.GlobalUI.js b/app/assets/javascripts/src/Metamaps.GlobalUI.js
index fc8f46ea..4c2d9a05 100644
--- a/app/assets/javascripts/src/Metamaps.GlobalUI.js
+++ b/app/assets/javascripts/src/Metamaps.GlobalUI.js
@@ -366,6 +366,23 @@ Metamaps.GlobalUI.Search = {
self.close(0, true);
}
break;
+ case 65:
+ case 97:
+ e.preventDefault();
+ if (e.ctrlKey){
+ Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
+ Metamaps.Control.selectNode(n,e);
+ });
+
+ Metamaps.Visualize.mGraph.plot();
+ }
+
+ break;
+ case 69:
+ case 101:
+ e.preventDefault();
+ Metamaps.JIT.zoomExtents();
+ break;
default:
break; //console.log(e.which);
}
diff --git a/app/assets/javascripts/src/Metamaps.JIT.js b/app/assets/javascripts/src/Metamaps.JIT.js
index ee405736..9562e2fd 100644
--- a/app/assets/javascripts/src/Metamaps.JIT.js
+++ b/app/assets/javascripts/src/Metamaps.JIT.js
@@ -319,7 +319,7 @@ Metamaps.JIT = {
if (Metamaps.Mouse.boxStartCoordinates) {
Metamaps.Visualize.mGraph.busy = false;
Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos();
- Metamaps.JIT.selectWithBox(e);
+ Metamaps.JIT.zoomToBox();
return;
}
@@ -672,8 +672,6 @@ Metamaps.JIT = {
var scale = dist / lastDist;
- console.log(scale);
-
if (8 >= Metamaps.Visualize.mGraph.canvas.scaleOffsetX * scale && Metamaps.Visualize.mGraph.canvas.scaleOffsetX * scale >= 1) {
Metamaps.Visualize.mGraph.canvas.scale(scale, scale);
}
@@ -969,7 +967,9 @@ Metamaps.JIT = {
var fromNodeY = -1 * synapse.get('edge').nodeFrom.pos.y;
var toNodeX = synapse.get('edge').nodeTo.pos.x;
var toNodeY = -1 * synapse.get('edge').nodeTo.pos.y;
-
+ var from = synapse.get('edge').nodeFrom;
+ var to = synapse.get('edge').nodeTo;
+
var maxX = fromNodeX;
var maxY = fromNodeY;
var minX = fromNodeX;
@@ -988,7 +988,7 @@ Metamaps.JIT = {
(eX > maxBoxX) ? (maxBoxX = eX):(minBoxX = eX);
(eY > maxBoxY) ? (maxBoxY = eY):(minBoxY = eY);
- //Fins the slopes from the synapse fromNode to the 4 corners of the selection box
+ //Find the slopes from the synapse fromNode to the 4 corners of the selection box
var slopes = [];
slopes.push( (sY - fromNodeY) / (sX - fromNodeX) );
slopes.push( (sY - fromNodeY) / (eX - fromNodeX) );
@@ -1007,6 +1007,10 @@ Metamaps.JIT = {
var b = fromNodeY - synSlope * fromNodeX;
var selectTest = false;
+ if (from.name == 'node 3' && to.name == 'node1'){
+ console.log(from.pos.x,-1*from.pos.y,to.pos.x,-1*to.pos.y,sX,sY,eX,eY);
+ }
+
//if the synapse slope is within a range that would intersect with the selection box
if (synSlope <= maxSlope && synSlope >= minSlope){
@@ -1027,17 +1031,18 @@ Metamaps.JIT = {
testY = sY;
testX = (testY - b)/synSlope;
- if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testY <= maxBoxX){
+ if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testX <= maxBoxX){
selectTest = true;
}
testY = eY;
testX = (testY - b)/synSlope;
- if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testY <= maxBoxX){
+ if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testX <= maxBoxX){
selectTest = true;
}
}
+ //console.log('From '+from.name + ' to ' + to.name + ' is a ' +selectTest);
//The test synapse was selected!
if(selectTest){
if(e.ctrlKey){
@@ -1102,15 +1107,23 @@ Metamaps.JIT = {
// wait a certain length of time, then check again, then run this code
setTimeout(function () {
if (!Metamaps.JIT.nodeWasDoubleClicked()) {
- if (!e.shiftKey) {
+ if (!e.shiftKey && !e.ctrlKey) {
Metamaps.Control.deselectAllNodes();
Metamaps.Control.deselectAllEdges();
}
- if (node.selected) {
- Metamaps.Control.deselectNode(node);
- } else {
+ if(e.ctrlKey || e.shiftKey){
+ if (node.selected) {
+ Metamaps.Control.deselectNode(node);
+ } else {
+ Metamaps.Control.selectNode(node,e);
+ }
+ }
+ else{
+ Metamaps.Control.deselectAllNodes();
+ Metamaps.Control.deselectAllEdges();
Metamaps.Control.selectNode(node,e);
}
+
//trigger animation to final styles
Metamaps.Visualize.mGraph.fx.animate({
modes: ['edge-property:lineWidth:color:alpha'],
@@ -1138,7 +1151,6 @@ Metamaps.JIT = {
// create new menu for clicked on node
var rightclickmenu = document.createElement("div");
rightclickmenu.className = "rightclickmenu";
-
// add the proper options to the menu
var menustring = '
';
@@ -1170,8 +1182,7 @@ Metamaps.JIT = {
top: e.clientY
});
//add the menu to the page
- $('#wrapper').append(rightclickmenu);
-
+ $('#infovis-canvaswidget').append(rightclickmenu);
// attach events to clicks on the list items
@@ -1494,7 +1505,55 @@ Metamaps.JIT = {
canvas.translate(-1*offsetX,-1*offsetY);
},
- zoomExtents: function (event) {
+ zoomToBox: function () {
+ var sX = Metamaps.Mouse.boxStartCoordinates.x,
+ sY = Metamaps.Mouse.boxStartCoordinates.y,
+ eX = Metamaps.Mouse.boxEndCoordinates.x,
+ eY = Metamaps.Mouse.boxEndCoordinates.y;
+
+ Metamaps.JIT.centerMap();
+
+ var height = $(document).height(),
+ width = $(document).width();
+
+ var spanX = Math.abs(sX - eX);
+ var spanY = Math.abs(sY - eY);
+ var ratioX = width / spanX;
+ var ratioY = height / spanY;
+ console.log(ratioX,ratioY);
+
+ var newRatio = Math.min(ratioX,ratioY);
+
+ var canvas = Metamaps.Visualize.mGraph.canvas;
+
+ if(canvas.scaleOffsetX *newRatio<= 5 && canvas.scaleOffsetX*newRatio >= 0.2){
+ canvas.scale(newRatio,newRatio);
+ }
+ else if(canvas.scaleOffsetX * newRatio > 5){
+ newRatio = 5/ canvas.scaleOffsetX;
+ canvas.scale(newRatio,newRatio);
+ }
+ else{
+ newRatio = 0.2/ canvas.scaleOffsetX;
+ canvas.scale(newRatio,newRatio);
+ }
+
+
+
+
+
+ var cogX = (sX + eX)/2;
+ var cogY = (sY + eY)/2;
+
+ canvas.translate(-1* cogX, -1* cogY);
+
+
+ Metamaps.Mouse.boxStartCoordinates = false;
+ Metamaps.Mouse.boxEndCoordinates = false;
+ Metamaps.Visualize.mGraph.plot();
+
+ },
+ zoomExtents: function () {
Metamaps.JIT.centerMap();
var height = $(document).height(),
width = $(document).width(),
@@ -1503,119 +1562,98 @@ Metamaps.JIT = {
if (Metamaps.Selected.Nodes.length > 0) {
var nodes = Metamaps.Selected.Nodes;
+ }
+ else {
+ var nodes = _.values(Metamaps.Visualize.mGraph.graph.nodes);
+ }
- if(nodes.length > 1){
- nodes.forEach(function (n) {
- var x = n.pos.x,
- y = n.pos.y;
+ if(nodes.length > 1){
+ nodes.forEach(function (n) {
+ var x = n.pos.x,
+ y = n.pos.y;
- if (counter == 0){
- maxX = x;
- minX = x;
- maxY = y;
- minY = y;
- }
+ if (counter == 0){
+ maxX = x;
+ minX = x;
+ maxY = y;
+ minY = y;
+ }
- maxX = Math.max(x,maxX);
- maxY = Math.max(y,maxY);
- minX = Math.min(x,minX);
- minY = Math.min(y,minY);
+ var arrayOfLabelLines = Metamaps.Util.splitLine(n.name, 30).split('\n'),
+ dim = n.getData('dim'),
+ ctx = Metamaps.Visualize.mGraph.canvas.getCtx();
- counter++;
- });
+ var height = 25 * arrayOfLabelLines.length;
- var spanX = maxX - minX;
- var spanY = maxY - minY;
- var ratioX = spanX / width;
- var ratioY = spanY / height;
+ var index, lineWidths = [];
+ for (index = 0; index < arrayOfLabelLines.length; ++index) {
+ lineWidths.push(ctx.measureText(arrayOfLabelLines[index]).width)
+ }
+ var width = Math.max.apply(null, lineWidths) + 8;
- var newRatio = Math.max(ratioX,ratioY);
+ maxX = Math.max(x + width /2,maxX);
+ maxY = Math.max(y + n.getData("height") + 5 + height,maxY);
+ minX = Math.min(x - width /2,minX);
+ minY = Math.min(y - dim,minY);
- var canvas = Metamaps.Visualize.mGraph.canvas;
+ counter++;
+ });
- canvas.scale(1/newRatio*0.8,1/newRatio*0.8);
+ var spanX = maxX - minX;
+ var spanY = maxY - minY;
+ var ratioX = spanX / width;
+ var ratioY = spanY / height;
- counter = 0;
+ var newRatio = Math.max(ratioX,ratioY);
+ var scaleMultiplier = 1/newRatio*0.9;
- nodes.forEach(function (n) {
- var x = n.pos.x,
- y = n.pos.y;
-
- if (counter == 0){
- maxX = x;
- minX = x;
- maxY = y;
- minY = y;
- }
-
- maxX = Math.max(x,maxX);
- maxY = Math.max(y,maxY);
- minX = Math.min(x,minX);
- minY = Math.min(y,minY);
-
- counter++;
- });
+ var canvas = Metamaps.Visualize.mGraph.canvas;
+ if(canvas.scaleOffsetX *scaleMultiplier<= 3 && canvas.scaleOffsetX*scaleMultiplier >= 0.2){
+ canvas.scale(scaleMultiplier,scaleMultiplier);
}
+ else if(canvas.scaleOffsetX * scaleMultiplier > 3){
+ scaleMultiplier = 3/ canvas.scaleOffsetX;
+ canvas.scale(scaleMultiplier,scaleMultiplier);
+ }
+ else{
+ scaleMultiplier = 0.2/ canvas.scaleOffsetX;
+ canvas.scale(scaleMultiplier,scaleMultiplier);
+ }
+
+
+ counter = 0;
+
+ nodes.forEach(function (n) {
+ var x = n.pos.x,
+ y = n.pos.y;
+
+ if (counter == 0){
+ maxX = x;
+ minX = x;
+ maxY = y;
+ minY = y;
+ }
+
+ var arrayOfLabelLines = Metamaps.Util.splitLine(n.name, 30).split('\n'),
+ dim = n.getData('dim'),
+ ctx = Metamaps.Visualize.mGraph.canvas.getCtx();
+
+ var height = 25 * arrayOfLabelLines.length;
+
+ var index, lineWidths = [];
+ for (index = 0; index < arrayOfLabelLines.length; ++index) {
+ lineWidths.push(ctx.measureText(arrayOfLabelLines[index]).width)
+ }
+ var width = Math.max.apply(null, lineWidths) + 8;
+
+ maxX = Math.max(x + width /2,maxX);
+ maxY = Math.max(y + n.getData("height") + 5 + height,maxY);
+ minX = Math.min(x - width /2,minX);
+ minY = Math.min(y - dim,minY);
+
+ counter++;
+ });
}
- else{
- var nodes = Metamaps.Visualize.mGraph.graph;
-
- if(Object.keys(nodes).length >1){
- nodes.eachNode(function (n) {
- var x = n.pos.x,
- y = n.pos.y;
-
- if (counter == 0){
- maxX = x;
- minX = x;
- maxY = y;
- minY = y;
- }
-
- maxX = Math.max(x,maxX);
- maxY = Math.max(y,maxY);
- minX = Math.min(x,minX);
- minY = Math.min(y,minY);
-
- counter++;
- });
-
- var spanX = maxX - minX;
- var spanY = maxY - minY;
- var ratioX = spanX / width;
- var ratioY = spanY / height;
-
- var newRatio = Math.max(ratioX,ratioY);
-
- var canvas = Metamaps.Visualize.mGraph.canvas;
-
- canvas.scale(1/newRatio*0.8,1/newRatio*0.8);
-
- counter = 0;
-
- nodes.eachNode(function (n) {
- var x = n.pos.x,
- y = n.pos.y;
-
- if (counter == 0){
- maxX = x;
- minX = x;
- maxY = y;
- minY = y;
- }
-
- maxX = Math.max(x,maxX);
- maxY = Math.max(y,maxY);
- minX = Math.min(x,minX);
- minY = Math.min(y,minY);
-
- counter++;
- });
- }
- }
-
-
-
var cogX = (maxX + minX)/2;
var cogY = (maxY + minY)/2;
diff --git a/app/assets/javascripts/src/Metamaps.js b/app/assets/javascripts/src/Metamaps.js
index d0f6057d..ba648acf 100644
--- a/app/assets/javascripts/src/Metamaps.js
+++ b/app/assets/javascripts/src/Metamaps.js
@@ -47,6 +47,7 @@ Metamaps.Touch = {
Metamaps.Mouse = {
didPan: false,
+ didBoxZoom: false,
changeInX: 0,
changeInY: 0,
edgeHoveringOver: false,
@@ -2021,11 +2022,13 @@ Metamaps.Control = {
if (Metamaps.Selected.Nodes.indexOf(node) != -1) return;
node.selected = true;
node.setData('dim', 30, 'current');
+ /*
if(!(e.ctrlKey) && !(e.altKey)){
node.eachAdjacency(function (adj) {
Metamaps.Control.selectEdge(adj);
});
}
+ */
Metamaps.Selected.Nodes.push(node);
},
diff --git a/db/schema.rb b/db/schema.rb
index 4c22e7e5..50334775 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1,133 +1,133 @@
-# encoding: UTF-8
-# This file is auto-generated from the current state of the database. Instead
-# of editing this file, please use the migrations feature of Active Record to
-# incrementally modify your database, and then regenerate this schema definition.
-#
-# Note that this schema.rb definition is the authoritative source for your
-# database schema. If you need to create the application database on another
-# system, you should be using db:schema:load, not running all the migrations
-# from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
-#
-# It's strongly recommended to check this file into your version control system.
-
-ActiveRecord::Schema.define(:version => 20140815162253) do
-
- create_table "in_metacode_sets", :force => true do |t|
- t.integer "metacode_id"
- t.integer "metacode_set_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- add_index "in_metacode_sets", ["metacode_id"], :name => "index_in_metacode_sets_on_metacode_id"
- add_index "in_metacode_sets", ["metacode_set_id"], :name => "index_in_metacode_sets_on_metacode_set_id"
-
- create_table "mappings", :force => true do |t|
- t.text "category"
- t.integer "xloc"
- t.integer "yloc"
- t.integer "topic_id"
- t.integer "synapse_id"
- t.integer "map_id"
- t.integer "user_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- create_table "maps", :force => true do |t|
- t.text "name"
- t.boolean "arranged"
- t.text "desc"
- t.text "permission"
- t.integer "user_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.boolean "featured"
- t.string "screenshot_file_name"
- t.string "screenshot_content_type"
- t.integer "screenshot_file_size"
- t.datetime "screenshot_updated_at"
- end
-
- create_table "metacode_sets", :force => true do |t|
- t.string "name"
- t.text "desc"
- t.integer "user_id"
- t.boolean "mapperContributed"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- add_index "metacode_sets", ["user_id"], :name => "index_metacode_sets_on_user_id"
-
- create_table "metacodes", :force => true do |t|
- t.text "name"
- t.string "icon"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- create_table "synapses", :force => true do |t|
- t.text "desc"
- t.text "category"
- t.text "weight"
- t.text "permission"
- t.integer "node1_id"
- t.integer "node2_id"
- t.integer "user_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- end
-
- create_table "topics", :force => true do |t|
- t.text "name"
- t.text "desc"
- t.text "link"
- t.text "permission"
- t.integer "user_id"
- t.integer "metacode_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "image_file_name"
- t.string "image_content_type"
- t.integer "image_file_size"
- t.datetime "image_updated_at"
- t.string "audio_file_name"
- t.string "audio_content_type"
- t.integer "audio_file_size"
- t.datetime "audio_updated_at"
- end
-
- create_table "users", :force => true do |t|
- t.string "name"
- t.string "email"
- t.text "settings"
- t.string "code", :limit => 8
- t.string "joinedwithcode", :limit => 8
- t.string "crypted_password"
- t.string "password_salt"
- t.string "persistence_token"
- t.string "perishable_token"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
- t.string "encrypted_password", :limit => 128, :default => ""
- t.string "remember_token"
- t.datetime "remember_created_at"
- t.string "reset_password_token"
- t.datetime "last_sign_in_at"
- t.string "last_sign_in_ip"
- t.integer "sign_in_count", :default => 0
- t.datetime "current_sign_in_at"
- t.string "current_sign_in_ip"
- t.datetime "reset_password_sent_at"
- t.boolean "admin"
- t.string "image_file_name"
- t.string "image_content_type"
- t.integer "image_file_size"
- t.datetime "image_updated_at"
- end
-
- add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
-
-end
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20140815162253) do
+
+ create_table "in_metacode_sets", :force => true do |t|
+ t.integer "metacode_id"
+ t.integer "metacode_set_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ add_index "in_metacode_sets", ["metacode_id"], :name => "index_in_metacode_sets_on_metacode_id"
+ add_index "in_metacode_sets", ["metacode_set_id"], :name => "index_in_metacode_sets_on_metacode_set_id"
+
+ create_table "mappings", :force => true do |t|
+ t.text "category"
+ t.integer "xloc"
+ t.integer "yloc"
+ t.integer "topic_id"
+ t.integer "synapse_id"
+ t.integer "map_id"
+ t.integer "user_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "maps", :force => true do |t|
+ t.text "name"
+ t.boolean "arranged"
+ t.text "desc"
+ t.text "permission"
+ t.integer "user_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.boolean "featured"
+ t.string "screenshot_file_name"
+ t.string "screenshot_content_type"
+ t.integer "screenshot_file_size"
+ t.datetime "screenshot_updated_at"
+ end
+
+ create_table "metacode_sets", :force => true do |t|
+ t.string "name"
+ t.text "desc"
+ t.integer "user_id"
+ t.boolean "mapperContributed"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ add_index "metacode_sets", ["user_id"], :name => "index_metacode_sets_on_user_id"
+
+ create_table "metacodes", :force => true do |t|
+ t.text "name"
+ t.string "icon"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "synapses", :force => true do |t|
+ t.text "desc"
+ t.text "category"
+ t.text "weight"
+ t.text "permission"
+ t.integer "node1_id"
+ t.integer "node2_id"
+ t.integer "user_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ create_table "topics", :force => true do |t|
+ t.text "name"
+ t.text "desc"
+ t.text "link"
+ t.text "permission"
+ t.integer "user_id"
+ t.integer "metacode_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.string "image_file_name"
+ t.string "image_content_type"
+ t.integer "image_file_size"
+ t.datetime "image_updated_at"
+ t.string "audio_file_name"
+ t.string "audio_content_type"
+ t.integer "audio_file_size"
+ t.datetime "audio_updated_at"
+ end
+
+ create_table "users", :force => true do |t|
+ t.string "name"
+ t.string "email"
+ t.text "settings"
+ t.string "code", :limit => 8
+ t.string "joinedwithcode", :limit => 8
+ t.string "crypted_password"
+ t.string "password_salt"
+ t.string "persistence_token"
+ t.string "perishable_token"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.string "encrypted_password", :limit => 128, :default => ""
+ t.string "remember_token"
+ t.datetime "remember_created_at"
+ t.string "reset_password_token"
+ t.datetime "last_sign_in_at"
+ t.string "last_sign_in_ip"
+ t.integer "sign_in_count", :default => 0
+ t.datetime "current_sign_in_at"
+ t.string "current_sign_in_ip"
+ t.datetime "reset_password_sent_at"
+ t.boolean "admin"
+ t.string "image_file_name"
+ t.string "image_content_type"
+ t.integer "image_file_size"
+ t.datetime "image_updated_at"
+ end
+
+ add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
+
+end