mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-25 23:54:55 +01:00
Added tests palette and layout
This commit is contained in:
parent
cbc461e760
commit
d515e0bb57
@ -977,8 +977,7 @@ const Designer = new Class(
|
|||||||
changeTopicShape: function (shape) {
|
changeTopicShape: function (shape) {
|
||||||
var validateFunc = function (topic) {
|
var validateFunc = function (topic) {
|
||||||
return !(
|
return !(
|
||||||
topic.getType() == INodeModel.CENTRAL_TOPIC_TYPE &&
|
topic.getType() == INodeModel.CENTRAL_TOPIC_TYPE && shape == TopicShape.LINE
|
||||||
shape == TopicShape.LINE
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1001,11 +1000,9 @@ const Designer = new Class(
|
|||||||
addIconType: function (iconType) {
|
addIconType: function (iconType) {
|
||||||
var topicsIds = this.getModel().filterTopicsIds();
|
var topicsIds = this.getModel().filterTopicsIds();
|
||||||
if (topicsIds.length > 0) {
|
if (topicsIds.length > 0) {
|
||||||
this._actionDispatcher.addFeatureToTopic(
|
this._actionDispatcher.addFeatureToTopic(topicsIds[0], TopicFeature.Icon.id, {
|
||||||
topicsIds[0],
|
id: iconType,
|
||||||
TopicFeature.Icon.id,
|
});
|
||||||
{ id: iconType }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -21,17 +21,17 @@ const Messages = new Class({
|
|||||||
init: function (locale) {
|
init: function (locale) {
|
||||||
locale = $defined(locale) ? locale : 'en';
|
locale = $defined(locale) ? locale : 'en';
|
||||||
var bundle = Messages.BUNDLES[locale];
|
var bundle = Messages.BUNDLES[locale];
|
||||||
if (bundle == null && locale.indexOf("_") != -1) {
|
if (bundle == null && locale.indexOf('_') != -1) {
|
||||||
// Try to locate without the specialization ...
|
// Try to locate without the specialization ...
|
||||||
locale = locale.substring(0, locale.indexOf("_"));
|
locale = locale.substring(0, locale.indexOf('_'));
|
||||||
bundle = Messages.BUNDLES[locale];
|
bundle = Messages.BUNDLES[locale];
|
||||||
}
|
}
|
||||||
Messages.__bundle = bundle;
|
Messages.__bundle = bundle;
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
$msg = function (key) {
|
global.$msg = function (key) {
|
||||||
if (!Messages.__bundle) {
|
if (!Messages.__bundle) {
|
||||||
Messages.init('en');
|
Messages.init('en');
|
||||||
}
|
}
|
||||||
|
@ -15,31 +15,29 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
const Core = require('@wismapping/core-js')
|
const Core = require('@wismapping/core-js');
|
||||||
const core = Core();
|
const core = Core();
|
||||||
const XMLSerializerFactory = require('./persistence/XMLSerializerFactory');
|
const XMLSerializerFactory = require('./persistence/XMLSerializerFactory');
|
||||||
|
|
||||||
const PersistenceManager = new Class({
|
const PersistenceManager = new Class({
|
||||||
Static: {
|
Static: {
|
||||||
loadFromDom: function (mapId, mapDom) {
|
loadFromDom: function (mapId, mapDom) {
|
||||||
$assert(mapId, "mapId can not be null");
|
$assert(mapId, 'mapId can not be null');
|
||||||
$assert(mapDom, "mapDom can not be null");
|
$assert(mapDom, 'mapDom can not be null');
|
||||||
|
|
||||||
var serializer = XMLSerializerFactory.getSerializerFromDocument(mapDom);
|
var serializer = XMLSerializerFactory.getSerializerFromDocument(mapDom);
|
||||||
return serializer.loadFromDom(mapDom, mapId);
|
return serializer.loadFromDom(mapDom, mapId);
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {},
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
save: function (mindmap, editorProperties, saveHistory, events, sync) {
|
save: function (mindmap, editorProperties, saveHistory, events, sync) {
|
||||||
$assert(mindmap, "mindmap can not be null");
|
$assert(mindmap, 'mindmap can not be null');
|
||||||
$assert(editorProperties, "editorProperties can not be null");
|
$assert(editorProperties, 'editorProperties can not be null');
|
||||||
|
|
||||||
var mapId = mindmap.getId();
|
var mapId = mindmap.getId();
|
||||||
$assert(mapId, "mapId can not be null");
|
$assert(mapId, 'mapId can not be null');
|
||||||
|
|
||||||
var serializer = XMLSerializerFactory.getSerializerFromMindmap(mindmap);
|
var serializer = XMLSerializerFactory.getSerializerFromMindmap(mindmap);
|
||||||
var domMap = serializer.toXML(mindmap);
|
var domMap = serializer.toXML(mindmap);
|
||||||
@ -55,26 +53,26 @@ const PersistenceManager = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
load: function (mapId) {
|
load: function (mapId) {
|
||||||
$assert(mapId, "mapId can not be null");
|
$assert(mapId, 'mapId can not be null');
|
||||||
var domDocument = this.loadMapDom(mapId);
|
var domDocument = this.loadMapDom(mapId);
|
||||||
return PersistenceManager.loadFromDom(mapId, domDocument);
|
return PersistenceManager.loadFromDom(mapId, domDocument);
|
||||||
},
|
},
|
||||||
|
|
||||||
discardChanges: function (mapId) {
|
discardChanges: function (mapId) {
|
||||||
throw new Error("Method must be implemented");
|
throw new Error('Method must be implemented');
|
||||||
},
|
},
|
||||||
|
|
||||||
loadMapDom: function (mapId) {
|
loadMapDom: function (mapId) {
|
||||||
throw new Error("Method must be implemented");
|
throw new Error('Method must be implemented');
|
||||||
},
|
},
|
||||||
|
|
||||||
saveMapXml: function (mapId, mapXml, pref, saveHistory, events, sync) {
|
saveMapXml: function (mapId, mapXml, pref, saveHistory, events, sync) {
|
||||||
throw new Error("Method must be implemented");
|
throw new Error('Method must be implemented');
|
||||||
},
|
},
|
||||||
|
|
||||||
unlockMap: function (mindmap) {
|
unlockMap: function (mindmap) {
|
||||||
throw new Error("Method must be implemented");
|
throw new Error('Method must be implemented');
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
PersistenceManager.init = function (instance) {
|
PersistenceManager.init = function (instance) {
|
||||||
|
@ -378,4 +378,4 @@ const CommandContext = new Class(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export {StandaloneActionDispatcher, CommandContext}
|
export { StandaloneActionDispatcher, CommandContext };
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
const web2D = require('@wismapping/web2d')
|
const web2D = require('@wismapping/web2d');
|
||||||
const web2d = web2D()
|
const web2d = web2D();
|
||||||
const NodeGraph = require('./NodeGraph').default;
|
const NodeGraph = require('./NodeGraph').default;
|
||||||
const { TopicShape } = require('./model/INodeModel');
|
const { TopicShape } = require('./model/INodeModel');
|
||||||
const TopicStyle = require('./TopicStyle').default;
|
const TopicStyle = require('./TopicStyle').default;
|
||||||
@ -240,10 +240,7 @@ const Topic = new Class(
|
|||||||
/** @return outer shape */
|
/** @return outer shape */
|
||||||
getOuterShape: function () {
|
getOuterShape: function () {
|
||||||
if (!$defined(this._outerShape)) {
|
if (!$defined(this._outerShape)) {
|
||||||
var rect = this._buildShape(
|
var rect = this._buildShape(Topic.OUTER_SHAPE_ATTRIBUTES, TopicShape.ROUNDED_RECT);
|
||||||
Topic.OUTER_SHAPE_ATTRIBUTES,
|
|
||||||
TopicShape.ROUNDED_RECT
|
|
||||||
);
|
|
||||||
rect.setPosition(-2, -3);
|
rect.setPosition(-2, -3);
|
||||||
rect.setOpacity(0);
|
rect.setOpacity(0);
|
||||||
this._outerShape = rect;
|
this._outerShape = rect;
|
||||||
@ -991,9 +988,7 @@ const Topic = new Class(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var textShape = this.getTextShape();
|
var textShape = this.getTextShape();
|
||||||
textShape.setVisibility(
|
textShape.setVisibility(this.getShapeType() != TopicShape.IMAGE ? value : false);
|
||||||
this.getShapeType() != TopicShape.IMAGE ? value : false
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
@ -1091,10 +1086,7 @@ const Topic = new Class(
|
|||||||
outgoingLine.removeFromWorkspace(workspace);
|
outgoingLine.removeFromWorkspace(workspace);
|
||||||
|
|
||||||
// Remove from workspace.
|
// Remove from workspace.
|
||||||
EventBus.instance.fireEvent(
|
EventBus.instance.fireEvent(EventBus.events.NodeDisconnectEvent, this.getModel());
|
||||||
EventBus.events.NodeDisconnectEvent,
|
|
||||||
this.getModel()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Change text based on the current connection ...
|
// Change text based on the current connection ...
|
||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
@ -1216,10 +1208,7 @@ const Topic = new Class(
|
|||||||
workspace.removeChild(line);
|
workspace.removeChild(line);
|
||||||
}
|
}
|
||||||
this._isInWorkspace = false;
|
this._isInWorkspace = false;
|
||||||
EventBus.instance.fireEvent(
|
EventBus.instance.fireEvent(EventBus.events.NodeRemoved, this.getModel());
|
||||||
EventBus.events.NodeRemoved,
|
|
||||||
this.getModel()
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
@ -1228,20 +1217,14 @@ const Topic = new Class(
|
|||||||
workspace.append(elem);
|
workspace.append(elem);
|
||||||
if (!this.isInWorkspace()) {
|
if (!this.isInWorkspace()) {
|
||||||
if (!this.isCentralTopic()) {
|
if (!this.isCentralTopic()) {
|
||||||
EventBus.instance.fireEvent(
|
EventBus.instance.fireEvent(EventBus.events.NodeAdded, this.getModel());
|
||||||
EventBus.events.NodeAdded,
|
|
||||||
this.getModel()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getModel().isConnected())
|
if (this.getModel().isConnected())
|
||||||
EventBus.instance.fireEvent(
|
EventBus.instance.fireEvent(EventBus.events.NodeConnectEvent, {
|
||||||
EventBus.events.NodeConnectEvent,
|
|
||||||
{
|
|
||||||
parentNode: this.getOutgoingConnectedTopic().getModel(),
|
parentNode: this.getOutgoingConnectedTopic().getModel(),
|
||||||
childNode: this.getModel(),
|
childNode: this.getModel(),
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
this._isInWorkspace = true;
|
this._isInWorkspace = true;
|
||||||
this._adjustShapes();
|
this._adjustShapes();
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
const Events = require('./Events').default;
|
const Events = require('./Events').default;
|
||||||
const MultilineTextEditor = require('./MultilineTextEditor').default;
|
const MultilineTextEditor = require('./MultilineTextEditor').default;
|
||||||
const TopicEvent = require('./Topic');
|
//const TopicEvent = require('./Topic').default;
|
||||||
const { TopicShape } = require('./model/INodeModel');
|
const { TopicShape } = require('./model/INodeModel');
|
||||||
|
|
||||||
const TopicEventDispatcher = new Class({
|
const TopicEventDispatcher = new Class({
|
||||||
@ -78,7 +78,7 @@ const TopicEventDispatcher = new Class({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
TopicEvent = {
|
const TopicEvent = {
|
||||||
EDIT: 'editnode',
|
EDIT: 'editnode',
|
||||||
CLICK: 'clicknode',
|
CLICK: 'clicknode',
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
const ConnectionLine = require('../ConnectionLine').default;
|
const ConnectionLine = require('../ConnectionLine').default;
|
||||||
|
|
||||||
RelationshipModel = new Class(
|
const RelationshipModel = new Class(
|
||||||
/** @lends RelationshipModel */ {
|
/** @lends RelationshipModel */ {
|
||||||
Static: {
|
Static: {
|
||||||
_nextUUID: function () {
|
_nextUUID: function () {
|
||||||
|
@ -31,7 +31,7 @@ const FloatingTip = new Class({
|
|||||||
content: '',
|
content: '',
|
||||||
delay: 0,
|
delay: 0,
|
||||||
container: false,
|
container: false,
|
||||||
destroyOnExit: false
|
destroyOnExit: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function (element, options) {
|
initialize: function (element, options) {
|
||||||
@ -62,7 +62,7 @@ const FloatingTip = new Class({
|
|||||||
this.element.popover('hide');
|
this.element.popover('hide');
|
||||||
this.fireEvent('hide');
|
this.fireEvent('hide');
|
||||||
return this;
|
return this;
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default FloatingTip;
|
export default FloatingTip;
|
||||||
|
@ -17,14 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const ModalDialogNotifier = new Class({
|
const ModalDialogNotifier = new Class({
|
||||||
|
|
||||||
initialize: function () {},
|
initialize: function () {},
|
||||||
|
|
||||||
//FIXME: replace by alert()
|
//FIXME: replace by alert()
|
||||||
show: function (message, title) {
|
show: function (message, title) {
|
||||||
$assert(message, "message can not be null");
|
$assert(message, 'message can not be null');
|
||||||
|
|
||||||
var modalDialog = $('<div class="modal fade">' +
|
var modalDialog = $(
|
||||||
|
'<div class="modal fade">' +
|
||||||
'<div class="modal-dialog">' +
|
'<div class="modal-dialog">' +
|
||||||
'<div class="modal-content">' +
|
'<div class="modal-content">' +
|
||||||
'<div class="modal-body"></div>' +
|
'<div class="modal-body"></div>' +
|
||||||
@ -37,18 +37,18 @@ const ModalDialogNotifier = new Class({
|
|||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>');
|
'</div>'
|
||||||
|
);
|
||||||
|
|
||||||
var p = '<p>' + message + '</p>'
|
var p = '<p>' + message + '</p>';
|
||||||
var h4 = title ? '<h4>' + title + '</h4>' : "";
|
var h4 = title ? '<h4>' + title + '</h4>' : '';
|
||||||
|
|
||||||
modalDialog.find('.alert-content').append(h4 + p);
|
modalDialog.find('.alert-content').append(h4 + p);
|
||||||
modalDialog.modal();
|
modalDialog.modal();
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var dialogNotifier = new ModalDialogNotifier();
|
var dialogNotifier = new ModalDialogNotifier();
|
||||||
$notifyModal = dialogNotifier.show.bind(dialogNotifier);
|
const $notifyModal = dialogNotifier.show.bind(dialogNotifier);
|
||||||
|
|
||||||
export default ModalDialogNotifier;
|
export default ModalDialogNotifier;
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const ToolbarNotifier = new Class({
|
const ToolbarNotifier = new Class({
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.container = $('#headerNotifier');
|
this.container = $('#headerNotifier');
|
||||||
},
|
},
|
||||||
@ -32,16 +31,18 @@ const ToolbarNotifier = new Class({
|
|||||||
if (this.container && !this.container.data('transitioning')) {
|
if (this.container && !this.container.data('transitioning')) {
|
||||||
this.container.data('transitioning', true);
|
this.container.data('transitioning', true);
|
||||||
this.container.text(msg);
|
this.container.text(msg);
|
||||||
this.container.css({top: "5px", left: ($(window).width() - this.container.width()) / 2 - 9});
|
this.container.css({
|
||||||
|
top: '5px',
|
||||||
|
left: ($(window).width() - this.container.width()) / 2 - 9,
|
||||||
|
});
|
||||||
this.container.show().fadeOut(5000);
|
this.container.show().fadeOut(5000);
|
||||||
}
|
}
|
||||||
this.container.data('transitioning', false);
|
this.container.data('transitioning', false);
|
||||||
}
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var toolbarNotifier = new ToolbarNotifier();
|
var toolbarNotifier = new ToolbarNotifier();
|
||||||
$notify = function(msg) {
|
const $notify = function (msg) {
|
||||||
toolbarNotifier.logMessage(msg);
|
toolbarNotifier.logMessage(msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ const FloatingTip = require('./FloatingTip').default;
|
|||||||
const ToolbarPaneItem = new Class({
|
const ToolbarPaneItem = new Class({
|
||||||
Extends: ToolbarItem,
|
Extends: ToolbarItem,
|
||||||
initialize: function (buttonId, model) {
|
initialize: function (buttonId, model) {
|
||||||
$assert(buttonId, "buttonId can not be null");
|
$assert(buttonId, 'buttonId can not be null');
|
||||||
$assert(model, "model can not be null");
|
$assert(model, 'model can not be null');
|
||||||
this._model = model;
|
this._model = model;
|
||||||
var me = this;
|
var me = this;
|
||||||
var fn = function () {
|
var fn = function () {
|
||||||
@ -49,15 +49,16 @@ const ToolbarPaneItem = new Class({
|
|||||||
},
|
},
|
||||||
className: 'toolbarPaneTip',
|
className: 'toolbarPaneTip',
|
||||||
trigger: 'manual',
|
trigger: 'manual',
|
||||||
template: '<div class="popover popoverGray" role="tooltip"><div class="arrow arrowGray"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
|
template:
|
||||||
|
'<div class="popover popoverGray" role="tooltip"><div class="arrow arrowGray"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
|
||||||
});
|
});
|
||||||
|
|
||||||
this._tip.addEvent('hide', function () {
|
this._tip.addEvent('hide', function () {
|
||||||
me._visible = false
|
me._visible = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
this._tip.addEvent('show', function () {
|
this._tip.addEvent('show', function () {
|
||||||
me._visible = true
|
me._visible = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
return panelElem;
|
return panelElem;
|
||||||
@ -116,11 +117,9 @@ const ToolbarPaneItem = new Class({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
buildPanel: function () {
|
buildPanel: function () {
|
||||||
throw "Method must be implemented";
|
throw 'Method must be implemented';
|
||||||
}.protect()
|
}.protect(),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default ToolbarPaneItem;
|
export default ToolbarPaneItem;
|
||||||
|
@ -9,12 +9,12 @@ const linkEditor = require('./LinkEditor').default;
|
|||||||
const linkIconTooltip = require('./LinkIconTooltip').default;
|
const linkIconTooltip = require('./LinkIconTooltip').default;
|
||||||
const listToolbarPanel = require('./ListToolbarPanel').default;
|
const listToolbarPanel = require('./ListToolbarPanel').default;
|
||||||
const menu = require('./Menu').default;
|
const menu = require('./Menu').default;
|
||||||
const modalDialogNotifier = require('./ModalDialogNotifier');
|
const modalDialogNotifier = require('./ModalDialogNotifier').default;
|
||||||
const noteEditor = require('./NoteEditor');
|
const noteEditor = require('./NoteEditor').default;
|
||||||
const toolbarItem = require('./ToolbarItem');
|
const toolbarItem = require('./ToolbarItem').default;
|
||||||
const toolbarNotifier = require('./ToolbarNotifier');
|
const toolbarNotifier = require('./ToolbarNotifier').default;
|
||||||
const toolbarPanelItem = require('./ToolbarPaneItem');
|
const toolbarPanelItem = require('./ToolbarPaneItem').default;
|
||||||
const topicShapePanel = require('./TopicShapePanel');
|
const topicShapePanel = require('./TopicShapePanel').default;
|
||||||
|
|
||||||
export const Widgets = {
|
export const Widgets = {
|
||||||
ColorPalettePanel: colorPalettePanel,
|
ColorPalettePanel: colorPalettePanel,
|
||||||
|
@ -21,11 +21,11 @@ function mindplot() {
|
|||||||
const { Components } = require('./components');
|
const { Components } = require('./components');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Commands,
|
commands: Commands,
|
||||||
Layout,
|
layout: Layout,
|
||||||
Models,
|
models: Models,
|
||||||
Persistence,
|
persistence: Persistence,
|
||||||
Widgets,
|
widget: Widgets,
|
||||||
Components,
|
component: Components,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,9 @@
|
|||||||
"url": "git+https://ezequielVega@bitbucket.org/lilabyus/wisemapping-frontend.git"
|
"url": "git+https://ezequielVega@bitbucket.org/lilabyus/wisemapping-frontend.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack --config webpack.prod.js",
|
"build": "yarn build:dev && yarn build:test",
|
||||||
|
"build:dev": "webpack --config webpack.prod.js",
|
||||||
|
"build:test": "webpack --config webpack.test.js",
|
||||||
"start": "webpack serve --config webpack.dev.js"
|
"start": "webpack serve --config webpack.dev.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -32,7 +34,6 @@
|
|||||||
"@babel/preset-env": "^7.14.7",
|
"@babel/preset-env": "^7.14.7",
|
||||||
"babel-loader": "^8.2.2",
|
"babel-loader": "^8.2.2",
|
||||||
"clean-webpack-plugin": "^4.0.0-alpha.0",
|
"clean-webpack-plugin": "^4.0.0-alpha.0",
|
||||||
"core-js": "^3.15.2",
|
|
||||||
"webpack": "^5.44.0",
|
"webpack": "^5.44.0",
|
||||||
"webpack-cli": "^4.7.2",
|
"webpack-cli": "^4.7.2",
|
||||||
"webpack-dev-server": "^3.11.2",
|
"webpack-dev-server": "^3.11.2",
|
||||||
|
@ -1,39 +1,28 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script type='text/javascript' src='../../../lib/components/libraries/mootools/mootools-core-1.4.5-full-nocompat-yc.js'></script>
|
<script
|
||||||
<script type='text/javascript' src='../../../../core-js/target/core.js'></script>
|
type="text/javascript"
|
||||||
|
src="../../../lib/components/libraries/jquery/jquery-2.1.0.min.js"
|
||||||
|
></script>
|
||||||
|
<script
|
||||||
|
type="text/javascript"
|
||||||
|
src="../../../lib/components/libraries/mootools/mootools-core-1.4.5-full-nocompat-yc.js"
|
||||||
|
></script>
|
||||||
|
<script
|
||||||
|
type="text/javascript"
|
||||||
|
src="../../../lib/components/libraries/underscorejs/underscore-min.js"
|
||||||
|
></script>
|
||||||
|
|
||||||
<script type='text/javascript' src='../../../lib/components/header.js'></script>
|
<script type="text/javascript" src="../../../../core-js/dist/core.js"></script>
|
||||||
<script type='text/javascript' src='../../../lib/components/layout/Node.js'></script>
|
<script type="text/javascript" src="../../../lib/components/header.js"></script>
|
||||||
<script type='text/javascript' src='../../../lib/components/layout/RootedTreeSet.js'></script>
|
<script type="text/javascript" src="../../../dist/main.js"></script>
|
||||||
|
|
||||||
<script type='text/javascript' src='../../../lib/components/layout/LayoutManager.js'></script>
|
|
||||||
<script type='text/javascript' src='../../../lib/components/layout/ChildrenSorterStrategy.js'></script>
|
|
||||||
<script type='text/javascript' src='../../../lib/components/layout/AbstractBasicSorter.js'></script>
|
|
||||||
<script type='text/javascript' src='../../../lib/components/layout/SymmetricSorter.js'></script>
|
|
||||||
<script type='text/javascript' src='../../../lib/components/layout/GridSorter.js'></script>
|
|
||||||
<script type='text/javascript' src='../../../lib/components/layout/BalancedSorter.js'></script>
|
|
||||||
<script type='text/javascript' src='../../../lib/components/layout/OriginalLayout.js'></script>
|
|
||||||
<script type='text/javascript' src='../../../lib/components/layout/ChangeEvent.js'></script>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="test/raphael-min.js"></script>
|
<script type="text/javascript" src="test/raphael-min.js"></script>
|
||||||
<script type="text/javascript" src="test/raphael-plugins.js"></script>
|
<script type="text/javascript" src="test/raphael-plugins.js"></script>
|
||||||
|
|
||||||
<script type='text/javascript' src='test/TestSuite.js'></script>
|
<script type="text/javascript" src="../../../dist/test/layout.test.js"></script>
|
||||||
<script type='text/javascript' src='test/BalancedTestSuite.js'></script>
|
|
||||||
<script type='text/javascript' src='test/SymmetricTestSuite.js'></script>
|
|
||||||
<script type='text/javascript' src='test/FreeTestSuite.js'></script>
|
|
||||||
|
|
||||||
<script type='text/javascript'>
|
|
||||||
window.addEvent('domready', function() {
|
|
||||||
var basicTest = new mindplot.layout.TestSuite();
|
|
||||||
var balancedTest = new mindplot.layout.BalancedTestSuite();
|
|
||||||
var symmetricTest = new mindplot.layout.SymmetricTestSuite();
|
|
||||||
var freeTest = new mindplot.layout.FreeTestSuite();
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
div.col {
|
div.col {
|
||||||
@ -44,12 +33,9 @@
|
|||||||
float: none;
|
float: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div id="basicTest" style="display: none">
|
||||||
|
|
||||||
<div id="basicTest" style="display: none;">
|
|
||||||
<h1>Basic Tests</h1>
|
<h1>Basic Tests</h1>
|
||||||
|
|
||||||
<h3>testAligned:</h3>
|
<h3>testAligned:</h3>
|
||||||
@ -95,7 +81,7 @@
|
|||||||
<div id="testReconnectSingleNode2" class="col"></div>
|
<div id="testReconnectSingleNode2" class="col"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="balancedTest" style="display: none;">
|
<div id="balancedTest" style="display: none">
|
||||||
<h1>Balanced Sorter Tests</h1>
|
<h1>Balanced Sorter Tests</h1>
|
||||||
|
|
||||||
<h3>testBalanced:</h3>
|
<h3>testBalanced:</h3>
|
||||||
@ -126,7 +112,7 @@
|
|||||||
<div id="testBalancedNodeDragPredict3"></div>
|
<div id="testBalancedNodeDragPredict3"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="symmetricTest" style="display: none;">
|
<div id="symmetricTest" style="display: none">
|
||||||
<h1>Symmetric Sorter Tests</h1>
|
<h1>Symmetric Sorter Tests</h1>
|
||||||
<h3>testSymmetry:</h3>
|
<h3>testSymmetry:</h3>
|
||||||
<div id="testSymmetry"></div>
|
<div id="testSymmetry"></div>
|
||||||
@ -142,7 +128,7 @@
|
|||||||
<div id="testSymmetricDragPredict1"></div>
|
<div id="testSymmetricDragPredict1"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="freeTest" style="display: none;">
|
<div id="freeTest" style="display: none">
|
||||||
<h1>Free Positioning Tests</h1>
|
<h1>Free Positioning Tests</h1>
|
||||||
|
|
||||||
<h3>testFreePosition:</h3>
|
<h3>testFreePosition:</h3>
|
||||||
@ -190,6 +176,5 @@
|
|||||||
<div id="testFreeOverlap1" class="col"></div>
|
<div id="testFreeOverlap1" class="col"></div>
|
||||||
<div id="testFreeOverlap2" class="col"></div>
|
<div id="testFreeOverlap2" class="col"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,41 +1,16 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script type='text/javascript'
|
<script src="../../../lib/components/libraries/jquery/jquery-2.1.0.min.js"></script>
|
||||||
src='../../../../../wise-doc/src/main/webapp/js/mootools-core-1.3.2-full-compat.js'></script>
|
<script src="../../../lib/components/libraries/mootools/mootools-core-1.4.5-full-nocompat-yc.js"></script>
|
||||||
<script type='text/javascript'
|
<script src="../../../lib/components/libraries/underscorejs/underscore-min.js"></script>
|
||||||
src='../../../../../wise-doc/src/main/webapp/js/mootools-more-1.3.2.1-yui.js'></script>
|
<script src="../../../lib/components/libraries/bootstrap/js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script type='text/javascript' src='../../../main/javascript/header.js'></script>
|
|
||||||
<script type='text/javascript' src='../../../../../core-js/target/classes/core.js'></script>
|
|
||||||
|
|
||||||
<script type='text/javascript' src='../../../main/javascript/widget/ToolbarItem.js'></script>
|
|
||||||
<script type='text/javascript' src='../../../main/javascript/widget/ColorPalettePanel.js'></script>
|
|
||||||
|
|
||||||
<script type='text/javascript'>
|
|
||||||
window.addEvent("load", function(e) {
|
|
||||||
var model = {
|
|
||||||
getValue: function() {
|
|
||||||
|
|
||||||
},
|
|
||||||
setValue : function(value) {
|
|
||||||
console.log("value:" + value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var palette = new mindplot.widget.ColorPalettePanel('myButton', model,"/mindplot/src/main/javascript/widget");
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
<script type="text/javascript" src="../../../../core-js/dist/core.js"></script>
|
||||||
|
<script type="text/javascript" src="../../../dist/test/palette.test.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div id="myButton" style="border: 1px red solid">The button</div>
|
||||||
<div id="myButton" style="border: 1px red solid">
|
|
||||||
The button
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -15,11 +15,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
mindplot.layout.BalancedTestSuite = new Class({
|
const TestSuite = require('./TestSuite').default;
|
||||||
Extends: mindplot.layout.TestSuite,
|
|
||||||
|
const BalancedTestSuite = new Class({
|
||||||
|
Extends: TestSuite,
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
$('#balancedTest').setStyle("display","block");
|
$('#balancedTest').css('display', 'block');
|
||||||
|
|
||||||
this.testBalanced();
|
this.testBalanced();
|
||||||
this.testBalancedPredict();
|
this.testBalancedPredict();
|
||||||
@ -27,145 +29,169 @@ mindplot.layout.BalancedTestSuite = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
testBalanced: function () {
|
testBalanced: function () {
|
||||||
console.log("testBalanced:");
|
console.log('testBalanced:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var plotsize = { width: 1000, height: 200 };
|
var plotsize = { width: 1000, height: 200 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced1", plotsize);
|
manager.plot('testBalanced1', plotsize);
|
||||||
|
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 2, 1);
|
manager.connectNode(0, 2, 1);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced2", plotsize);
|
manager.plot('testBalanced2', plotsize);
|
||||||
|
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 3, 2);
|
manager.connectNode(0, 3, 2);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced3", plotsize);
|
manager.plot('testBalanced3', plotsize);
|
||||||
|
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 4, 3);
|
manager.connectNode(0, 4, 3);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced4", plotsize);
|
manager.plot('testBalanced4', plotsize);
|
||||||
|
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 5, 4);
|
manager.connectNode(0, 5, 4);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced5", plotsize);
|
manager.plot('testBalanced5', plotsize);
|
||||||
|
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(6, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 6, 5);
|
manager.connectNode(0, 6, 5);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced6", plotsize);
|
manager.plot('testBalanced6', plotsize);
|
||||||
|
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(7, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(8, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(9, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(3, 7, 0)
|
manager.connectNode(3, 7, 0);
|
||||||
manager.connectNode(7, 8, 0)
|
manager.connectNode(7, 8, 0);
|
||||||
manager.connectNode(7, 9, 1);
|
manager.connectNode(7, 9, 1);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced7", plotsize);
|
manager.plot('testBalanced7', plotsize);
|
||||||
|
|
||||||
manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(10, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(11, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(12, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(12, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(6, 10, 0)
|
manager.connectNode(6, 10, 0);
|
||||||
manager.connectNode(10, 11, 0)
|
manager.connectNode(10, 11, 0);
|
||||||
manager.connectNode(10, 12, 1);
|
manager.connectNode(10, 12, 1);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced8", plotsize);
|
manager.plot('testBalanced8', plotsize);
|
||||||
|
|
||||||
manager.addNode(13, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(13, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 13, 4);
|
manager.connectNode(0, 13, 4);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced9", {width:1000, height:400});
|
manager.plot('testBalanced9', { width: 1000, height: 400 });
|
||||||
|
|
||||||
// Check orders have shifted accordingly
|
// Check orders have shifted accordingly
|
||||||
$assert(manager.find(5).getOrder() == 6, "Node 5 should have order 6");
|
$assert(manager.find(5).getOrder() == 6, 'Node 5 should have order 6');
|
||||||
|
|
||||||
manager.addNode(14, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(14, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 14, 5);
|
manager.connectNode(0, 14, 5);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced10", {width:1000, height:400});
|
manager.plot('testBalanced10', { width: 1000, height: 400 });
|
||||||
|
|
||||||
// Check orders have shifted accordingly
|
// Check orders have shifted accordingly
|
||||||
$assert(manager.find(6).getOrder() == 7, "Node 6 should have order 7");
|
$assert(manager.find(6).getOrder() == 7, 'Node 6 should have order 7');
|
||||||
|
|
||||||
manager.addNode(15, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(15, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 15, 4);
|
manager.connectNode(0, 15, 4);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced11", {width:1000, height:400});
|
manager.plot('testBalanced11', { width: 1000, height: 400 });
|
||||||
|
|
||||||
// Check orders have shifted accordingly
|
// Check orders have shifted accordingly
|
||||||
$assert(manager.find(13).getOrder() == 6, "Node 13 should have order 6");
|
$assert(manager.find(13).getOrder() == 6, 'Node 13 should have order 6');
|
||||||
$assert(manager.find(5).getOrder() == 8, "Node 5 should have order 8");
|
$assert(manager.find(5).getOrder() == 8, 'Node 5 should have order 8');
|
||||||
|
|
||||||
manager.addNode(16, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(16, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 16, 25);
|
manager.connectNode(0, 16, 25);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced12", {width:1000, height:400});
|
manager.plot('testBalanced12', { width: 1000, height: 400 });
|
||||||
|
|
||||||
// Check orders have shifted accordingly
|
// Check orders have shifted accordingly
|
||||||
$assert(manager.find(16).getOrder() == 9, "Node 16 should have order 9");
|
$assert(manager.find(16).getOrder() == 9, 'Node 16 should have order 9');
|
||||||
|
|
||||||
manager.addNode(17, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(17, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(18, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(18, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(19, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(19, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 17, 11);
|
manager.connectNode(0, 17, 11);
|
||||||
manager.connectNode(0, 18, 13);
|
manager.connectNode(0, 18, 13);
|
||||||
manager.connectNode(0, 19, 10);
|
manager.connectNode(0, 19, 10);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBalanced13", {width:1000, height:400});
|
manager.plot('testBalanced13', { width: 1000, height: 400 });
|
||||||
|
|
||||||
// Check that everything is ok
|
// Check that everything is ok
|
||||||
$assert(manager.find(1).getPosition().x > manager.find(0).getPosition().x,
|
$assert(
|
||||||
"even order nodes must be at right of central topic");
|
manager.find(1).getPosition().x > manager.find(0).getPosition().x,
|
||||||
$assert(manager.find(3).getPosition().x > manager.find(0).getPosition().x,
|
'even order nodes must be at right of central topic'
|
||||||
"even order nodes must be at right of central topic");
|
);
|
||||||
$assert(manager.find(5).getPosition().x > manager.find(0).getPosition().x,
|
$assert(
|
||||||
"even order nodes must be at right of central topic");
|
manager.find(3).getPosition().x > manager.find(0).getPosition().x,
|
||||||
$assert(manager.find(2).getPosition().x < manager.find(0).getPosition().x,
|
'even order nodes must be at right of central topic'
|
||||||
"odd order nodes must be at right of central topic");
|
);
|
||||||
$assert(manager.find(4).getPosition().x < manager.find(0).getPosition().x,
|
$assert(
|
||||||
"odd order nodes must be at right of central topic");
|
manager.find(5).getPosition().x > manager.find(0).getPosition().x,
|
||||||
$assert(manager.find(6).getPosition().x < manager.find(0).getPosition().x,
|
'even order nodes must be at right of central topic'
|
||||||
"odd order nodes must be at right of central topic");
|
);
|
||||||
$assert(manager.find(7).getPosition().x > manager.find(3).getPosition().x,
|
$assert(
|
||||||
"children of 1st level even order nodes must be to the right");
|
manager.find(2).getPosition().x < manager.find(0).getPosition().x,
|
||||||
$assert(manager.find(8).getPosition().x > manager.find(7).getPosition().x,
|
'odd order nodes must be at right of central topic'
|
||||||
"children of 1st level even order nodes must be to the right");
|
);
|
||||||
$assert(manager.find(9).getPosition().x > manager.find(7).getPosition().x,
|
$assert(
|
||||||
"children of 1st level even order nodes must be to the right");
|
manager.find(4).getPosition().x < manager.find(0).getPosition().x,
|
||||||
$assert(manager.find(10).getPosition().x < manager.find(6).getPosition().x,
|
'odd order nodes must be at right of central topic'
|
||||||
"children of 1st level odd order nodes must be to the left");
|
);
|
||||||
$assert(manager.find(11).getPosition().x < manager.find(10).getPosition().x,
|
$assert(
|
||||||
"children of 1st level odd order nodes must be to the left");
|
manager.find(6).getPosition().x < manager.find(0).getPosition().x,
|
||||||
$assert(manager.find(12).getPosition().x < manager.find(10).getPosition().x,
|
'odd order nodes must be at right of central topic'
|
||||||
"children of 1st level odd order nodes must be to the left");
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(7).getPosition().x > manager.find(3).getPosition().x,
|
||||||
|
'children of 1st level even order nodes must be to the right'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(8).getPosition().x > manager.find(7).getPosition().x,
|
||||||
|
'children of 1st level even order nodes must be to the right'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(9).getPosition().x > manager.find(7).getPosition().x,
|
||||||
|
'children of 1st level even order nodes must be to the right'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(10).getPosition().x < manager.find(6).getPosition().x,
|
||||||
|
'children of 1st level odd order nodes must be to the left'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(11).getPosition().x < manager.find(10).getPosition().x,
|
||||||
|
'children of 1st level odd order nodes must be to the left'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(12).getPosition().x < manager.find(10).getPosition().x,
|
||||||
|
'children of 1st level odd order nodes must be to the left'
|
||||||
|
);
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testBalancedPredict: function () {
|
testBalancedPredict: function () {
|
||||||
console.log("testBalancedPredict:");
|
console.log('testBalancedPredict:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(7, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(8, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(9, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(10, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(11, TestSuite.NODE_SIZE, position);
|
||||||
|
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(0, 2, 1);
|
manager.connectNode(0, 2, 1);
|
||||||
@ -181,208 +207,291 @@ mindplot.layout.BalancedTestSuite = new Class({
|
|||||||
manager.layout();
|
manager.layout();
|
||||||
|
|
||||||
// Graph 1
|
// Graph 1
|
||||||
var graph1 = manager.plot("testBalancedPredict1", {width:1000, height:400});
|
var graph1 = manager.plot('testBalancedPredict1', { width: 1000, height: 400 });
|
||||||
|
|
||||||
console.log("\tAdded as child of node 0 and dropped at (165, -70):");
|
console.log('\tAdded as child of node 0 and dropped at (165, -70):');
|
||||||
var prediction1a = manager.predict(0, null, { x: 165, y: -70 });
|
var prediction1a = manager.predict(0, null, { x: 165, y: -70 });
|
||||||
this._plotPrediction(graph1, prediction1a);
|
this._plotPrediction(graph1, prediction1a);
|
||||||
$assert(prediction1a.position.y < manager.find(1).getPosition().y &&
|
$assert(
|
||||||
prediction1a.position.x == manager.find(1).getPosition().x, "Prediction is incorrectly positioned");
|
prediction1a.position.y < manager.find(1).getPosition().y &&
|
||||||
$assert(prediction1a.order == 0, "Prediction order should be 0");
|
prediction1a.position.x == manager.find(1).getPosition().x,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction1a.order == 0, 'Prediction order should be 0');
|
||||||
|
|
||||||
console.log("\tAdded as child of node 0 and dropped at (165, -10):");
|
console.log('\tAdded as child of node 0 and dropped at (165, -10):');
|
||||||
var prediction1b = manager.predict(0, null, { x: 165, y: -10 });
|
var prediction1b = manager.predict(0, null, { x: 165, y: -10 });
|
||||||
this._plotPrediction(graph1, prediction1b);
|
this._plotPrediction(graph1, prediction1b);
|
||||||
$assert(prediction1b.position.y > manager.find(1).getPosition().y &&
|
$assert(
|
||||||
|
prediction1b.position.y > manager.find(1).getPosition().y &&
|
||||||
prediction1b.position.y < manager.find(3).getPosition().y &&
|
prediction1b.position.y < manager.find(3).getPosition().y &&
|
||||||
prediction1b.position.x == manager.find(1).getPosition().x, "Prediction is incorrectly positioned");
|
prediction1b.position.x == manager.find(1).getPosition().x,
|
||||||
$assert(prediction1b.order == 2, "Prediction order should be 2");
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction1b.order == 2, 'Prediction order should be 2');
|
||||||
|
|
||||||
console.log("\tAdded as child of node 0 and dropped at (145, 15):");
|
console.log('\tAdded as child of node 0 and dropped at (145, 15):');
|
||||||
var prediction1c = manager.predict(0, null, { x: 145, y: 15 });
|
var prediction1c = manager.predict(0, null, { x: 145, y: 15 });
|
||||||
this._plotPrediction(graph1, prediction1c);
|
this._plotPrediction(graph1, prediction1c);
|
||||||
$assert(prediction1c.position.y > manager.find(3).getPosition().y &&
|
$assert(
|
||||||
|
prediction1c.position.y > manager.find(3).getPosition().y &&
|
||||||
prediction1c.position.y < manager.find(5).getPosition().y &&
|
prediction1c.position.y < manager.find(5).getPosition().y &&
|
||||||
prediction1c.position.x == manager.find(3).getPosition().x, "Prediction is incorrectly positioned");
|
prediction1c.position.x == manager.find(3).getPosition().x,
|
||||||
$assert(prediction1c.order == 4, "Prediction order should be 4");
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction1c.order == 4, 'Prediction order should be 4');
|
||||||
|
|
||||||
console.log("\tAdded as child of node 0 and dropped at (145, 70):");
|
console.log('\tAdded as child of node 0 and dropped at (145, 70):');
|
||||||
var prediction1d = manager.predict(0, null, { x: 145, y: 70 });
|
var prediction1d = manager.predict(0, null, { x: 145, y: 70 });
|
||||||
this._plotPrediction(graph1, prediction1d);
|
this._plotPrediction(graph1, prediction1d);
|
||||||
$assert(prediction1d.position.y > manager.find(5).getPosition().y &&
|
$assert(
|
||||||
prediction1d.position.x == manager.find(5).getPosition().x, "Prediction is incorrectly positioned");
|
prediction1d.position.y > manager.find(5).getPosition().y &&
|
||||||
$assert(prediction1d.order == 6, "Prediction order should be 6");
|
prediction1d.position.x == manager.find(5).getPosition().x,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction1d.order == 6, 'Prediction order should be 6');
|
||||||
|
|
||||||
// Graph 2
|
// Graph 2
|
||||||
var graph2 = manager.plot("testBalancedPredict2", {width:1000, height:400});
|
var graph2 = manager.plot('testBalancedPredict2', { width: 1000, height: 400 });
|
||||||
|
|
||||||
console.log("\tAdded as child of node 0 and dropped at (-145, -50):");
|
console.log('\tAdded as child of node 0 and dropped at (-145, -50):');
|
||||||
var prediction2a = manager.predict(0, null, { x: -145, y: -50 });
|
var prediction2a = manager.predict(0, null, { x: -145, y: -50 });
|
||||||
this._plotPrediction(graph2, prediction2a);
|
this._plotPrediction(graph2, prediction2a);
|
||||||
$assert(prediction2a.position.y < manager.find(2).getPosition().y &&
|
$assert(
|
||||||
prediction2a.position.x == manager.find(2).getPosition().x, "Prediction is incorrectly positioned");
|
prediction2a.position.y < manager.find(2).getPosition().y &&
|
||||||
$assert(prediction2a.order == 1, "Prediction order should be 1");
|
prediction2a.position.x == manager.find(2).getPosition().x,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction2a.order == 1, 'Prediction order should be 1');
|
||||||
|
|
||||||
console.log("\tAdded as child of node 0 and dropped at (-145, -10):");
|
console.log('\tAdded as child of node 0 and dropped at (-145, -10):');
|
||||||
var prediction2b = manager.predict(0, null, { x: -145, y: -10 });
|
var prediction2b = manager.predict(0, null, { x: -145, y: -10 });
|
||||||
this._plotPrediction(graph2, prediction2b);
|
this._plotPrediction(graph2, prediction2b);
|
||||||
$assert(prediction2b.position.y > manager.find(2).getPosition().y &&
|
$assert(
|
||||||
|
prediction2b.position.y > manager.find(2).getPosition().y &&
|
||||||
prediction2b.position.y < manager.find(4).getPosition().y &&
|
prediction2b.position.y < manager.find(4).getPosition().y &&
|
||||||
prediction2b.position.x == manager.find(2).getPosition().x, "Prediction is incorrectly positioned");
|
prediction2b.position.x == manager.find(2).getPosition().x,
|
||||||
$assert(prediction2b.order == 3, "Prediction order should be 3");
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction2b.order == 3, 'Prediction order should be 3');
|
||||||
|
|
||||||
console.log("\tAdded as child of node 0 and dropped at (-145, 40):");
|
console.log('\tAdded as child of node 0 and dropped at (-145, 40):');
|
||||||
var prediction2c = manager.predict(0, null, { x: -145, y: 400 });
|
var prediction2c = manager.predict(0, null, { x: -145, y: 400 });
|
||||||
this._plotPrediction(graph2, prediction2c);
|
this._plotPrediction(graph2, prediction2c);
|
||||||
$assert(prediction2c.position.y > manager.find(4).getPosition().y &&
|
$assert(
|
||||||
prediction2c.position.x == manager.find(4).getPosition().x, "Prediction is incorrectly positioned");
|
prediction2c.position.y > manager.find(4).getPosition().y &&
|
||||||
$assert(prediction2c.order == 5, "Prediction order should be 5");
|
prediction2c.position.x == manager.find(4).getPosition().x,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction2c.order == 5, 'Prediction order should be 5');
|
||||||
|
|
||||||
// Graph 3
|
// Graph 3
|
||||||
console.log("\tPredict nodes added with no position:");
|
console.log('\tPredict nodes added with no position:');
|
||||||
var graph3 = manager.plot("testBalancedPredict3", {width:1000, height:400});
|
var graph3 = manager.plot('testBalancedPredict3', { width: 1000, height: 400 });
|
||||||
var prediction3 = manager.predict(0, null, null);
|
var prediction3 = manager.predict(0, null, null);
|
||||||
this._plotPrediction(graph3, prediction3);
|
this._plotPrediction(graph3, prediction3);
|
||||||
$assert(prediction3.position.y > manager.find(4).getPosition().y &&
|
$assert(
|
||||||
prediction3.position.x == manager.find(4).getPosition().x, "Prediction is incorrectly positioned");
|
prediction3.position.y > manager.find(4).getPosition().y &&
|
||||||
$assert(prediction3.order == 5, "Prediction order should be 5");
|
prediction3.position.x == manager.find(4).getPosition().x,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction3.order == 5, 'Prediction order should be 5');
|
||||||
|
|
||||||
console.log("\tPredict nodes added with no position:");
|
console.log('\tPredict nodes added with no position:');
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, prediction3.position);
|
manager.addNode(6, TestSuite.NODE_SIZE, prediction3.position);
|
||||||
manager.connectNode(0, 6, prediction3.order);
|
manager.connectNode(0, 6, prediction3.order);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
var graph4 = manager.plot("testBalancedPredict4", {width:1000, height:400});
|
var graph4 = manager.plot('testBalancedPredict4', { width: 1000, height: 400 });
|
||||||
var prediction4 = manager.predict(0, null, null);
|
var prediction4 = manager.predict(0, null, null);
|
||||||
this._plotPrediction(graph4, prediction4);
|
this._plotPrediction(graph4, prediction4);
|
||||||
$assert(prediction4.position.y > manager.find(5).getPosition().y &&
|
$assert(
|
||||||
prediction4.position.x == manager.find(5).getPosition().x, "Prediction is incorrectly positioned");
|
prediction4.position.y > manager.find(5).getPosition().y &&
|
||||||
$assert(prediction4.order == 6, "Prediction order should be 6");
|
prediction4.position.x == manager.find(5).getPosition().x,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction4.order == 6, 'Prediction order should be 6');
|
||||||
|
|
||||||
console.log("\tPredict nodes added only a root node:");
|
console.log('\tPredict nodes added only a root node:');
|
||||||
manager.removeNode(1).removeNode(2).removeNode(3).removeNode(4).removeNode(5);
|
manager.removeNode(1).removeNode(2).removeNode(3).removeNode(4).removeNode(5);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
var graph5 = manager.plot("testBalancedPredict5", {width:1000, height:400});
|
var graph5 = manager.plot('testBalancedPredict5', { width: 1000, height: 400 });
|
||||||
var prediction5a = manager.predict(0, null, null);
|
var prediction5a = manager.predict(0, null, null);
|
||||||
var prediction5b = manager.predict(0, null, { x: 40, y: 100 });
|
var prediction5b = manager.predict(0, null, { x: 40, y: 100 });
|
||||||
this._plotPrediction(graph5, prediction5a);
|
this._plotPrediction(graph5, prediction5a);
|
||||||
this._plotPrediction(graph5, prediction5b);
|
this._plotPrediction(graph5, prediction5b);
|
||||||
$assert(prediction5a.position.x > manager.find(0).getPosition().x &&
|
$assert(
|
||||||
prediction5a.position.y == manager.find(0).getPosition().y, "Prediction is incorrectly positioned");
|
prediction5a.position.x > manager.find(0).getPosition().x &&
|
||||||
$assert(prediction5a.order == 0, "Prediction order should be 0");
|
prediction5a.position.y == manager.find(0).getPosition().y,
|
||||||
$assert(prediction5a.position.x == prediction5b.position.x &&
|
'Prediction is incorrectly positioned'
|
||||||
prediction5a.position.y == prediction5b.position.y, "Both predictions should be the same");
|
);
|
||||||
$assert(prediction5a.order == prediction5b.order, "Both predictions should be the same");
|
$assert(prediction5a.order == 0, 'Prediction order should be 0');
|
||||||
|
$assert(
|
||||||
|
prediction5a.position.x == prediction5b.position.x &&
|
||||||
|
prediction5a.position.y == prediction5b.position.y,
|
||||||
|
'Both predictions should be the same'
|
||||||
|
);
|
||||||
|
$assert(prediction5a.order == prediction5b.order, 'Both predictions should be the same');
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testBalancedNodeDragPredict: function () {
|
testBalancedNodeDragPredict: function () {
|
||||||
console.log("testBalancedNodeDragPredict:");
|
console.log('testBalancedNodeDragPredict:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Graph 1
|
// Graph 1
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,1,0);
|
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
var graph1 = manager.plot("testBalancedNodeDragPredict1", {width:800, height:400});
|
var graph1 = manager.plot('testBalancedNodeDragPredict1', { width: 800, height: 400 });
|
||||||
|
|
||||||
var prediction1a = manager.predict(0, 1, { x: 50, y: 50 });
|
var prediction1a = manager.predict(0, 1, { x: 50, y: 50 });
|
||||||
this._plotPrediction(graph1, prediction1a);
|
this._plotPrediction(graph1, prediction1a);
|
||||||
$assert(prediction1a.position.x == manager.find(1).getPosition().x &&
|
$assert(
|
||||||
|
prediction1a.position.x == manager.find(1).getPosition().x &&
|
||||||
prediction1a.position.y == manager.find(1).getPosition().y,
|
prediction1a.position.y == manager.find(1).getPosition().y,
|
||||||
"Prediction position should be the same as node 1");
|
'Prediction position should be the same as node 1'
|
||||||
$assert(prediction1a.order == manager.find(1).getOrder(), "Prediction order should be the same as node 1");
|
);
|
||||||
|
$assert(
|
||||||
|
prediction1a.order == manager.find(1).getOrder(),
|
||||||
|
'Prediction order should be the same as node 1'
|
||||||
|
);
|
||||||
|
|
||||||
var prediction1b = manager.predict(0, 1, { x: 50, y: -50 });
|
var prediction1b = manager.predict(0, 1, { x: 50, y: -50 });
|
||||||
this._plotPrediction(graph1, prediction1b);
|
this._plotPrediction(graph1, prediction1b);
|
||||||
$assert(prediction1b.position.x == manager.find(1).getPosition().x &&
|
$assert(
|
||||||
|
prediction1b.position.x == manager.find(1).getPosition().x &&
|
||||||
prediction1b.position.y == manager.find(1).getPosition().y,
|
prediction1b.position.y == manager.find(1).getPosition().y,
|
||||||
"Prediction position should be the same as node 1");
|
'Prediction position should be the same as node 1'
|
||||||
$assert(prediction1b.order == manager.find(1).getOrder(), "Prediction order should be the same as node 1");
|
);
|
||||||
|
$assert(
|
||||||
|
prediction1b.order == manager.find(1).getOrder(),
|
||||||
|
'Prediction order should be the same as node 1'
|
||||||
|
);
|
||||||
|
|
||||||
var prediction1c = manager.predict(0, 1, { x: -50, y: 50 });
|
var prediction1c = manager.predict(0, 1, { x: -50, y: 50 });
|
||||||
this._plotPrediction(graph1, prediction1c);
|
this._plotPrediction(graph1, prediction1c);
|
||||||
$assert(prediction1c.position.x < manager.find(0).getPosition().x &&
|
$assert(
|
||||||
prediction1c.position.y == manager.find(0).getPosition().y, "Prediction is incorrectly positioned");
|
prediction1c.position.x < manager.find(0).getPosition().x &&
|
||||||
$assert(prediction1c.order == 1, "Prediction order should be the same as node 1");
|
prediction1c.position.y == manager.find(0).getPosition().y,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction1c.order == 1, 'Prediction order should be the same as node 1');
|
||||||
|
|
||||||
var prediction1d = manager.predict(0, 1, { x: -50, y: -50 });
|
var prediction1d = manager.predict(0, 1, { x: -50, y: -50 });
|
||||||
this._plotPrediction(graph1, prediction1d);
|
this._plotPrediction(graph1, prediction1d);
|
||||||
$assert(prediction1d.position.x < manager.find(0).getPosition().x &&
|
$assert(
|
||||||
prediction1d.position.y == manager.find(0).getPosition().y, "Prediction is incorrectly positioned");
|
prediction1d.position.x < manager.find(0).getPosition().x &&
|
||||||
$assert(prediction1d.order == 1, "Prediction order should be the same as node 1");
|
prediction1d.position.y == manager.find(0).getPosition().y,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction1d.order == 1, 'Prediction order should be the same as node 1');
|
||||||
|
|
||||||
// Graph 2
|
// Graph 2
|
||||||
manager.disconnectNode(1);
|
manager.disconnectNode(1);
|
||||||
manager.connectNode(0, 1, 1);
|
manager.connectNode(0, 1, 1);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
var graph2 = manager.plot("testBalancedNodeDragPredict2", {width:800, height:400});
|
var graph2 = manager.plot('testBalancedNodeDragPredict2', { width: 800, height: 400 });
|
||||||
|
|
||||||
var prediction2a = manager.predict(0, 1, { x: 50, y: 50 });
|
var prediction2a = manager.predict(0, 1, { x: 50, y: 50 });
|
||||||
this._plotPrediction(graph2, prediction2a);
|
this._plotPrediction(graph2, prediction2a);
|
||||||
$assert(prediction2a.position.x > manager.find(0).getPosition().x &&
|
$assert(
|
||||||
prediction2a.position.y == manager.find(0).getPosition().y, "Prediction is positioned incorrectly");
|
prediction2a.position.x > manager.find(0).getPosition().x &&
|
||||||
$assert(prediction2a.order == 0, "Prediction order should be 0");
|
prediction2a.position.y == manager.find(0).getPosition().y,
|
||||||
|
'Prediction is positioned incorrectly'
|
||||||
|
);
|
||||||
|
$assert(prediction2a.order == 0, 'Prediction order should be 0');
|
||||||
|
|
||||||
var prediction2b = manager.predict(0, 1, { x: 50, y: -50 });
|
var prediction2b = manager.predict(0, 1, { x: 50, y: -50 });
|
||||||
this._plotPrediction(graph2, prediction2b);
|
this._plotPrediction(graph2, prediction2b);
|
||||||
$assert(prediction2b.position.x > manager.find(0).getPosition().x &&
|
$assert(
|
||||||
prediction2b.position.y == manager.find(0).getPosition().y, "Prediction is positioned incorrectly");
|
prediction2b.position.x > manager.find(0).getPosition().x &&
|
||||||
$assert(prediction2b.order == 0, "Prediction order should be 0");
|
prediction2b.position.y == manager.find(0).getPosition().y,
|
||||||
|
'Prediction is positioned incorrectly'
|
||||||
|
);
|
||||||
|
$assert(prediction2b.order == 0, 'Prediction order should be 0');
|
||||||
|
|
||||||
var prediction2c = manager.predict(0, 1, { x: -50, y: 50 });
|
var prediction2c = manager.predict(0, 1, { x: -50, y: 50 });
|
||||||
this._plotPrediction(graph2, prediction2c);
|
this._plotPrediction(graph2, prediction2c);
|
||||||
$assert(prediction2c.position.x == manager.find(1).getPosition().x &&
|
$assert(
|
||||||
|
prediction2c.position.x == manager.find(1).getPosition().x &&
|
||||||
prediction2c.position.y == manager.find(1).getPosition().y,
|
prediction2c.position.y == manager.find(1).getPosition().y,
|
||||||
"Prediction position should be the same as node 1");
|
'Prediction position should be the same as node 1'
|
||||||
$assert(prediction2c.order == manager.find(1).getOrder(), "Prediction order should be the same as node 1");
|
);
|
||||||
|
$assert(
|
||||||
|
prediction2c.order == manager.find(1).getOrder(),
|
||||||
|
'Prediction order should be the same as node 1'
|
||||||
|
);
|
||||||
|
|
||||||
var prediction2d = manager.predict(0, 1, { x: -50, y: -50 });
|
var prediction2d = manager.predict(0, 1, { x: -50, y: -50 });
|
||||||
this._plotPrediction(graph2, prediction2d);
|
this._plotPrediction(graph2, prediction2d);
|
||||||
$assert(prediction2d.position.x == manager.find(1).getPosition().x &&
|
$assert(
|
||||||
|
prediction2d.position.x == manager.find(1).getPosition().x &&
|
||||||
prediction2d.position.y == manager.find(1).getPosition().y,
|
prediction2d.position.y == manager.find(1).getPosition().y,
|
||||||
"Prediction position should be the same as node 1");
|
'Prediction position should be the same as node 1'
|
||||||
$assert(prediction2d.order == manager.find(1).getOrder(), "Prediction order should be the same as node 1");
|
);
|
||||||
|
$assert(
|
||||||
|
prediction2d.order == manager.find(1).getOrder(),
|
||||||
|
'Prediction order should be the same as node 1'
|
||||||
|
);
|
||||||
|
|
||||||
// Graph 3
|
// Graph 3
|
||||||
manager.disconnectNode(1);
|
manager.disconnectNode(1);
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,2,2);
|
manager.addNode(2, TestSuite.NODE_SIZE, position).connectNode(0, 2, 2);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
var graph3 = manager.plot("testBalancedNodeDragPredict3", {width:800, height:400});
|
var graph3 = manager.plot('testBalancedNodeDragPredict3', { width: 800, height: 400 });
|
||||||
|
|
||||||
var prediction3a = manager.predict(0, 1, { x: 50, y: 50 });
|
var prediction3a = manager.predict(0, 1, { x: 50, y: 50 });
|
||||||
this._plotPrediction(graph3, prediction3a);
|
this._plotPrediction(graph3, prediction3a);
|
||||||
$assert(prediction3a.position.x == manager.find(2).getPosition().x &&
|
$assert(
|
||||||
prediction3a.position.y > manager.find(2).getPosition().y, "Prediction is incorrectly positioned");
|
prediction3a.position.x == manager.find(2).getPosition().x &&
|
||||||
$assert(prediction3a.order == 4, "Prediction order should be 4");
|
prediction3a.position.y > manager.find(2).getPosition().y,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction3a.order == 4, 'Prediction order should be 4');
|
||||||
|
|
||||||
var prediction3b = manager.predict(0, 1, { x: 50, y: -50 });
|
var prediction3b = manager.predict(0, 1, { x: 50, y: -50 });
|
||||||
this._plotPrediction(graph3, prediction3b);
|
this._plotPrediction(graph3, prediction3b);
|
||||||
$assert(prediction3b.position.x == manager.find(1).getPosition().x &&
|
$assert(
|
||||||
|
prediction3b.position.x == manager.find(1).getPosition().x &&
|
||||||
prediction3b.position.y == manager.find(1).getPosition().y &&
|
prediction3b.position.y == manager.find(1).getPosition().y &&
|
||||||
prediction3b.order == manager.find(1).getOrder(), "Prediction should be the exact same as dragged node");
|
prediction3b.order == manager.find(1).getOrder(),
|
||||||
|
'Prediction should be the exact same as dragged node'
|
||||||
|
);
|
||||||
|
|
||||||
var prediction3c = manager.predict(0, 1, { x: -50, y: 50 });
|
var prediction3c = manager.predict(0, 1, { x: -50, y: 50 });
|
||||||
this._plotPrediction(graph3, prediction3c);
|
this._plotPrediction(graph3, prediction3c);
|
||||||
$assert(prediction3c.position.x < manager.find(0).getPosition().x &&
|
$assert(
|
||||||
prediction3c.position.y == manager.find(0).getPosition().y, "Prediction is incorrectly positioned");
|
prediction3c.position.x < manager.find(0).getPosition().x &&
|
||||||
$assert(prediction3c.order == 1, "Prediction order should be 1");
|
prediction3c.position.y == manager.find(0).getPosition().y,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction3c.order == 1, 'Prediction order should be 1');
|
||||||
|
|
||||||
var prediction3d = manager.predict(0, 1, { x: -50, y: -50 });
|
var prediction3d = manager.predict(0, 1, { x: -50, y: -50 });
|
||||||
this._plotPrediction(graph3, prediction3d);
|
this._plotPrediction(graph3, prediction3d);
|
||||||
$assert(prediction3d.position.x < manager.find(0).getPosition().x &&
|
$assert(
|
||||||
prediction3d.position.y == manager.find(0).getPosition().y, "Prediction is incorrectly positioned");
|
prediction3d.position.x < manager.find(0).getPosition().x &&
|
||||||
$assert(prediction3d.order == 1, "Prediction order should be 1");
|
prediction3d.position.y == manager.find(0).getPosition().y,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction3d.order == 1, 'Prediction order should be 1');
|
||||||
|
|
||||||
var prediction3e = manager.predict(0, 1, { x: 50, y: 0 });
|
var prediction3e = manager.predict(0, 1, { x: 50, y: 0 });
|
||||||
this._plotPrediction(graph3, prediction3e);
|
this._plotPrediction(graph3, prediction3e);
|
||||||
$assert(prediction3e.position.x == manager.find(1).getPosition().x &&
|
$assert(
|
||||||
|
prediction3e.position.x == manager.find(1).getPosition().x &&
|
||||||
prediction3e.position.y == manager.find(1).getPosition().y,
|
prediction3e.position.y == manager.find(1).getPosition().y,
|
||||||
"Prediction position should be the same as node 1");
|
'Prediction position should be the same as node 1'
|
||||||
$assert(prediction3e.order == manager.find(1).getOrder(), "Prediction order should be the same as node 1");
|
);
|
||||||
|
$assert(
|
||||||
|
prediction3e.order == manager.find(1).getOrder(),
|
||||||
|
'Prediction order should be the same as node 1'
|
||||||
|
);
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default BalancedTestSuite;
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
mindplot.layout.FreeTestSuite = new Class({
|
const TestSuite = require('./TestSuite').default;
|
||||||
Extends: mindplot.layout.TestSuite,
|
const FreeTestSuite = new Class({
|
||||||
|
Extends: TestSuite,
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
$('#freeTest').setStyle("display","block");
|
$('#freeTest').css('display', 'block');
|
||||||
|
|
||||||
this.testFreePosition();
|
this.testFreePosition();
|
||||||
this.testFreePredict();
|
this.testFreePredict();
|
||||||
@ -32,120 +33,132 @@ mindplot.layout.FreeTestSuite = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
testFreePosition: function () {
|
testFreePosition: function () {
|
||||||
console.log("testFreePosition:");
|
console.log('testFreePosition:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(6, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(7, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(8, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(9, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(10, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(11, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(12, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(12, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(13, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(13, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(14, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(14, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(15, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(15, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(16, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(16, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(17, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(17, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(18, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(18, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(19, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(19, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(20, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(20, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(21, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(21, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(22, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(22, TestSuite.NODE_SIZE, position);
|
||||||
|
|
||||||
manager.connectNode(0, 1, 0).connectNode(0, 2, 1).connectNode(0, 3, 2).connectNode(0, 4, 3);
|
manager.connectNode(0, 1, 0).connectNode(0, 2, 1).connectNode(0, 3, 2).connectNode(0, 4, 3);
|
||||||
manager.connectNode(4, 21, 0).connectNode(4, 22, 0);
|
manager.connectNode(4, 21, 0).connectNode(4, 22, 0);
|
||||||
manager.connectNode(1, 5, 0);
|
manager.connectNode(1, 5, 0);
|
||||||
manager.connectNode(5, 6, 0).connectNode(6, 8, 0).connectNode(8, 9, 0);
|
manager.connectNode(5, 6, 0).connectNode(6, 8, 0).connectNode(8, 9, 0);
|
||||||
manager.connectNode(5, 7, 1).connectNode(7, 10, 0);
|
manager.connectNode(5, 7, 1).connectNode(7, 10, 0);
|
||||||
manager.connectNode(3,11,0).connectNode(11,14,0).connectNode(14,18,0).connectNode(14,19,1).connectNode(14,20,2);
|
manager
|
||||||
manager.connectNode(3,12,1).connectNode(12,15,0).connectNode(12,16,1).connectNode(12,17,2);
|
.connectNode(3, 11, 0)
|
||||||
|
.connectNode(11, 14, 0)
|
||||||
|
.connectNode(14, 18, 0)
|
||||||
|
.connectNode(14, 19, 1)
|
||||||
|
.connectNode(14, 20, 2);
|
||||||
|
manager
|
||||||
|
.connectNode(3, 12, 1)
|
||||||
|
.connectNode(12, 15, 0)
|
||||||
|
.connectNode(12, 16, 1)
|
||||||
|
.connectNode(12, 17, 2);
|
||||||
manager.connectNode(3, 13, 2);
|
manager.connectNode(3, 13, 2);
|
||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testFreePosition1", {width:1400, height:600});
|
manager.plot('testFreePosition1', { width: 1400, height: 600 });
|
||||||
|
|
||||||
console.log("\tmove node 12 to (300,30):");
|
console.log('\tmove node 12 to (300,30):');
|
||||||
manager.moveNode(12, { x: 300, y: 30 });
|
manager.moveNode(12, { x: 300, y: 30 });
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testFreePosition2", {width:1400, height:600});
|
manager.plot('testFreePosition2', { width: 1400, height: 600 });
|
||||||
this._assertFreePosition(manager, 12, {x:300, y:30})
|
this._assertFreePosition(manager, 12, { x: 300, y: 30 });
|
||||||
|
|
||||||
console.log("\tmove node 13 to (340,180):");
|
console.log('\tmove node 13 to (340,180):');
|
||||||
var node13Pos = { x: 340, y: 180 };
|
var node13Pos = { x: 340, y: 180 };
|
||||||
manager.moveNode(13, node13Pos);
|
manager.moveNode(13, node13Pos);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testFreePosition3", {width:1400, height:600});
|
manager.plot('testFreePosition3', { width: 1400, height: 600 });
|
||||||
this._assertFreePosition(manager, 13, node13Pos);
|
this._assertFreePosition(manager, 13, node13Pos);
|
||||||
|
|
||||||
console.log("\tmove node 11 to (250,-50):");
|
console.log('\tmove node 11 to (250,-50):');
|
||||||
manager.moveNode(11, { x: 250, y: -50 });
|
manager.moveNode(11, { x: 250, y: -50 });
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testFreePosition4", {width:1400, height:600});
|
manager.plot('testFreePosition4', { width: 1400, height: 600 });
|
||||||
this._assertFreePosition(manager, 11, { x: 250, y: -50 });
|
this._assertFreePosition(manager, 11, { x: 250, y: -50 });
|
||||||
$assert(manager.find(13).getPosition().x == node13Pos.x && manager.find(13).getPosition().y == node13Pos.y,
|
$assert(
|
||||||
"Node 13 shouldn't have moved");
|
manager.find(13).getPosition().x == node13Pos.x &&
|
||||||
|
manager.find(13).getPosition().y == node13Pos.y,
|
||||||
|
"Node 13 shouldn't have moved"
|
||||||
|
);
|
||||||
|
|
||||||
console.log("\tmove node 7 to (350,-190):");
|
console.log('\tmove node 7 to (350,-190):');
|
||||||
manager.moveNode(7, { x: 350, y: -190 });
|
manager.moveNode(7, { x: 350, y: -190 });
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testFreePosition5", {width:1400, height:600});
|
manager.plot('testFreePosition5', { width: 1400, height: 600 });
|
||||||
this._assertFreePosition(manager, 7, { x: 350, y: -190 });
|
this._assertFreePosition(manager, 7, { x: 350, y: -190 });
|
||||||
|
|
||||||
console.log("\tadd node 23 to 12:");
|
console.log('\tadd node 23 to 12:');
|
||||||
manager.addNode(23, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(23, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(12, 23, 3);
|
manager.connectNode(12, 23, 3);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testFreePosition6", {width:1400, height:600});
|
manager.plot('testFreePosition6', { width: 1400, height: 600 });
|
||||||
this._assertFreePosition(manager, null, null);
|
this._assertFreePosition(manager, null, null);
|
||||||
|
|
||||||
console.log("\tmove node 4 to (-300, 190):");
|
console.log('\tmove node 4 to (-300, 190):');
|
||||||
manager.moveNode(4, { x: -300, y: 190 });
|
manager.moveNode(4, { x: -300, y: 190 });
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testFreePosition7", {width:1400, height:600});
|
manager.plot('testFreePosition7', { width: 1400, height: 600 });
|
||||||
this._assertFreePosition(manager, 4, { x: -300, y: 190 });
|
this._assertFreePosition(manager, 4, { x: -300, y: 190 });
|
||||||
|
|
||||||
console.log("\tadd node 24 to 3:");
|
console.log('\tadd node 24 to 3:');
|
||||||
manager.addNode(24, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(24, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(3, 24, 3);
|
manager.connectNode(3, 24, 3);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testFreePosition8", {width:1400, height:600});
|
manager.plot('testFreePosition8', { width: 1400, height: 600 });
|
||||||
this._assertFreePosition(manager, null, null);
|
this._assertFreePosition(manager, null, null);
|
||||||
|
|
||||||
console.log("\tadd node 25 to 17:");
|
console.log('\tadd node 25 to 17:');
|
||||||
manager.addNode(25, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(25, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(17, 25, 0);
|
manager.connectNode(17, 25, 0);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testFreePosition9", {width:1400, height:600});
|
manager.plot('testFreePosition9', { width: 1400, height: 600 });
|
||||||
this._assertFreePosition(manager, null, null);
|
this._assertFreePosition(manager, null, null);
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testFreePredict: function () {
|
testFreePredict: function () {
|
||||||
console.log("testFreePredict:");
|
console.log('testFreePredict:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(6, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(7, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(8, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(9, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(10, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(11, TestSuite.NODE_SIZE, position);
|
||||||
|
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(0, 2, 1);
|
manager.connectNode(0, 2, 1);
|
||||||
@ -160,50 +173,62 @@ mindplot.layout.FreeTestSuite = new Class({
|
|||||||
manager.connectNode(2, 10, 1);
|
manager.connectNode(2, 10, 1);
|
||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
var graph = manager.plot("testFreePredict1", {width:1000, height:400});
|
var graph = manager.plot('testFreePredict1', { width: 1000, height: 400 });
|
||||||
|
|
||||||
var pos1 = { x: 370, y: 80 };
|
var pos1 = { x: 370, y: 80 };
|
||||||
var predict1 = manager.predict(5, 11, pos1, true);
|
var predict1 = manager.predict(5, 11, pos1, true);
|
||||||
this._plotPrediction(graph, predict1);
|
this._plotPrediction(graph, predict1);
|
||||||
$assert(predict1.position.x == pos1.x && predict1.position.y == pos1.y, "free predict should return the same position");
|
$assert(
|
||||||
|
predict1.position.x == pos1.x && predict1.position.y == pos1.y,
|
||||||
|
'free predict should return the same position'
|
||||||
|
);
|
||||||
|
|
||||||
var pos2 = { x: -200, y: 80 };
|
var pos2 = { x: -200, y: 80 };
|
||||||
var predict2 = manager.predict(0, 2, pos2, true);
|
var predict2 = manager.predict(0, 2, pos2, true);
|
||||||
this._plotPrediction(graph, predict2);
|
this._plotPrediction(graph, predict2);
|
||||||
$assert(predict2.position.x == pos2.x && predict2.position.y == pos2.y, "free predict should return the same position");
|
$assert(
|
||||||
|
predict2.position.x == pos2.x && predict2.position.y == pos2.y,
|
||||||
|
'free predict should return the same position'
|
||||||
|
);
|
||||||
|
|
||||||
var pos3 = { x: 200, y: 30 };
|
var pos3 = { x: 200, y: 30 };
|
||||||
var node5 = manager.find(5);
|
var node5 = manager.find(5);
|
||||||
var predict3 = manager.predict(3, 5, pos3, true);
|
var predict3 = manager.predict(3, 5, pos3, true);
|
||||||
this._plotPrediction(graph, predict3);
|
this._plotPrediction(graph, predict3);
|
||||||
$assert(predict3.position.x == node5.getPosition().x && predict3.position.y == pos3.y, "free predict should return the x-coordinate of the node");
|
$assert(
|
||||||
|
predict3.position.x == node5.getPosition().x && predict3.position.y == pos3.y,
|
||||||
|
'free predict should return the x-coordinate of the node'
|
||||||
|
);
|
||||||
|
|
||||||
var pos4 = { x: -100, y: 45 };
|
var pos4 = { x: -100, y: 45 };
|
||||||
var node10 = manager.find(10);
|
var node10 = manager.find(10);
|
||||||
var predict4 = manager.predict(2, 10, pos4, true);
|
var predict4 = manager.predict(2, 10, pos4, true);
|
||||||
this._plotPrediction(graph, predict4);
|
this._plotPrediction(graph, predict4);
|
||||||
$assert(predict4.position.x == node10.getPosition().x && predict4.position.y == pos4.y, "free predict should return the x-coordinate of the node");
|
$assert(
|
||||||
|
predict4.position.x == node10.getPosition().x && predict4.position.y == pos4.y,
|
||||||
|
'free predict should return the x-coordinate of the node'
|
||||||
|
);
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testReconnectFreeNode: function () {
|
testReconnectFreeNode: function () {
|
||||||
console.log("testReconnectFreeNode:");
|
console.log('testReconnectFreeNode:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(6, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(7, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(8, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(9, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(10, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(11, TestSuite.NODE_SIZE, position);
|
||||||
|
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(0, 2, 1);
|
manager.connectNode(0, 2, 1);
|
||||||
@ -218,123 +243,129 @@ mindplot.layout.FreeTestSuite = new Class({
|
|||||||
manager.connectNode(2, 10, 1);
|
manager.connectNode(2, 10, 1);
|
||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testReconnectFreeNode1", {width:1000, height:400});
|
manager.plot('testReconnectFreeNode1', { width: 1000, height: 400 });
|
||||||
|
|
||||||
console.log("\tmove node 5");
|
console.log('\tmove node 5');
|
||||||
manager.moveNode(5, { x: 250, y: 30 });
|
manager.moveNode(5, { x: 250, y: 30 });
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testReconnectFreeNode2", {width:1000, height:400});
|
manager.plot('testReconnectFreeNode2', { width: 1000, height: 400 });
|
||||||
this._assertFreePosition(manager, 5, { x: 250, y: 30 });
|
this._assertFreePosition(manager, 5, { x: 250, y: 30 });
|
||||||
|
|
||||||
console.log("\treconnect node 5 to node 2");
|
console.log('\treconnect node 5 to node 2');
|
||||||
manager.disconnectNode(5);
|
manager.disconnectNode(5);
|
||||||
manager.connectNode(2, 5, 2);
|
manager.connectNode(2, 5, 2);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testReconnectFreeNode3", {width:1000, height:400});
|
manager.plot('testReconnectFreeNode3', { width: 1000, height: 400 });
|
||||||
$assert(manager.find(5).getPosition().y > manager.find(10).getPosition().y &&
|
$assert(
|
||||||
manager.find(5).getPosition().x == manager.find(10).getPosition().x, "Node 5 is incorrectly positioned"
|
manager.find(5).getPosition().y > manager.find(10).getPosition().y &&
|
||||||
|
manager.find(5).getPosition().x == manager.find(10).getPosition().x,
|
||||||
|
'Node 5 is incorrectly positioned'
|
||||||
);
|
);
|
||||||
$assert(manager.find(5).getOrder() == 2, "Node 5 should have order 2");
|
$assert(manager.find(5).getOrder() == 2, 'Node 5 should have order 2');
|
||||||
|
|
||||||
console.log("\tmove node 8");
|
console.log('\tmove node 8');
|
||||||
manager.moveNode(8, { x: -370, y: 60 });
|
manager.moveNode(8, { x: -370, y: 60 });
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testReconnectFreeNode4", {width:1000, height:400});
|
manager.plot('testReconnectFreeNode4', { width: 1000, height: 400 });
|
||||||
this._assertFreePosition(manager, 8, { x: -370, y: 60 });
|
this._assertFreePosition(manager, 8, { x: -370, y: 60 });
|
||||||
|
|
||||||
console.log("\treconnect node 5 to node 10");
|
console.log('\treconnect node 5 to node 10');
|
||||||
manager.disconnectNode(5);
|
manager.disconnectNode(5);
|
||||||
manager.connectNode(10, 5, 0);
|
manager.connectNode(10, 5, 0);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testReconnectFreeNode5", {width:1000, height:400});
|
manager.plot('testReconnectFreeNode5', { width: 1000, height: 400 });
|
||||||
$assert(manager.find(5).getPosition().y == manager.find(10).getPosition().y &&
|
$assert(
|
||||||
manager.find(5).getPosition().x < manager.find(10).getPosition().x, "Node 5 is incorrectly positioned"
|
manager.find(5).getPosition().y == manager.find(10).getPosition().y &&
|
||||||
|
manager.find(5).getPosition().x < manager.find(10).getPosition().x,
|
||||||
|
'Node 5 is incorrectly positioned'
|
||||||
);
|
);
|
||||||
$assert(manager.find(5).getOrder() == 0, "Node 5 should have order 0");
|
$assert(manager.find(5).getOrder() == 0, 'Node 5 should have order 0');
|
||||||
|
|
||||||
console.log("reconnect node 5 to node 3");
|
console.log('reconnect node 5 to node 3');
|
||||||
manager.disconnectNode(5);
|
manager.disconnectNode(5);
|
||||||
manager.connectNode(3, 5, 2);
|
manager.connectNode(3, 5, 2);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testReconnectFreeNode6", {width:1000, height:400});
|
manager.plot('testReconnectFreeNode6', { width: 1000, height: 400 });
|
||||||
$assert(manager.find(5).getPosition().y > manager.find(6).getPosition().y &&
|
$assert(
|
||||||
manager.find(5).getPosition().x == manager.find(6).getPosition().x, "Node 5 is incorrectly positioned"
|
manager.find(5).getPosition().y > manager.find(6).getPosition().y &&
|
||||||
|
manager.find(5).getPosition().x == manager.find(6).getPosition().x,
|
||||||
|
'Node 5 is incorrectly positioned'
|
||||||
);
|
);
|
||||||
$assert(manager.find(5).getOrder() == 2, "Node 5 should have order 2");
|
$assert(manager.find(5).getOrder() == 2, 'Node 5 should have order 2');
|
||||||
|
|
||||||
console.log("\tmove node 8");
|
console.log('\tmove node 8');
|
||||||
manager.moveNode(8, { x: 370, y: 30 });
|
manager.moveNode(8, { x: 370, y: 30 });
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testReconnectFreeNode7", {width:1000, height:400});
|
manager.plot('testReconnectFreeNode7', { width: 1000, height: 400 });
|
||||||
this._assertFreePosition(manager, 8, { x: 370, y: 30 });
|
this._assertFreePosition(manager, 8, { x: 370, y: 30 });
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testSiblingOverlapping: function () {
|
testSiblingOverlapping: function () {
|
||||||
console.log("testSiblingOverlapping:");
|
console.log('testSiblingOverlapping:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,1,0);
|
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,2,0);
|
manager.addNode(2, TestSuite.NODE_SIZE, position).connectNode(1, 2, 0);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,3,1);
|
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(1, 3, 1);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,4,2);
|
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(1, 4, 2);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,5,3);
|
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(1, 5, 3);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,6,4);
|
manager.addNode(6, TestSuite.NODE_SIZE, position).connectNode(1, 6, 4);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,7,5);
|
manager.addNode(7, TestSuite.NODE_SIZE, position).connectNode(1, 7, 5);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,8,6);
|
manager.addNode(8, TestSuite.NODE_SIZE, position).connectNode(1, 8, 6);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,9,4);
|
manager.addNode(9, TestSuite.NODE_SIZE, position).connectNode(0, 9, 4);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testSiblingOverlapping1", {width:800, height:600});
|
manager.plot('testSiblingOverlapping1', { width: 800, height: 600 });
|
||||||
|
|
||||||
console.log("\tmove node 2");
|
console.log('\tmove node 2');
|
||||||
manager.moveNode(2, { x: 250, y: -30 });
|
manager.moveNode(2, { x: 250, y: -30 });
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testSiblingOverlapping2", {width:800, height:600});
|
manager.plot('testSiblingOverlapping2', { width: 800, height: 600 });
|
||||||
this._assertFreePosition(manager, 2, { x: 250, y: -30 });
|
this._assertFreePosition(manager, 2, { x: 250, y: -30 });
|
||||||
|
|
||||||
console.log("\tmove node 7");
|
console.log('\tmove node 7');
|
||||||
manager.moveNode(7, { x: 250, y: 100 });
|
manager.moveNode(7, { x: 250, y: 100 });
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testSiblingOverlapping3", {width:800, height:600});
|
manager.plot('testSiblingOverlapping3', { width: 800, height: 600 });
|
||||||
this._assertFreePosition(manager, 7, { x: 250, y: 100 });
|
this._assertFreePosition(manager, 7, { x: 250, y: 100 });
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testRootNodeChildrenPositioning: function () {
|
testRootNodeChildrenPositioning: function () {
|
||||||
console.log("testRootNodeChildrenPositioning:");
|
console.log('testRootNodeChildrenPositioning:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,1,0);
|
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,2,1);
|
manager.addNode(2, TestSuite.NODE_SIZE, position).connectNode(0, 2, 1);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,3,2);
|
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(0, 3, 2);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,4,3);
|
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(0, 4, 3);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,5,4);
|
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(0, 5, 4);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,6,5);
|
manager.addNode(6, TestSuite.NODE_SIZE, position).connectNode(0, 6, 5);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testRootNodeChildrenPositioning1", {width:800, height:600});
|
manager.plot('testRootNodeChildrenPositioning1', { width: 800, height: 600 });
|
||||||
|
|
||||||
console.log("\tmove node 1");
|
console.log('\tmove node 1');
|
||||||
manager.moveNode(1, { x: 150, y: 0 });
|
manager.moveNode(1, { x: 150, y: 0 });
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testRootNodeChildrenPositioning2", {width:800, height:600});
|
manager.plot('testRootNodeChildrenPositioning2', { width: 800, height: 600 });
|
||||||
this._assertFreePosition(manager, 1, { x: 150, y: 0 });
|
this._assertFreePosition(manager, 1, { x: 150, y: 0 });
|
||||||
|
|
||||||
console.log("\tmove node 4");
|
console.log('\tmove node 4');
|
||||||
manager.moveNode(4, { x: -140, y: 30 });
|
manager.moveNode(4, { x: -140, y: 30 });
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testRootNodeChildrenPositioning3", {width:800, height:600});
|
manager.plot('testRootNodeChildrenPositioning3', { width: 800, height: 600 });
|
||||||
this._assertFreePosition(manager, 4, { x: -140, y: 30 });
|
this._assertFreePosition(manager, 4, { x: -140, y: 30 });
|
||||||
|
|
||||||
console.log("\tmove node 2");
|
console.log('\tmove node 2');
|
||||||
manager.moveNode(2, { x: -150, y: -50 });
|
manager.moveNode(2, { x: -150, y: -50 });
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testRootNodeChildrenPositioning4", {width:800, height:600});
|
manager.plot('testRootNodeChildrenPositioning4', { width: 800, height: 600 });
|
||||||
this._assertFreePosition(manager, 2, { x: -150, y: -50 });
|
this._assertFreePosition(manager, 2, { x: -150, y: -50 });
|
||||||
|
|
||||||
//TODO(gb): fix this. It's not working
|
//TODO(gb): fix this. It's not working
|
||||||
@ -344,131 +375,168 @@ mindplot.layout.FreeTestSuite = new Class({
|
|||||||
// manager.plot("testRootNodeChildrenPositioning5", {width:800, height:600});
|
// manager.plot("testRootNodeChildrenPositioning5", {width:800, height:600});
|
||||||
// this._assertFreePosition(manager, 6, {x:-150, y:-50});
|
// this._assertFreePosition(manager, 6, {x:-150, y:-50});
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testBalancedFreePredict: function () {
|
testBalancedFreePredict: function () {
|
||||||
console.log("testBalancedFreePredict:");
|
console.log('testBalancedFreePredict:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,1,0);
|
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
var graph1 = manager.plot("testBalancedFreePredict1", {width:800, height:400});
|
var graph1 = manager.plot('testBalancedFreePredict1', { width: 800, height: 400 });
|
||||||
|
|
||||||
var predict1 = manager.predict(0, 1, { x: 70, y: 0 }, true);
|
var predict1 = manager.predict(0, 1, { x: 70, y: 0 }, true);
|
||||||
this._plotPrediction(graph1, predict1);
|
this._plotPrediction(graph1, predict1);
|
||||||
$assert(predict1.position.x == manager.find(1).getPosition().x, "Prediction x pos should be the same as node 1");
|
$assert(
|
||||||
|
predict1.position.x == manager.find(1).getPosition().x,
|
||||||
|
'Prediction x pos should be the same as node 1'
|
||||||
|
);
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testFreeReorder: function () {
|
testFreeReorder: function () {
|
||||||
console.log("testFreeReorder:");
|
console.log('testFreeReorder:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,1,0);
|
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,4,0);
|
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(1, 4, 0);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,5,1);
|
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(1, 5, 1);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,6,2);
|
manager.addNode(6, TestSuite.NODE_SIZE, position).connectNode(1, 6, 2);
|
||||||
|
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,2,2);
|
manager.addNode(2, TestSuite.NODE_SIZE, position).connectNode(0, 2, 2);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2,7,0);
|
manager.addNode(7, TestSuite.NODE_SIZE, position).connectNode(2, 7, 0);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2,8,1);
|
manager.addNode(8, TestSuite.NODE_SIZE, position).connectNode(2, 8, 1);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2,9,2);
|
manager.addNode(9, TestSuite.NODE_SIZE, position).connectNode(2, 9, 2);
|
||||||
manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2,10,3);
|
manager.addNode(10, TestSuite.NODE_SIZE, position).connectNode(2, 10, 3);
|
||||||
|
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,3,4);
|
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(0, 3, 4);
|
||||||
manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3,11,0);
|
manager.addNode(11, TestSuite.NODE_SIZE, position).connectNode(3, 11, 0);
|
||||||
manager.addNode(12, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3,12,1);
|
manager.addNode(12, TestSuite.NODE_SIZE, position).connectNode(3, 12, 1);
|
||||||
manager.addNode(13, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3,13,2);
|
manager.addNode(13, TestSuite.NODE_SIZE, position).connectNode(3, 13, 2);
|
||||||
manager.addNode(14, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3,14,3);
|
manager.addNode(14, TestSuite.NODE_SIZE, position).connectNode(3, 14, 3);
|
||||||
manager.addNode(15, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3,15,4);
|
manager.addNode(15, TestSuite.NODE_SIZE, position).connectNode(3, 15, 4);
|
||||||
manager.addNode(16, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3,16,5);
|
manager.addNode(16, TestSuite.NODE_SIZE, position).connectNode(3, 16, 5);
|
||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.moveNode(14, { x: 270, y: -160 });
|
manager.moveNode(14, { x: 270, y: -160 });
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testFreeReorder1", {width:800, height:1200});
|
manager.plot('testFreeReorder1', { width: 800, height: 1200 });
|
||||||
$assert(manager.find(14).getPosition().y > manager.find(10).getPosition().y, "Node 14 should be below branch 2");
|
$assert(
|
||||||
|
manager.find(14).getPosition().y > manager.find(10).getPosition().y,
|
||||||
|
'Node 14 should be below branch 2'
|
||||||
|
);
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testFreeOverlap: function () {
|
testFreeOverlap: function () {
|
||||||
console.log("testFreeOverlap:");
|
console.log('testFreeOverlap:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,1,0);
|
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,4,0);
|
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(1, 4, 0);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,5,1);
|
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(1, 5, 1);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1,6,2);
|
manager.addNode(6, TestSuite.NODE_SIZE, position).connectNode(1, 6, 2);
|
||||||
|
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,2,2);
|
manager.addNode(2, TestSuite.NODE_SIZE, position).connectNode(0, 2, 2);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2,7,0);
|
manager.addNode(7, TestSuite.NODE_SIZE, position).connectNode(2, 7, 0);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2,8,1);
|
manager.addNode(8, TestSuite.NODE_SIZE, position).connectNode(2, 8, 1);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2,9,2);
|
manager.addNode(9, TestSuite.NODE_SIZE, position).connectNode(2, 9, 2);
|
||||||
manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2,10,3);
|
manager.addNode(10, TestSuite.NODE_SIZE, position).connectNode(2, 10, 3);
|
||||||
|
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,3,4);
|
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(0, 3, 4);
|
||||||
manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3,11,0);
|
manager.addNode(11, TestSuite.NODE_SIZE, position).connectNode(3, 11, 0);
|
||||||
manager.addNode(12, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3,12,1);
|
manager.addNode(12, TestSuite.NODE_SIZE, position).connectNode(3, 12, 1);
|
||||||
manager.addNode(13, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3,13,2);
|
manager.addNode(13, TestSuite.NODE_SIZE, position).connectNode(3, 13, 2);
|
||||||
manager.addNode(14, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3,14,3);
|
manager.addNode(14, TestSuite.NODE_SIZE, position).connectNode(3, 14, 3);
|
||||||
manager.addNode(15, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3,15,4);
|
manager.addNode(15, TestSuite.NODE_SIZE, position).connectNode(3, 15, 4);
|
||||||
manager.addNode(16, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3,16,5);
|
manager.addNode(16, TestSuite.NODE_SIZE, position).connectNode(3, 16, 5);
|
||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testFreeOverlap1", {width:800, height:1200});
|
manager.plot('testFreeOverlap1', { width: 800, height: 1200 });
|
||||||
|
|
||||||
manager.moveNode(14, { x: 270, y: 7 });
|
manager.moveNode(14, { x: 270, y: 7 });
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testFreeOverlap2", {width:800, height:1200});
|
manager.plot('testFreeOverlap2', { width: 800, height: 1200 });
|
||||||
$assert(manager.find(2).getPosition().y > manager.find(1).getPosition().y, "Branches 1 and 2 are overlapping");
|
$assert(
|
||||||
|
manager.find(2).getPosition().y > manager.find(1).getPosition().y,
|
||||||
|
'Branches 1 and 2 are overlapping'
|
||||||
|
);
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
_assertFreePosition: function (manager, id, position) {
|
_assertFreePosition: function (manager, id, position) {
|
||||||
if (id != null && position.x != null && position.y != null) {
|
if (id != null && position.x != null && position.y != null) {
|
||||||
var node = manager.find(id);
|
var node = manager.find(id);
|
||||||
$assert(node.getPosition().x == position.x && node.getPosition().y == position.y,
|
$assert(
|
||||||
"Freely moved node " + id + " is not left at free position (" + position.x + "," + position.y + "). " +
|
node.getPosition().x == position.x && node.getPosition().y == position.y,
|
||||||
"Actual position: (" + node.getPosition().x + "," + node.getPosition().y + ")");
|
'Freely moved node ' +
|
||||||
|
id +
|
||||||
|
' is not left at free position (' +
|
||||||
|
position.x +
|
||||||
|
',' +
|
||||||
|
position.y +
|
||||||
|
'). ' +
|
||||||
|
'Actual position: (' +
|
||||||
|
node.getPosition().x +
|
||||||
|
',' +
|
||||||
|
node.getPosition().y +
|
||||||
|
')'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var treeSet = manager._treeSet;
|
var treeSet = manager._treeSet;
|
||||||
_.each(treeSet._rootNodes, function(rootNode) {
|
_.each(
|
||||||
|
treeSet._rootNodes,
|
||||||
|
function (rootNode) {
|
||||||
var heightById = rootNode.getSorter().computeChildrenIdByHeights(treeSet, rootNode);
|
var heightById = rootNode.getSorter().computeChildrenIdByHeights(treeSet, rootNode);
|
||||||
this._assertBranchCollision(treeSet, rootNode, heightById);
|
this._assertBranchCollision(treeSet, rootNode, heightById);
|
||||||
}, this);
|
},
|
||||||
|
this
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
_assertBranchCollision: function (treeSet, node, heightById) {
|
_assertBranchCollision: function (treeSet, node, heightById) {
|
||||||
var children = treeSet.getChildren(node);
|
var children = treeSet.getChildren(node);
|
||||||
var childOfRootNode = treeSet._rootNodes.contains(node);
|
var childOfRootNode = treeSet._rootNodes.contains(node);
|
||||||
|
|
||||||
_.each(children, function(child) {
|
_.each(
|
||||||
|
children,
|
||||||
|
function (child) {
|
||||||
var height = heightById[child.getId()];
|
var height = heightById[child.getId()];
|
||||||
var siblings = treeSet.getSiblings(child);
|
var siblings = treeSet.getSiblings(child);
|
||||||
if (childOfRootNode) {
|
if (childOfRootNode) {
|
||||||
siblings = siblings.filter(function (sibling) {
|
siblings = siblings.filter(function (sibling) {
|
||||||
return (child.getOrder() % 2) == (sibling.getOrder() % 2);
|
return child.getOrder() % 2 == sibling.getOrder() % 2;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
_.each(siblings, function(sibling) {
|
_.each(
|
||||||
|
siblings,
|
||||||
|
function (sibling) {
|
||||||
this._branchesOverlap(child, sibling, heightById);
|
this._branchesOverlap(child, sibling, heightById);
|
||||||
}, this);
|
},
|
||||||
}, this);
|
this
|
||||||
|
);
|
||||||
|
},
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
_.each(children, function(child) {
|
_.each(
|
||||||
|
children,
|
||||||
|
function (child) {
|
||||||
this._assertBranchCollision(treeSet, child, heightById);
|
this._assertBranchCollision(treeSet, child, heightById);
|
||||||
}, this)
|
},
|
||||||
|
this
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
_branchesOverlap: function (branchA, branchB, heightById) {
|
_branchesOverlap: function (branchA, branchB, heightById) {
|
||||||
@ -477,6 +545,11 @@ mindplot.layout.FreeTestSuite = new Class({
|
|||||||
var topB = branchB.getPosition().y - heightById[branchB.getId()] / 2;
|
var topB = branchB.getPosition().y - heightById[branchB.getId()] / 2;
|
||||||
var bottomB = branchB.getPosition().y + heightById[branchB.getId()] / 2;
|
var bottomB = branchB.getPosition().y + heightById[branchB.getId()] / 2;
|
||||||
|
|
||||||
$assert(topA >= bottomB || bottomA <= topB, "Branches " + branchA.getId() + " and " + branchB.getId() + " overlap");
|
$assert(
|
||||||
}
|
topA >= bottomB || bottomA <= topB,
|
||||||
|
'Branches ' + branchA.getId() + ' and ' + branchB.getId() + ' overlap'
|
||||||
|
);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default FreeTestSuite;
|
||||||
|
@ -15,11 +15,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
mindplot.layout.SymmetricTestSuite = new Class({
|
const TestSuite = require('./TestSuite').default;
|
||||||
Extends: mindplot.layout.TestSuite,
|
|
||||||
|
const SymmetricTestSuite = new Class({
|
||||||
|
Extends: TestSuite,
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
$('#symmetricTest').setStyle("display","block");
|
$('#symmetricTest').css('display', 'block');
|
||||||
|
|
||||||
this.testSymmetry();
|
this.testSymmetry();
|
||||||
this.testSymmetricPredict();
|
this.testSymmetricPredict();
|
||||||
@ -27,24 +29,24 @@ mindplot.layout.SymmetricTestSuite = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
testSymmetry: function () {
|
testSymmetry: function () {
|
||||||
console.log("testSymmetry:")
|
console.log('testSymmetry:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(6, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(7, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(8, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(9, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(10, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(11, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(12, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(12, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(13, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(13, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(14, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(14, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 14, 0);
|
manager.connectNode(0, 14, 0);
|
||||||
manager.connectNode(14, 13, 0);
|
manager.connectNode(14, 13, 0);
|
||||||
manager.connectNode(13, 1, 0);
|
manager.connectNode(13, 1, 0);
|
||||||
@ -61,38 +63,53 @@ mindplot.layout.SymmetricTestSuite = new Class({
|
|||||||
manager.connectNode(6, 12, 1);
|
manager.connectNode(6, 12, 1);
|
||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testSymmetry",{width:1600, height:400});
|
manager.plot('testSymmetry', { width: 1600, height: 400 });
|
||||||
|
|
||||||
// All nodes should be positioned symmetrically with respect to their common ancestors
|
// All nodes should be positioned symmetrically with respect to their common ancestors
|
||||||
$assert(manager.find(14).getPosition().y == manager.find(13).getPosition().y, "Symmetry is not respected");
|
$assert(
|
||||||
$assert(manager.find(5).getPosition().y == manager.find(10).getPosition().y, "Symmetry is not respected");
|
manager.find(14).getPosition().y == manager.find(13).getPosition().y,
|
||||||
$assert(manager.find(11).getPosition().y - manager.find(6).getPosition().y ==
|
'Symmetry is not respected'
|
||||||
-(manager.find(12).getPosition().y - manager.find(6).getPosition().y), "Symmetry is not respected");
|
);
|
||||||
$assert(manager.find(8).getPosition().y - manager.find(1).getPosition().y ==
|
$assert(
|
||||||
-(manager.find(11).getPosition().y - manager.find(1).getPosition().y), "Symmetry is not respected");
|
manager.find(5).getPosition().y == manager.find(10).getPosition().y,
|
||||||
$assert(manager.find(9).getPosition().y - manager.find(1).getPosition().y ==
|
'Symmetry is not respected'
|
||||||
-(manager.find(11).getPosition().y - manager.find(1).getPosition().y), "Symmetry is not respected");
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(11).getPosition().y - manager.find(6).getPosition().y ==
|
||||||
|
-(manager.find(12).getPosition().y - manager.find(6).getPosition().y),
|
||||||
|
'Symmetry is not respected'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(8).getPosition().y - manager.find(1).getPosition().y ==
|
||||||
|
-(manager.find(11).getPosition().y - manager.find(1).getPosition().y),
|
||||||
|
'Symmetry is not respected'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(9).getPosition().y - manager.find(1).getPosition().y ==
|
||||||
|
-(manager.find(11).getPosition().y - manager.find(1).getPosition().y),
|
||||||
|
'Symmetry is not respected'
|
||||||
|
);
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testSymmetricPredict: function () {
|
testSymmetricPredict: function () {
|
||||||
console.log("testSymmetricPredict:");
|
console.log('testSymmetricPredict:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(6, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(7, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(8, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(9, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(10, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(11, TestSuite.NODE_SIZE, position);
|
||||||
|
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(0, 2, 1);
|
manager.connectNode(0, 2, 1);
|
||||||
@ -109,158 +126,221 @@ mindplot.layout.SymmetricTestSuite = new Class({
|
|||||||
manager.layout();
|
manager.layout();
|
||||||
|
|
||||||
// Graph
|
// Graph
|
||||||
var graph1 = manager.plot("testSymmetricPredict1", {width:1000, height:400});
|
var graph1 = manager.plot('testSymmetricPredict1', { width: 1000, height: 400 });
|
||||||
|
|
||||||
console.log("\tAdded as child of node 9 and dropped at (-280, 45):");
|
console.log('\tAdded as child of node 9 and dropped at (-280, 45):');
|
||||||
var prediction1a = manager.predict(9, null, { x: -280, y: 45 });
|
var prediction1a = manager.predict(9, null, { x: -280, y: 45 });
|
||||||
this._plotPrediction(graph1, prediction1a);
|
this._plotPrediction(graph1, prediction1a);
|
||||||
$assert(prediction1a.position.x < manager.find(9).getPosition().x &&
|
$assert(
|
||||||
prediction1a.position.y == manager.find(9).getPosition().y, "Prediction incorrectly positioned");
|
prediction1a.position.x < manager.find(9).getPosition().x &&
|
||||||
$assert(prediction1a.order == 0, "Prediction order should be 0");
|
prediction1a.position.y == manager.find(9).getPosition().y,
|
||||||
|
'Prediction incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction1a.order == 0, 'Prediction order should be 0');
|
||||||
|
|
||||||
console.log("\tAdded as child of node 1 and dropped at (155, -90):");
|
console.log('\tAdded as child of node 1 and dropped at (155, -90):');
|
||||||
var prediction1b = manager.predict(1, null, { x: -155, y: -90 });
|
var prediction1b = manager.predict(1, null, { x: -155, y: -90 });
|
||||||
this._plotPrediction(graph1, prediction1b);
|
this._plotPrediction(graph1, prediction1b);
|
||||||
$assert(prediction1b.position.x > manager.find(1).getPosition().x &&
|
$assert(
|
||||||
prediction1b.position.y == manager.find(1).getPosition().y, "Prediction is incorrectly positioned");
|
prediction1b.position.x > manager.find(1).getPosition().x &&
|
||||||
$assert(prediction1b.order == 0, "Prediction order should be 0");
|
prediction1b.position.y == manager.find(1).getPosition().y,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction1b.order == 0, 'Prediction order should be 0');
|
||||||
|
|
||||||
// Graph 2
|
// Graph 2
|
||||||
var graph2 = manager.plot("testSymmetricPredict2", {width:1000, height:400});
|
var graph2 = manager.plot('testSymmetricPredict2', { width: 1000, height: 400 });
|
||||||
|
|
||||||
console.log("\tAdded as child of node 5 and dropped at (380, -30):");
|
console.log('\tAdded as child of node 5 and dropped at (380, -30):');
|
||||||
var prediction2d = manager.predict(5, null, { x: 380, y: -30 });
|
var prediction2d = manager.predict(5, null, { x: 380, y: -30 });
|
||||||
this._plotPrediction(graph2, prediction2d);
|
this._plotPrediction(graph2, prediction2d);
|
||||||
$assert(prediction2d.position.y < manager.find(7).getPosition().y &&
|
$assert(
|
||||||
prediction2d.position.x == manager.find(7).getPosition().x, "Prediction is incorrectly positioned" );
|
prediction2d.position.y < manager.find(7).getPosition().y &&
|
||||||
$assert(prediction2d.order == 0, "Prediction order should be 0");
|
prediction2d.position.x == manager.find(7).getPosition().x,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction2d.order == 0, 'Prediction order should be 0');
|
||||||
|
|
||||||
console.log("\tAdded as child of node 5 and dropped at (375, 15):");
|
console.log('\tAdded as child of node 5 and dropped at (375, 15):');
|
||||||
var prediction2a = manager.predict(5, null, { x: 375, y: 15 });
|
var prediction2a = manager.predict(5, null, { x: 375, y: 15 });
|
||||||
this._plotPrediction(graph2, prediction2a);
|
this._plotPrediction(graph2, prediction2a);
|
||||||
$assert(prediction2a.position.y > manager.find(7).getPosition().y &&
|
$assert(
|
||||||
|
prediction2a.position.y > manager.find(7).getPosition().y &&
|
||||||
prediction2a.position.y < manager.find(8).getPosition().y &&
|
prediction2a.position.y < manager.find(8).getPosition().y &&
|
||||||
prediction2a.position.x == manager.find(7).getPosition().x, "Prediction is incorrectly positioned");
|
prediction2a.position.x == manager.find(7).getPosition().x,
|
||||||
$assert(prediction2a.order == 1, "Prediction order should be 1");
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction2a.order == 1, 'Prediction order should be 1');
|
||||||
|
|
||||||
console.log("\tAdded as child of node 5 and dropped at (375, 45):");
|
console.log('\tAdded as child of node 5 and dropped at (375, 45):');
|
||||||
var prediction2b = manager.predict(5, null, { x: 375, y: 45 });
|
var prediction2b = manager.predict(5, null, { x: 375, y: 45 });
|
||||||
this._plotPrediction(graph2, prediction2b);
|
this._plotPrediction(graph2, prediction2b);
|
||||||
$assert(prediction2b.position.y > manager.find(8).getPosition().y &&
|
$assert(
|
||||||
|
prediction2b.position.y > manager.find(8).getPosition().y &&
|
||||||
prediction2b.position.y < manager.find(11).getPosition().y &&
|
prediction2b.position.y < manager.find(11).getPosition().y &&
|
||||||
prediction2b.position.x == manager.find(7).getPosition().x, "Prediction is incorrectly positioned");
|
prediction2b.position.x == manager.find(7).getPosition().x,
|
||||||
$assert(prediction2b.order == 2, "Prediction order should be 2");
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction2b.order == 2, 'Prediction order should be 2');
|
||||||
|
|
||||||
console.log("\tAdded as child of node 5 and dropped at (375, 45):");
|
console.log('\tAdded as child of node 5 and dropped at (375, 45):');
|
||||||
var prediction2c = manager.predict(5, null, { x: 375, y: 65 });
|
var prediction2c = manager.predict(5, null, { x: 375, y: 65 });
|
||||||
this._plotPrediction(graph2, prediction2c);
|
this._plotPrediction(graph2, prediction2c);
|
||||||
$assert(prediction2c.position.y > manager.find(11).getPosition().y &&
|
$assert(
|
||||||
prediction2c.position.x == manager.find(11).getPosition().x, "Prediction is incorrectly positioned");
|
prediction2c.position.y > manager.find(11).getPosition().y &&
|
||||||
$assert(prediction2c.order == 3, "Prediction order should be 3");
|
prediction2c.position.x == manager.find(11).getPosition().x,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction2c.order == 3, 'Prediction order should be 3');
|
||||||
|
|
||||||
// Graph 3
|
// Graph 3
|
||||||
var graph3 = manager.plot("testSymmetricPredict3", {width:1000, height:400});
|
var graph3 = manager.plot('testSymmetricPredict3', { width: 1000, height: 400 });
|
||||||
|
|
||||||
console.log("\tAdded as child of node 3 and dropped at (280, 45):");
|
console.log('\tAdded as child of node 3 and dropped at (280, 45):');
|
||||||
var prediction3a = manager.predict(3, null, { x: 280, y: 45 });
|
var prediction3a = manager.predict(3, null, { x: 280, y: 45 });
|
||||||
this._plotPrediction(graph3, prediction3a);
|
this._plotPrediction(graph3, prediction3a);
|
||||||
$assert(prediction3a.position.y > manager.find(5).getPosition().y &&
|
$assert(
|
||||||
|
prediction3a.position.y > manager.find(5).getPosition().y &&
|
||||||
prediction3a.position.y < manager.find(6).getPosition().y &&
|
prediction3a.position.y < manager.find(6).getPosition().y &&
|
||||||
prediction3a.position.x == manager.find(5).getPosition().x, "Prediction is incorrectly positioned");
|
prediction3a.position.x == manager.find(5).getPosition().x,
|
||||||
$assert(prediction3a.order == 2, "Prediction order should be 2");
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction3a.order == 2, 'Prediction order should be 2');
|
||||||
|
|
||||||
console.log("\tAdded as child of node 3 and dropped at (255, 110):");
|
console.log('\tAdded as child of node 3 and dropped at (255, 110):');
|
||||||
var prediction3b = manager.predict(3, null, { x: 255, y: 110 });
|
var prediction3b = manager.predict(3, null, { x: 255, y: 110 });
|
||||||
this._plotPrediction(graph3, prediction3b);
|
this._plotPrediction(graph3, prediction3b);
|
||||||
$assert(prediction3b.position.y > manager.find(6).getPosition().y &&
|
$assert(
|
||||||
prediction3b.position.x == manager.find(6).getPosition().x, "Prediction incorrectly positioned");
|
prediction3b.position.y > manager.find(6).getPosition().y &&
|
||||||
$assert(prediction3b.order == 3, "Prediction order should be 3");
|
prediction3b.position.x == manager.find(6).getPosition().x,
|
||||||
|
'Prediction incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction3b.order == 3, 'Prediction order should be 3');
|
||||||
|
|
||||||
// Graph 4
|
// Graph 4
|
||||||
console.log("\tAdded as child of node 2 and dropped at (-260, 0):");
|
console.log('\tAdded as child of node 2 and dropped at (-260, 0):');
|
||||||
var graph4 = manager.plot("testSymmetricPredict4", {width:1000, height:400});
|
var graph4 = manager.plot('testSymmetricPredict4', { width: 1000, height: 400 });
|
||||||
var prediction4 = manager.predict(2, null, { x: -260, y: 0 });
|
var prediction4 = manager.predict(2, null, { x: -260, y: 0 });
|
||||||
this._plotPrediction(graph4, prediction4);
|
this._plotPrediction(graph4, prediction4);
|
||||||
$assert(prediction4.position.y > manager.find(9).getPosition().y &&
|
$assert(
|
||||||
|
prediction4.position.y > manager.find(9).getPosition().y &&
|
||||||
prediction4.position.y < manager.find(10).getPosition().y &&
|
prediction4.position.y < manager.find(10).getPosition().y &&
|
||||||
prediction4.position.x == manager.find(9).getPosition().x, "Prediction is incorrectly positioned");
|
prediction4.position.x == manager.find(9).getPosition().x,
|
||||||
$assert(prediction4.order == 1, "Prediction order should be 1");
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction4.order == 1, 'Prediction order should be 1');
|
||||||
|
|
||||||
// Graph 5
|
// Graph 5
|
||||||
console.log("\tPredict nodes added with no position:");
|
console.log('\tPredict nodes added with no position:');
|
||||||
var graph5 = manager.plot("testSymmetricPredict5", {width:1000, height:400});
|
var graph5 = manager.plot('testSymmetricPredict5', { width: 1000, height: 400 });
|
||||||
var prediction5a = manager.predict(1, null, null);
|
var prediction5a = manager.predict(1, null, null);
|
||||||
this._plotPrediction(graph5, prediction5a);
|
this._plotPrediction(graph5, prediction5a);
|
||||||
$assert(prediction5a.position.y == manager.find(1).getPosition().y &&
|
$assert(
|
||||||
prediction5a.position.x > manager.find(1).getPosition().x, "Prediction is incorrectly positioned");
|
prediction5a.position.y == manager.find(1).getPosition().y &&
|
||||||
$assert(prediction5a.order == 0, "Prediction order should be 0");
|
prediction5a.position.x > manager.find(1).getPosition().x,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction5a.order == 0, 'Prediction order should be 0');
|
||||||
|
|
||||||
var prediction5b = manager.predict(2, null, null);
|
var prediction5b = manager.predict(2, null, null);
|
||||||
this._plotPrediction(graph5, prediction5b);
|
this._plotPrediction(graph5, prediction5b);
|
||||||
$assert(prediction5b.position.y > manager.find(10).getPosition().y &&
|
$assert(
|
||||||
|
prediction5b.position.y > manager.find(10).getPosition().y &&
|
||||||
prediction5b.position.x < manager.find(2).getPosition().x &&
|
prediction5b.position.x < manager.find(2).getPosition().x &&
|
||||||
prediction5b.position.x == manager.find(10).getPosition().x, "Prediction is incorrectly positioned");
|
prediction5b.position.x == manager.find(10).getPosition().x,
|
||||||
$assert(prediction5b.order == 2, "Prediction order should be 2");
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction5b.order == 2, 'Prediction order should be 2');
|
||||||
|
|
||||||
var prediction5c = manager.predict(3, null, null);
|
var prediction5c = manager.predict(3, null, null);
|
||||||
this._plotPrediction(graph5, prediction5c);
|
this._plotPrediction(graph5, prediction5c);
|
||||||
$assert(prediction5c.position.y > manager.find(6).getPosition().y &&
|
$assert(
|
||||||
|
prediction5c.position.y > manager.find(6).getPosition().y &&
|
||||||
prediction5c.position.x > manager.find(3).getPosition().x &&
|
prediction5c.position.x > manager.find(3).getPosition().x &&
|
||||||
prediction5c.position.x == manager.find(6).getPosition().x, "Prediction is incorrectly positioned");
|
prediction5c.position.x == manager.find(6).getPosition().x,
|
||||||
$assert(prediction5c.order == 3, "Prediction order should be 3");
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction5c.order == 3, 'Prediction order should be 3');
|
||||||
|
|
||||||
var prediction5d = manager.predict(10, null, null);
|
var prediction5d = manager.predict(10, null, null);
|
||||||
this._plotPrediction(graph5, prediction5d);
|
this._plotPrediction(graph5, prediction5d);
|
||||||
$assert(prediction5d.position.y == manager.find(10).getPosition().y &&
|
$assert(
|
||||||
prediction5d.position.x < manager.find(10).getPosition().x, "Prediction is incorrectly positioned");
|
prediction5d.position.y == manager.find(10).getPosition().y &&
|
||||||
$assert(prediction5d.order == 0, "Prediction order should be 0");
|
prediction5d.position.x < manager.find(10).getPosition().x,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction5d.order == 0, 'Prediction order should be 0');
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testSymmetricDragPredict: function () {
|
testSymmetricDragPredict: function () {
|
||||||
console.log("testSymmetricDragPredict:");
|
console.log('testSymmetricDragPredict:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0, 1, 1);
|
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 1);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1, 2, 0);
|
manager.addNode(2, TestSuite.NODE_SIZE, position).connectNode(1, 2, 0);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
|
|
||||||
// Graph 1
|
// Graph 1
|
||||||
var graph1 = manager.plot("testSymmetricDragPredict1", {width:1000, height:400});
|
var graph1 = manager.plot('testSymmetricDragPredict1', { width: 1000, height: 400 });
|
||||||
|
|
||||||
var prediction1a = manager.predict(1, 2, { x: -250, y: -20 });
|
var prediction1a = manager.predict(1, 2, { x: -250, y: -20 });
|
||||||
this._plotPrediction(graph1, prediction1a);
|
this._plotPrediction(graph1, prediction1a);
|
||||||
$assert(prediction1a.position.x == manager.find(2).getPosition().x &&
|
$assert(
|
||||||
prediction1a.position.y == manager.find(2).getPosition().y, "Prediction position should be the same as node 2");
|
prediction1a.position.x == manager.find(2).getPosition().x &&
|
||||||
$assert(prediction1a.order == manager.find(2).getOrder(), "Predicition order should be the same as node 2");
|
prediction1a.position.y == manager.find(2).getPosition().y,
|
||||||
|
'Prediction position should be the same as node 2'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
prediction1a.order == manager.find(2).getOrder(),
|
||||||
|
'Predicition order should be the same as node 2'
|
||||||
|
);
|
||||||
|
|
||||||
var prediction1b = manager.predict(1, 2, { x: -250, y: 20 });
|
var prediction1b = manager.predict(1, 2, { x: -250, y: 20 });
|
||||||
this._plotPrediction(graph1, prediction1b);
|
this._plotPrediction(graph1, prediction1b);
|
||||||
$assert(prediction1b.position.x == manager.find(2).getPosition().x &&
|
$assert(
|
||||||
prediction1b.position.y == manager.find(2).getPosition().y, "Prediction position should be the same as node 2");
|
prediction1b.position.x == manager.find(2).getPosition().x &&
|
||||||
$assert(prediction1b.order == manager.find(2).getOrder(), "Predicition order should be the same as node 2");
|
prediction1b.position.y == manager.find(2).getPosition().y,
|
||||||
|
'Prediction position should be the same as node 2'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
prediction1b.order == manager.find(2).getOrder(),
|
||||||
|
'Predicition order should be the same as node 2'
|
||||||
|
);
|
||||||
|
|
||||||
var prediction1c = manager.predict(0, 2, { x: -100, y: -20 });
|
var prediction1c = manager.predict(0, 2, { x: -100, y: -20 });
|
||||||
this._plotPrediction(graph1, prediction1c);
|
this._plotPrediction(graph1, prediction1c);
|
||||||
$assert(prediction1c.position.x == manager.find(1).getPosition().x &&
|
$assert(
|
||||||
prediction1c.position.y < manager.find(1).getPosition().y, "Prediction is incorrectly positioned");
|
prediction1c.position.x == manager.find(1).getPosition().x &&
|
||||||
$assert(prediction1c.order == 1, "Prediction order should be 1");
|
prediction1c.position.y < manager.find(1).getPosition().y,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction1c.order == 1, 'Prediction order should be 1');
|
||||||
|
|
||||||
var prediction1d = manager.predict(0, 2, { x: -100, y: 20 });
|
var prediction1d = manager.predict(0, 2, { x: -100, y: 20 });
|
||||||
this._plotPrediction(graph1, prediction1d);
|
this._plotPrediction(graph1, prediction1d);
|
||||||
$assert(prediction1d.position.x == manager.find(1).getPosition().x &&
|
$assert(
|
||||||
prediction1d.position.y > manager.find(1).getPosition().y, "Prediction is incorrectly positioned");
|
prediction1d.position.x == manager.find(1).getPosition().x &&
|
||||||
$assert(prediction1d.order == 3, "Prediction order should be 3");
|
prediction1d.position.y > manager.find(1).getPosition().y,
|
||||||
|
'Prediction is incorrectly positioned'
|
||||||
|
);
|
||||||
|
$assert(prediction1d.order == 3, 'Prediction order should be 3');
|
||||||
|
|
||||||
var prediction1e = manager.predict(1, 2, { x: -250, y: 0 });
|
var prediction1e = manager.predict(1, 2, { x: -250, y: 0 });
|
||||||
this._plotPrediction(graph1, prediction1e);
|
this._plotPrediction(graph1, prediction1e);
|
||||||
$assert(prediction1e.position.x == manager.find(2).getPosition().x &&
|
$assert(
|
||||||
prediction1e.position.y == manager.find(2).getPosition().y, "Prediction position should be the same as node 2");
|
prediction1e.position.x == manager.find(2).getPosition().x &&
|
||||||
$assert(prediction1e.order == manager.find(2).getOrder(), "Predicition order should be the same as node 2");
|
prediction1e.position.y == manager.find(2).getPosition().y,
|
||||||
|
'Prediction position should be the same as node 2'
|
||||||
console.log("OK!\n\n");
|
);
|
||||||
}
|
$assert(
|
||||||
|
prediction1e.order == manager.find(2).getOrder(),
|
||||||
|
'Predicition order should be the same as node 2'
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('OK!\n\n');
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default SymmetricTestSuite;
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
mindplot.layout.TestSuite = new Class({
|
const TestSuite = new Class({
|
||||||
Extends: mindplot.layout.ChildrenSorterStrategy,
|
Extends: mindplot.layout.ChildrenSorterStrategy,
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
$('#basicTest').setStyle("display","block");
|
$('#basicTest').css('display', 'block');
|
||||||
|
|
||||||
// this.testAligned();
|
// this.testAligned();
|
||||||
this.testBaselineAligned1();
|
this.testBaselineAligned1();
|
||||||
@ -34,142 +34,169 @@ mindplot.layout.TestSuite = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
testAligned: function () {
|
testAligned: function () {
|
||||||
console.log("testAligned:");
|
console.log('testAligned:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1, 2, 0);
|
manager.addNode(2, TestSuite.NODE_SIZE, position).connectNode(1, 2, 0);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2, 3, 0);
|
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(2, 3, 0);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3, 4, 0);
|
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(3, 4, 0);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,5,2);
|
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(0, 5, 2);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,6,4);
|
manager.addNode(6, TestSuite.NODE_SIZE, position).connectNode(0, 6, 4);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0,7,6);
|
manager.addNode(7, TestSuite.NODE_SIZE, position).connectNode(0, 7, 6);
|
||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testAligned", {width:1200,height:200});
|
manager.plot('testAligned', { width: 1200, height: 200 });
|
||||||
|
|
||||||
// Child nodes should be vertically aligned
|
// Child nodes should be vertically aligned
|
||||||
$assert(manager.find(1).getPosition().y == manager.find(2).getPosition().y, "Child nodes are not vertically aligned");
|
$assert(
|
||||||
$assert(manager.find(1).getPosition().y == manager.find(3).getPosition().y, "Child nodes are not vertically aligned");
|
manager.find(1).getPosition().y == manager.find(2).getPosition().y,
|
||||||
$assert(manager.find(1).getPosition().y == manager.find(4).getPosition().y, "Child nodes are not vertically aligned");
|
'Child nodes are not vertically aligned'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(1).getPosition().y == manager.find(3).getPosition().y,
|
||||||
|
'Child nodes are not vertically aligned'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(1).getPosition().y == manager.find(4).getPosition().y,
|
||||||
|
'Child nodes are not vertically aligned'
|
||||||
|
);
|
||||||
|
|
||||||
// Siblings should be horizontally aligned
|
// Siblings should be horizontally aligned
|
||||||
$assert(manager.find(1).getPosition().x == manager.find(5).getPosition().x, "Sibling nodes are not horizontally aligned");
|
$assert(
|
||||||
$assert(manager.find(1).getPosition().x == manager.find(6).getPosition().x, "Sibling nodes are not horizontally aligned");
|
manager.find(1).getPosition().x == manager.find(5).getPosition().x,
|
||||||
$assert(manager.find(1).getPosition().x == manager.find(7).getPosition().x, "Sibling nodes are not horizontally aligned");
|
'Sibling nodes are not horizontally aligned'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(1).getPosition().x == manager.find(6).getPosition().x,
|
||||||
|
'Sibling nodes are not horizontally aligned'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(1).getPosition().x == manager.find(7).getPosition().x,
|
||||||
|
'Sibling nodes are not horizontally aligned'
|
||||||
|
);
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testBaselineAligned1: function () {
|
testBaselineAligned1: function () {
|
||||||
console.log("testBaselineAligned1:");
|
console.log('testBaselineAligned1:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1, 3, 0);
|
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(1, 3, 0);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(3, 5, 0);
|
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(3, 5, 0);
|
||||||
manager.addNode(6, { width: 140, height: 130 }, position).connectNode(3, 6, 1);
|
manager.addNode(6, { width: 140, height: 130 }, position).connectNode(3, 6, 1);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(6, 7, 0);
|
manager.addNode(7, TestSuite.NODE_SIZE, position).connectNode(6, 7, 0);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(7, 8, 0);
|
manager.addNode(8, TestSuite.NODE_SIZE, position).connectNode(7, 8, 0);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(7, 9, 1);
|
manager.addNode(9, TestSuite.NODE_SIZE, position).connectNode(7, 9, 1);
|
||||||
manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(7, 10, 2);
|
manager.addNode(10, TestSuite.NODE_SIZE, position).connectNode(7, 10, 2);
|
||||||
manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(7, 11, 3);
|
manager.addNode(11, TestSuite.NODE_SIZE, position).connectNode(7, 11, 3);
|
||||||
manager.addNode(12, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(7, 12, 4);
|
manager.addNode(12, TestSuite.NODE_SIZE, position).connectNode(7, 12, 4);
|
||||||
manager.addNode(13, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(7, 13, 5);
|
manager.addNode(13, TestSuite.NODE_SIZE, position).connectNode(7, 13, 5);
|
||||||
manager.addNode(14, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(7, 14, 6);
|
manager.addNode(14, TestSuite.NODE_SIZE, position).connectNode(7, 14, 6);
|
||||||
manager.addNode(15, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(7, 15, 7);
|
manager.addNode(15, TestSuite.NODE_SIZE, position).connectNode(7, 15, 7);
|
||||||
manager.addNode(16, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(7, 16, 8);
|
manager.addNode(16, TestSuite.NODE_SIZE, position).connectNode(7, 16, 8);
|
||||||
manager.addNode(17, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(7, 17, 9);
|
manager.addNode(17, TestSuite.NODE_SIZE, position).connectNode(7, 17, 9);
|
||||||
manager.addNode(29, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(6, 29, 1);
|
manager.addNode(29, TestSuite.NODE_SIZE, position).connectNode(6, 29, 1);
|
||||||
manager.addNode(30, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(6, 30, 2);
|
manager.addNode(30, TestSuite.NODE_SIZE, position).connectNode(6, 30, 2);
|
||||||
manager.addNode(31, { width: 100, height: 50 }, position).connectNode(6, 31, 3);
|
manager.addNode(31, { width: 100, height: 50 }, position).connectNode(6, 31, 3);
|
||||||
|
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(1, 4, 1);
|
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(1, 4, 1);
|
||||||
manager.addNode(18, { width: 80, height: 70 }, position).connectNode(4, 18, 0);
|
manager.addNode(18, { width: 80, height: 70 }, position).connectNode(4, 18, 0);
|
||||||
manager.addNode(19, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(18, 19, 0);
|
manager.addNode(19, TestSuite.NODE_SIZE, position).connectNode(18, 19, 0);
|
||||||
manager.addNode(20, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(19, 20, 0);
|
manager.addNode(20, TestSuite.NODE_SIZE, position).connectNode(19, 20, 0);
|
||||||
manager.addNode(21, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(20, 21, 0);
|
manager.addNode(21, TestSuite.NODE_SIZE, position).connectNode(20, 21, 0);
|
||||||
|
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0, 2, 1);
|
manager.addNode(2, TestSuite.NODE_SIZE, position).connectNode(0, 2, 1);
|
||||||
manager.addNode(22, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2, 22, 0);
|
manager.addNode(22, TestSuite.NODE_SIZE, position).connectNode(2, 22, 0);
|
||||||
manager.addNode(24, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(22, 24, 0);
|
manager.addNode(24, TestSuite.NODE_SIZE, position).connectNode(22, 24, 0);
|
||||||
|
|
||||||
manager.addNode(23, { width: 80, height: 50 }, position).connectNode(2, 23, 1);
|
manager.addNode(23, { width: 80, height: 50 }, position).connectNode(2, 23, 1);
|
||||||
manager.addNode(25, { width: 80, height: 40 }, position).connectNode(23, 25, 0);
|
manager.addNode(25, { width: 80, height: 40 }, position).connectNode(23, 25, 0);
|
||||||
manager.addNode(26, { width: 80, height: 80 }, position).connectNode(25, 26, 0);
|
manager.addNode(26, { width: 80, height: 80 }, position).connectNode(25, 26, 0);
|
||||||
manager.addNode(27, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(26, 27, 0);
|
manager.addNode(27, TestSuite.NODE_SIZE, position).connectNode(26, 27, 0);
|
||||||
manager.addNode(28, { width: 80, height: 80 }, position).connectNode(27, 28, 0);
|
manager.addNode(28, { width: 80, height: 80 }, position).connectNode(27, 28, 0);
|
||||||
|
|
||||||
// manager.layout();
|
// manager.layout();
|
||||||
// manager.plot("testBaselineAligned1", {width:1600,height:800});
|
// manager.plot("testBaselineAligned1", {width:1600,height:800});
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testBaselineAligned2: function () {
|
testBaselineAligned2: function () {
|
||||||
console.log("testBaselineAligned2:");
|
console.log('testBaselineAligned2:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
|
||||||
manager.addNode(2, { width: 130, height: 200 }, position).connectNode(1, 2, 0);
|
manager.addNode(2, { width: 130, height: 200 }, position).connectNode(1, 2, 0);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2, 3, 0);
|
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(2, 3, 0);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2, 4, 1);
|
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(2, 4, 1);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2, 5, 2);
|
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(2, 5, 2);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position).connectNode(2, 6, 3);
|
manager.addNode(6, TestSuite.NODE_SIZE, position).connectNode(2, 6, 3);
|
||||||
|
|
||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testBaselineAligned2", {width:1600,height:800});
|
manager.plot('testBaselineAligned2', { width: 1600, height: 800 });
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testEvents: function () {
|
testEvents: function () {
|
||||||
console.log("testEvents:");
|
console.log('testEvents:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, {x:0, y: 60});
|
manager.addNode(4, TestSuite.NODE_SIZE, { x: 0, y: 60 });
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(0, 2, 1);
|
manager.connectNode(0, 2, 1);
|
||||||
manager.connectNode(1, 3, 0);
|
manager.connectNode(1, 3, 0);
|
||||||
|
|
||||||
var events = [];
|
var events = [];
|
||||||
manager.addEvent('change', function (event) {
|
manager.addEvent('change', function (event) {
|
||||||
console.log("\tUpdated nodes: {id:" + event.getId() + ", order: " + event.getOrder() + ",position: {" + event.getPosition().x + "," + event.getPosition().y + "}");
|
console.log(
|
||||||
|
'\tUpdated nodes: {id:' +
|
||||||
|
event.getId() +
|
||||||
|
', order: ' +
|
||||||
|
event.getOrder() +
|
||||||
|
',position: {' +
|
||||||
|
event.getPosition().x +
|
||||||
|
',' +
|
||||||
|
event.getPosition().y +
|
||||||
|
'}'
|
||||||
|
);
|
||||||
events.push(event);
|
events.push(event);
|
||||||
});
|
});
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testEvents1", {width:800, height:200});
|
manager.plot('testEvents1', { width: 800, height: 200 });
|
||||||
|
|
||||||
console.log("\t--- Layout without changes should not affect the tree ---");
|
console.log('\t--- Layout without changes should not affect the tree ---');
|
||||||
events.empty();
|
events.empty();
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testEvents2", {width:800, height:200});
|
manager.plot('testEvents2', { width: 800, height: 200 });
|
||||||
|
|
||||||
// Check no events where fired
|
// Check no events where fired
|
||||||
$assert(events.length == 0, "Unnecessary tree updated.");
|
$assert(events.length == 0, 'Unnecessary tree updated.');
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testEventsComplex: function () {
|
testEventsComplex: function () {
|
||||||
console.log("testEventsComplex:");
|
console.log('testEventsComplex:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, {x:0, y:60});
|
manager.addNode(6, TestSuite.NODE_SIZE, { x: 0, y: 60 });
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(0, 2, 1);
|
manager.connectNode(0, 2, 1);
|
||||||
manager.connectNode(0, 3, 2);
|
manager.connectNode(0, 3, 2);
|
||||||
@ -178,38 +205,48 @@ mindplot.layout.TestSuite = new Class({
|
|||||||
|
|
||||||
var events = [];
|
var events = [];
|
||||||
manager.addEvent('change', function (event) {
|
manager.addEvent('change', function (event) {
|
||||||
console.log("\tUpdated nodes: {id:" + event.getId() + ", order: " + event.getOrder() + ",position: {" + event.getPosition().x + "," + event.getPosition().y + "}");
|
console.log(
|
||||||
|
'\tUpdated nodes: {id:' +
|
||||||
|
event.getId() +
|
||||||
|
', order: ' +
|
||||||
|
event.getOrder() +
|
||||||
|
',position: {' +
|
||||||
|
event.getPosition().x +
|
||||||
|
',' +
|
||||||
|
event.getPosition().y +
|
||||||
|
'}'
|
||||||
|
);
|
||||||
events.push(event);
|
events.push(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testEventsComplex1", {width:800, height:200});
|
manager.plot('testEventsComplex1', { width: 800, height: 200 });
|
||||||
|
|
||||||
console.log("\t--- Connect a new node ---");
|
console.log('\t--- Connect a new node ---');
|
||||||
|
|
||||||
events.empty();
|
events.empty();
|
||||||
manager.connectNode(3, 6, 2);
|
manager.connectNode(3, 6, 2);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testEventsComplex2", {width:800, height:200});
|
manager.plot('testEventsComplex2', { width: 800, height: 200 });
|
||||||
|
|
||||||
// Check only 4 nodes were repositioned
|
// Check only 4 nodes were repositioned
|
||||||
$assert(events.length == 4, "Only 4 nodes should be repositioned.");
|
$assert(events.length == 4, 'Only 4 nodes should be repositioned.');
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testDisconnect: function () {
|
testDisconnect: function () {
|
||||||
console.log("testDisconnect:");
|
console.log('testDisconnect:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(6, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(7, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(1, 2, 0);
|
manager.connectNode(1, 2, 0);
|
||||||
manager.connectNode(1, 3, 1);
|
manager.connectNode(1, 3, 1);
|
||||||
@ -221,53 +258,63 @@ mindplot.layout.TestSuite = new Class({
|
|||||||
var events = [];
|
var events = [];
|
||||||
manager.addEvent('change', function (event) {
|
manager.addEvent('change', function (event) {
|
||||||
var pos = event.getPosition();
|
var pos = event.getPosition();
|
||||||
var posStr = pos ? ",position: {" + pos.x + "," + pos.y : "";
|
var posStr = pos ? ',position: {' + pos.x + ',' + pos.y : '';
|
||||||
var node = manager.find(event.getId());
|
var node = manager.find(event.getId());
|
||||||
console.log("\tUpdated nodes: {id:" + event.getId() + ", order: " + event.getOrder() + posStr + "}");
|
console.log(
|
||||||
|
'\tUpdated nodes: {id:' +
|
||||||
|
event.getId() +
|
||||||
|
', order: ' +
|
||||||
|
event.getOrder() +
|
||||||
|
posStr +
|
||||||
|
'}'
|
||||||
|
);
|
||||||
events.push(event);
|
events.push(event);
|
||||||
});
|
});
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testDisconnect1", {width:1200, height:400});
|
manager.plot('testDisconnect1', { width: 1200, height: 400 });
|
||||||
|
|
||||||
console.log("--- Disconnect node 2 ---");
|
console.log('--- Disconnect node 2 ---');
|
||||||
events.empty();
|
events.empty();
|
||||||
manager.disconnectNode(2);
|
manager.disconnectNode(2);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testDisconnect2", {width:1200, height:400});
|
manager.plot('testDisconnect2', { width: 1200, height: 400 });
|
||||||
|
|
||||||
// Check that orders have been shifted accordingly
|
// Check that orders have been shifted accordingly
|
||||||
$assert(manager.find(2).getOrder() == 0, "Node 2 should have order 0");
|
$assert(manager.find(2).getOrder() == 0, 'Node 2 should have order 0');
|
||||||
$assert(manager.find(3).getOrder() == 0, "Node 3 should now have order 0");
|
$assert(manager.find(3).getOrder() == 0, 'Node 3 should now have order 0');
|
||||||
$assert(manager.find(4).getOrder() == 1, "Node 4 should have order 1");
|
$assert(manager.find(4).getOrder() == 1, 'Node 4 should have order 1');
|
||||||
|
|
||||||
console.log("--- Disconnect node 4 ---");
|
console.log('--- Disconnect node 4 ---');
|
||||||
manager.disconnectNode(4);
|
manager.disconnectNode(4);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testDisconnect3", {width:1200, height:400});
|
manager.plot('testDisconnect3', { width: 1200, height: 400 });
|
||||||
|
|
||||||
// Check that nodes 1 and 3 are now vertically aligned
|
// Check that nodes 1 and 3 are now vertically aligned
|
||||||
$assert(manager.find(1).getPosition().y == manager.find(3).getPosition().y, "Nodes 1 and 3 should now be vertically aligned");
|
$assert(
|
||||||
|
manager.find(1).getPosition().y == manager.find(3).getPosition().y,
|
||||||
|
'Nodes 1 and 3 should now be vertically aligned'
|
||||||
|
);
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testReconnect: function () {
|
testReconnect: function () {
|
||||||
console.log("testReconnect:");
|
console.log('testReconnect:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(6, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(7, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(8, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(9, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(10, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(11, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(12, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(12, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(0, 2, 1);
|
manager.connectNode(0, 2, 1);
|
||||||
manager.connectNode(0, 3, 2);
|
manager.connectNode(0, 3, 2);
|
||||||
@ -282,39 +329,52 @@ mindplot.layout.TestSuite = new Class({
|
|||||||
manager.connectNode(6, 12, 1);
|
manager.connectNode(6, 12, 1);
|
||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testReconnect1",{width:1200, height:400});
|
manager.plot('testReconnect1', { width: 1200, height: 400 });
|
||||||
|
|
||||||
// Reconnect node 6 to node 4
|
// Reconnect node 6 to node 4
|
||||||
console.log("\tReconnect node 6 to node 4");
|
console.log('\tReconnect node 6 to node 4');
|
||||||
manager.disconnectNode(6);
|
manager.disconnectNode(6);
|
||||||
manager.connectNode(4, 6, 0);
|
manager.connectNode(4, 6, 0);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testReconnect2",{width:1200, height:400});
|
manager.plot('testReconnect2', { width: 1200, height: 400 });
|
||||||
|
|
||||||
// Check nodes are left aligned correctly
|
// Check nodes are left aligned correctly
|
||||||
$assert(manager.find(1).getPosition().y == manager.find(7).getPosition().y, "Nodes 1 and 7 should be vertically aligned");
|
$assert(
|
||||||
$assert(manager.find(4).getPosition().y == manager.find(6).getPosition().y, "Nodes 4 and 6 should be vertically aligned");
|
manager.find(1).getPosition().y == manager.find(7).getPosition().y,
|
||||||
$assert(manager.find(4).getPosition().x > manager.find(6).getPosition().x, "Node 6 and their children should be to the left of node 4");
|
'Nodes 1 and 7 should be vertically aligned'
|
||||||
$assert(manager.find(6).getPosition().x > manager.find(11).getPosition().x && manager.find(11).getPosition().x == manager.find(12).getPosition().x, "Nodes 11 and 12 should be to the left of node 6 and horizontally aligned");
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(4).getPosition().y == manager.find(6).getPosition().y,
|
||||||
|
'Nodes 4 and 6 should be vertically aligned'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(4).getPosition().x > manager.find(6).getPosition().x,
|
||||||
|
'Node 6 and their children should be to the left of node 4'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(6).getPosition().x > manager.find(11).getPosition().x &&
|
||||||
|
manager.find(11).getPosition().x == manager.find(12).getPosition().x,
|
||||||
|
'Nodes 11 and 12 should be to the left of node 6 and horizontally aligned'
|
||||||
|
);
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testRemoveNode: function () {
|
testRemoveNode: function () {
|
||||||
console.log("testRemoveNode:");
|
console.log('testRemoveNode:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(3, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(6, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(6, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(7, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(7, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(8, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(9, TestSuite.NODE_SIZE, position);
|
||||||
|
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(0, 5, 1);
|
manager.connectNode(0, 5, 1);
|
||||||
@ -329,62 +389,68 @@ mindplot.layout.TestSuite = new Class({
|
|||||||
var events = [];
|
var events = [];
|
||||||
manager.addEvent('change', function (event) {
|
manager.addEvent('change', function (event) {
|
||||||
var pos = event.getPosition();
|
var pos = event.getPosition();
|
||||||
var posStr = pos ? ",position: {" + pos.x + "," + event.getPosition().y : "";
|
var posStr = pos ? ',position: {' + pos.x + ',' + event.getPosition().y : '';
|
||||||
events.push(event);
|
events.push(event);
|
||||||
});
|
});
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testRemoveNode1", {width:1000, height:200});
|
manager.plot('testRemoveNode1', { width: 1000, height: 200 });
|
||||||
|
|
||||||
console.log("\t--- Remove node 3 ---");
|
console.log('\t--- Remove node 3 ---');
|
||||||
manager.removeNode(3);
|
manager.removeNode(3);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testRemoveNode2", {width:1000, height:200});
|
manager.plot('testRemoveNode2', { width: 1000, height: 200 });
|
||||||
|
|
||||||
// Check nodes are correctly aligned and node 6 is aligned with the root node
|
// Check nodes are correctly aligned and node 6 is aligned with the root node
|
||||||
$assert(manager.find(1).getPosition().y == manager.find(2).getPosition().y, "Nodes 1 and 2 should be vertically algined");
|
$assert(
|
||||||
$assert(manager.find(6).getPosition().y == manager.find(0).getPosition().y, "Node 6 should be aligned to the root node");
|
manager.find(1).getPosition().y == manager.find(2).getPosition().y,
|
||||||
|
'Nodes 1 and 2 should be vertically algined'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
manager.find(6).getPosition().y == manager.find(0).getPosition().y,
|
||||||
|
'Node 6 should be aligned to the root node'
|
||||||
|
);
|
||||||
|
|
||||||
console.log("\t--- Remove node 6 ---");
|
console.log('\t--- Remove node 6 ---');
|
||||||
manager.removeNode(6);
|
manager.removeNode(6);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testRemoveNode3", {width:1000, height:200});
|
manager.plot('testRemoveNode3', { width: 1000, height: 200 });
|
||||||
|
|
||||||
// Check orders were shifted accordingly
|
// Check orders were shifted accordingly
|
||||||
$assert(manager.find(8).getOrder() == 2, "Node 8 should have order 2");
|
$assert(manager.find(8).getOrder() == 2, 'Node 8 should have order 2');
|
||||||
|
|
||||||
console.log("\t--- Remove node 5 ---");
|
console.log('\t--- Remove node 5 ---');
|
||||||
manager.removeNode(5);
|
manager.removeNode(5);
|
||||||
manager.layout(true);
|
manager.layout(true);
|
||||||
manager.plot("testRemoveNode4", {width:1000, height:200});
|
manager.plot('testRemoveNode4', { width: 1000, height: 200 });
|
||||||
|
|
||||||
// Check orders were shifted accordingly
|
// Check orders were shifted accordingly
|
||||||
$assert(manager.find(7).getOrder() == 1, "Node 7 should have order 1");
|
$assert(manager.find(7).getOrder() == 1, 'Node 7 should have order 1');
|
||||||
$assert(manager.find(9).getOrder() == 3, "Node 9 should have order 3");
|
$assert(manager.find(9).getOrder() == 3, 'Node 9 should have order 3');
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testSize: function () {
|
testSize: function () {
|
||||||
console.log("testSize:");
|
console.log('testSize:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
manager.addNode(1, { width: 60, height: 60 }, position);
|
manager.addNode(1, { width: 60, height: 60 }, position);
|
||||||
manager.addNode(2, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(2, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(3, { width: 260, height: 30 }, position);
|
manager.addNode(3, { width: 260, height: 30 }, position);
|
||||||
manager.addNode(4, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(4, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(5, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(5, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(7, { width: 80, height: 80 }, position);
|
manager.addNode(7, { width: 80, height: 80 }, position);
|
||||||
manager.addNode(8, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(8, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(9, { width: 30, height: 30 }, position);
|
manager.addNode(9, { width: 30, height: 30 }, position);
|
||||||
manager.addNode(10, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(10, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(11, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(11, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(12, { width: 100, height: 70 }, position);
|
manager.addNode(12, { width: 100, height: 70 }, position);
|
||||||
manager.addNode(13, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(13, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(14, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(14, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(15, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(15, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(16, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(16, TestSuite.NODE_SIZE, position);
|
||||||
manager.addNode(17, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(17, TestSuite.NODE_SIZE, position);
|
||||||
|
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.connectNode(1, 16, 0);
|
manager.connectNode(1, 16, 0);
|
||||||
@ -404,30 +470,43 @@ mindplot.layout.TestSuite = new Class({
|
|||||||
manager.connectNode(13, 14, 0);
|
manager.connectNode(13, 14, 0);
|
||||||
|
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testSize1", {width: 1400, height: 400});
|
manager.plot('testSize1', { width: 1400, height: 400 });
|
||||||
|
|
||||||
// Check that all enlarged nodes shift children accordingly
|
// Check that all enlarged nodes shift children accordingly
|
||||||
$assert(manager.find(10).getPosition().x > manager.find(3).getPosition().x && manager.find(10).getPosition().x == manager.find(11).getPosition().x, "Nodes 10 and 11 should be horizontally algined and to the right of enlarged node 3");
|
$assert(
|
||||||
|
manager.find(10).getPosition().x > manager.find(3).getPosition().x &&
|
||||||
|
manager.find(10).getPosition().x == manager.find(11).getPosition().x,
|
||||||
|
'Nodes 10 and 11 should be horizontally algined and to the right of enlarged node 3'
|
||||||
|
);
|
||||||
var xPosNode7 = manager.find(7).getPosition().x;
|
var xPosNode7 = manager.find(7).getPosition().x;
|
||||||
var xPosNode8 = manager.find(8).getPosition().x;
|
var xPosNode8 = manager.find(8).getPosition().x;
|
||||||
|
|
||||||
manager.updateNodeSize(4, { width: 100, height: 30 });
|
manager.updateNodeSize(4, { width: 100, height: 30 });
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testSize2", {width: 1400, height: 400});
|
manager.plot('testSize2', { width: 1400, height: 400 });
|
||||||
|
|
||||||
// Check that all enlarged nodes shift children accordingly
|
// Check that all enlarged nodes shift children accordingly
|
||||||
$assert(manager.find(2).getPosition().x - manager.find(4).getPosition().x == 10, "Node 4 should have been shifted by 10");
|
$assert(
|
||||||
$assert(xPosNode7 - manager.find(7).getPosition().x == 20, "Node 7 should have been shifted by 20");
|
manager.find(2).getPosition().x - manager.find(4).getPosition().x == 10,
|
||||||
$assert(xPosNode8 - manager.find(8).getPosition().x == 20, "Node 8 should have been shifted by 20");
|
'Node 4 should have been shifted by 10'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
xPosNode7 - manager.find(7).getPosition().x == 20,
|
||||||
|
'Node 7 should have been shifted by 20'
|
||||||
|
);
|
||||||
|
$assert(
|
||||||
|
xPosNode8 - manager.find(8).getPosition().x == 20,
|
||||||
|
'Node 8 should have been shifted by 20'
|
||||||
|
);
|
||||||
|
|
||||||
var graph2 = manager.plot("testSize3", {width: 1400, height: 400});
|
var graph2 = manager.plot('testSize3', { width: 1400, height: 400 });
|
||||||
this._plotPrediction(graph2, manager.predict(0, null, { x: -145, y: 400 }));
|
this._plotPrediction(graph2, manager.predict(0, null, { x: -145, y: 400 }));
|
||||||
this._plotPrediction(graph2, manager.predict(9, null, { x: -330, y: 70 }));
|
this._plotPrediction(graph2, manager.predict(9, null, { x: -330, y: 70 }));
|
||||||
this._plotPrediction(graph2, manager.predict(9, null, { x: -330, y: 120 }));
|
this._plotPrediction(graph2, manager.predict(9, null, { x: -330, y: 120 }));
|
||||||
this._plotPrediction(graph2, manager.predict(0, null, { x: 15, y: 20 }));
|
this._plotPrediction(graph2, manager.predict(0, null, { x: 15, y: 20 }));
|
||||||
//TODO(gb): make asserts
|
//TODO(gb): make asserts
|
||||||
|
|
||||||
var graph3 = manager.plot("testSize4", {width: 1400, height: 400});
|
var graph3 = manager.plot('testSize4', { width: 1400, height: 400 });
|
||||||
this._plotPrediction(graph3, manager.predict(0, null, null));
|
this._plotPrediction(graph3, manager.predict(0, null, null));
|
||||||
this._plotPrediction(graph3, manager.predict(9, null, null));
|
this._plotPrediction(graph3, manager.predict(9, null, null));
|
||||||
this._plotPrediction(graph3, manager.predict(3, null, null));
|
this._plotPrediction(graph3, manager.predict(3, null, null));
|
||||||
@ -437,50 +516,69 @@ mindplot.layout.TestSuite = new Class({
|
|||||||
var yPosNode2 = manager.find(2).getPosition().y;
|
var yPosNode2 = manager.find(2).getPosition().y;
|
||||||
manager.updateNodeSize(7, { width: 80, height: 120 });
|
manager.updateNodeSize(7, { width: 80, height: 120 });
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testSize5", {width: 1400, height: 400});
|
manager.plot('testSize5', { width: 1400, height: 400 });
|
||||||
|
|
||||||
// Check that all enlarged nodes shift children accordingly
|
// Check that all enlarged nodes shift children accordingly
|
||||||
$assert(yPosNode2 - manager.find(2).getPosition().y == 20, "Node 2 should have been shifted by 20");
|
$assert(
|
||||||
|
yPosNode2 - manager.find(2).getPosition().y == 20,
|
||||||
|
'Node 2 should have been shifted by 20'
|
||||||
|
);
|
||||||
|
|
||||||
console.log("OK!\n\n");
|
console.log('OK!\n\n');
|
||||||
},
|
},
|
||||||
|
|
||||||
testReconnectSingleNode: function () {
|
testReconnectSingleNode: function () {
|
||||||
console.log("testReconnectSingleNode:");
|
console.log('testReconnectSingleNode:');
|
||||||
var position = { x: 0, y: 0 };
|
var position = { x: 0, y: 0 };
|
||||||
var manager = new mindplot.layout.LayoutManager(0, mindplot.layout.TestSuite.ROOT_NODE_SIZE);
|
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
|
||||||
|
|
||||||
// Prepare a sample graph ...
|
// Prepare a sample graph ...
|
||||||
manager.addNode(1, mindplot.layout.TestSuite.NODE_SIZE, position);
|
manager.addNode(1, TestSuite.NODE_SIZE, position);
|
||||||
manager.connectNode(0, 1, 0);
|
manager.connectNode(0, 1, 0);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
var graph = manager.plot("testReconnectSingleNode1", {width:1000, height:400});
|
var graph = manager.plot('testReconnectSingleNode1', { width: 1000, height: 400 });
|
||||||
var prediction = manager.predict(0, null, { x: -50, y: 0 });
|
var prediction = manager.predict(0, null, { x: -50, y: 0 });
|
||||||
this._plotPrediction(graph, prediction);
|
this._plotPrediction(graph, prediction);
|
||||||
|
|
||||||
// Check prediction is to the left of the root node
|
// Check prediction is to the left of the root node
|
||||||
$assert(prediction.position.x < manager.find(0).getPosition().x, "Prediction should be to the left of the root node");
|
$assert(
|
||||||
$assert(prediction.order == 1, "Prediction should have order 1");
|
prediction.position.x < manager.find(0).getPosition().x,
|
||||||
|
'Prediction should be to the left of the root node'
|
||||||
|
);
|
||||||
|
$assert(prediction.order == 1, 'Prediction should have order 1');
|
||||||
|
|
||||||
manager.disconnectNode(1);
|
manager.disconnectNode(1);
|
||||||
manager.connectNode(0, 1, 1);
|
manager.connectNode(0, 1, 1);
|
||||||
manager.layout();
|
manager.layout();
|
||||||
manager.plot("testReconnectSingleNode2", {width:1000, height:400});
|
manager.plot('testReconnectSingleNode2', { width: 1000, height: 400 });
|
||||||
|
|
||||||
// Check reconnected node is to the left of the root node
|
// Check reconnected node is to the left of the root node
|
||||||
$assert(manager.find(1).getPosition().x < manager.find(0).getPosition().x, "Node 1 should now be to the left of the root node");
|
$assert(
|
||||||
$assert(manager.find(1).getOrder() == 1, "Node 1 should now have order 0");
|
manager.find(1).getPosition().x < manager.find(0).getPosition().x,
|
||||||
|
'Node 1 should now be to the left of the root node'
|
||||||
|
);
|
||||||
|
$assert(manager.find(1).getOrder() == 1, 'Node 1 should now have order 0');
|
||||||
},
|
},
|
||||||
|
|
||||||
_plotPrediction: function (canvas, prediction) {
|
_plotPrediction: function (canvas, prediction) {
|
||||||
var position = prediction.position;
|
var position = prediction.position;
|
||||||
var order = prediction.order;
|
var order = prediction.order;
|
||||||
console.log("\t\tprediction {order:" + order + ", position: (" + position.x + "," + position.y + ")}");
|
console.log(
|
||||||
var cx = position.x + canvas.width / 2 - mindplot.layout.TestSuite.NODE_SIZE.width / 2;
|
'\t\tprediction {order:' +
|
||||||
var cy = position.y + canvas.height / 2 - mindplot.layout.TestSuite.NODE_SIZE.height / 2;
|
order +
|
||||||
canvas.rect(cx, cy, mindplot.layout.TestSuite.NODE_SIZE.width, mindplot.layout.TestSuite.NODE_SIZE.height);
|
', position: (' +
|
||||||
}
|
position.x +
|
||||||
|
',' +
|
||||||
|
position.y +
|
||||||
|
')}'
|
||||||
|
);
|
||||||
|
var cx = position.x + canvas.width / 2 - TestSuite.NODE_SIZE.width / 2;
|
||||||
|
var cy = position.y + canvas.height / 2 - TestSuite.NODE_SIZE.height / 2;
|
||||||
|
canvas.rect(cx, cy, TestSuite.NODE_SIZE.width, TestSuite.NODE_SIZE.height);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
mindplot.layout.TestSuite.NODE_SIZE = {width:80, height:30},
|
(TestSuite.NODE_SIZE = { width: 80, height: 30 }),
|
||||||
mindplot.layout.TestSuite.ROOT_NODE_SIZE = {width:120, height:40}
|
(TestSuite.ROOT_NODE_SIZE = { width: 120, height: 40 });
|
||||||
|
|
||||||
|
export default TestSuite;
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
const Mindplot = require('../../../../lib/mindplot');
|
||||||
|
global.mindplot = Mindplot();
|
||||||
|
|
||||||
|
const TestSuite = require('./TestSuite').default;
|
||||||
|
const BalancedTestSuite = require('./BalancedTestSuite').default;
|
||||||
|
const SymmetricTestSuite = require('./SymmetricTestSuite').default;
|
||||||
|
const FreeTestSuite = require('./FreeTestSuite').default;
|
||||||
|
|
||||||
|
window.addEventListener('DOMContentLoaded', function () {
|
||||||
|
var basicTest = new TestSuite();
|
||||||
|
var balancedTest = new BalancedTestSuite();
|
||||||
|
var symmetricTest = new SymmetricTestSuite();
|
||||||
|
var freeTest = new FreeTestSuite();
|
||||||
|
});
|
@ -11,6 +11,6 @@ window.addEventListener('load', function (e) {
|
|||||||
var palette = new mindplot.widget.ColorPalettePanel(
|
var palette = new mindplot.widget.ColorPalettePanel(
|
||||||
'myButton',
|
'myButton',
|
||||||
model,
|
model,
|
||||||
'/mindplot/src/main/javascript/widget'
|
'../../../lib/components/widget'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -8,6 +8,7 @@ const prodConfig = {
|
|||||||
optimization: {
|
optimization: {
|
||||||
splitChunks: {
|
splitChunks: {
|
||||||
chunks: 'all',
|
chunks: 'all',
|
||||||
|
minSize: 2000000,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -3,12 +3,16 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|||||||
|
|
||||||
/** @type {import('webpack').Configuration} */
|
/** @type {import('webpack').Configuration} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: './lib/mindplot',
|
entry: {
|
||||||
|
palette: path.resolve(__dirname, './test/javascript/static/test/testPalette'),
|
||||||
|
layout: path.resolve(__dirname, './test/javascript/static/test/testLayout'),
|
||||||
|
},
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, 'dist', 'test'),
|
path: path.resolve(__dirname, 'dist', 'test'),
|
||||||
filename: '[name].js',
|
filename: '[name].test.js',
|
||||||
publicPath: '',
|
publicPath: '',
|
||||||
},
|
},
|
||||||
|
mode: 'production',
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
entry: './test/javascript/render/testing.js',
|
entry: './test/javascript/render/testing.js',
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, 'target', 'tests'),
|
path: path.resolve(__dirname, 'dist', 'tests'),
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
publicPath: '',
|
publicPath: '',
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user