Skip to content

Commit

Permalink
Merge branch 'unstable'
Browse files Browse the repository at this point in the history
  • Loading branch information
kinimesi committed Oct 17, 2018
2 parents 5489dcf + cf3425a commit 2c16ca1
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 6 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 iVis@Bilkent

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ cytoscape-grid-guide

## Description

<img src="guideline-example.png" width="300">
| Guideline example | Grid example |
| ------------- | ------------- |
|<img src="guideline-example.png" width="300"> | <img src="grid-example.png" width="300">|

A sophisticated and highly customizable Cytoscape.js extension for grid and guideline interactions, distributed under [The MIT License](https://opensource.org/licenses/MIT). The following features are provided:

Expand Down
36 changes: 33 additions & 3 deletions cytoscape-grid-guide.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict"

module.exports = createRBTree
Expand Down Expand Up @@ -1405,6 +1405,20 @@ module.exports = function (opts, cy, $, debounce) {
var ctx = $canvas[ 0 ].getContext( '2d' );
$container.append( $canvas );

var resetCanvas = function () {
$canvas
.attr('height', 0)
.attr('width', 0)
.css( {
'position': 'absolute',
'top': 0,
'left': 0,
'z-index': options.gridStackOrder
});
};

resetCanvas();

var drawGrid = function() {
var zoom = cy.zoom();
var canvasWidth = $container.width();
Expand Down Expand Up @@ -1481,6 +1495,7 @@ module.exports = function (opts, cy, $, debounce) {
return {
initCanvas: resizeCanvas,
resizeCanvas: resizeCanvas,
resetCanvas: resetCanvas,
clearCanvas: clearDrawing,
drawGrid: drawGrid,
changeOptions: changeOptions,
Expand Down Expand Up @@ -1587,13 +1602,13 @@ module.exports = function (cy, snap, resize, snapToGridDuringDrag, drawGrid, gui
function setDrawGrid(enable) {
cy[eventStatus(enable)]('zoom', drawGridOnZoom);
cy[eventStatus(enable)]('pan', drawGridOnPan);
cy[eventStatus(enable)]('ready', drawGrid.resizeCanvas);

if (enable) {
drawGrid.initCanvas();
$(window).on('resize', drawGrid.resizeCanvas);
} else {
drawGrid.clearCanvas();
drawGrid.resetCanvas();
$(window).off('resize', drawGrid.resizeCanvas);
}
}
Expand Down Expand Up @@ -1649,6 +1664,7 @@ module.exports = function (cy, snap, resize, snapToGridDuringDrag, drawGrid, gui
cy.off("pan", guidelinesPanHandler);
cy.off("drag", "node", guidelinesDragHandler);
cy.off("free", guidelinesFreeHandler);
guidelines.resetCanvas();
$(window).off("resize", guidelinesWindowResizeHandler);
}
}
Expand Down Expand Up @@ -1794,7 +1810,20 @@ module.exports = function (opts, cy, $, debounce) {
var $container = $(cy.container());
var ctx = $canvas[0].getContext('2d');
$container.append($canvas);
resizeCanvas();

var resetCanvas = function () {
$canvas
.attr('height', 0)
.attr('width', 0)
.css( {
'position': 'absolute',
'top': 0,
'left': 0,
'z-index': options.gridStackOrder
});
};

resetCanvas();

/* Global variables */
var VTree = null;
Expand Down Expand Up @@ -2737,6 +2766,7 @@ module.exports = function (opts, cy, $, debounce) {
getMousePos: getMousePos,
setMousePos: setMousePos,
resizeCanvas: resizeCanvas,
resetCanvas: resetCanvas,
}
};

Expand Down
Binary file added grid-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified guideline-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/draw_grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ module.exports = function (opts, cy, $, debounce) {
var ctx = $canvas[ 0 ].getContext( '2d' );
$container.append( $canvas );

var resetCanvas = function () {
$canvas
.attr('height', 0)
.attr('width', 0)
.css( {
'position': 'absolute',
'top': 0,
'left': 0,
'z-index': options.gridStackOrder
});
};

resetCanvas();

var drawGrid = function() {
var zoom = cy.zoom();
var canvasWidth = $container.width();
Expand Down Expand Up @@ -88,6 +102,7 @@ module.exports = function (opts, cy, $, debounce) {
return {
initCanvas: resizeCanvas,
resizeCanvas: resizeCanvas,
resetCanvas: resetCanvas,
clearCanvas: clearDrawing,
drawGrid: drawGrid,
changeOptions: changeOptions,
Expand Down
3 changes: 2 additions & 1 deletion src/events_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ module.exports = function (cy, snap, resize, snapToGridDuringDrag, drawGrid, gui
function setDrawGrid(enable) {
cy[eventStatus(enable)]('zoom', drawGridOnZoom);
cy[eventStatus(enable)]('pan', drawGridOnPan);
cy[eventStatus(enable)]('ready', drawGrid.resizeCanvas);

if (enable) {
drawGrid.initCanvas();
$(window).on('resize', drawGrid.resizeCanvas);
} else {
drawGrid.clearCanvas();
drawGrid.resetCanvas();
$(window).off('resize', drawGrid.resizeCanvas);
}
}
Expand Down Expand Up @@ -158,6 +158,7 @@ module.exports = function (cy, snap, resize, snapToGridDuringDrag, drawGrid, gui
cy.off("pan", guidelinesPanHandler);
cy.off("drag", "node", guidelinesDragHandler);
cy.off("free", guidelinesFreeHandler);
guidelines.resetCanvas();
$(window).off("resize", guidelinesWindowResizeHandler);
}
}
Expand Down
16 changes: 15 additions & 1 deletion src/guidelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,20 @@ module.exports = function (opts, cy, $, debounce) {
var $container = $(cy.container());
var ctx = $canvas[0].getContext('2d');
$container.append($canvas);
resizeCanvas();

var resetCanvas = function () {
$canvas
.attr('height', 0)
.attr('width', 0)
.css( {
'position': 'absolute',
'top': 0,
'left': 0,
'z-index': options.gridStackOrder
});
};

resetCanvas();

/* Global variables */
var VTree = null;
Expand Down Expand Up @@ -1003,5 +1016,6 @@ module.exports = function (opts, cy, $, debounce) {
getMousePos: getMousePos,
setMousePos: setMousePos,
resizeCanvas: resizeCanvas,
resetCanvas: resetCanvas,
}
};

0 comments on commit 2c16ca1

Please sign in to comment.