mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-10 17:33:24 +01:00
Mindplot module migration
This commit is contained in:
parent
d515e0bb57
commit
0567dedb88
@ -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
|
||||
}
|
||||
|
@ -15,25 +15,25 @@
|
||||
* 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*/{
|
||||
|
||||
Extends:Topic,
|
||||
const CentralTopic = new Class(
|
||||
/** @lends CentralTopic*/ {
|
||||
Extends: Topic,
|
||||
/**
|
||||
* @extends mindplot.Topic
|
||||
* @constructs
|
||||
* @param model
|
||||
* @param options
|
||||
*/
|
||||
initialize:function (model, options) {
|
||||
initialize: function (model, options) {
|
||||
this.parent(model, options);
|
||||
},
|
||||
|
||||
_registerEvents:function () {
|
||||
_registerEvents: function () {
|
||||
this.parent();
|
||||
|
||||
// This disable the drag of the central topic. But solves the problem of deselecting the nodes when the screen is clicked.
|
||||
@ -43,41 +43,39 @@ const CentralTopic = new Class(/** @lends CentralTopic*/{
|
||||
},
|
||||
|
||||
/** */
|
||||
workoutIncomingConnectionPoint:function () {
|
||||
workoutIncomingConnectionPoint: function () {
|
||||
return this.getPosition();
|
||||
},
|
||||
|
||||
/** */
|
||||
setCursor:function (type) {
|
||||
type = (type == 'move') ? 'default' : type;
|
||||
setCursor: function (type) {
|
||||
type = type == 'move' ? 'default' : type;
|
||||
this.parent(type);
|
||||
},
|
||||
|
||||
/** */
|
||||
updateTopicShape:function () {
|
||||
|
||||
},
|
||||
|
||||
_updatePositionOnChangeSize:function () {
|
||||
updateTopicShape: function () {},
|
||||
|
||||
_updatePositionOnChangeSize: function () {
|
||||
// Center main topic ...
|
||||
var zeroPoint = new core.Point(0, 0);
|
||||
this.setPosition(zeroPoint);
|
||||
},
|
||||
|
||||
/** */
|
||||
getShrinkConnector:function () {
|
||||
getShrinkConnector: function () {
|
||||
return null;
|
||||
},
|
||||
|
||||
/** */
|
||||
workoutOutgoingConnectionPoint:function (targetPosition) {
|
||||
workoutOutgoingConnectionPoint: function (targetPosition) {
|
||||
$assert(targetPosition, 'targetPoint can not be null');
|
||||
var pos = this.getPosition();
|
||||
var isAtRight = Shape.isAtRight(targetPosition, pos);
|
||||
var size = this.getSize();
|
||||
return Shape.calculateRectConnectionPoint(pos, size, !isAtRight);
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
export default CentralTopic;
|
||||
|
@ -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({
|
||||
|
@ -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
|
||||
|
@ -31,7 +31,7 @@ const Messages = new Class({
|
||||
},
|
||||
});
|
||||
|
||||
global.$msg = function (key) {
|
||||
const $msg = function (key) {
|
||||
if (!Messages.__bundle) {
|
||||
Messages.init('en');
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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({
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
||||
/**
|
||||
@ -29,18 +30,18 @@ const AbstractBasicSorter = new Class(/** @lends AbstractBasicSorter */{
|
||||
* @param {} node
|
||||
* @return the height of a node and its children if existing and not shrunken
|
||||
*/
|
||||
computeChildrenIdByHeights: function(treeSet, node) {
|
||||
computeChildrenIdByHeights: function (treeSet, node) {
|
||||
var result = {};
|
||||
this._computeChildrenHeight(treeSet, node, result);
|
||||
return result;
|
||||
},
|
||||
|
||||
_getVerticalPadding: function() {
|
||||
_getVerticalPadding: function () {
|
||||
return AbstractBasicSorter.INTERNODE_VERTICAL_PADDING;
|
||||
},
|
||||
|
||||
_computeChildrenHeight : function(treeSet, node, heightCache) {
|
||||
var height = node.getSize().height + (this._getVerticalPadding() * 2); // 2* Top and down padding;
|
||||
_computeChildrenHeight: function (treeSet, node, heightCache) {
|
||||
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);
|
||||
}
|
||||
@ -62,20 +67,20 @@ const AbstractBasicSorter = new Class(/** @lends AbstractBasicSorter */{
|
||||
return result;
|
||||
},
|
||||
|
||||
_getSortedChildren:function(treeSet, node) {
|
||||
_getSortedChildren: function (treeSet, node) {
|
||||
var result = treeSet.getChildren(node);
|
||||
result.sort(function(a, b) {
|
||||
return a.getOrder() - b.getOrder()
|
||||
result.sort(function (a, b) {
|
||||
return a.getOrder() - b.getOrder();
|
||||
});
|
||||
return result;
|
||||
},
|
||||
|
||||
_getRelativeDirection: function(reference, position) {
|
||||
_getRelativeDirection: function (reference, position) {
|
||||
var offset = position.x - reference.x;
|
||||
return offset >= 0 ? 1 : -1;
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
);
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -17,15 +17,14 @@
|
||||
*/
|
||||
const AbstractBasicSorter = require('./AbstractBasicSorter').default;
|
||||
|
||||
const BalancedSorter = new Class(/** @lends BalancedSorter */{
|
||||
Extends:AbstractBasicSorter,
|
||||
const BalancedSorter = new Class(
|
||||
/** @lends BalancedSorter */ {
|
||||
Extends: AbstractBasicSorter,
|
||||
/**
|
||||
* @constructs
|
||||
* @extends mindplot.layout.AbstractBasicSorter
|
||||
*/
|
||||
initialize:function () {
|
||||
|
||||
},
|
||||
initialize: function () {},
|
||||
|
||||
/**
|
||||
* @param {} graph
|
||||
@ -35,31 +34,53 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
|
||||
* @param {Boolean} free
|
||||
* @return an array with order and position
|
||||
*/
|
||||
predict:function (graph, parent, node, position, free) {
|
||||
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}];
|
||||
return [0, { x: xPos, y: position.y }];
|
||||
}
|
||||
|
||||
var rootNode = graph.getRootNode(parent);
|
||||
|
||||
// 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,30 +110,47 @@ 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 ...
|
||||
var result = null;
|
||||
var last = children.getLast();
|
||||
position = position || {x:last.getPosition().x, y:last.getPosition().y + 1};
|
||||
position = position || { x: last.getPosition().x, y: last.getPosition().y + 1 };
|
||||
_.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;
|
||||
result = [child.getOrder() + 2, {x:cpos.x, y:cpos.y + yOffset}];
|
||||
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 }];
|
||||
}
|
||||
});
|
||||
|
||||
// Position wasn't below any node, so it must be inserted above
|
||||
if (!result) {
|
||||
var first = children[0];
|
||||
result = [position.x > 0 ? 0 : 1, {
|
||||
x:first.getPosition().x,
|
||||
y:first.getPosition().y - first.getSize().height - BalancedSorter.INTERNODE_VERTICAL_PADDING * 2
|
||||
}];
|
||||
result = [
|
||||
position.x > 0 ? 0 : 1,
|
||||
{
|
||||
x: first.getPosition().x,
|
||||
y:
|
||||
first.getPosition().y -
|
||||
first.getSize().height -
|
||||
BalancedSorter.INTERNODE_VERTICAL_PADDING * 2,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -118,7 +162,7 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
|
||||
* @param {} child
|
||||
* @param {} order
|
||||
*/
|
||||
insert:function (treeSet, parent, child, order) {
|
||||
insert: function (treeSet, parent, child, order) {
|
||||
var children = this._getChildrenForOrder(parent, treeSet, order);
|
||||
|
||||
// If no children, return 0 or 1 depending on the side
|
||||
@ -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);
|
||||
},
|
||||
|
||||
@ -147,7 +191,7 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
|
||||
* @param {} treeSet
|
||||
* @param {} node
|
||||
*/
|
||||
detach:function (treeSet, node) {
|
||||
detach: function (treeSet, node) {
|
||||
var parent = treeSet.getParent(node);
|
||||
// Filter nodes on one side..
|
||||
var children = this._getChildrenForOrder(parent, treeSet, node.getOrder());
|
||||
@ -165,18 +209,23 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
|
||||
* @param {} node
|
||||
* @return offsets
|
||||
*/
|
||||
computeOffsets:function (treeSet, node) {
|
||||
$assert(treeSet, "treeSet can no be null.");
|
||||
$assert(node, "node can no be null.");
|
||||
computeOffsets: function (treeSet, node) {
|
||||
$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,12 +256,16 @@ 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};
|
||||
result[heights[i].id] = { x: xOffset, y: yOffset };
|
||||
}
|
||||
return result;
|
||||
},
|
||||
@ -222,7 +275,7 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
|
||||
* @param {} node
|
||||
* @throw will throw an error if order elements are missing
|
||||
*/
|
||||
verify:function (treeSet, node) {
|
||||
verify: function (treeSet, node) {
|
||||
// Check that all is consistent ...
|
||||
var children = this._getChildrenForOrder(node, treeSet, node.getOrder());
|
||||
|
||||
@ -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()
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@ -240,27 +301,28 @@ const BalancedSorter = new Class(/** @lends BalancedSorter */{
|
||||
* @param {} child
|
||||
* @return the direction of the child within the treeSet
|
||||
*/
|
||||
getChildDirection:function (treeSet, child) {
|
||||
getChildDirection: function (treeSet, child) {
|
||||
return child.getOrder() % 2 == 0 ? 1 : -1;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {String} the print name of this class
|
||||
*/
|
||||
toString:function () {
|
||||
return "Balanced Sorter";
|
||||
toString: function () {
|
||||
return 'Balanced Sorter';
|
||||
},
|
||||
|
||||
_getChildrenForOrder:function (parent, graph, order) {
|
||||
_getChildrenForOrder: function (parent, graph, order) {
|
||||
return this._getSortedChildren(graph, parent).filter(function (child) {
|
||||
return child.getOrder() % 2 == order % 2;
|
||||
});
|
||||
},
|
||||
|
||||
_getVerticalPadding:function () {
|
||||
_getVerticalPadding: function () {
|
||||
return BalancedSorter.INTERNODE_VERTICAL_PADDING;
|
||||
},
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -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
|
||||
@ -30,10 +31,10 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
|
||||
* @throws will throw an error if the root node id is null or undefined
|
||||
* @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");
|
||||
var position = position || {x:0, y:0};
|
||||
initialize: function (rootNodeId, rootSize) {
|
||||
$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();
|
||||
this._layout = new OriginalLayout(this._treeSet);
|
||||
@ -48,8 +49,8 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
|
||||
* @param size
|
||||
* @throws will throw an error if id is null or undefined
|
||||
*/
|
||||
updateNodeSize: function(id, size) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
updateNodeSize: function (id, size) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
|
||||
var node = this._treeSet.find(id);
|
||||
node.setSize(size);
|
||||
@ -62,9 +63,9 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
|
||||
* @throws will throw an error if value is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
updateShrinkState: function(id, value) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
$assert($defined(value), "value can not be null");
|
||||
updateShrinkState: function (id, value) {
|
||||
$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);
|
||||
@ -76,7 +77,7 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
|
||||
* @param id
|
||||
* @return {@link RootedTreeSet}.find(id)
|
||||
*/
|
||||
find: function(id) {
|
||||
find: function (id) {
|
||||
return this._treeSet.find(id);
|
||||
},
|
||||
|
||||
@ -88,16 +89,16 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
|
||||
* @throws will throw an error if the position's x property is null or undefined
|
||||
* @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");
|
||||
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');
|
||||
|
||||
var node = this._treeSet.find(id);
|
||||
// @Todo: this should not be here. This is broking the isolated node support...
|
||||
// node.setFree(true);
|
||||
// node.setFreeDisplacement({x:position.x - node.getPosition().x, y:position.y - node.getPosition().y});
|
||||
// node.setFree(true);
|
||||
// node.setFreeDisplacement({x:position.x - node.getPosition().x, y:position.y - node.getPosition().y});
|
||||
node.setPosition(position);
|
||||
},
|
||||
|
||||
@ -110,10 +111,10 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
|
||||
* @throws will throw an error if order is null or undefined
|
||||
* @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");
|
||||
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');
|
||||
|
||||
this._layout.connectNode(parentId, childId, order);
|
||||
|
||||
@ -125,8 +126,8 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
disconnectNode: function(id) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
disconnectNode: function (id) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
this._layout.disconnectNode(id);
|
||||
|
||||
return this;
|
||||
@ -139,8 +140,8 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
addNode:function(id, size, position) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
addNode: function (id, size, position) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
var result = this._layout.createNode(id, size, position, 'topic');
|
||||
this._treeSet.add(result);
|
||||
|
||||
@ -153,8 +154,8 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
|
||||
* @throws will throw an error if id is null or undefined
|
||||
* @return this
|
||||
*/
|
||||
removeNode: function(id) {
|
||||
$assert($defined(id), "id can not be null");
|
||||
removeNode: function (id) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
var node = this._treeSet.find(id);
|
||||
|
||||
// Is It connected ?
|
||||
@ -176,21 +177,21 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
|
||||
* @param {Boolean=} free true specifies free node positioning
|
||||
* @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");
|
||||
predict: function (parentId, nodeId, position, free) {
|
||||
$assert($defined(parentId), 'parentId can not be null');
|
||||
|
||||
var parent = this._treeSet.find(parentId);
|
||||
var node = nodeId ? this._treeSet.find(nodeId) : null;
|
||||
var sorter = parent.getSorter();
|
||||
|
||||
var result = sorter.predict(this._treeSet, parent, node, position, free);
|
||||
return {order:result[0],position:result[1]};
|
||||
return { order: result[0], position: result[1] };
|
||||
},
|
||||
|
||||
/**
|
||||
* logs dump to console
|
||||
*/
|
||||
dump: function() {
|
||||
dump: function () {
|
||||
console.log(this._treeSet.dump());
|
||||
},
|
||||
|
||||
@ -200,12 +201,19 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
|
||||
* @throws will throw an error if containerId is null or undefined
|
||||
* @return canvas
|
||||
*/
|
||||
plot: function(containerId, size) {
|
||||
$assert(containerId, "containerId cannot be null");
|
||||
size = size || {width:200,height:200};
|
||||
plot: function (containerId, size) {
|
||||
$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;
|
||||
@ -216,37 +224,41 @@ const LayoutManager = new Class(/** @lends LayoutManager */{
|
||||
* @param fireEvents
|
||||
* @return this
|
||||
*/
|
||||
layout: function(fireEvents) {
|
||||
layout: function (fireEvents) {
|
||||
// File repositioning ...
|
||||
this._layout.layout();
|
||||
|
||||
// Collect changes ...
|
||||
this._collectChanges();
|
||||
|
||||
if ($(fireEvents).length>0 || fireEvents) {
|
||||
if ($(fireEvents).length > 0 || fireEvents) {
|
||||
this._flushEvents();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_flushEvents: function() {
|
||||
_.each(this._events, function(event) {
|
||||
_flushEvents: function () {
|
||||
_.each(
|
||||
this._events,
|
||||
function (event) {
|
||||
this.fireEvent('change', event);
|
||||
}, this);
|
||||
},
|
||||
this
|
||||
);
|
||||
this._events = [];
|
||||
},
|
||||
|
||||
_collectChanges: function(nodes) {
|
||||
if (!nodes)
|
||||
nodes = this._treeSet.getTreeRoots();
|
||||
_collectChanges: function (nodes) {
|
||||
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) {
|
||||
var event = this._events.some(function (event) {
|
||||
return event.id == id;
|
||||
});
|
||||
if (!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;
|
||||
|
@ -16,7 +16,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const Node = new Class(/** @lends Node */{
|
||||
const Node = new Class(
|
||||
/** @lends Node */ {
|
||||
/**
|
||||
* @constructs
|
||||
* @param id
|
||||
@ -28,11 +29,11 @@ const Node = new Class(/** @lends Node */{
|
||||
* @throws will throw an error if position is null or undefined
|
||||
* @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");
|
||||
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');
|
||||
|
||||
this._id = id;
|
||||
this._sorter = sorter;
|
||||
@ -44,48 +45,51 @@ const Node = new Class(/** @lends Node */{
|
||||
},
|
||||
|
||||
/** */
|
||||
getId:function () {
|
||||
getId: function () {
|
||||
return this._id;
|
||||
},
|
||||
|
||||
/** */
|
||||
setFree:function (value) {
|
||||
setFree: function (value) {
|
||||
this._setProperty('free', value);
|
||||
},
|
||||
|
||||
/** */
|
||||
isFree:function () {
|
||||
isFree: function () {
|
||||
return this._getProperty('free');
|
||||
},
|
||||
|
||||
/** */
|
||||
hasFreeChanged:function () {
|
||||
hasFreeChanged: function () {
|
||||
return this._isPropertyChanged('free');
|
||||
},
|
||||
|
||||
/** */
|
||||
hasFreeDisplacementChanged:function () {
|
||||
hasFreeDisplacementChanged: function () {
|
||||
return this._isPropertyChanged('freeDisplacement');
|
||||
},
|
||||
|
||||
/** */
|
||||
setShrunken:function (value) {
|
||||
setShrunken: function (value) {
|
||||
this._setProperty('shrink', value);
|
||||
},
|
||||
|
||||
/** */
|
||||
areChildrenShrunken:function () {
|
||||
areChildrenShrunken: function () {
|
||||
return this._getProperty('shrink');
|
||||
},
|
||||
|
||||
/** */
|
||||
setOrder:function (order) {
|
||||
$assert(typeof order === 'number' && isFinite(order), "Order can not be null. Value:" + order);
|
||||
setOrder: function (order) {
|
||||
$assert(
|
||||
typeof order === 'number' && isFinite(order),
|
||||
'Order can not be null. Value:' + order
|
||||
);
|
||||
this._setProperty('order', order);
|
||||
},
|
||||
|
||||
/** */
|
||||
resetPositionState:function () {
|
||||
resetPositionState: function () {
|
||||
var prop = this._properties['position'];
|
||||
if (prop) {
|
||||
prop.hasChanged = false;
|
||||
@ -93,7 +97,7 @@ const Node = new Class(/** @lends Node */{
|
||||
},
|
||||
|
||||
/** */
|
||||
resetOrderState:function () {
|
||||
resetOrderState: function () {
|
||||
var prop = this._properties['order'];
|
||||
if (prop) {
|
||||
prop.hasChanged = false;
|
||||
@ -101,7 +105,7 @@ const Node = new Class(/** @lends Node */{
|
||||
},
|
||||
|
||||
/** */
|
||||
resetFreeState:function () {
|
||||
resetFreeState: function () {
|
||||
var prop = this._properties['freeDisplacement'];
|
||||
if (prop) {
|
||||
prop.hasChanged = false;
|
||||
@ -109,82 +113,89 @@ const Node = new Class(/** @lends Node */{
|
||||
},
|
||||
|
||||
/** */
|
||||
getOrder:function () {
|
||||
getOrder: function () {
|
||||
return this._getProperty('order');
|
||||
},
|
||||
|
||||
/** */
|
||||
hasOrderChanged:function () {
|
||||
hasOrderChanged: function () {
|
||||
return this._isPropertyChanged('order');
|
||||
},
|
||||
|
||||
/** */
|
||||
hasPositionChanged:function () {
|
||||
hasPositionChanged: function () {
|
||||
return this._isPropertyChanged('position');
|
||||
},
|
||||
|
||||
/** */
|
||||
hasSizeChanged:function () {
|
||||
hasSizeChanged: function () {
|
||||
return this._isPropertyChanged('size');
|
||||
},
|
||||
|
||||
/** */
|
||||
getPosition:function () {
|
||||
getPosition: function () {
|
||||
return this._getProperty('position');
|
||||
},
|
||||
|
||||
/** */
|
||||
setSize:function (size) {
|
||||
$assert($defined(size), "Size can not be null");
|
||||
setSize: function (size) {
|
||||
$assert($defined(size), 'Size can not be null');
|
||||
this._setProperty('size', Object.clone(size));
|
||||
},
|
||||
|
||||
/** */
|
||||
getSize:function () {
|
||||
getSize: function () {
|
||||
return this._getProperty('size');
|
||||
},
|
||||
|
||||
/** */
|
||||
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");
|
||||
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');
|
||||
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));
|
||||
},
|
||||
|
||||
/** */
|
||||
resetFreeDisplacement:function () {
|
||||
this._setProperty('freeDisplacement', {x:0, y:0});
|
||||
resetFreeDisplacement: function () {
|
||||
this._setProperty('freeDisplacement', { x: 0, y: 0 });
|
||||
},
|
||||
|
||||
/** */
|
||||
getFreeDisplacement:function () {
|
||||
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");
|
||||
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');
|
||||
|
||||
// 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);
|
||||
},
|
||||
|
||||
_setProperty:function (key, value) {
|
||||
_setProperty: function (key, value) {
|
||||
var prop = this._properties[key];
|
||||
if (!prop) {
|
||||
prop = {
|
||||
hasChanged:false,
|
||||
value:null,
|
||||
oldValue:null
|
||||
hasChanged: false,
|
||||
value: null,
|
||||
oldValue: null,
|
||||
};
|
||||
}
|
||||
|
||||
@ -197,26 +208,42 @@ const Node = new Class(/** @lends Node */{
|
||||
this._properties[key] = prop;
|
||||
},
|
||||
|
||||
_getProperty:function (key) {
|
||||
_getProperty: function (key) {
|
||||
var prop = this._properties[key];
|
||||
return $defined(prop) ? prop.value : null;
|
||||
},
|
||||
|
||||
_isPropertyChanged:function (key) {
|
||||
_isPropertyChanged: function (key) {
|
||||
var prop = this._properties[key];
|
||||
return prop ? prop.hasChanged : false;
|
||||
},
|
||||
|
||||
/** */
|
||||
getSorter:function () {
|
||||
getSorter: function () {
|
||||
return this._sorter;
|
||||
},
|
||||
|
||||
/** @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() + "]";
|
||||
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() +
|
||||
']'
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
);
|
||||
|
||||
export default Node;
|
||||
|
@ -15,35 +15,35 @@
|
||||
* 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
|
||||
*/
|
||||
initialize:function (treeSet) {
|
||||
initialize: function (treeSet) {
|
||||
this._treeSet = treeSet;
|
||||
},
|
||||
|
||||
/** */
|
||||
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");
|
||||
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');
|
||||
|
||||
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) {
|
||||
|
||||
connectNode: function (parentId, childId, order) {
|
||||
var parent = this._treeSet.find(parentId);
|
||||
var child = this._treeSet.find(childId);
|
||||
|
||||
@ -59,10 +59,10 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
|
||||
},
|
||||
|
||||
/** */
|
||||
disconnectNode:function (nodeId) {
|
||||
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);
|
||||
@ -80,10 +80,11 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
|
||||
},
|
||||
|
||||
/** */
|
||||
layout:function () {
|
||||
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) {
|
||||
|
||||
_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,12 +156,16 @@ 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) {
|
||||
_calculateAlignOffset: function (node, child, heightById) {
|
||||
if (child.isFree()) {
|
||||
return 0;
|
||||
}
|
||||
@ -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 {
|
||||
@ -184,28 +203,40 @@ const OriginalLayout = new Class(/** @lends OriginalLayout */{
|
||||
return offset;
|
||||
},
|
||||
|
||||
_branchIsTaller:function (node, heightById) {
|
||||
return heightById[node.getId()] > (node.getSize().height + node.getSorter()._getVerticalPadding() * 2);
|
||||
_branchIsTaller: function (node, heightById) {
|
||||
return (
|
||||
heightById[node.getId()] >
|
||||
node.getSize().height + node.getSorter()._getVerticalPadding() * 2
|
||||
);
|
||||
},
|
||||
|
||||
_fixOverlapping:function (node, heightById) {
|
||||
_fixOverlapping: function (node, heightById) {
|
||||
var children = this._treeSet.getChildren(node);
|
||||
|
||||
if (node.isFree()) {
|
||||
this._shiftBranches(node, heightById);
|
||||
}
|
||||
|
||||
_.each(children, function (child) {
|
||||
_.each(
|
||||
children,
|
||||
function (child) {
|
||||
this._fixOverlapping(child, heightById);
|
||||
}, this);
|
||||
},
|
||||
this
|
||||
);
|
||||
},
|
||||
|
||||
_shiftBranches:function (node, heightById) {
|
||||
_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,21 +246,29 @@ 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) {
|
||||
_branchesOverlap: function (branchA, branchB, heightById) {
|
||||
// a branch doesn't really overlap with itself
|
||||
if (branchA == branchB) {
|
||||
return false;
|
||||
@ -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}
|
||||
|
@ -16,9 +16,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
const RootedTreeSet = new Class(
|
||||
/** @lends RootedTreeSet */ {
|
||||
/** @constructs */
|
||||
initialize:function () {
|
||||
initialize: function () {
|
||||
this._rootNodes = [];
|
||||
},
|
||||
|
||||
@ -26,17 +27,17 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @param root
|
||||
* @throws will throw an error if root is null or undefined
|
||||
*/
|
||||
setRoot:function (root) {
|
||||
setRoot: function (root) {
|
||||
$assert(root, 'root can not be null');
|
||||
this._rootNodes.push(this._decodate(root));
|
||||
},
|
||||
|
||||
/** getter */
|
||||
getTreeRoots:function () {
|
||||
getTreeRoots: function () {
|
||||
return this._rootNodes;
|
||||
},
|
||||
|
||||
_decodate:function (node) {
|
||||
_decodate: function (node) {
|
||||
node._children = [];
|
||||
return node;
|
||||
},
|
||||
@ -47,19 +48,21 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @throws will throw an error if node with id already exists
|
||||
* @throws will throw an error if node has been added already
|
||||
*/
|
||||
add:function (node) {
|
||||
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
|
||||
*/
|
||||
remove:function (nodeId) {
|
||||
remove: function (nodeId) {
|
||||
$assert($defined(nodeId), 'nodeId can not be null');
|
||||
var node = this.find(nodeId);
|
||||
this._rootNodes.erase(node);
|
||||
@ -72,13 +75,16 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @throws will throw an error if childId is null or undefined
|
||||
* @throws will throw an error if node with id childId is already a child of parent
|
||||
*/
|
||||
connect:function (parentId, childId) {
|
||||
connect: function (parentId, childId) {
|
||||
$assert($defined(parentId), 'parent can not be null');
|
||||
$assert($defined(childId), 'child can not be null');
|
||||
|
||||
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;
|
||||
@ -90,10 +96,10 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @throws will throw an error if nodeId is null or undefined
|
||||
* @throws will throw an error if node is not connected
|
||||
*/
|
||||
disconnect:function (nodeId) {
|
||||
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);
|
||||
@ -107,7 +113,7 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @throws will throw an error if node cannot be found
|
||||
* @return node
|
||||
*/
|
||||
find:function (id, validate) {
|
||||
find: function (id, validate) {
|
||||
$assert($defined(id), 'id can not be null');
|
||||
|
||||
var graphs = this._rootNodes;
|
||||
@ -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) {
|
||||
_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;
|
||||
@ -148,7 +154,7 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @throws will throw an error if nodeId is null or undefined
|
||||
* @return children
|
||||
*/
|
||||
getChildren:function (node) {
|
||||
getChildren: function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return node._children;
|
||||
},
|
||||
@ -158,8 +164,8 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @throws will throw an error if node is null or undefined
|
||||
* @return root node or the provided node, if it has no parent
|
||||
*/
|
||||
getRootNode:function (node) {
|
||||
$assert(node, "node cannot be null");
|
||||
getRootNode: function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
var parent = this.getParent(node);
|
||||
if ($defined(parent)) {
|
||||
return this.getRootNode(parent);
|
||||
@ -172,12 +178,12 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @param node
|
||||
* @throws will throw an error if node is null or undefined
|
||||
* @return {Array} ancestors*/
|
||||
getAncestors:function (node) {
|
||||
getAncestors: function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return this._getAncestors(this.getParent(node), []);
|
||||
},
|
||||
|
||||
_getAncestors:function (node, ancestors) {
|
||||
_getAncestors: function (node, ancestors) {
|
||||
var result = ancestors;
|
||||
if (node) {
|
||||
result.push(node);
|
||||
@ -191,7 +197,7 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @throws will throw an error if node is null or undefined
|
||||
* @return {Array} siblings
|
||||
*/
|
||||
getSiblings:function (node) {
|
||||
getSiblings: function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
if (!$defined(node._parent)) {
|
||||
return [];
|
||||
@ -207,12 +213,12 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @throws will throw an error if node is null or undefined
|
||||
* @return {Boolean} whether the node has a single path to a single leaf (no branching)
|
||||
*/
|
||||
hasSinglePathToSingleLeaf:function (node) {
|
||||
hasSinglePathToSingleLeaf: function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return this._hasSinglePathToSingleLeaf(node);
|
||||
},
|
||||
|
||||
_hasSinglePathToSingleLeaf:function (node) {
|
||||
_hasSinglePathToSingleLeaf: function (node) {
|
||||
var children = this.getChildren(node);
|
||||
|
||||
if (children.length == 1) {
|
||||
@ -225,7 +231,7 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
/**
|
||||
* @param node
|
||||
* @return {Boolean} whether the node is the start of a subbranch*/
|
||||
isStartOfSubBranch:function (node) {
|
||||
isStartOfSubBranch: function (node) {
|
||||
return this.getSiblings(node).length > 0 && this.getChildren(node).length == 1;
|
||||
},
|
||||
|
||||
@ -234,7 +240,7 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @throws will throw an error if node is null or undefined
|
||||
* @return {Boolean} whether the node is a leaf
|
||||
*/
|
||||
isLeaf:function (node) {
|
||||
isLeaf: function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return this.getChildren(node).length == 0;
|
||||
},
|
||||
@ -244,7 +250,7 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @throws will throw an error if node is null or undefined
|
||||
* @return parent
|
||||
*/
|
||||
getParent:function (node) {
|
||||
getParent: function (node) {
|
||||
$assert(node, 'node cannot be null');
|
||||
return node._parent;
|
||||
},
|
||||
@ -252,22 +258,22 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
/**
|
||||
* @return result
|
||||
*/
|
||||
dump:function () {
|
||||
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";
|
||||
_dump: function (node, indent) {
|
||||
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;
|
||||
@ -276,7 +282,7 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
/**
|
||||
* @param canvas
|
||||
*/
|
||||
plot:function (canvas) {
|
||||
plot: function (canvas) {
|
||||
var branches = this._rootNodes;
|
||||
for (var i = 0; i < branches.length; i++) {
|
||||
var branch = branches[i];
|
||||
@ -284,24 +290,71 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
}
|
||||
},
|
||||
|
||||
_plot:function (canvas, node, root) {
|
||||
_plot: function (canvas, node, root) {
|
||||
var children = this.getChildren(node);
|
||||
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++) {
|
||||
@ -314,8 +367,7 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @param node
|
||||
* @param position
|
||||
*/
|
||||
updateBranchPosition:function (node, 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);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@ -335,9 +386,9 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @param xOffset
|
||||
* @param yOffset
|
||||
*/
|
||||
shiftBranchPosition:function (node, xOffset, yOffset) {
|
||||
shiftBranchPosition: function (node, xOffset, yOffset) {
|
||||
var position = node.getPosition();
|
||||
node.setPosition({x:position.x + xOffset, y:position.y + yOffset});
|
||||
node.setPosition({ x: position.x + xOffset, y: position.y + yOffset });
|
||||
|
||||
var children = this.getChildren(node);
|
||||
var me = this;
|
||||
@ -351,12 +402,18 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @param yOffset
|
||||
* @return siblings in the offset (vertical) direction, i.e. with lower or higher order, respectively
|
||||
*/
|
||||
getSiblingsInVerticalDirection:function (node, yOffset) {
|
||||
getSiblingsInVerticalDirection: function (node, yOffset) {
|
||||
// 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;
|
||||
});
|
||||
|
||||
@ -373,7 +430,7 @@ const RootedTreeSet = new Class(/** @lends RootedTreeSet */{
|
||||
* @return branches of the root node on the same side as the given node's, in the given
|
||||
* vertical direction
|
||||
*/
|
||||
getBranchesInVerticalDirection:function (node, yOffset) {
|
||||
getBranchesInVerticalDirection: function (node, yOffset) {
|
||||
// direct descendants of the root that do not contain the node and are on the same side
|
||||
// and on the direction of the offset
|
||||
var rootNode = this.getRootNode(node);
|
||||
@ -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;
|
||||
|
@ -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.
|
||||
@ -37,39 +36,64 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
|
||||
* @param free Free drag or not
|
||||
* @return {*}
|
||||
*/
|
||||
predict:function (graph, parent, node, position, free) {
|
||||
|
||||
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}];
|
||||
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
|
||||
x: parentChild.getPosition().x,
|
||||
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
|
||||
x: parentChild.getPosition().x,
|
||||
y:
|
||||
parentChild.getPosition().y +
|
||||
(nodeAfter.getPosition().y - parentChild.getPosition().y) / 2,
|
||||
};
|
||||
|
||||
return [order, position];
|
||||
}
|
||||
}
|
||||
@ -128,8 +170,11 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
|
||||
// Position wasn't below any node, so it must be fitted above the first
|
||||
var first = parentChildren[0];
|
||||
var position = {
|
||||
x:first.getPosition().x,
|
||||
y:first.getPosition().y - first.getSize().height - SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2
|
||||
x: first.getPosition().x,
|
||||
y:
|
||||
first.getPosition().y -
|
||||
first.getSize().height -
|
||||
SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2,
|
||||
};
|
||||
return [0, position];
|
||||
},
|
||||
@ -141,9 +186,12 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
|
||||
* @param order
|
||||
* @throws will throw an error if the order is not strictly continuous
|
||||
*/
|
||||
insert:function (treeSet, parent, child, order) {
|
||||
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++) {
|
||||
@ -157,11 +205,11 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
|
||||
* @param treeSet
|
||||
* @param node
|
||||
* @throws will throw an error if the node is in the wrong position*/
|
||||
detach:function (treeSet, node) {
|
||||
detach: function (treeSet, node) {
|
||||
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++) {
|
||||
@ -182,17 +230,24 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
|
||||
* value, is null or undefined
|
||||
* @return offsets
|
||||
*/
|
||||
computeOffsets:function (treeSet, node) {
|
||||
$assert(treeSet, "treeSet can no be null.");
|
||||
$assert(node, "node can no be null.");
|
||||
computeOffsets: function (treeSet, node) {
|
||||
$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,12 +264,16 @@ 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};
|
||||
result[heights[i].id] = { x: xOffset, y: yOffset };
|
||||
}
|
||||
return result;
|
||||
},
|
||||
@ -224,12 +283,12 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
|
||||
* @param node
|
||||
* @throws will throw an error if order elements are missing
|
||||
*/
|
||||
verify:function (treeSet, node) {
|
||||
verify: function (treeSet, node) {
|
||||
// Check that all is consistent ...
|
||||
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');
|
||||
}
|
||||
},
|
||||
|
||||
@ -237,9 +296,9 @@ const SymmetricSorter = new Class(/** @lends SymmetricSorter */{
|
||||
* @param treeSet
|
||||
* @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");
|
||||
getChildDirection: function (treeSet, child) {
|
||||
$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";
|
||||
toString: function () {
|
||||
return 'Symmetric Sorter';
|
||||
},
|
||||
|
||||
_getVerticalPadding:function () {
|
||||
_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;
|
||||
|
76
packages/mindplot/lib/components/libraries/mootools/mootools-core-1.4.5.js
vendored
Normal file
76
packages/mindplot/lib/components/libraries/mootools/mootools-core-1.4.5.js
vendored
Normal 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);}};})();
|
6382
packages/mindplot/lib/components/libraries/mootools/mootools-core-1.6.0.js
vendored
Normal file
6382
packages/mindplot/lib/components/libraries/mootools/mootools-core-1.6.0.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -421,5 +421,5 @@ INodeModel._nextUUID = function () {
|
||||
};
|
||||
INodeModel._uuid = 0;
|
||||
|
||||
export default INodeModel;
|
||||
export { TopicShape };
|
||||
export default INodeModel;
|
||||
|
@ -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,
|
||||
};
|
||||
|
7
packages/mindplot/lib/components/util/index.js
Normal file
7
packages/mindplot/lib/components/util/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
const fadeEffect = require('./FadeEffect').default;
|
||||
const shape = require('./Shape').default;
|
||||
|
||||
export const Utils = {
|
||||
FadeEffect: fadeEffect,
|
||||
Shape: shape,
|
||||
};
|
@ -18,47 +18,46 @@
|
||||
const ToolbarPaneItem = require('./ToolbarPaneItem').default;
|
||||
|
||||
const ColorPalettePanel = new Class({
|
||||
Extends:ToolbarPaneItem,
|
||||
Extends: ToolbarPaneItem,
|
||||
|
||||
initialize:function (buttonId, model, baseUrl) {
|
||||
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 () {
|
||||
|
||||
_load: function () {
|
||||
if (!ColorPalettePanel._panelContent) {
|
||||
|
||||
// Load all the CSS styles ...
|
||||
$('<link>')
|
||||
.appendTo($('head'))
|
||||
.attr({type : 'text/css', rel : 'stylesheet'})
|
||||
.attr({ type: 'text/css', rel: 'stylesheet' })
|
||||
.attr('href', this._baseUrl + '/colorPalette.css');
|
||||
|
||||
// Load panel html fragment ...
|
||||
var result;
|
||||
$.ajax({
|
||||
url:this._baseUrl + '/colorPalette.html',
|
||||
method:'get',
|
||||
async:false,
|
||||
success:function (responseText) {
|
||||
url: `${this._baseUrl}/colorPalette.html`,
|
||||
method: 'GET',
|
||||
async: false,
|
||||
success: function (responseText) {
|
||||
result = responseText;
|
||||
},
|
||||
error:function () {
|
||||
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');
|
||||
buildPanel: function () {
|
||||
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();
|
||||
});
|
||||
@ -76,18 +75,20 @@ const ColorPalettePanel = new Class({
|
||||
return content;
|
||||
},
|
||||
|
||||
_updateSelectedItem:function () {
|
||||
_updateSelectedItem: function () {
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -46,4 +46,5 @@ const $notify = function (msg) {
|
||||
toolbarNotifier.logMessage(msg);
|
||||
};
|
||||
|
||||
export { $notify };
|
||||
export default ToolbarNotifier;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div id="basicTest" style="display: none;">
|
||||
<h1>Basic Tests</h1>
|
||||
|
||||
<h3>testAligned:</h3>
|
||||
@ -79,9 +72,9 @@
|
||||
<h3>testReconnectSingleNode:</h3>
|
||||
<div id="testReconnectSingleNode1" 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>
|
||||
|
||||
<h3>testBalanced:</h3>
|
||||
@ -110,9 +103,9 @@
|
||||
<div id="testBalancedNodeDragPredict1"></div>
|
||||
<div id="testBalancedNodeDragPredict2"></div>
|
||||
<div id="testBalancedNodeDragPredict3"></div>
|
||||
</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>
|
||||
@ -126,9 +119,9 @@
|
||||
|
||||
<h3>testSymmetricDragPredict:</h3>
|
||||
<div id="testSymmetricDragPredict1"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="freeTest" style="display: none">
|
||||
<div id="freeTest" style="display: none;">
|
||||
<h1>Free Positioning Tests</h1>
|
||||
|
||||
<h3>testFreePosition:</h3>
|
||||
@ -175,6 +168,7 @@
|
||||
<h3>testFreeOverlap:</h3>
|
||||
<div id="testFreeOverlap1" class="col"></div>
|
||||
<div id="testFreeOverlap2" class="col"></div>
|
||||
</div>
|
||||
</body>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -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>
|
||||
|
@ -17,6 +17,9 @@
|
||||
*/
|
||||
const TestSuite = require('./TestSuite').default;
|
||||
|
||||
const Mindplot = require('../../../../lib/mindplot');
|
||||
const mindplot = Mindplot();
|
||||
|
||||
const BalancedTestSuite = new Class({
|
||||
Extends: TestSuite,
|
||||
|
||||
|
@ -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,
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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');
|
||||
|
14
packages/mindplot/test/javascript/static/testing.html
Normal file
14
packages/mindplot/test/javascript/static/testing.html
Normal 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>
|
@ -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: [
|
||||
{
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user