Mindplot module migration

This commit is contained in:
Ezequiel-Vega 2021-09-02 13:32:23 -03:00
parent d515e0bb57
commit 0567dedb88
37 changed files with 11320 additions and 3725 deletions

View File

@ -8,6 +8,6 @@ function coreJs() {
require('./Utils'); // eslint-disable-line
global.Options = require('@wisemapping/mindplot/lib/components/Options');
global.BootstrapDialog = require('@wisemapping/mindplot/lib/components/libraries/bootstrap/BootstrapDialog');
//require('@wisemapping/mindplot/lib/components/libraries/bootstrap/BootstrapDialog.Request');
require('@wisemapping/mindplot/lib/components/libraries/bootstrap/BootstrapDialog.Request');
return global.core; // eslint-disable-line no-undef
}

View File

@ -15,13 +15,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const Core = require('@wismapping/core-js')
const Core = require('@wismapping/core-js');
const core = Core();
const Topic = require('./Topic').default;
const Shape = require('./util/Shape').default;
const CentralTopic = new Class(/** @lends CentralTopic*/{
const CentralTopic = new Class(
/** @lends CentralTopic*/ {
Extends: Topic,
/**
* @extends mindplot.Topic
@ -49,17 +49,14 @@ const CentralTopic = new Class(/** @lends CentralTopic*/{
/** */
setCursor: function (type) {
type = (type == 'move') ? 'default' : type;
type = type == 'move' ? 'default' : type;
this.parent(type);
},
/** */
updateTopicShape:function () {
},
updateTopicShape: function () {},
_updatePositionOnChangeSize: function () {
// Center main topic ...
var zeroPoint = new core.Point(0, 0);
this.setPosition(zeroPoint);
@ -77,7 +74,8 @@ const CentralTopic = new Class(/** @lends CentralTopic*/{
var isAtRight = Shape.isAtRight(targetPosition, pos);
var size = this.getSize();
return Shape.calculateRectConnectionPoint(pos, size, !isAtRight);
},
}
});
);
export default CentralTopic;

View File

@ -21,7 +21,7 @@ const web2D = require('@wismapping/web2d');
const web2d = web2D();
const INodeModel = require('./model/INodeModel').default;
const { TopicShape } = require('./model/INodeModel').default;
const { TopicShape } = require('./model/INodeModel');
const Topic = require('./Topic').default;
const ConnectionLine = new Class({

View File

@ -24,8 +24,7 @@ const Topic = require('./Topic').default;
const { TopicShape } = require('./model/INodeModel');
const Shape = require('./util/Shape').default;
const MainTopic = new Class(
/** @lends MainTopic */ {
const MainTopic = new Class(/** @lends MainTopic */ {
Extends: Topic,
/**
* @extends mindplot.Topic

View File

@ -31,7 +31,7 @@ const Messages = new Class({
},
});
global.$msg = function (key) {
const $msg = function (key) {
if (!Messages.__bundle) {
Messages.init('en');
}

View File

@ -201,6 +201,7 @@ const NodeGraph = new Class(
NodeGraph.create = function (nodeModel, options) {
const CentralTopic = require('./CentralTopic').default;
const MainTopic = require('./MainTopic').default;
$assert(nodeModel, 'Model can not be null');
var type = nodeModel.getType();

View File

@ -15,14 +15,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const RichTextEditor = require('./Ri')
const TextEditor = require('./TextEditor').default;
const TextEditorFactory = {};
TextEditorFactory.getTextEditorFromName = function (name) {
var editorClass = null;
if (name == "RichTextEditor") {
if (name == 'RichTextEditor') {
editorClass = RichTextEditor;
} else {
editorClass = TextEditor;

View File

@ -17,7 +17,6 @@
*/
const Events = require('./Events').default;
const MultilineTextEditor = require('./MultilineTextEditor').default;
//const TopicEvent = require('./Topic').default;
const { TopicShape } = require('./model/INodeModel');
const TopicEventDispatcher = new Class({

View File

@ -1,14 +1,16 @@
const acitonDispatcher = require('./ActionDispatcher').default;
import LocalStorageManager from './LocalStorageManager';
const actionDispatcher = require('./ActionDispatcher').default;
const actionIcon = require('./ActionIcon').default;
const centralTopic = require('./CentralTopic').default;
const command = require('./Command').default;
const connectionLine = require('./ConnectionLine').default;
const controlPoint = require('./ControlPoint').default;
const designer = require('./Designer').default;
const designerAcitonRun = require('./DesignerActionRunner').default;
const designerActionRunner = require('./DesignerActionRunner').default;
const designerKeyboard = require('./DesignerKeyboard').default;
const desginerModel = require('./DesignerModel').default;
const desginerUndoManager = require('./DesignerUndoManager').default;
const designerModal = require('./DesignerModel').default;
const designerUndoManager = require('./DesignerUndoManager').default;
const dragConnector = require('./DragConnector').default;
const dragManager = require('./DragManager').default;
const dragPivot = require('./DragPivot').default;
@ -17,36 +19,28 @@ const editorOptions = require('./EditorOptions').default;
const editorProperties = require('./EditorProperties').default;
const events = require('./Events').default;
const footer = require('./footer');
//const header =require('./header');
const header = require('./header');
const icon = require('./Icon').default;
const iconGroup = require('./IconGroup').default;
const imageIcon = require('./ImageIcon').default;
const keyboard = require('./Keyboard').default;
const linkIcon = require('./LinkIcon').default;
const localStorageManager = require('./LocalStorageManager').default;
const localSorageManager = require('./LocalStorageManager').default;
const mainTopic = require('./MainTopic').default;
const messages = require('./Messages').default;
const messageBundle_ca = require('./MessageBundle_ca').default;
const messageBundle_de = require('./MessageBundle_de').default;
const messageBundle_en = require('./MessageBundle_en').default;
const messageBundle_es = require('./MessageBundle_es').default;
const messageBundle_fr = require('./MessageBundle_fr').default;
const messageBundle_pt_BR = require('./MessageBundle_pt_BR').default;
const messageBundle_zh_CN = require('./MessageBundle_zh_CN').default;
const messageBundle_zh_TW = require('./MessageBundle_zh_TW').default;
const multilineTextEditor = require('./MultilineTextEditor').default;
const nodeGraph = require('./NodeGraph').default;
const noteIcon = require('./NoteIcon').default;
const options = require('./Options').default;
const persistenceManger = require('./PersistenceManager').default;
const persistenceManager = require('./PersistenceManager').default;
const relationship = require('./Relationship').default;
const relationshipPivot = require('./RelationshipPivot').default;
const restPersistenceManager = require('./RestPersistenceManager').default;
const resetPersistenceManager = require('./RestPersistenceManager').default;
const screenManager = require('./ScreenManager').default;
const shrinkConnector = require('./ShrinkConnector').default;
const standaloneActionDispatcher = require('./StandaloneActionDispatcher').default;
const textEditor = require('./TextEditor').default;
//const textEditorFacotry = require('./TextEditorFactory').default;
const textEditorFactory = require('./TextEditorFactory').default;
const topic = require('./Topic').default;
const topicEventDispatcher = require('./TopicEventDispatcher').default;
const topicFeature = require('./TopicFeature').default;
@ -54,17 +48,17 @@ const topicStyle = require('./TopicStyle').default;
const workspace = require('./Workspace').default;
export const Components = {
ActionDispatcher: acitonDispatcher,
ActionDispatcher: actionDispatcher,
ActionIcon: actionIcon,
CentralTopic: centralTopic,
Command: command,
ConnectionLine: connectionLine,
ControlPoint: controlPoint,
Designer: designer,
DesignerActionRunner: designerAcitonRun,
DesignerActionRunner: designerActionRunner,
DesignerKeyboard: designerKeyboard,
DesignerModel: desginerModel,
DesignerUndoManager: desginerUndoManager,
DesignerModel: designerModal,
DesignerUndoManager: designerUndoManager,
DragConnector: dragConnector,
DragManager: dragManager,
DragPivot: dragPivot,
@ -72,34 +66,30 @@ export const Components = {
EditorOptions: editorOptions,
EditorProperties: editorProperties,
Events: events,
footer: footer,
header: header,
Icon: icon,
IconGroup: iconGroup,
ImageIcon: imageIcon,
Keyboard: keyboard,
LinkIcon: linkIcon,
LocalStorageManager: localStorageManager,
localSorageManager: localSorageManager,
MainTopic: mainTopic,
MessageBundle_ca: messageBundle_ca,
MessageBundle_de: messageBundle_de,
MessageBundle_en: messageBundle_en,
MessageBundle_es: messageBundle_es,
MesasgeBundle_fr: messageBundle_fr,
MessageBundle_pt_BR: messageBundle_pt_BR,
MessageBundle_zh_CN: messageBundle_zh_CN,
MessageBundle_zh_TW: messageBundle_zh_TW,
Messages: messages,
MultilineTextEditor: multilineTextEditor,
NodeGraph: nodeGraph,
NoteIcon: noteIcon,
Options: options,
PersistenceManager: persistenceManger,
PersistenceManager: persistenceManager,
Relationship: relationship,
RelationshipPivot: relationshipPivot,
RestPersistenceManager: restPersistenceManager,
RestPersistenceManager: resetPersistenceManager,
ScreenManager: screenManager,
ShrinkConnector: shrinkConnector,
StandaloneActionDispatcher: standaloneActionDispatcher,
TextEditor: textEditor,
//TextEditorFactory: textEditorFacotry,
TextEditorFactory: textEditorFactory,
Topic: topic,
TopicEventDispatcher: topicEventDispatcher,
TopicFeature: topicFeature,

View File

@ -15,13 +15,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const ChildrenSorterStrategy = require('./ChildrenSorterStrategy').default
const ChildrenSorterStrategy = require('./ChildrenSorterStrategy').default;
/**
* @class
* @extends mindplot.layout.ChildrenSorterStrategy
*/
const AbstractBasicSorter = new Class(/** @lends AbstractBasicSorter */{
const AbstractBasicSorter = new Class(
/** @lends AbstractBasicSorter */ {
Extends: ChildrenSorterStrategy,
/**
@ -40,7 +41,7 @@ const AbstractBasicSorter = new Class(/** @lends AbstractBasicSorter */{
},
_computeChildrenHeight: function (treeSet, node, heightCache) {
var height = node.getSize().height + (this._getVerticalPadding() * 2); // 2* Top and down padding;
var height = node.getSize().height + this._getVerticalPadding() * 2; // 2* Top and down padding;
var result;
var children = treeSet.getChildren(node);
@ -48,9 +49,13 @@ const AbstractBasicSorter = new Class(/** @lends AbstractBasicSorter */{
result = height;
} else {
var childrenHeight = 0;
_.each(children, function(child) {
_.each(
children,
function (child) {
childrenHeight += this._computeChildrenHeight(treeSet, child, heightCache);
}, this);
},
this
);
result = Math.max(height, childrenHeight);
}
@ -65,7 +70,7 @@ const AbstractBasicSorter = new Class(/** @lends AbstractBasicSorter */{
_getSortedChildren: function (treeSet, node) {
var result = treeSet.getChildren(node);
result.sort(function (a, b) {
return a.getOrder() - b.getOrder()
return a.getOrder() - b.getOrder();
});
return result;
},
@ -73,9 +78,9 @@ const AbstractBasicSorter = new Class(/** @lends AbstractBasicSorter */{
_getRelativeDirection: function (reference, position) {
var offset = position.x - reference.x;
return offset >= 0 ? 1 : -1;
},
}
});
);
/**
* @constant

View File

@ -17,15 +17,14 @@
*/
const AbstractBasicSorter = require('./AbstractBasicSorter').default;
const BalancedSorter = new Class(/** @lends BalancedSorter */{
const BalancedSorter = new Class(
/** @lends BalancedSorter */ {
Extends: AbstractBasicSorter,
/**
* @constructs
* @extends mindplot.layout.AbstractBasicSorter
*/
initialize:function () {
},
initialize: function () {},
/**
* @param {} graph
@ -38,17 +37,33 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
predict: function (graph, parent, node, position, free) {
// If its a free node...
if (free) {
$assert($defined(position), "position cannot be null for predict in free positioning");
$assert($defined(node), "node cannot be null for predict in free positioning");
$assert(
$defined(position),
'position cannot be null for predict in free positioning'
);
$assert($defined(node), 'node cannot be null for predict in free positioning');
var rootNode = graph.getRootNode(parent);
var direction = this._getRelativeDirection(rootNode.getPosition(), node.getPosition());
var direction = this._getRelativeDirection(
rootNode.getPosition(),
node.getPosition()
);
var limitXPos = parent.getPosition().x + direction * (parent.getSize().width / 2 + node.getSize().width / 2 + BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
var limitXPos =
parent.getPosition().x +
direction *
(parent.getSize().width / 2 +
node.getSize().width / 2 +
BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
var xPos = direction > 0 ?
(position.x >= limitXPos ? position.x : limitXPos) :
(position.x <= limitXPos ? position.x : limitXPos);
var xPos =
direction > 0
? position.x >= limitXPos
? position.x
: limitXPos
: position.x <= limitXPos
? position.x
: limitXPos;
return [0, { x: xPos, y: position.y }];
}
@ -57,9 +72,15 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
// If it is a dragged node...
if (node) {
$assert($defined(position), "position cannot be null for predict in dragging");
var nodeDirection = this._getRelativeDirection(rootNode.getPosition(), node.getPosition());
var positionDirection = this._getRelativeDirection(rootNode.getPosition(), position);
$assert($defined(position), 'position cannot be null for predict in dragging');
var nodeDirection = this._getRelativeDirection(
rootNode.getPosition(),
node.getPosition()
);
var positionDirection = this._getRelativeDirection(
rootNode.getPosition(),
position
);
var siblings = graph.getSiblings(node);
var sameParent = parent == graph.getParent(node);
@ -73,7 +94,13 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
var left = this._getChildrenForOrder(parent, graph, 1);
}
// Filter nodes on one side..
var order = position ? (position.x > rootNode.getPosition().x ? 0 : 1) : ((right.length - left.length) > 0 ? 1 : 0);
var order = position
? position.x > rootNode.getPosition().x
? 0
: 1
: right.length - left.length > 0
? 1
: 0;
var direction = order % 2 == 0 ? 1 : -1;
// Exclude the dragged node (if set)
@ -83,7 +110,17 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
// No children?
if (children.length == 0) {
return [order, {x:parent.getPosition().x + direction * (parent.getSize().width / 2 + BalancedSorter.INTERNODE_HORIZONTAL_PADDING * 2), y:parent.getPosition().y}];
return [
order,
{
x:
parent.getPosition().x +
direction *
(parent.getSize().width / 2 +
BalancedSorter.INTERNODE_HORIZONTAL_PADDING * 2),
y: parent.getPosition().y,
},
];
}
// Try to fit within ...
@ -93,9 +130,10 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
_.each(children, function (child, index) {
var cpos = child.getPosition();
if (position.y > cpos.y) {
yOffset = child == last ?
child.getSize().height + BalancedSorter.INTERNODE_VERTICAL_PADDING * 2 :
(children[index + 1].getPosition().y - child.getPosition().y) / 2;
let yOffset =
child == last
? child.getSize().height + BalancedSorter.INTERNODE_VERTICAL_PADDING * 2
: (children[index + 1].getPosition().y - child.getPosition().y) / 2;
result = [child.getOrder() + 2, { x: cpos.x, y: cpos.y + yOffset }];
}
});
@ -103,10 +141,16 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
// Position wasn't below any node, so it must be inserted above
if (!result) {
var first = children[0];
result = [position.x > 0 ? 0 : 1, {
result = [
position.x > 0 ? 0 : 1,
{
x: first.getPosition().x,
y:first.getPosition().y - first.getSize().height - BalancedSorter.INTERNODE_VERTICAL_PADDING * 2
}];
y:
first.getPosition().y -
first.getSize().height -
BalancedSorter.INTERNODE_VERTICAL_PADDING * 2,
},
];
}
return result;
@ -139,7 +183,7 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
}
}
var newOrder = order > (max + 1) ? (max + 2) : order;
var newOrder = order > max + 1 ? max + 2 : order;
child.setOrder(newOrder);
},
@ -166,17 +210,22 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
* @return offsets
*/
computeOffsets: function (treeSet, node) {
$assert(treeSet, "treeSet can no be null.");
$assert(node, "node can no be null.");
$assert(treeSet, 'treeSet can no be null.');
$assert(node, 'node can no be null.');
var children = this._getSortedChildren(treeSet, node);
// Compute heights ...
var heights = children.map(
function (child) {
return {id:child.getId(), order:child.getOrder(), width:child.getSize().width, height:this._computeChildrenHeight(treeSet, child)};
}, this).reverse();
var heights = children
.map(function (child) {
return {
id: child.getId(),
order: child.getOrder(),
width: child.getSize().width,
height: this._computeChildrenHeight(treeSet, child),
};
}, this)
.reverse();
// Compute the center of the branch ...
var totalPHeight = 0;
@ -207,10 +256,14 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
}
var yOffset = ysum + heights[i].height / 2;
var xOffset = direction * (node.getSize().width / 2 + heights[i].width / 2 + +BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
var xOffset =
direction *
(node.getSize().width / 2 +
heights[i].width / 2 +
+BalancedSorter.INTERNODE_HORIZONTAL_PADDING);
$assert(!isNaN(xOffset), "xOffset can not be null");
$assert(!isNaN(yOffset), "yOffset can not be null");
$assert(!isNaN(xOffset), 'xOffset can not be null');
$assert(!isNaN(yOffset), 'yOffset can not be null');
result[heights[i].id] = { x: xOffset, y: yOffset };
}
@ -230,8 +283,16 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
// All even numbered nodes should be "continuous" by themselves
var factor = node.getOrder() % 2 == 0 ? 2 : 1;
for (var i = 0; i < children.length; i++) {
var order = i == 0 && factor == 1 ? 1 : (factor * i);
$assert(children[i].getOrder() == order, "Missing order elements. Missing order: " + (i * factor) + ". Parent:" + node.getId() + ",Node:" + children[i].getId());
var order = i == 0 && factor == 1 ? 1 : factor * i;
$assert(
children[i].getOrder() == order,
'Missing order elements. Missing order: ' +
i * factor +
'. Parent:' +
node.getId() +
',Node:' +
children[i].getId()
);
}
},
@ -248,7 +309,7 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
* @return {String} the print name of this class
*/
toString: function () {
return "Balanced Sorter";
return 'Balanced Sorter';
},
_getChildrenForOrder: function (parent, graph, order) {
@ -259,8 +320,9 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
_getVerticalPadding: function () {
return BalancedSorter.INTERNODE_VERTICAL_PADDING;
},
}
});
);
/**
* @constant

View File

@ -15,12 +15,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const Events = require('../Events').default
const RootedTreeSet = require('./RootedTreeSet').default
const OriginalLayout = require('./OriginalLayout').default
const Events = require('../Events').default;
const RootedTreeSet = require('./RootedTreeSet').default;
const OriginalLayout = require('./OriginalLayout').default;
const ChangeEvent = require('./ChangeEvent').default;
const LayoutManager = new Class(/** @lends LayoutManager */{
const LayoutManager = new Class(
/** @lends LayoutManager */ {
Extends: Events,
/**
* @constructs
@ -31,8 +32,8 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
* @throws will throw an error if the root size is null
*/
initialize: function (rootNodeId, rootSize) {
$assert($defined(rootNodeId), "rootNodeId can not be null");
$assert(rootSize, "rootSize can not be null");
$assert($defined(rootNodeId), 'rootNodeId can not be null');
$assert(rootSize, 'rootSize can not be null');
var position = position || { x: 0, y: 0 };
this._treeSet = new RootedTreeSet();
@ -49,7 +50,7 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
* @throws will throw an error if id is null or undefined
*/
updateNodeSize: function (id, size) {
$assert($defined(id), "id can not be null");
$assert($defined(id), 'id can not be null');
var node = this._treeSet.find(id);
node.setSize(size);
@ -63,8 +64,8 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
* @return this
*/
updateShrinkState: function (id, value) {
$assert($defined(id), "id can not be null");
$assert($defined(value), "value can not be null");
$assert($defined(id), 'id can not be null');
$assert($defined(value), 'value can not be null');
var node = this._treeSet.find(id);
node.setShrunken(value);
@ -89,10 +90,10 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
* @throws will throw an error if the position's y property is null or undefined
*/
moveNode: function (id, position) {
$assert($defined(id), "id cannot be null");
$assert($defined(position), "position cannot be null");
$assert($defined(position.x), "x can not be null");
$assert($defined(position.y), "y can not be null");
$assert($defined(id), 'id cannot be null');
$assert($defined(position), 'position cannot be null');
$assert($defined(position.x), 'x can not be null');
$assert($defined(position.y), 'y can not be null');
var node = this._treeSet.find(id);
// @Todo: this should not be here. This is broking the isolated node support...
@ -111,9 +112,9 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
* @return this
*/
connectNode: function (parentId, childId, order) {
$assert($defined(parentId), "parentId cannot be null");
$assert($defined(childId), "childId cannot be null");
$assert($defined(order), "order cannot be null");
$assert($defined(parentId), 'parentId cannot be null');
$assert($defined(childId), 'childId cannot be null');
$assert($defined(order), 'order cannot be null');
this._layout.connectNode(parentId, childId, order);
@ -126,7 +127,7 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
* @return this
*/
disconnectNode: function (id) {
$assert($defined(id), "id can not be null");
$assert($defined(id), 'id can not be null');
this._layout.disconnectNode(id);
return this;
@ -140,7 +141,7 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
* @return this
*/
addNode: function (id, size, position) {
$assert($defined(id), "id can not be null");
$assert($defined(id), 'id can not be null');
var result = this._layout.createNode(id, size, position, 'topic');
this._treeSet.add(result);
@ -154,7 +155,7 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
* @return this
*/
removeNode: function (id) {
$assert($defined(id), "id can not be null");
$assert($defined(id), 'id can not be null');
var node = this._treeSet.find(id);
// Is It connected ?
@ -177,7 +178,7 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
* @throws will throw an error if parentId is null or undefined
*/
predict: function (parentId, nodeId, position, free) {
$assert($defined(parentId), "parentId can not be null");
$assert($defined(parentId), 'parentId can not be null');
var parent = this._treeSet.find(parentId);
var node = nodeId ? this._treeSet.find(nodeId) : null;
@ -201,11 +202,18 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
* @return canvas
*/
plot: function (containerId, size) {
$assert(containerId, "containerId cannot be null");
$assert(containerId, 'containerId cannot be null');
size = size || { width: 200, height: 200 };
var squaresize = 10;
var canvas = Raphael(containerId, size.width, size.height);
canvas.drawGrid(0, 0, size.width, size.height, size.width / squaresize, size.height / squaresize);
canvas.drawGrid(
0,
0,
size.width,
size.height,
size.width / squaresize,
size.height / squaresize
);
this._treeSet.plot(canvas);
return canvas;
@ -231,19 +239,23 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
},
_flushEvents: function () {
_.each(this._events, function(event) {
_.each(
this._events,
function (event) {
this.fireEvent('change', event);
}, this);
},
this
);
this._events = [];
},
_collectChanges: function (nodes) {
if (!nodes)
nodes = this._treeSet.getTreeRoots();
if (!nodes) nodes = this._treeSet.getTreeRoots();
_.each(nodes, function(node) {
_.each(
nodes,
function (node) {
if (node.hasOrderChanged() || node.hasPositionChanged()) {
// Find or create a event ...
var id = node.getId();
var event = this._events.some(function (event) {
@ -263,9 +275,11 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
this._events.push(event);
}
this._collectChanges(this._treeSet.getChildren(node));
}, this);
},
this
);
},
}
});
);
export default LayoutManager;

View File

@ -16,7 +16,8 @@
* limitations under the License.
*/
const Node = new Class(/** @lends Node */{
const Node = new Class(
/** @lends Node */ {
/**
* @constructs
* @param id
@ -29,10 +30,10 @@ const Node = new Class(/** @lends Node */{
* @throws will throw an error if sorter is null or undefined
*/
initialize: function (id, size, position, sorter) {
$assert(typeof id === 'number' && isFinite(id), "id can not be null");
$assert(size, "size can not be null");
$assert(position, "position can not be null");
$assert(sorter, "sorter can not be null");
$assert(typeof id === 'number' && isFinite(id), 'id can not be null');
$assert(size, 'size can not be null');
$assert(position, 'position can not be null');
$assert(sorter, 'sorter can not be null');
this._id = id;
this._sorter = sorter;
@ -80,7 +81,10 @@ const Node = new Class(/** @lends Node */{
/** */
setOrder: function (order) {
$assert(typeof order === 'number' && isFinite(order), "Order can not be null. Value:" + order);
$assert(
typeof order === 'number' && isFinite(order),
'Order can not be null. Value:' + order
);
this._setProperty('order', order);
},
@ -135,7 +139,7 @@ const Node = new Class(/** @lends Node */{
/** */
setSize: function (size) {
$assert($defined(size), "Size can not be null");
$assert($defined(size), 'Size can not be null');
this._setProperty('size', Object.clone(size));
},
@ -146,11 +150,14 @@ const Node = new Class(/** @lends Node */{
/** */
setFreeDisplacement: function (displacement) {
$assert($defined(displacement), "Position can not be null");
$assert($defined(displacement.x), "x can not be null");
$assert($defined(displacement.y), "y can not be null");
$assert($defined(displacement), 'Position can not be null');
$assert($defined(displacement.x), 'x can not be null');
$assert($defined(displacement.y), 'y can not be null');
var oldDisplacement = this.getFreeDisplacement();
var newDisplacement = {x:oldDisplacement.x + displacement.x, y:oldDisplacement.y + displacement.y};
var newDisplacement = {
x: oldDisplacement.x + displacement.x,
y: oldDisplacement.y + displacement.y,
};
this._setProperty('freeDisplacement', Object.clone(newDisplacement));
},
@ -163,18 +170,22 @@ const Node = new Class(/** @lends Node */{
/** */
getFreeDisplacement: function () {
var freeDisplacement = this._getProperty('freeDisplacement');
return (freeDisplacement || {x:0, y:0});
return freeDisplacement || { x: 0, y: 0 };
},
/** */
setPosition: function (position) {
$assert($defined(position), "Position can not be null");
$assert($defined(position.x), "x can not be null");
$assert($defined(position.y), "y can not be null");
$assert($defined(position), 'Position can not be null');
$assert($defined(position.x), 'x can not be null');
$assert($defined(position.y), 'y can not be null');
// This is a performance improvement to avoid movements that really could be avoided.
var currentPos = this.getPosition();
if (currentPos == null || Math.abs(currentPos.x - position.x) > 2 || Math.abs(currentPos.y - position.y) > 2)
if (
currentPos == null ||
Math.abs(currentPos.x - position.x) > 2 ||
Math.abs(currentPos.y - position.y) > 2
)
this._setProperty('position', position);
},
@ -184,7 +195,7 @@ const Node = new Class(/** @lends Node */{
prop = {
hasChanged: false,
value: null,
oldValue:null
oldValue: null,
};
}
@ -214,9 +225,25 @@ const Node = new Class(/** @lends Node */{
/** @return {String} returns id, order, position, size and shrink information*/
toString: function () {
return "[id:" + this.getId() + ", order:" + this.getOrder() + ", position: {" + this.getPosition().x + "," + this.getPosition().y + "}, size: {" + this.getSize().width + "," + this.getSize().height + "}, shrink:" + this.areChildrenShrunken() + "]";
return (
'[id:' +
this.getId() +
', order:' +
this.getOrder() +
', position: {' +
this.getPosition().x +
',' +
this.getPosition().y +
'}, size: {' +
this.getSize().width +
',' +
this.getSize().height +
'}, shrink:' +
this.areChildrenShrunken() +
']'
);
},
}
});
);
export default Node;

View File

@ -15,11 +15,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const Node = require('./Node').default;
const SymmetricSorter = require('./SymmetricSorter').default
const SymmetricSorter = require('./SymmetricSorter').default;
const BalancedSorter = require('./BalancedSorter').default;
const OriginalLayout = new Class(/** @lends OriginalLayout */{
const OriginalLayout = new Class(
/** @lends OriginalLayout */ {
/**
* @constructs
* @param treeSet
@ -30,20 +32,18 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
/** */
createNode: function (id, size, position, type) {
$assert($defined(id), "id can not be null");
$assert(size, "size can not be null");
$assert(position, "position can not be null");
$assert(type, "type can not be null");
$assert($defined(id), 'id can not be null');
$assert(size, 'size can not be null');
$assert(position, 'position can not be null');
$assert(type, 'type can not be null');
var strategy = type === 'root' ?
OriginalLayout.BALANCED_SORTER :
OriginalLayout.SYMMETRIC_SORTER;
var strategy =
type === 'root' ? OriginalLayout.BALANCED_SORTER : OriginalLayout.SYMMETRIC_SORTER;
return new Node(id, size, position, strategy);
},
/** */
connectNode: function (parentId, childId, order) {
var parent = this._treeSet.find(parentId);
var child = this._treeSet.find(childId);
@ -62,7 +62,7 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
disconnectNode: function (nodeId) {
var node = this._treeSet.find(nodeId);
var parent = this._treeSet.getParent(node);
$assert(parent, "Node already disconnected");
$assert(parent, 'Node already disconnected');
// Make it fixed
node.setFree(false);
@ -82,8 +82,9 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
/** */
layout: function () {
var roots = this._treeSet.getTreeRoots();
_.each(roots, function (node) {
_.each(
roots,
function (node) {
// Calculate all node heights ...
var sorter = node.getSorter();
@ -92,11 +93,12 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
this._layoutChildren(node, heightById);
this._fixOverlapping(node, heightById);
}, this);
},
this
);
},
_layoutChildren: function (node, heightById) {
var nodeId = node.getId();
var children = this._treeSet.getChildren(node);
var parent = this._treeSet.getParent(node);
@ -126,9 +128,15 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
var childFreeDisplacement = child.getFreeDisplacement();
var direction = node.getSorter().getChildDirection(me._treeSet, child);
if ((direction > 0 && childFreeDisplacement.x < 0) || (direction < 0 && childFreeDisplacement.x > 0)) {
if (
(direction > 0 && childFreeDisplacement.x < 0) ||
(direction < 0 && childFreeDisplacement.x > 0)
) {
child.resetFreeDisplacement();
child.setFreeDisplacement({x:-childFreeDisplacement.x, y:childFreeDisplacement.y});
child.setFreeDisplacement({
x: -childFreeDisplacement.x,
y: childFreeDisplacement.y,
});
}
offset.x += child.getFreeDisplacement().x;
@ -137,7 +145,10 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
var parentX = parentPosition.x;
var parentY = parentPosition.y;
var newPos = {x:parentX + offset.x, y:parentY + offset.y + me._calculateAlignOffset(node, child, heightById)};
var newPos = {
x: parentX + offset.x,
y: parentY + offset.y + me._calculateAlignOffset(node, child, heightById),
};
me._treeSet.updateBranchPosition(child, newPos);
});
@ -145,9 +156,13 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
}
// Continue reordering the children nodes ...
_.each(children, function (child) {
_.each(
children,
function (child) {
this._layoutChildren(child, heightById);
}, this);
},
this
);
},
_calculateAlignOffset: function (node, child, heightById) {
@ -160,9 +175,14 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
var nodeHeight = node.getSize().height;
var childHeight = child.getSize().height;
if (this._treeSet.isStartOfSubBranch(child) && this._branchIsTaller(child, heightById)) {
if (
this._treeSet.isStartOfSubBranch(child) &&
this._branchIsTaller(child, heightById)
) {
if (this._treeSet.hasSinglePathToSingleLeaf(child)) {
offset = heightById[child.getId()] / 2 - (childHeight + child.getSorter()._getVerticalPadding() * 2) / 2;
offset =
heightById[child.getId()] / 2 -
(childHeight + child.getSorter()._getVerticalPadding() * 2) / 2;
} else {
offset = this._treeSet.isLeaf(child) ? 0 : -(childHeight - nodeHeight) / 2;
}
@ -172,8 +192,7 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
} else {
offset = nodeHeight / 2 - childHeight / 2;
}
}
else if (childHeight > nodeHeight) {
} else if (childHeight > nodeHeight) {
if (this._treeSet.getSiblings(child).length > 0) {
offset = 0;
} else {
@ -185,7 +204,10 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
},
_branchIsTaller: function (node, heightById) {
return heightById[node.getId()] > (node.getSize().height + node.getSorter()._getVerticalPadding() * 2);
return (
heightById[node.getId()] >
node.getSize().height + node.getSorter()._getVerticalPadding() * 2
);
},
_fixOverlapping: function (node, heightById) {
@ -195,17 +217,26 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
this._shiftBranches(node, heightById);
}
_.each(children, function (child) {
_.each(
children,
function (child) {
this._fixOverlapping(child, heightById);
}, this);
},
this
);
},
_shiftBranches: function (node, heightById) {
var shiftedBranches = [node];
var siblingsToShift = this._treeSet.getSiblingsInVerticalDirection(node, node.getFreeDisplacement().y);
var siblingsToShift = this._treeSet.getSiblingsInVerticalDirection(
node,
node.getFreeDisplacement().y
);
var last = node;
_.each(siblingsToShift, function (sibling) {
_.each(
siblingsToShift,
function (sibling) {
var overlappingOccurs = shiftedBranches.some(function (shiftedBranch) {
return this._branchesOverlap(shiftedBranch, sibling, heightById);
}, this);
@ -215,18 +246,26 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
this._treeSet.shiftBranchPosition(sibling, 0, sAmount);
shiftedBranches.push(sibling);
}
}, this);
},
this
);
var branchesToShift = this._treeSet.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y).filter(function (branch) {
var branchesToShift = this._treeSet
.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y)
.filter(function (branch) {
return !shiftedBranches.contains(branch);
});
_.each(branchesToShift, function (branch) {
_.each(
branchesToShift,
function (branch) {
var bAmount = node.getFreeDisplacement().y;
this._treeSet.shiftBranchPosition(branch, 0, bAmount);
shiftedBranches.push(branch);
last = branch;
}, this);
},
this
);
},
_branchesOverlap: function (branchA, branchB, heightById) {
@ -241,10 +280,9 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
var bottomB = branchB.getPosition().y + heightById[branchB.getId()] / 2;
return !(topA >= bottomB || bottomA <= topB);
},
}
});
);
/**
* @type {mindplot.layout.SymmetricSorter}

View File

@ -16,7 +16,8 @@
* limitations under the License.
*/
const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
const RootedTreeSet = new Class(
/** @lends RootedTreeSet */ {
/** @constructs */
initialize: function () {
this._rootNodes = [];
@ -49,12 +50,14 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
*/
add: function (node) {
$assert(node, 'node can not be null');
$assert(!this.find(node.getId(), false), 'node already exits with this id. Id:' + node.getId());
$assert(
!this.find(node.getId(), false),
'node already exits with this id. Id:' + node.getId()
);
$assert(!node._children, 'node already added');
this._rootNodes.push(this._decodate(node));
},
/**
* @param nodeId
* @throws will throw an error if nodeId is null or undefined
@ -78,7 +81,10 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
var parent = this.find(parentId);
var child = this.find(childId, true);
$assert(!child._parent, 'node already connected. Id:' + child.getId() + ",previous:" + child._parent);
$assert(
!child._parent,
'node already connected. Id:' + child.getId() + ',previous:' + child._parent
);
parent._children.push(child);
child._parent = parent;
@ -93,7 +99,7 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
disconnect: function (nodeId) {
$assert($defined(nodeId), 'nodeId can not be null');
var node = this.find(nodeId);
$assert(node._parent, "Node is not connected");
$assert(node._parent, 'Node is not connected');
node._parent._children.erase(node);
this._rootNodes.push(node);
@ -120,15 +126,16 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
}
}
validate = !$defined(validate) ? true : validate;
$assert(validate ? result : true, 'node could not be found id:' + id + "\n,RootedTreeSet" + this.dump());
$assert(
validate ? result : true,
'node could not be found id:' + id + '\n,RootedTreeSet' + this.dump()
);
return result;
},
_find: function (id, parent) {
if (parent.getId() == id) {
return parent;
}
var result = null;
@ -136,8 +143,7 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
for (var i = 0; i < children.length; i++) {
var child = children[i];
result = this._find(id, child);
if (result)
break;
if (result) break;
}
return result;
@ -159,7 +165,7 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
* @return root node or the provided node, if it has no parent
*/
getRootNode: function (node) {
$assert(node, "node cannot be null");
$assert(node, 'node cannot be null');
var parent = this.getParent(node);
if ($defined(parent)) {
return this.getRootNode(parent);
@ -254,20 +260,20 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
*/
dump: function () {
var branches = this._rootNodes;
var result = "";
var result = '';
for (var i = 0; i < branches.length; i++) {
var branch = branches[i];
result += this._dump(branch, "");
result += this._dump(branch, '');
}
return result;
},
_dump: function (node, indent) {
var result = indent + node + "\n";
var result = indent + node + '\n';
var children = this.getChildren(node);
for (var i = 0; i < children.length; i++) {
var child = children[i];
result += this._dump(child, indent + " ");
result += this._dump(child, indent + ' ');
}
return result;
@ -289,19 +295,66 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
var cx = node.getPosition().x + canvas.width / 2 - node.getSize().width / 2;
var cy = node.getPosition().y + canvas.height / 2 - node.getSize().height / 2;
var rect = canvas.rect(cx, cy, node.getSize().width, node.getSize().height);
var order = node.getOrder() == null ? "r" : node.getOrder();
var text = canvas.text(node.getPosition().x + canvas.width / 2, node.getPosition().y + canvas.height / 2, node.getId() + "[" + order + "]");
var order = node.getOrder() == null ? 'r' : node.getOrder();
var text = canvas.text(
node.getPosition().x + canvas.width / 2,
node.getPosition().y + canvas.height / 2,
node.getId() + '[' + order + ']'
);
text.attr('fill', '#FFF');
var fillColor = this._rootNodes.contains(node) ? "#000" : (node.isFree() ? "#abc" : "#c00");
var fillColor = this._rootNodes.contains(node)
? '#000'
: node.isFree()
? '#abc'
: '#c00';
rect.attr('fill', fillColor);
var rectPosition = {x:rect.attr("x") - canvas.width / 2 + rect.attr("width") / 2, y:rect.attr("y") - canvas.height / 2 + rect.attr("height") / 2};
var rectSize = {width:rect.attr("width"), height:rect.attr("height")};
var rectPosition = {
x: rect.attr('x') - canvas.width / 2 + rect.attr('width') / 2,
y: rect.attr('y') - canvas.height / 2 + rect.attr('height') / 2,
};
var rectSize = { width: rect.attr('width'), height: rect.attr('height') };
rect.click(function () {
console.log("[id:" + node.getId() + ", order:" + node.getOrder() + ", position:(" + rectPosition.x + "," + rectPosition.y + "), size:" + rectSize.width + "x" + rectSize.height + ", freeDisplacement:(" + node.getFreeDisplacement().x + "," + node.getFreeDisplacement().y + ")]");
console.log(
'[id:' +
node.getId() +
', order:' +
node.getOrder() +
', position:(' +
rectPosition.x +
',' +
rectPosition.y +
'), size:' +
rectSize.width +
'x' +
rectSize.height +
', freeDisplacement:(' +
node.getFreeDisplacement().x +
',' +
node.getFreeDisplacement().y +
')]'
);
});
text.click(function () {
console.log("[id:" + node.getId() + ", order:" + node.getOrder() + ", position:(" + rectPosition.x + "," + rectPosition.y + "), size:" + rectSize.width + "x" + rectSize.height + ", freeDisplacement:(" + node.getFreeDisplacement().x + "," + node.getFreeDisplacement().y + ")]");
console.log(
'[id:' +
node.getId() +
', order:' +
node.getOrder() +
', position:(' +
rectPosition.x +
',' +
rectPosition.y +
'), size:' +
rectSize.width +
'x' +
rectSize.height +
', freeDisplacement:(' +
node.getFreeDisplacement().x +
',' +
node.getFreeDisplacement().y +
')]'
);
});
for (var i = 0; i < children.length; i++) {
@ -315,7 +368,6 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
* @param position
*/
updateBranchPosition: function (node, position) {
var oldPos = node.getPosition();
node.setPosition(position);
@ -327,7 +379,6 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
_.each(children, function (child) {
me.shiftBranchPosition(child, xOffset, yOffset);
});
},
/**
@ -355,8 +406,14 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
// siblings with lower or higher order, depending on the direction of the offset and on the same side as their parent
var parent = this.getParent(node);
var siblings = this.getSiblings(node).filter(function (sibling) {
var sameSide = node.getPosition().x > parent.getPosition().x ? sibling.getPosition().x > parent.getPosition().x : sibling.getPosition().x < parent.getPosition().x;
var orderOK = yOffset < 0 ? sibling.getOrder() < node.getOrder() : sibling.getOrder() > node.getOrder();
var sameSide =
node.getPosition().x > parent.getPosition().x
? sibling.getPosition().x > parent.getPosition().x
: sibling.getPosition().x < parent.getPosition().x;
var orderOK =
yOffset < 0
? sibling.getOrder() < node.getOrder()
: sibling.getOrder() > node.getOrder();
return orderOK && sameSide;
});
@ -383,14 +440,20 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
var branch = branches[0];
var rootDescendants = this.getSiblings(branch).filter(function (sibling) {
var sameSide = node.getPosition().x > rootNode.getPosition().x ? sibling.getPosition().x > rootNode.getPosition().x : sibling.getPosition().x < rootNode.getPosition().x;
var sameDirection = yOffset < 0 ? sibling.getOrder() < branch.getOrder() : sibling.getOrder() > branch.getOrder();
var sameSide =
node.getPosition().x > rootNode.getPosition().x
? sibling.getPosition().x > rootNode.getPosition().x
: sibling.getPosition().x < rootNode.getPosition().x;
var sameDirection =
yOffset < 0
? sibling.getOrder() < branch.getOrder()
: sibling.getOrder() > branch.getOrder();
return sameSide && sameDirection;
}, this);
return rootDescendants;
},
}
});
);
export default RootedTreeSet;

View File

@ -17,15 +17,14 @@
*/
const AbstractBasicSorter = require('./AbstractBasicSorter').default;
const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
const SymmetricSorter = new Class(
/** @lends SymmetricSorter */ {
Extends: AbstractBasicSorter,
/**
* @constructs
* @extends mindplot.layout.AbstractBasicSorter
*/
initialize:function () {
},
initialize: function () {},
/**
* Predict the order and position of a dragged node.
@ -38,38 +37,63 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
* @return {*}
*/
predict: function (graph, parent, node, position, free) {
var self = this;
var rootNode = graph.getRootNode(parent);
// If its a free node...
if (free) {
$assert($defined(position), "position cannot be null for predict in free positioning");
$assert($defined(node), "node cannot be null for predict in free positioning");
$assert(
$defined(position),
'position cannot be null for predict in free positioning'
);
$assert($defined(node), 'node cannot be null for predict in free positioning');
var direction = this._getRelativeDirection(rootNode.getPosition(), parent.getPosition());
var limitXPos = parent.getPosition().x + direction * (parent.getSize().width / 2 + node.getSize().width / 2 + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
var direction = this._getRelativeDirection(
rootNode.getPosition(),
parent.getPosition()
);
var limitXPos =
parent.getPosition().x +
direction *
(parent.getSize().width / 2 +
node.getSize().width / 2 +
SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
var xPos = direction > 0 ?
(position.x >= limitXPos ? position.x : limitXPos) :
(position.x <= limitXPos ? position.x : limitXPos);
var xPos =
direction > 0
? position.x >= limitXPos
? position.x
: limitXPos
: position.x <= limitXPos
? position.x
: limitXPos;
return [0, { x: xPos, y: position.y }];
}
// Its not a dragged node (it is being added)
if (!node) {
var parentDirection = self._getRelativeDirection(rootNode.getPosition(), parent.getPosition());
var parentDirection = self._getRelativeDirection(
rootNode.getPosition(),
parent.getPosition()
);
var position = {
x:parent.getPosition().x + parentDirection * (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
y:parent.getPosition().y
x:
parent.getPosition().x +
parentDirection *
(parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
y: parent.getPosition().y,
};
return [graph.getChildren(parent).length, position];
}
// If it is a dragged node...
$assert($defined(position), "position cannot be null for predict in dragging");
var nodeDirection = this._getRelativeDirection(rootNode.getPosition(), node.getPosition());
$assert($defined(position), 'position cannot be null for predict in dragging');
var nodeDirection = this._getRelativeDirection(
rootNode.getPosition(),
node.getPosition()
);
var positionDirection = this._getRelativeDirection(rootNode.getPosition(), position);
var siblings = graph.getSiblings(node);
@ -84,8 +108,11 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
if (parentChildren.length == 0) {
// Fit as a child of the parent node...
var position = {
x:parent.getPosition().x + positionDirection * (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
y:parent.getPosition().y
x:
parent.getPosition().x +
positionDirection *
(parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
y: parent.getPosition().y,
};
return [0, position];
} else {
@ -94,31 +121,46 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
var last = parentChildren.getLast();
for (var i = 0; i < parentChildren.length; i++) {
var parentChild = parentChildren[i];
var nodeAfter = (i + 1) == parentChild.length ? null : parentChildren[i + 1];
var nodeAfter = i + 1 == parentChild.length ? null : parentChildren[i + 1];
// Fit at the bottom
if (!nodeAfter && position.y > parentChild.getPosition().y) {
var order = (graph.getParent(node) && graph.getParent(node).getId() == parent.getId()) ?
last.getOrder() : last.getOrder() + 1;
var order =
graph.getParent(node) && graph.getParent(node).getId() == parent.getId()
? last.getOrder()
: last.getOrder() + 1;
var position = {
x: parentChild.getPosition().x,
y:parentChild.getPosition().y + parentChild.getSize().height + SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2
y:
parentChild.getPosition().y +
parentChild.getSize().height +
SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2,
};
return [order, position];
}
// Fit after this node
if (nodeAfter && position.y > parentChild.getPosition().y && position.y < nodeAfter.getPosition().y) {
if (nodeAfter.getId() == node.getId() || parentChild.getId() == node.getId()) {
if (
nodeAfter &&
position.y > parentChild.getPosition().y &&
position.y < nodeAfter.getPosition().y
) {
if (
nodeAfter.getId() == node.getId() ||
parentChild.getId() == node.getId()
) {
return [node.getOrder(), node.getPosition()];
} else {
var order = position.y > node.getPosition().y ?
nodeAfter.getOrder() - 1 : parentChild.getOrder() + 1;
var order =
position.y > node.getPosition().y
? nodeAfter.getOrder() - 1
: parentChild.getOrder() + 1;
var position = {
x: parentChild.getPosition().x,
y:parentChild.getPosition().y + (nodeAfter.getPosition().y - parentChild.getPosition().y) / 2
y:
parentChild.getPosition().y +
(nodeAfter.getPosition().y - parentChild.getPosition().y) / 2,
};
return [order, position];
}
}
@ -129,7 +171,10 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
var first = parentChildren[0];
var position = {
x: first.getPosition().x,
y:first.getPosition().y - first.getSize().height - SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2
y:
first.getPosition().y -
first.getSize().height -
SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2,
};
return [0, position];
},
@ -143,7 +188,10 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
*/
insert: function (treeSet, parent, child, order) {
var children = this._getSortedChildren(treeSet, parent);
$assert(order <= children.length, "Order must be continues and can not have holes. Order:" + order);
$assert(
order <= children.length,
'Order must be continues and can not have holes. Order:' + order
);
// Shift all the elements in one .
for (var i = order; i < children.length; i++) {
@ -161,7 +209,7 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
var parent = treeSet.getParent(node);
var children = this._getSortedChildren(treeSet, parent);
var order = node.getOrder();
$assert(children[order] === node, "Node seems not to be in the right position");
$assert(children[order] === node, 'Node seems not to be in the right position');
// Shift all the nodes ...
for (var i = node.getOrder() + 1; i < children.length; i++) {
@ -183,16 +231,23 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
* @return offsets
*/
computeOffsets: function (treeSet, node) {
$assert(treeSet, "treeSet can no be null.");
$assert(node, "node can no be null.");
$assert(treeSet, 'treeSet can no be null.');
$assert(node, 'node can no be null.');
var children = this._getSortedChildren(treeSet, node);
// Compute heights ...
var heights = children.map(
function (child) {
return {id:child.getId(), order:child.getOrder(), position:child.getPosition(), width:child.getSize().width, height:this._computeChildrenHeight(treeSet, child)};
}, this).reverse();
var heights = children
.map(function (child) {
return {
id: child.getId(),
order: child.getOrder(),
position: child.getPosition(),
width: child.getSize().width,
height: this._computeChildrenHeight(treeSet, child),
};
}, this)
.reverse();
// Compute the center of the branch ...
var totalHeight = 0;
@ -209,10 +264,14 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
var direction = this.getChildDirection(treeSet, childNode);
var yOffset = ysum + heights[i].height / 2;
var xOffset = direction * (heights[i].width / 2 + node.getSize().width / 2 + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
var xOffset =
direction *
(heights[i].width / 2 +
node.getSize().width / 2 +
SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
$assert(!isNaN(xOffset), "xOffset can not be null");
$assert(!isNaN(yOffset), "yOffset can not be null");
$assert(!isNaN(xOffset), 'xOffset can not be null');
$assert(!isNaN(yOffset), 'yOffset can not be null');
result[heights[i].id] = { x: xOffset, y: yOffset };
}
@ -229,7 +288,7 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
var children = this._getSortedChildren(treeSet, node);
for (var i = 0; i < children.length; i++) {
$assert(children[i].getOrder() == i, "missing order elements");
$assert(children[i].getOrder() == i, 'missing order elements');
}
},
@ -238,8 +297,8 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
* @param child
* @return direction of the given child from its parent or from the root node, if isolated*/
getChildDirection: function (treeSet, child) {
$assert(treeSet, "treeSet can no be null.");
$assert(treeSet.getParent(child), "This should not happen");
$assert(treeSet, 'treeSet can no be null.');
$assert(treeSet.getParent(child), 'This should not happen');
var result;
var rootNode = treeSet.getRootNode(child);
@ -252,20 +311,20 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
var grandParent = treeSet.getParent(parent);
var sorter = grandParent.getSorter();
result = sorter.getChildDirection(treeSet, parent);
}
return result;
},
/** @return {String} the print name of this class */
toString: function () {
return "Symmetric Sorter";
return 'Symmetric Sorter';
},
_getVerticalPadding: function () {
return SymmetricSorter.INTERNODE_VERTICAL_PADDING;
},
}
});
);
/**
* @constant
@ -280,4 +339,4 @@ SymmetricSorter.INTERNODE_VERTICAL_PADDING = 5;
*/
SymmetricSorter.INTERNODE_HORIZONTAL_PADDING = 30;
export default SymmetricSorter
export default SymmetricSorter;

View File

@ -0,0 +1,76 @@
/*
---
MooTools: the javascript framework
web build:
- http://mootools.net/core/b28139f033891d55fabb70ffafd6813b
packager build:
- packager build Core/Core Core/Array Core/Class Core/Class.Extras
copyrights:
- [MooTools](http://mootools.net)
licenses:
- [MIT License](http://mootools.net/license.txt)
...
*/
(function(){this.MooTools={version:"1.4.5",build:"ab8ea8824dc3b24b6666867a2c4ed58ebb762cf0"};var o=this.typeOf=function(i){if(i==null){return"null";}if(i.$family!=null){return i.$family();
}if(i.nodeName){if(i.nodeType==1){return"element";}if(i.nodeType==3){return(/\S/).test(i.nodeValue)?"textnode":"whitespace";}}else{if(typeof i.length=="number"){if(i.callee){return"arguments";
}if("item" in i){return"collection";}}}return typeof i;};var j=this.instanceOf=function(t,i){if(t==null){return false;}var s=t.$constructor||t.constructor;
while(s){if(s===i){return true;}s=s.parent;}if(!t.hasOwnProperty){return false;}return t instanceof i;};var f=this.Function;var p=true;for(var k in {toString:1}){p=null;
}if(p){p=["hasOwnProperty","valueOf","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","constructor"];}f.prototype.overloadSetter=function(s){var i=this;
return function(u,t){if(u==null){return this;}if(s||typeof u!="string"){for(var v in u){i.call(this,v,u[v]);}if(p){for(var w=p.length;w--;){v=p[w];if(u.hasOwnProperty(v)){i.call(this,v,u[v]);
}}}}else{i.call(this,u,t);}return this;};};f.prototype.overloadGetter=function(s){var i=this;return function(u){var v,t;if(typeof u!="string"){v=u;}else{if(arguments.length>1){v=arguments;
}else{if(s){v=[u];}}}if(v){t={};for(var w=0;w<v.length;w++){t[v[w]]=i.call(this,v[w]);}}else{t=i.call(this,u);}return t;};};f.prototype.extend=function(i,s){this[i]=s;
}.overloadSetter();f.prototype.implement=function(i,s){this.prototype[i]=s;}.overloadSetter();var n=Array.prototype.slice;f.from=function(i){return(o(i)=="function")?i:function(){return i;
};};Array.from=function(i){if(i==null){return[];}return(a.isEnumerable(i)&&typeof i!="string")?(o(i)=="array")?i:n.call(i):[i];};Number.from=function(s){var i=parseFloat(s);
return isFinite(i)?i:null;};String.from=function(i){return i+"";};f.implement({hide:function(){this.$hidden=true;return this;},protect:function(){this.$protected=true;
return this;}});var a=this.Type=function(u,t){if(u){var s=u.toLowerCase();var i=function(v){return(o(v)==s);};a["is"+u]=i;if(t!=null){t.prototype.$family=(function(){return s;
}).hide();}}if(t==null){return null;}t.extend(this);t.$constructor=a;t.prototype.$constructor=t;return t;};var e=Object.prototype.toString;a.isEnumerable=function(i){return(i!=null&&typeof i.length=="number"&&e.call(i)!="[object Function]");
};var q={};var r=function(i){var s=o(i.prototype);return q[s]||(q[s]=[]);};var b=function(t,x){if(x&&x.$hidden){return;}var s=r(this);for(var u=0;u<s.length;
u++){var w=s[u];if(o(w)=="type"){b.call(w,t,x);}else{w.call(this,t,x);}}var v=this.prototype[t];if(v==null||!v.$protected){this.prototype[t]=x;}if(this[t]==null&&o(x)=="function"){m.call(this,t,function(i){return x.apply(i,n.call(arguments,1));
});}};var m=function(i,t){if(t&&t.$hidden){return;}var s=this[i];if(s==null||!s.$protected){this[i]=t;}};a.implement({implement:b.overloadSetter(),extend:m.overloadSetter(),alias:function(i,s){b.call(this,i,this.prototype[s]);
}.overloadSetter(),mirror:function(i){r(this).push(i);return this;}});new a("Type",a);var d=function(s,x,v){var u=(x!=Object),B=x.prototype;if(u){x=new a(s,x);
}for(var y=0,w=v.length;y<w;y++){var C=v[y],A=x[C],z=B[C];if(A){A.protect();}if(u&&z){x.implement(C,z.protect());}}if(u){var t=B.propertyIsEnumerable(v[0]);
x.forEachMethod=function(G){if(!t){for(var F=0,D=v.length;F<D;F++){G.call(B,B[v[F]],v[F]);}}for(var E in B){G.call(B,B[E],E);}};}return d;};d("String",String,["charAt","charCodeAt","concat","indexOf","lastIndexOf","match","quote","replace","search","slice","split","substr","substring","trim","toLowerCase","toUpperCase"])("Array",Array,["pop","push","reverse","shift","sort","splice","unshift","concat","join","slice","indexOf","lastIndexOf","filter","forEach","every","map","some","reduce","reduceRight"])("Number",Number,["toExponential","toFixed","toLocaleString","toPrecision"])("Function",f,["apply","call","bind"])("RegExp",RegExp,["exec","test"])("Object",Object,["create","defineProperty","defineProperties","keys","getPrototypeOf","getOwnPropertyDescriptor","getOwnPropertyNames","preventExtensions","isExtensible","seal","isSealed","freeze","isFrozen"])("Date",Date,["now"]);
Object.extend=m.overloadSetter();Date.extend("now",function(){return +(new Date);});new a("Boolean",Boolean);Number.prototype.$family=function(){return isFinite(this)?"number":"null";
}.hide();Number.extend("random",function(s,i){return Math.floor(Math.random()*(i-s+1)+s);});var g=Object.prototype.hasOwnProperty;Object.extend("forEach",function(i,t,u){for(var s in i){if(g.call(i,s)){t.call(u,i[s],s,i);
}}});Object.each=Object.forEach;Array.implement({forEach:function(u,v){for(var t=0,s=this.length;t<s;t++){if(t in this){u.call(v,this[t],t,this);}}},each:function(i,s){Array.forEach(this,i,s);
return this;}});var l=function(i){switch(o(i)){case"array":return i.clone();case"object":return Object.clone(i);default:return i;}};Array.implement("clone",function(){var s=this.length,t=new Array(s);
while(s--){t[s]=l(this[s]);}return t;});var h=function(s,i,t){switch(o(t)){case"object":if(o(s[i])=="object"){Object.merge(s[i],t);}else{s[i]=Object.clone(t);
}break;case"array":s[i]=t.clone();break;default:s[i]=t;}return s;};Object.extend({merge:function(z,u,t){if(o(u)=="string"){return h(z,u,t);}for(var y=1,s=arguments.length;
y<s;y++){var w=arguments[y];for(var x in w){h(z,x,w[x]);}}return z;},clone:function(i){var t={};for(var s in i){t[s]=l(i[s]);}return t;},append:function(w){for(var v=1,t=arguments.length;
v<t;v++){var s=arguments[v]||{};for(var u in s){w[u]=s[u];}}return w;}});["Object","WhiteSpace","TextNode","Collection","Arguments"].each(function(i){new a(i);
});var c=Date.now();String.extend("uniqueID",function(){return(c++).toString(36);});})();Array.implement({every:function(c,d){for(var b=0,a=this.length>>>0;
b<a;b++){if((b in this)&&!c.call(d,this[b],b,this)){return false;}}return true;},filter:function(d,f){var c=[];for(var e,b=0,a=this.length>>>0;b<a;b++){if(b in this){e=this[b];
if(d.call(f,e,b,this)){c.push(e);}}}return c;},indexOf:function(c,d){var b=this.length>>>0;for(var a=(d<0)?Math.max(0,b+d):d||0;a<b;a++){if(this[a]===c){return a;
}}return -1;},map:function(c,e){var d=this.length>>>0,b=Array(d);for(var a=0;a<d;a++){if(a in this){b[a]=c.call(e,this[a],a,this);}}return b;},some:function(c,d){for(var b=0,a=this.length>>>0;
b<a;b++){if((b in this)&&c.call(d,this[b],b,this)){return true;}}return false;},clean:function(){return this.filter(function(a){return a!=null;});},invoke:function(a){var b=Array.slice(arguments,1);
return this.map(function(c){return c[a].apply(c,b);});},associate:function(c){var d={},b=Math.min(this.length,c.length);for(var a=0;a<b;a++){d[c[a]]=this[a];
}return d;},link:function(c){var a={};for(var e=0,b=this.length;e<b;e++){for(var d in c){if(c[d](this[e])){a[d]=this[e];delete c[d];break;}}}return a;},contains:function(a,b){return this.indexOf(a,b)!=-1;
},append:function(a){this.push.apply(this,a);return this;},getLast:function(){return(this.length)?this[this.length-1]:null;},getRandom:function(){return(this.length)?this[Number.random(0,this.length-1)]:null;
},include:function(a){if(!this.contains(a)){this.push(a);}return this;},combine:function(c){for(var b=0,a=c.length;b<a;b++){this.include(c[b]);}return this;
},erase:function(b){for(var a=this.length;a--;){if(this[a]===b){this.splice(a,1);}}return this;},empty:function(){this.length=0;return this;},flatten:function(){var d=[];
for(var b=0,a=this.length;b<a;b++){var c=typeOf(this[b]);if(c=="null"){continue;}d=d.concat((c=="array"||c=="collection"||c=="arguments"||instanceOf(this[b],Array))?Array.flatten(this[b]):this[b]);
}return d;},pick:function(){for(var b=0,a=this.length;b<a;b++){if(this[b]!=null){return this[b];}}return null;},rgbToHex:function(d){if(this.length<3){return null;}if(this.length==4&&this[3]==0&&!d){return"transparent";
}var b=[];for(var a=0;a<3;a++){var c=(this[a]-0).toString(16);b.push((c.length==1)?"0"+c:c);}return(d)?b:"#"+b.join("");}});String.implement({test:function(a,b){return((typeOf(a)=="regexp")?a:new RegExp(""+a,b)).test(this);
},contains:function(a,b){return(b)?(b+this+b).indexOf(b+a+b)>-1:String(this).indexOf(a)>-1;},trim:function(){return String(this).replace(/^\s+|\s+$/g,"");
},clean:function(){return String(this).replace(/\s+/g," ").trim();},camelCase:function(){return String(this).replace(/-\D/g,function(a){return a.charAt(1).toUpperCase();
});},hyphenate:function(){return String(this).replace(/[A-Z]/g,function(a){return("-"+a.charAt(0).toLowerCase());});},capitalize:function(){return String(this).replace(/\b[a-z]/g,function(a){return a.toUpperCase();
});},escapeRegExp:function(){return String(this).replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1");},rgbToHex:function(b){var a=String(this).match(/\d{1,3}/g);
return(a)?a.rgbToHex(b):null;},substitute:function(a,b){return String(this).replace(b||(/\\?\{([^{}]+)\}/g),function(d,c){if(d.charAt(0)=="\\"){return d.slice(1);
}return(a[c]!=null)?a[c]:"";});}});
Function.implement({bind:function(e){var a=this,b=arguments.length>1?Array.slice(arguments,1):null,d=function(){};var c=function(){var g=e,h=arguments.length;if(this instanceof c){d.prototype=a.prototype;g=new d;}var f=(!b&&!h)?a.call(g):a.apply(g,b&&h?b.concat(Array.slice(arguments)):b||arguments);return g==e?f:g;};return c;},pass:function(b,c){var a=this;if(b!=null){b=Array.from(b);}return function(){return a.apply(c,b||arguments);};},delay:function(b,c,a){return setTimeout(this.pass((a==null?[]:a),c),b);},});
Number.alias("each","times");(function(b){var a={};b.each(function(c){if(!Number[c]){a[c]=function(){return Math[c].apply(null,[this].concat(Array.from(arguments)));
};}});Number.implement(a);})(["abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","sin","sqrt","tan"]);(function(){var a=this.Class=new Type("Class",function(h){if(instanceOf(h,Function)){h={initialize:h};
}var g=function(){e(this);if(g.$prototyping){return this;}this.$caller=null;var i=(this.initialize)?this.initialize.apply(this,arguments):this;this.$caller=this.caller=null;
return i;}.extend(this).implement(h);g.$constructor=a;g.prototype.$constructor=g;g.prototype.parent=c;return g;});var c=function(){if(!this.$caller){throw new Error('The method "parent" cannot be called.');
}var g=this.$caller.$name,h=this.$caller.$owner.parent,i=(h)?h.prototype[g]:null;if(!i){throw new Error('The method "'+g+'" has no parent.');}return i.apply(this,arguments);
};var e=function(g){for(var h in g){var j=g[h];switch(typeOf(j)){case"object":var i=function(){};i.prototype=j;g[h]=e(new i);break;case"array":g[h]=j.clone();
break;}}return g;};var b=function(g,h,j){if(j.$origin){j=j.$origin;}var i=function(){if(j.$protected&&this.$caller==null){throw new Error('The method "'+h+'" cannot be called.');
}var l=this.caller,m=this.$caller;this.caller=m;this.$caller=i;var k=j.apply(this,arguments);this.$caller=m;this.caller=l;return k;}.extend({$owner:g,$origin:j,$name:h});
return i;};var f=function(h,i,g){if(a.Mutators.hasOwnProperty(h)){i=a.Mutators[h].call(this,i);if(i==null){return this;}}if(typeOf(i)=="function"){if(i.$hidden){return this;
}this.prototype[h]=(g)?i:b(this,h,i);}else{Object.merge(this.prototype,h,i);}return this;};var d=function(g){g.$prototyping=true;var h=new g;delete g.$prototyping;
return h;};a.implement("implement",f.overloadSetter());a.Mutators={Extends:function(g){this.parent=g;this.prototype=d(g);},Implements:function(g){Array.from(g).each(function(j){var h=new j;for(var i in h){f.call(this,i,h[i],true);}},this);}};})();

File diff suppressed because it is too large Load Diff

View File

@ -421,5 +421,5 @@ INodeModel._nextUUID = function () {
};
INodeModel._uuid = 0;
export default INodeModel;
export { TopicShape };
export default INodeModel;

View File

@ -1,21 +1,21 @@
const featureModel = require('./FeatureModel').default;
const iconModel = require('./IconModel').default;
const imindmap = require('./IMindmap').default;
const inodeModel = require('./INodeModel').default;
const iMindmap = require('./IMindmap').default;
const iNodeModel = require('./INodeModel').default;
const linkModel = require('./LinkModel').default;
const noteModel = require('./NoteModel').default;
const mindmap = require('./Mindmap').default;
const nodeModel = require('./NodeModel').default;
const noteModel = require('./NoteModel').default;
const relationshipModel = require('./RelationshipModel').default;
export const Models = {
export const Model = {
FeatureModel: featureModel,
IconModel: iconModel,
IMindmap: imindmap,
INodeModel: inodeModel,
IMindmap: iMindmap,
INodeModel: iNodeModel,
LinkModel: linkModel,
NoteModel: noteModel,
Mindmap: mindmap,
NodeModel: nodeModel,
NoteModel: noteModel,
RelationshipModel: relationshipModel,
};

View File

@ -0,0 +1,7 @@
const fadeEffect = require('./FadeEffect').default;
const shape = require('./Shape').default;
export const Utils = {
FadeEffect: fadeEffect,
Shape: shape,
};

View File

@ -23,13 +23,11 @@ const ColorPalettePanel = new Class({
initialize: function (buttonId, model, baseUrl) {
this._baseUrl = baseUrl;
this.parent(buttonId, model);
$assert($defined(baseUrl), "baseUrl can not be null");
$assert($defined(baseUrl), 'baseUrl can not be null');
},
_load: function () {
if (!ColorPalettePanel._panelContent) {
// Load all the CSS styles ...
$('<link>')
.appendTo($('head'))
@ -39,26 +37,27 @@ const ColorPalettePanel = new Class({
// Load panel html fragment ...
var result;
$.ajax({
url:this._baseUrl + '/colorPalette.html',
method:'get',
url: `${this._baseUrl}/colorPalette.html`,
method: 'GET',
async: false,
success: function (responseText) {
result = responseText;
},
error: function () {
result = '<div>Sorry, your request failed :(</div>';
}
},
});
ColorPalettePanel._panelContent = result;
}
return ColorPalettePanel._panelContent;
},
buildPanel: function () {
var content = $('<div class="toolbarPanel"></div>').attr('id', this._buttonId + 'colorPalette');
var content = $('<div class="toolbarPanel"></div>').attr(
'id',
this._buttonId + 'colorPalette'
);
content.html(this._load());
// Register on toolbar elements ...
@ -67,7 +66,7 @@ const ColorPalettePanel = new Class({
var me = this;
_.each(colorCells, function (elem) {
$(elem).on('click', function () {
var color = $(elem).css("background-color");
var color = $(elem).css('background-color');
model.setValue(color);
me.hide();
});
@ -80,14 +79,16 @@ const ColorPalettePanel = new Class({
var panelElem = this.getPanelElem();
// Clear selected cell based on the color ...
panelElem.find("td[class='palette-cell palette-cell-selected']").attr('class', 'palette-cell');
panelElem
.find("td[class='palette-cell palette-cell-selected']")
.attr('class', 'palette-cell');
// Mark the cell as selected ...
var colorCells = panelElem.find('div[class=palette-colorswatch]');
var model = this.getModel();
var modelValue = model.getValue();
_.each(colorCells, function (elem) {
var color = $(elem).css("background-color").rgbToHex();
var color = $(elem).css('background-color').rgbToHex();
if (modelValue != null && modelValue[0] == 'r') {
modelValue = modelValue.rgbToHex();
}
@ -97,8 +98,7 @@ const ColorPalettePanel = new Class({
}
});
return panelElem;
}
},
});
export default ColorPalettePanel;

View File

@ -6,7 +6,6 @@
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
@ -50,5 +49,7 @@ const ModalDialogNotifier = new Class({
var dialogNotifier = new ModalDialogNotifier();
const $notifyModal = dialogNotifier.show.bind(dialogNotifier);
$notifyModal;
export { $notifyModal };
export default ModalDialogNotifier;

View File

@ -46,4 +46,5 @@ const $notify = function (msg) {
toolbarNotifier.logMessage(msg);
};
export { $notify };
export default ToolbarNotifier;

View File

@ -3,7 +3,7 @@ const floatingTip = require('./FloatingTip').default;
const fontFamilyPanel = require('./FontFamilyPanel').default;
const fontSizePanel = require('./FontSizePanel').default;
const iconPanel = require('./IconPanel').default;
const imenu = require('./IMenu').default;
const iMenu = require('./IMenu').default;
const keyboardShortcutTooltip = require('./KeyboardShortcutTooltip').default;
const linkEditor = require('./LinkEditor').default;
const linkIconTooltip = require('./LinkIconTooltip').default;
@ -22,7 +22,7 @@ export const Widgets = {
FontFamilyPanel: fontFamilyPanel,
FontSizePanel: fontSizePanel,
IconPanel: iconPanel,
Imenu: imenu,
IMenu: iMenu,
KeyboardShortcutTooltip: keyboardShortcutTooltip,
LinkEditor: linkEditor,
LinkIconTooltip: linkIconTooltip,

View File

@ -9,23 +9,27 @@ function mindplot() {
const { Layout } = require('./components/layout');
// Model
const { Models } = require('./components/model');
const { Model } = require('./components/model');
// Persistence
const { Persistence } = require('./components/persistence');
// Utils
const { Utils } = require('./components/util');
// Widgets
const { Widgets } = require('./components/widget');
// Commponents
// Components
const { Components } = require('./components');
return {
commands: Commands,
layout: Layout,
models: Models,
layouts: Layout,
models: Model,
persistence: Persistence,
widget: Widgets,
component: Components,
utils: Utils,
widgets: Widgets,
components: Components,
};
}

View File

@ -20,9 +20,9 @@
"url": "git+https://ezequielVega@bitbucket.org/lilabyus/wisemapping-frontend.git"
},
"scripts": {
"build": "yarn build:dev && yarn build:test",
"build:dev": "webpack --config webpack.prod.js",
"build:test": "webpack --config webpack.test.js",
"build": "yarn mindplot:build && yarn test:build",
"test:build": "webpack --config webpack.test.js",
"mindplot:build": "webpack --config webpack.prod.js",
"start": "webpack serve --config webpack.dev.js"
},
"dependencies": {
@ -31,7 +31,6 @@
},
"devDependencies": {
"@babel/core": "^7.14.6",
"@babel/preset-env": "^7.14.7",
"babel-loader": "^8.2.2",
"clean-webpack-plugin": "^4.0.0-alpha.0",
"webpack": "^5.44.0",

View File

@ -1,28 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<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="../../../../core-js/dist/core.js"></script>
<script type="text/javascript" src="../../../lib/components/header.js"></script>
<script type="text/javascript" src="../../../dist/main.js"></script>
<head>
<script 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 src="../../../lib/components/libraries/underscorejs/underscore-min.js"></script>
<script type='text/javascript' src='../../../../core-js/dist/core.js'></script>
<script src="../../../dist/main.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="../../../dist/test/layout.test.js"></script>
<script src="../../../dist/test/layout.test.js"></script>
<style type="text/css">
div.col {
@ -33,9 +23,12 @@
float: none;
}
</style>
</head>
<body>
<div id="basicTest" style="display: none">
<div id="basicTest" style="display: none;">
<h1>Basic Tests</h1>
<h3>testAligned:</h3>
@ -81,7 +74,7 @@
<div id="testReconnectSingleNode2" class="col"></div>
</div>
<div id="balancedTest" style="display: none">
<div id="balancedTest" style="display: none;">
<h1>Balanced Sorter Tests</h1>
<h3>testBalanced:</h3>
@ -112,7 +105,7 @@
<div id="testBalancedNodeDragPredict3"></div>
</div>
<div id="symmetricTest" style="display: none">
<div id="symmetricTest" style="display: none;">
<h1>Symmetric Sorter Tests</h1>
<h3>testSymmetry:</h3>
<div id="testSymmetry"></div>
@ -128,7 +121,7 @@
<div id="testSymmetricDragPredict1"></div>
</div>
<div id="freeTest" style="display: none">
<div id="freeTest" style="display: none;">
<h1>Free Positioning Tests</h1>
<h3>testFreePosition:</h3>
@ -176,5 +169,6 @@
<div id="testFreeOverlap1" class="col"></div>
<div id="testFreeOverlap2" class="col"></div>
</div>
</body>
</html>

View File

@ -1,16 +1,33 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<script src="../../../lib/components/libraries/jquery/jquery-2.1.0.min.js"></script>
<script src="../../../lib/components/libraries/mootools/mootools-core-1.4.5-full-nocompat-yc.js"></script>
<script src="../../../lib/components/libraries/underscorejs/underscore-min.js"></script>
<script src="../../../lib/components/libraries/bootstrap/js/bootstrap.min.js"></script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script
type="text/javascript"
src="../../../lib/components/libraries/jquery/jquery-2.1.0.js"
></script>
<script type="text/javascript" src="../../../../core-js/dist/core.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/libraries/bootstrap/js/bootstrap.min.js"
></script>
<script type="text/javascript" src="../../../dist/main.js"></script>
<script type="text/javascript" src="../../../dist/test/palette.test.js"></script>
</head>
<body>
<body>
<div id="myButton" style="border: 1px red solid">The button</div>
</body>
</body>
</html>

View File

@ -17,6 +17,9 @@
*/
const TestSuite = require('./TestSuite').default;
const Mindplot = require('../../../../lib/mindplot');
const mindplot = Mindplot();
const BalancedTestSuite = new Class({
Extends: TestSuite,

View File

@ -16,6 +16,9 @@
* limitations under the License.
*/
const TestSuite = require('./TestSuite').default;
const Mindplot = require('../../../../lib/mindplot');
const mindplot = Mindplot();
const FreeTestSuite = new Class({
Extends: TestSuite,

View File

@ -16,6 +16,8 @@
* limitations under the License.
*/
const TestSuite = require('./TestSuite').default;
const Mindplot = require('../../../../lib/mindplot');
const mindplot = Mindplot();
const SymmetricTestSuite = new Class({
Extends: TestSuite,
@ -154,6 +156,8 @@ const SymmetricTestSuite = new Class({
console.log('\tAdded as child of node 5 and dropped at (380, -30):');
var prediction2d = manager.predict(5, null, { x: 380, y: -30 });
this._plotPrediction(graph2, prediction2d);
// Prediction calculator error
$assert(
prediction2d.position.y < manager.find(7).getPosition().y &&
prediction2d.position.x == manager.find(7).getPosition().x,
@ -164,6 +168,7 @@ const SymmetricTestSuite = new Class({
console.log('\tAdded as child of node 5 and dropped at (375, 15):');
var prediction2a = manager.predict(5, null, { x: 375, y: 15 });
this._plotPrediction(graph2, prediction2a);
$assert(
prediction2a.position.y > manager.find(7).getPosition().y &&
prediction2a.position.y < manager.find(8).getPosition().y &&
@ -278,6 +283,7 @@ const SymmetricTestSuite = new Class({
console.log('testSymmetricDragPredict:');
var position = { x: 0, y: 0 };
var manager = new mindplot.layout.LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 1);
manager.addNode(2, TestSuite.NODE_SIZE, position).connectNode(1, 2, 0);
manager.layout();

View File

@ -15,12 +15,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const Mindplot = require('../../../../lib/mindplot');
const mindplot = Mindplot();
const TestSuite = new Class({
Extends: mindplot.layout.ChildrenSorterStrategy,
initialize: function () {
$('#basicTest').css('display', 'block');
// this.testAligned();
this.testBaselineAligned1();
this.testBaselineAligned2();
@ -230,6 +232,9 @@ const TestSuite = new Class({
manager.plot('testEventsComplex2', { width: 800, height: 200 });
// Check only 4 nodes were repositioned
console.log(events.length);
$assert(events.length == 4, 'Only 4 nodes should be repositioned.');
console.log('OK!\n\n');

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="../../../lib/components/libraries/jquery/jquery-2.1.0.min.js"></script>
<script src="../../../lib/components/libraries/mootools/mootools-core-1.6.0.js"></script>
<script src="../../../../core-js/dist/core.js"></script>
<script src="../../../dist/main.js"></script>
<script src="../../../dist/24.js"></script>
</head>
<body></body>
</html>

View File

@ -4,15 +4,21 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
/** @type {import('webpack').Configuration} */
module.exports = {
entry: {
palette: path.resolve(__dirname, './test/javascript/static/test/testPalette'),
layout: path.resolve(__dirname, './test/javascript/static/test/testLayout'),
testingLayout: './test/javascript/static/test/testingLayout',
testingPallete: './test/javascript/static/test/testingPalette',
},
output: {
path: path.resolve(__dirname, 'dist', 'test'),
filename: '[name].test.js',
path: path.resolve(__dirname, 'dist', 'tests'),
filename: '[name].js',
publicPath: '',
},
mode: 'production',
optimization: {
splitChunks: {
chunks: 'all',
minSize: 2000000,
},
},
devtool: 'source-map',
module: {
rules: [
{

View File

@ -35,7 +35,7 @@ function web2D() {
const verdanaFont = require('./components/peer/svg/VerdanaFont').default; //eslint-disable-line
const point = require('./components/Point').default; //eslint-disable-line
global.web2d = {
const web2d = {
ElementPeer: elementPeer,
Element: element,
Workspace: workspace,
@ -68,7 +68,7 @@ function web2D() {
Point: point,
};
return global.web2d; //eslint-disable-line
return web2d; //eslint-disable-line
}
module.exports = web2D; //eslint-disable-line

4859
yarn.lock

File diff suppressed because it is too large Load Diff