mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-25 15:37:56 +01:00
Merge branch 'images'
Conflicts: mindplot/src/main/javascript/StandaloneActionDispatcher.js
This commit is contained in:
commit
45a190bbac
@ -140,6 +140,7 @@
|
|||||||
<include>Workspace.js</include>
|
<include>Workspace.js</include>
|
||||||
<include>ShrinkConnector.js</include>
|
<include>ShrinkConnector.js</include>
|
||||||
<include>DesignerKeyboard.js</include>
|
<include>DesignerKeyboard.js</include>
|
||||||
|
<include>TopicStyle.js</include>
|
||||||
<include>NodeGraph.js</include>
|
<include>NodeGraph.js</include>
|
||||||
<include>Topic.js</include>
|
<include>Topic.js</include>
|
||||||
<include>CentralTopic.js</include>
|
<include>CentralTopic.js</include>
|
||||||
|
@ -36,29 +36,11 @@ mindplot.CentralTopic = new Class({
|
|||||||
return this.getPosition();
|
return this.getPosition();
|
||||||
},
|
},
|
||||||
|
|
||||||
_getInnerPadding:function () {
|
|
||||||
return 11;
|
|
||||||
},
|
|
||||||
|
|
||||||
getTopicType:function () {
|
|
||||||
return mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE;
|
|
||||||
},
|
|
||||||
|
|
||||||
setCursor:function (type) {
|
setCursor:function (type) {
|
||||||
type = (type == 'move') ? 'default' : type;
|
type = (type == 'move') ? 'default' : type;
|
||||||
this.parent(type);
|
this.parent(type);
|
||||||
},
|
},
|
||||||
|
|
||||||
isConnectedToCentralTopic:function () {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
_defaultShapeType:function () {
|
|
||||||
return mindplot.model.TopicShape.ROUNDED_RECT;
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
updateTopicShape:function () {
|
updateTopicShape:function () {
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -70,28 +52,6 @@ mindplot.CentralTopic = new Class({
|
|||||||
this.setPosition(zeroPoint);
|
this.setPosition(zeroPoint);
|
||||||
},
|
},
|
||||||
|
|
||||||
_defaultText:function () {
|
|
||||||
return $msg('CENTRAL_TOPIC');
|
|
||||||
},
|
|
||||||
|
|
||||||
_defaultBackgroundColor:function () {
|
|
||||||
return "rgb(80,157,192)";
|
|
||||||
},
|
|
||||||
|
|
||||||
_defaultBorderColor:function () {
|
|
||||||
return "rgb(57,113,177)";
|
|
||||||
},
|
|
||||||
|
|
||||||
_defaultFontStyle:function () {
|
|
||||||
return {
|
|
||||||
font:"Verdana",
|
|
||||||
size:10,
|
|
||||||
style:"normal",
|
|
||||||
weight:"bold",
|
|
||||||
color:"#ffffff"
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
getShrinkConnector:function () {
|
getShrinkConnector:function () {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
@ -160,6 +160,48 @@ mindplot.Designer = new Class({
|
|||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
// Register mouse drag and drop event ...
|
||||||
|
function noopHandler(evt) {
|
||||||
|
evt.stopPropagation();
|
||||||
|
evt.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable drag events ...
|
||||||
|
Element.NativeEvents.dragenter = 2;
|
||||||
|
Element.NativeEvents.dragexit = 2;
|
||||||
|
Element.NativeEvents.dragover = 2;
|
||||||
|
Element.NativeEvents.drop = 2;
|
||||||
|
|
||||||
|
screenManager.addEvent('dragenter', noopHandler);
|
||||||
|
screenManager.addEvent('dragexit', noopHandler);
|
||||||
|
screenManager.addEvent('dragover', noopHandler);
|
||||||
|
screenManager.addEvent('drop', function (evt) {
|
||||||
|
evt.stopPropagation();
|
||||||
|
evt.preventDefault();
|
||||||
|
//
|
||||||
|
var files = evt.event.dataTransfer.files;
|
||||||
|
console.log(event);
|
||||||
|
|
||||||
|
var count = files.length;
|
||||||
|
|
||||||
|
// Only call the handler if 1 or more files was dropped.
|
||||||
|
if (count > 0) {
|
||||||
|
|
||||||
|
var model = this.getMindmap().createNode();
|
||||||
|
model.setImageSize(80, 43);
|
||||||
|
model.setMetadata("{'media':'video,'url':'http://www.youtube.com/watch?v=P3FrXftyuzw&feature=g-vrec&context=G2b4ab69RVAAAAAAAAAA'}");
|
||||||
|
model.setImageUrl("images/logo-small.png");
|
||||||
|
model.setShapeType(mindplot.model.TopicShape.IMAGE);
|
||||||
|
|
||||||
|
var position = screenManager.getWorkspaceMousePosition(evt);
|
||||||
|
model.setPosition(position.x, position.y);
|
||||||
|
model.setPosition(100, 100);
|
||||||
|
|
||||||
|
this._actionDispatcher.addTopics([model]);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_buildDragManager:function (workspace) {
|
_buildDragManager:function (workspace) {
|
||||||
@ -357,7 +399,7 @@ mindplot.Designer = new Class({
|
|||||||
|
|
||||||
// Exclude central topic ..
|
// Exclude central topic ..
|
||||||
topics = topics.filter(function (topic) {
|
topics = topics.filter(function (topic) {
|
||||||
return topic.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE
|
return !topic.isCentralTopic();
|
||||||
});
|
});
|
||||||
|
|
||||||
this._clipboard = topics.map(function (topic) {
|
this._clipboard = topics.map(function (topic) {
|
||||||
@ -684,7 +726,7 @@ mindplot.Designer = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_removeTopic:function (node) {
|
_removeTopic:function (node) {
|
||||||
if (node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (!node.isCentralTopic()) {
|
||||||
var parent = node._parent;
|
var parent = node._parent;
|
||||||
node.disconnect(this._workspace);
|
node.disconnect(this._workspace);
|
||||||
|
|
||||||
@ -714,14 +756,14 @@ mindplot.Designer = new Class({
|
|||||||
// If there are more than one node selected,
|
// If there are more than one node selected,
|
||||||
$notify($msg('ENTITIES_COULD_NOT_BE_DELETED'));
|
$notify($msg('ENTITIES_COULD_NOT_BE_DELETED'));
|
||||||
return;
|
return;
|
||||||
} else if (topics.length == 1 && topics[0].getTopicType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
} else if (topics.length == 1 && topics[0].isCentralTopic()) {
|
||||||
$notify($msg('CENTRAL_TOPIC_CAN_NOT_BE_DELETED'));
|
$notify($msg('CENTRAL_TOPIC_CAN_NOT_BE_DELETED'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the central topic has been selected, I must filter ir
|
// If the central topic has been selected, I must filter ir
|
||||||
var topicIds = topics.filter(function (topic) {
|
var topicIds = topics.filter(function (topic) {
|
||||||
return topic.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE
|
return !topic.isCentralTopic();
|
||||||
}).map(function (topic) {
|
}).map(function (topic) {
|
||||||
return topic.getId()
|
return topic.getId()
|
||||||
});
|
});
|
||||||
|
@ -241,7 +241,7 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
'right':function (event) {
|
'right':function (event) {
|
||||||
var node = model.selectedTopic();
|
var node = model.selectedTopic();
|
||||||
if (node) {
|
if (node) {
|
||||||
if (node.getTopicType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (node.isCentralTopic()) {
|
||||||
this._goToSideChild(designer, node, 'RIGHT');
|
this._goToSideChild(designer, node, 'RIGHT');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -263,7 +263,7 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
'left':function (event) {
|
'left':function (event) {
|
||||||
var node = model.selectedTopic();
|
var node = model.selectedTopic();
|
||||||
if (node) {
|
if (node) {
|
||||||
if (node.getTopicType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (node.isCentralTopic()) {
|
||||||
this._goToSideChild(designer, node, 'LEFT');
|
this._goToSideChild(designer, node, 'LEFT');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -285,7 +285,7 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
'up':function (event) {
|
'up':function (event) {
|
||||||
var node = model.selectedTopic();
|
var node = model.selectedTopic();
|
||||||
if (node) {
|
if (node) {
|
||||||
if (node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (!node.isCentralTopic()) {
|
||||||
this._goToBrother(designer, node, 'UP');
|
this._goToBrother(designer, node, 'UP');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -299,7 +299,7 @@ mindplot.DesignerKeyboard = new Class({
|
|||||||
'down':function (event) {
|
'down':function (event) {
|
||||||
var node = model.selectedTopic();
|
var node = model.selectedTopic();
|
||||||
if (node) {
|
if (node) {
|
||||||
if (node.getTopicType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (!node.isCentralTopic()) {
|
||||||
this._goToBrother(designer, node, 'DOWN');
|
this._goToBrother(designer, node, 'DOWN');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,248 +1,163 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright [2011] [wisemapping]
|
* Copyright [2011] [wisemapping]
|
||||||
*
|
*
|
||||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
* "powered by wisemapping" text requirement on every single page;
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the license at
|
* You may obtain a copy of the license at
|
||||||
*
|
*
|
||||||
* http://www.wisemapping.org/license
|
* http://www.wisemapping.org/license
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mindplot.MainTopic = new Class({
|
mindplot.MainTopic = new Class({
|
||||||
Extends:mindplot.Topic,
|
Extends:mindplot.Topic,
|
||||||
initialize:function (model, options) {
|
initialize:function (model, options) {
|
||||||
this.parent(model, options);
|
this.parent(model, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
INNER_RECT_ATTRIBUTES:{stroke:'0.5 solid #009900'},
|
INNER_RECT_ATTRIBUTES:{stroke:'0.5 solid #009900'},
|
||||||
|
|
||||||
_buildDragShape:function () {
|
_buildDragShape:function () {
|
||||||
var innerShape = this._buildShape(this.INNER_RECT_ATTRIBUTES, this.getShapeType());
|
var innerShape = this._buildShape(this.INNER_RECT_ATTRIBUTES, this.getShapeType());
|
||||||
var size = this.getSize();
|
var size = this.getSize();
|
||||||
innerShape.setSize(size.width, size.height);
|
innerShape.setSize(size.width, size.height);
|
||||||
innerShape.setPosition(0, 0);
|
innerShape.setPosition(0, 0);
|
||||||
innerShape.setOpacity(0.5);
|
innerShape.setOpacity(0.5);
|
||||||
innerShape.setCursor('default');
|
innerShape.setCursor('default');
|
||||||
innerShape.setVisibility(true);
|
innerShape.setVisibility(true);
|
||||||
|
|
||||||
var brColor = this.getBorderColor();
|
var brColor = this.getBorderColor();
|
||||||
innerShape.setAttribute("strokeColor", brColor);
|
innerShape.setAttribute("strokeColor", brColor);
|
||||||
|
|
||||||
var bgColor = this.getBackgroundColor();
|
var bgColor = this.getBackgroundColor();
|
||||||
innerShape.setAttribute("fillColor", bgColor);
|
innerShape.setAttribute("fillColor", bgColor);
|
||||||
|
|
||||||
// Create group ...
|
// Create group ...
|
||||||
var groupAttributes = {width:100, height:100, coordSizeWidth:100, coordSizeHeight:100};
|
var groupAttributes = {width:100, height:100, coordSizeWidth:100, coordSizeHeight:100};
|
||||||
var group = new web2d.Group(groupAttributes);
|
var group = new web2d.Group(groupAttributes);
|
||||||
group.appendChild(innerShape);
|
group.appendChild(innerShape);
|
||||||
|
|
||||||
// Add Text ...
|
// Add Text ...
|
||||||
if (this.getShapeType() != mindplot.model.TopicShape.IMAGE) {
|
if (this.getShapeType() != mindplot.model.TopicShape.IMAGE) {
|
||||||
var textShape = this._buildTextShape(true);
|
var textShape = this._buildTextShape(true);
|
||||||
var text = this.getText();
|
var text = this.getText();
|
||||||
textShape.setText(text);
|
textShape.setText(text);
|
||||||
textShape.setOpacity(0.5);
|
textShape.setOpacity(0.5);
|
||||||
group.appendChild(textShape);
|
group.appendChild(textShape);
|
||||||
}
|
}
|
||||||
return group;
|
return group;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateTopicShape:function (targetTopic, workspace) {
|
||||||
_defaultShapeType:function () {
|
// Change figure based on the connected topic ...
|
||||||
return mindplot.model.TopicShape.LINE;
|
var model = this.getModel();
|
||||||
},
|
var shapeType = model.getShapeType();
|
||||||
|
if (!targetTopic.isCentralTopic()) {
|
||||||
updateTopicShape:function (targetTopic, workspace) {
|
if (!$defined(shapeType)) {
|
||||||
// Change figure based on the connected topic ...
|
// Get the real shape type ...
|
||||||
var model = this.getModel();
|
shapeType = this.getShapeType();
|
||||||
var shapeType = model.getShapeType();
|
this._setShapeType(shapeType, false);
|
||||||
if (targetTopic.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
}
|
||||||
if (!$defined(shapeType)) {
|
}
|
||||||
// Get the real shape type ...
|
},
|
||||||
shapeType = this.getShapeType();
|
|
||||||
this._setShapeType(shapeType, false);
|
disconnect:function (workspace) {
|
||||||
}
|
this.parent(workspace);
|
||||||
}
|
var size = this.getSize();
|
||||||
},
|
|
||||||
|
var model = this.getModel();
|
||||||
disconnect:function (workspace) {
|
var shapeType = model.getShapeType();
|
||||||
this.parent(workspace);
|
if (!$defined(shapeType)) {
|
||||||
var size = this.getSize();
|
// Change figure ...
|
||||||
|
shapeType = this.getShapeType();
|
||||||
var model = this.getModel();
|
this._setShapeType(mindplot.model.TopicShape.ROUNDED_RECT, false);
|
||||||
var shapeType = model.getShapeType();
|
}
|
||||||
if (!$defined(shapeType)) {
|
var innerShape = this.getInnerShape();
|
||||||
// Change figure ...
|
innerShape.setVisibility(true);
|
||||||
shapeType = this.getShapeType();
|
},
|
||||||
this._setShapeType(mindplot.model.TopicShape.ROUNDED_RECT, false);
|
|
||||||
}
|
_updatePositionOnChangeSize:function (oldSize, newSize) {
|
||||||
var innerShape = this.getInnerShape();
|
|
||||||
innerShape.setVisibility(true);
|
var xOffset = Math.round((newSize.width - oldSize.width) / 2);
|
||||||
},
|
var pos = this.getPosition();
|
||||||
|
if ($defined(pos)) {
|
||||||
getTopicType:function () {
|
if (pos.x > 0) {
|
||||||
return "MainTopic";
|
pos.x = pos.x + xOffset;
|
||||||
},
|
} else {
|
||||||
|
pos.x = pos.x - xOffset;
|
||||||
_updatePositionOnChangeSize:function (oldSize, newSize) {
|
}
|
||||||
|
this.setPosition(pos);
|
||||||
var xOffset = Math.round((newSize.width - oldSize.width) / 2);
|
}
|
||||||
var pos = this.getPosition();
|
},
|
||||||
if ($defined(pos)) {
|
|
||||||
if (pos.x > 0) {
|
workoutIncomingConnectionPoint:function (sourcePosition) {
|
||||||
pos.x = pos.x + xOffset;
|
$assert(sourcePosition, 'sourcePoint can not be null');
|
||||||
} else {
|
var pos = this.getPosition();
|
||||||
pos.x = pos.x - xOffset;
|
var size = this.getSize();
|
||||||
}
|
|
||||||
this.setPosition(pos);
|
var isAtRight = mindplot.util.Shape.isAtRight(sourcePosition, pos);
|
||||||
}
|
var result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight);
|
||||||
},
|
if (this.getShapeType() == mindplot.model.TopicShape.LINE) {
|
||||||
|
result.y = result.y + (this.getSize().height / 2);
|
||||||
workoutIncomingConnectionPoint:function (sourcePosition) {
|
}
|
||||||
$assert(sourcePosition, 'sourcePoint can not be null');
|
|
||||||
var pos = this.getPosition();
|
// Move a little the position...
|
||||||
var size = this.getSize();
|
var offset = mindplot.Topic.CONNECTOR_WIDTH / 2;
|
||||||
|
if (this.getPosition().x > 0) {
|
||||||
var isAtRight = mindplot.util.Shape.isAtRight(sourcePosition, pos);
|
result.x = result.x + offset;
|
||||||
var result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight);
|
} else {
|
||||||
if (this.getShapeType() == mindplot.model.TopicShape.LINE) {
|
result.x = result.x - offset;
|
||||||
result.y = result.y + (this.getSize().height / 2);
|
}
|
||||||
}
|
|
||||||
|
result.x = Math.ceil(result.x);
|
||||||
// Move a little the position...
|
result.y = Math.ceil(result.y);
|
||||||
var offset = mindplot.Topic.CONNECTOR_WIDTH / 2;
|
return result;
|
||||||
if (this.getPosition().x > 0) {
|
|
||||||
result.x = result.x + offset;
|
},
|
||||||
} else {
|
|
||||||
result.x = result.x - offset;
|
workoutOutgoingConnectionPoint:function (targetPosition) {
|
||||||
}
|
$assert(targetPosition, 'targetPoint can not be null');
|
||||||
|
var pos = this.getPosition();
|
||||||
result.x = Math.ceil(result.x);
|
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, pos);
|
||||||
result.y = Math.ceil(result.y);
|
var size = this.getSize();
|
||||||
return result;
|
|
||||||
|
var result;
|
||||||
},
|
if (this.getShapeType() == mindplot.model.TopicShape.LINE) {
|
||||||
|
|
||||||
workoutOutgoingConnectionPoint:function (targetPosition) {
|
result = new core.Point();
|
||||||
$assert(targetPosition, 'targetPoint can not be null');
|
var groupPosition = this._elem2d.getPosition();
|
||||||
var pos = this.getPosition();
|
var innerShareSize = this.getInnerShape().getSize();
|
||||||
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, pos);
|
|
||||||
var size = this.getSize();
|
if (innerShareSize) {
|
||||||
|
var magicCorrectionNumber = 0.3;
|
||||||
var result;
|
if (!isAtRight) {
|
||||||
if (this.getShapeType() == mindplot.model.TopicShape.LINE) {
|
result.x = groupPosition.x + innerShareSize.width - magicCorrectionNumber;
|
||||||
|
} else {
|
||||||
result = new core.Point();
|
result.x = groupPosition.x + magicCorrectionNumber;
|
||||||
var groupPosition = this._elem2d.getPosition();
|
}
|
||||||
var innerShareSize = this.getInnerShape().getSize();
|
result.y = groupPosition.y + innerShareSize.height;
|
||||||
|
} else {
|
||||||
if (innerShareSize) {
|
// Hack: When the size has not being defined. This is because the node has not being added.
|
||||||
var magicCorrectionNumber = 0.3;
|
// Try to do our best ...
|
||||||
if (!isAtRight) {
|
if (!isAtRight) {
|
||||||
result.x = groupPosition.x + innerShareSize.width - magicCorrectionNumber;
|
result.x = pos.x + (size.width / 2);
|
||||||
} else {
|
} else {
|
||||||
result.x = groupPosition.x + magicCorrectionNumber;
|
result.x = pos.x - (size.width / 2);
|
||||||
}
|
}
|
||||||
result.y = groupPosition.y + innerShareSize.height;
|
result.y = pos.y + (size.height / 2);
|
||||||
} else {
|
}
|
||||||
// Hack: When the size has not being defined. This is because the node has not being added.
|
|
||||||
// Try to do our best ...
|
} else {
|
||||||
if (!isAtRight) {
|
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
||||||
result.x = pos.x + (size.width / 2);
|
}
|
||||||
} else {
|
return result;
|
||||||
result.x = pos.x - (size.width / 2);
|
}
|
||||||
}
|
|
||||||
result.y = pos.y + (size.height / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
_getInnerPadding:function () {
|
|
||||||
var result;
|
|
||||||
var parent = this.getModel().getParent();
|
|
||||||
if (parent && mindplot.model.INodeModel.MAIN_TOPIC_TYPE == parent.getType()) {
|
|
||||||
result = 3;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
result = 4;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
isConnectedToCentralTopic:function () {
|
|
||||||
var model = this.getModel();
|
|
||||||
var parent = model.getParent();
|
|
||||||
|
|
||||||
return parent && parent.getType() === mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE;
|
|
||||||
},
|
|
||||||
|
|
||||||
_defaultText:function () {
|
|
||||||
var targetTopic = this.getOutgoingConnectedTopic();
|
|
||||||
var result = "";
|
|
||||||
if ($defined(targetTopic)) {
|
|
||||||
if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
|
||||||
result = $msg('MAIN_TOPIC');
|
|
||||||
} else {
|
|
||||||
result = $msg('SUB_TOPIC');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result = $msg('ISOLATED_TOPIC');
|
|
||||||
;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
_defaultFontStyle:function () {
|
|
||||||
var targetTopic = this.getOutgoingConnectedTopic();
|
|
||||||
var result;
|
|
||||||
if ($defined(targetTopic)) {
|
|
||||||
if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
|
||||||
result = {
|
|
||||||
font:"Arial",
|
|
||||||
size:8,
|
|
||||||
style:"normal",
|
|
||||||
weight:"normal",
|
|
||||||
color:"rgb(82,92,97)"
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
result = {
|
|
||||||
font:"Arial",
|
|
||||||
size:6,
|
|
||||||
style:"normal",
|
|
||||||
weight:"normal",
|
|
||||||
color:"rgb(82,92,97)"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result = {
|
|
||||||
font:"Verdana",
|
|
||||||
size:8,
|
|
||||||
style:"normal",
|
|
||||||
weight:"normal",
|
|
||||||
color:"rgb(82,92,97)"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
_defaultBackgroundColor:function () {
|
|
||||||
return "rgb(224,229,239)";
|
|
||||||
},
|
|
||||||
|
|
||||||
_defaultBorderColor:function () {
|
|
||||||
return 'rgb(2,59,185)';
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
@ -29,7 +29,7 @@ mindplot.Topic = new Class({
|
|||||||
|
|
||||||
// Position a topic ....
|
// Position a topic ....
|
||||||
var pos = model.getPosition();
|
var pos = model.getPosition();
|
||||||
if (pos != null && model.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (pos != null && this.isCentralTopic()) {
|
||||||
this.setPosition(pos);
|
this.setPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ mindplot.Topic = new Class({
|
|||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
var result = model.getShapeType();
|
var result = model.getShapeType();
|
||||||
if (!$defined(result)) {
|
if (!$defined(result)) {
|
||||||
result = this._defaultShapeType();
|
result = mindplot.TopicStyle.defaultShapeType(this);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
@ -134,7 +134,7 @@ mindplot.Topic = new Class({
|
|||||||
this._setBorderColor(brColor, false);
|
this._setBorderColor(brColor, false);
|
||||||
|
|
||||||
// Define the pointer ...
|
// Define the pointer ...
|
||||||
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE && !this.isReadOnly()) {
|
if (!this.isCentralTopic() && !this.isReadOnly()) {
|
||||||
this._innerShape.setCursor('move');
|
this._innerShape.setCursor('move');
|
||||||
} else {
|
} else {
|
||||||
this._innerShape.setCursor('default');
|
this._innerShape.setCursor('default');
|
||||||
@ -259,7 +259,7 @@ mindplot.Topic = new Class({
|
|||||||
_buildIconGroup:function () {
|
_buildIconGroup:function () {
|
||||||
var textHeight = this.getTextShape().getFontHeight();
|
var textHeight = this.getTextShape().getFontHeight();
|
||||||
var result = new mindplot.IconGroup(this.getId(), textHeight);
|
var result = new mindplot.IconGroup(this.getId(), textHeight);
|
||||||
var padding = this._getInnerPadding();
|
var padding = mindplot.TopicStyle.getInnerPadding(this);
|
||||||
result.setPosition(padding, padding);
|
result.setPosition(padding, padding);
|
||||||
|
|
||||||
// Load topic features ...
|
// Load topic features ...
|
||||||
@ -334,7 +334,7 @@ mindplot.Topic = new Class({
|
|||||||
|
|
||||||
if (!readOnly) {
|
if (!readOnly) {
|
||||||
// Propagate mouse events ...
|
// Propagate mouse events ...
|
||||||
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (!this.isCentralTopic()) {
|
||||||
result.setCursor('move');
|
result.setCursor('move');
|
||||||
} else {
|
} else {
|
||||||
result.setCursor('default');
|
result.setCursor('default');
|
||||||
@ -344,10 +344,6 @@ mindplot.Topic = new Class({
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
_getInnerPadding:function () {
|
|
||||||
throw "this must be implemented";
|
|
||||||
},
|
|
||||||
|
|
||||||
setFontFamily:function (value, updateModel) {
|
setFontFamily:function (value, updateModel) {
|
||||||
var textShape = this.getTextShape();
|
var textShape = this.getTextShape();
|
||||||
textShape.setFontFamily(value);
|
textShape.setFontFamily(value);
|
||||||
@ -395,7 +391,7 @@ mindplot.Topic = new Class({
|
|||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
var result = model.getFontWeight();
|
var result = model.getFontWeight();
|
||||||
if (!$defined(result)) {
|
if (!$defined(result)) {
|
||||||
var font = this._defaultFontStyle();
|
var font = mindplot.TopicStyle.defaultFontStyle(this);
|
||||||
result = font.weight;
|
result = font.weight;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -405,7 +401,7 @@ mindplot.Topic = new Class({
|
|||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
var result = model.getFontFamily();
|
var result = model.getFontFamily();
|
||||||
if (!$defined(result)) {
|
if (!$defined(result)) {
|
||||||
var font = this._defaultFontStyle();
|
var font = mindplot.TopicStyle.defaultFontStyle(this);
|
||||||
result = font.font;
|
result = font.font;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -415,7 +411,7 @@ mindplot.Topic = new Class({
|
|||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
var result = model.getFontColor();
|
var result = model.getFontColor();
|
||||||
if (!$defined(result)) {
|
if (!$defined(result)) {
|
||||||
var font = this._defaultFontStyle();
|
var font = mindplot.TopicStyle.defaultFontStyle(this);
|
||||||
result = font.color;
|
result = font.color;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -425,7 +421,7 @@ mindplot.Topic = new Class({
|
|||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
var result = model.getFontStyle();
|
var result = model.getFontStyle();
|
||||||
if (!$defined(result)) {
|
if (!$defined(result)) {
|
||||||
var font = this._defaultFontStyle();
|
var font = mindplot.TopicStyle.defaultFontStyle(this);
|
||||||
result = font.style;
|
result = font.style;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -435,7 +431,7 @@ mindplot.Topic = new Class({
|
|||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
var result = model.getFontSize();
|
var result = model.getFontSize();
|
||||||
if (!$defined(result)) {
|
if (!$defined(result)) {
|
||||||
var font = this._defaultFontStyle();
|
var font = mindplot.TopicStyle.defaultFontStyle(this);
|
||||||
result = font.size;
|
result = font.size;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -452,7 +448,7 @@ mindplot.Topic = new Class({
|
|||||||
|
|
||||||
_setText:function (text, updateModel) {
|
_setText:function (text, updateModel) {
|
||||||
var textShape = this.getTextShape();
|
var textShape = this.getTextShape();
|
||||||
textShape.setText(text == null ? this._defaultText() : text);
|
textShape.setText(text == null ? mindplot.TopicStyle.defaultText(this) : text);
|
||||||
|
|
||||||
if ($defined(updateModel) && updateModel) {
|
if ($defined(updateModel) && updateModel) {
|
||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
@ -474,7 +470,7 @@ mindplot.Topic = new Class({
|
|||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
var result = model.getText();
|
var result = model.getText();
|
||||||
if (!$defined(result)) {
|
if (!$defined(result)) {
|
||||||
result = this._defaultText();
|
result = mindplot.TopicStyle.defaultText(this);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
@ -502,7 +498,7 @@ mindplot.Topic = new Class({
|
|||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
var result = model.getBackgroundColor();
|
var result = model.getBackgroundColor();
|
||||||
if (!$defined(result)) {
|
if (!$defined(result)) {
|
||||||
result = this._defaultBackgroundColor();
|
result = mindplot.TopicStyle.defaultBackgroundColor(this);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
@ -530,7 +526,7 @@ mindplot.Topic = new Class({
|
|||||||
var model = this.getModel();
|
var model = this.getModel();
|
||||||
var result = model.getBorderColor();
|
var result = model.getBorderColor();
|
||||||
if (!$defined(result)) {
|
if (!$defined(result)) {
|
||||||
result = this._defaultBorderColor();
|
result = mindplot.TopicStyle.defaultBorderColor(this);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
@ -822,7 +818,7 @@ mindplot.Topic = new Class({
|
|||||||
setBranchVisibility:function (value) {
|
setBranchVisibility:function (value) {
|
||||||
var current = this;
|
var current = this;
|
||||||
var parent = this;
|
var parent = this;
|
||||||
while (parent != null && parent.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
while (parent != null && !parent.isCentralTopic()) {
|
||||||
current = parent;
|
current = parent;
|
||||||
parent = current.getParent();
|
parent = current.getParent();
|
||||||
}
|
}
|
||||||
@ -1109,7 +1105,7 @@ mindplot.Topic = new Class({
|
|||||||
var elem = this.get2DElement();
|
var elem = this.get2DElement();
|
||||||
workspace.appendChild(elem);
|
workspace.appendChild(elem);
|
||||||
if (!this.isInWorkspace()) {
|
if (!this.isInWorkspace()) {
|
||||||
if (this.getType() != mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
|
if (!this.isCentralTopic()) {
|
||||||
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeAdded, this.getModel());
|
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.NodeAdded, this.getModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1152,7 +1148,7 @@ mindplot.Topic = new Class({
|
|||||||
var textHeight = textShape.getHeight();
|
var textHeight = textShape.getHeight();
|
||||||
textHeight = textHeight != 0 ? textHeight : 20;
|
textHeight = textHeight != 0 ? textHeight : 20;
|
||||||
|
|
||||||
var topicPadding = this._getInnerPadding();
|
var topicPadding = mindplot.TopicStyle.getInnerPadding(this);
|
||||||
|
|
||||||
// Adjust the icon size to the size of the text ...
|
// Adjust the icon size to the size of the text ...
|
||||||
var iconGroup = this.getOrBuildIconGroup();
|
var iconGroup = this.getOrBuildIconGroup();
|
||||||
@ -1214,7 +1210,13 @@ mindplot.Topic = new Class({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
isCentralTopic:function () {
|
||||||
|
return this.getModel().getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
132
mindplot/src/main/javascript/TopicStyle.js
Normal file
132
mindplot/src/main/javascript/TopicStyle.js
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2011] [wisemapping]
|
||||||
|
*
|
||||||
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
|
* "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
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
mindplot.TopicStyle = new Class({
|
||||||
|
Static:{
|
||||||
|
_getStyles:function (topic) {
|
||||||
|
$assert(topic, "topic can not be null");
|
||||||
|
|
||||||
|
var result;
|
||||||
|
if (topic.isCentralTopic()) {
|
||||||
|
result = mindplot.TopicStyle.STYLES.CENTRAL_TOPIC;
|
||||||
|
} else {
|
||||||
|
var targetTopic = topic.getOutgoingConnectedTopic();
|
||||||
|
if ($defined(targetTopic)) {
|
||||||
|
if (targetTopic.isCentralTopic()) {
|
||||||
|
result = mindplot.TopicStyle.STYLES.MAIN_TOPIC;
|
||||||
|
} else {
|
||||||
|
result = mindplot.TopicStyle.STYLES.SUB_TOPIC;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = mindplot.TopicStyle.STYLES.ISOLATED_TOPIC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
defaultText:function (topic) {
|
||||||
|
var msgKey = this._getStyles(topic).msgKey;
|
||||||
|
return $msg(msgKey);
|
||||||
|
},
|
||||||
|
|
||||||
|
defaultFontStyle:function (topic) {
|
||||||
|
return this._getStyles(topic).fontStyle;
|
||||||
|
},
|
||||||
|
|
||||||
|
defaultBackgroundColor:function (topic) {
|
||||||
|
return this._getStyles(topic).backgroundColor;
|
||||||
|
},
|
||||||
|
|
||||||
|
defaultBorderColor:function (topic) {
|
||||||
|
return this._getStyles(topic).borderColor;
|
||||||
|
},
|
||||||
|
|
||||||
|
getInnerPadding:function (topic) {
|
||||||
|
return this._getStyles(topic).innerPadding;
|
||||||
|
},
|
||||||
|
|
||||||
|
defaultShapeType:function (topic) {
|
||||||
|
return this._getStyles(topic).shapeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mindplot.TopicStyle.STYLES =
|
||||||
|
{
|
||||||
|
CENTRAL_TOPIC:{
|
||||||
|
borderColor:'rgb(57,113,177)',
|
||||||
|
backgroundColor:'rgb(80,157,192)',
|
||||||
|
fontStyle:{
|
||||||
|
font:"Verdana",
|
||||||
|
size:10,
|
||||||
|
style:"normal",
|
||||||
|
weight:"bold",
|
||||||
|
color:"#ffffff"
|
||||||
|
},
|
||||||
|
msgKey:'CENTRAL_TOPIC',
|
||||||
|
innerPadding:11,
|
||||||
|
shapeType:mindplot.model.TopicShape.ROUNDED_RECT
|
||||||
|
},
|
||||||
|
|
||||||
|
MAIN_TOPIC:{
|
||||||
|
borderColor:'rgb(2,59,185)',
|
||||||
|
backgroundColor:'rgb(224,229,239)',
|
||||||
|
fontStyle:{
|
||||||
|
font:"Arial",
|
||||||
|
size:8,
|
||||||
|
style:"normal",
|
||||||
|
weight:"normal",
|
||||||
|
color:"rgb(82,92,97)"
|
||||||
|
},
|
||||||
|
msgKey:'MAIN_TOPIC',
|
||||||
|
innerPadding:3,
|
||||||
|
shapeType:mindplot.model.TopicShape.LINE
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
SUB_TOPIC:{
|
||||||
|
borderColor:'rgb(2,59,185)',
|
||||||
|
backgroundColor:'rgb(224,229,239)',
|
||||||
|
fontStyle:{
|
||||||
|
font:"Arial",
|
||||||
|
size:6,
|
||||||
|
style:"normal",
|
||||||
|
weight:"normal",
|
||||||
|
color:"rgb(82,92,97)"
|
||||||
|
},
|
||||||
|
msgKey:'SUB_TOPIC',
|
||||||
|
innerPadding:3,
|
||||||
|
shapeType:mindplot.model.TopicShape.LINE
|
||||||
|
},
|
||||||
|
|
||||||
|
ISOLATED_TOPIC:{
|
||||||
|
borderColor:'rgb(2,59,185)',
|
||||||
|
backgroundColor:'rgb(224,229,239)',
|
||||||
|
fontStyle:{
|
||||||
|
font:"Verdana",
|
||||||
|
size:8,
|
||||||
|
style:"normal",
|
||||||
|
weight:"normal",
|
||||||
|
color:"rgb(82,92,97)"
|
||||||
|
},
|
||||||
|
msgKey:'ISOLATED_TOPIC',
|
||||||
|
innerPadding:4,
|
||||||
|
shapeType:mindplot.model.TopicShape.LINE
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -357,7 +357,7 @@ public class FreemindImporter
|
|||||||
* 3 -> 2
|
* 3 -> 2
|
||||||
* 4 -> 4
|
* 4 -> 4
|
||||||
*/
|
*/
|
||||||
private int calcFirstLevelOrder(@NotNull List<Object> freeChilden, @NotNull Node freeChild) {
|
private int calcFirstLevelOrder(@NotNull List<Object> freeChilden, @Nullable Node freeChild) {
|
||||||
final List<Node> nodes = new ArrayList<Node>();
|
final List<Node> nodes = new ArrayList<Node>();
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user