mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
- Refactor node properties to topics.
This commit is contained in:
parent
7bbcd82488
commit
d2f9749d61
@ -140,6 +140,7 @@
|
||||
<include>Workspace.js</include>
|
||||
<include>ShrinkConnector.js</include>
|
||||
<include>DesignerKeyboard.js</include>
|
||||
<include>TopicStyle.js</include>
|
||||
<include>NodeGraph.js</include>
|
||||
<include>Topic.js</include>
|
||||
<include>CentralTopic.js</include>
|
||||
|
@ -36,20 +36,11 @@ mindplot.CentralTopic = new Class({
|
||||
return this.getPosition();
|
||||
},
|
||||
|
||||
_getInnerPadding:function () {
|
||||
return 11;
|
||||
},
|
||||
|
||||
setCursor:function (type) {
|
||||
type = (type == 'move') ? 'default' : type;
|
||||
this.parent(type);
|
||||
},
|
||||
|
||||
_defaultShapeType:function () {
|
||||
return mindplot.model.TopicShape.ROUNDED_RECT;
|
||||
},
|
||||
|
||||
|
||||
updateTopicShape:function () {
|
||||
|
||||
},
|
||||
@ -61,28 +52,6 @@ mindplot.CentralTopic = new Class({
|
||||
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 () {
|
||||
return null;
|
||||
},
|
||||
|
@ -55,11 +55,6 @@ mindplot.MainTopic = new Class({
|
||||
return group;
|
||||
},
|
||||
|
||||
|
||||
_defaultShapeType:function () {
|
||||
return mindplot.model.TopicShape.LINE;
|
||||
},
|
||||
|
||||
updateTopicShape:function (targetTopic, workspace) {
|
||||
// Change figure based on the connected topic ...
|
||||
var model = this.getModel();
|
||||
@ -163,74 +158,6 @@ mindplot.MainTopic = new Class({
|
||||
result = mindplot.util.Shape.calculateRectConnectionPoint(pos, size, isAtRight, true);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
_getInnerPadding:function () {
|
||||
var result;
|
||||
var parent = this.getModel().getParent();
|
||||
if (parent && !parent.isCentralTopic()) {
|
||||
result = 3;
|
||||
}
|
||||
else {
|
||||
result = 4;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
_defaultText:function () {
|
||||
var targetTopic = this.getOutgoingConnectedTopic();
|
||||
var result = "";
|
||||
if ($defined(targetTopic)) {
|
||||
if (targetTopic.isCentralTopic()) {
|
||||
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.isCentralTopic()) {
|
||||
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)';
|
||||
}
|
||||
|
||||
});
|
@ -107,7 +107,7 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
var result = model.getShapeType();
|
||||
if (!$defined(result)) {
|
||||
result = this._defaultShapeType();
|
||||
result = mindplot.TopicStyle.defaultShapeType(this);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
@ -259,7 +259,7 @@ mindplot.Topic = new Class({
|
||||
_buildIconGroup:function () {
|
||||
var textHeight = this.getTextShape().getFontHeight();
|
||||
var result = new mindplot.IconGroup(this.getId(), textHeight);
|
||||
var padding = this._getInnerPadding();
|
||||
var padding = mindplot.TopicStyle.getInnerPadding(this);
|
||||
result.setPosition(padding, padding);
|
||||
|
||||
// Load topic features ...
|
||||
@ -350,10 +350,6 @@ mindplot.Topic = new Class({
|
||||
return result;
|
||||
},
|
||||
|
||||
_getInnerPadding:function () {
|
||||
throw "this must be implemented";
|
||||
},
|
||||
|
||||
setFontFamily:function (value, updateModel) {
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setFontFamily(value);
|
||||
@ -401,7 +397,7 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
var result = model.getFontWeight();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
var font = mindplot.TopicStyle.defaultFontStyle(this);
|
||||
result = font.weight;
|
||||
}
|
||||
return result;
|
||||
@ -411,7 +407,7 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
var result = model.getFontFamily();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
var font = mindplot.TopicStyle.defaultFontStyle(this);
|
||||
result = font.font;
|
||||
}
|
||||
return result;
|
||||
@ -421,7 +417,7 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
var result = model.getFontColor();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
var font = mindplot.TopicStyle.defaultFontStyle(this);
|
||||
result = font.color;
|
||||
}
|
||||
return result;
|
||||
@ -431,7 +427,7 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
var result = model.getFontStyle();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
var font = mindplot.TopicStyle.defaultFontStyle(this);
|
||||
result = font.style;
|
||||
}
|
||||
return result;
|
||||
@ -441,7 +437,7 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
var result = model.getFontSize();
|
||||
if (!$defined(result)) {
|
||||
var font = this._defaultFontStyle();
|
||||
var font = mindplot.TopicStyle.defaultFontStyle(this);
|
||||
result = font.size;
|
||||
}
|
||||
return result;
|
||||
@ -458,7 +454,7 @@ mindplot.Topic = new Class({
|
||||
|
||||
_setText:function (text, updateModel) {
|
||||
var textShape = this.getTextShape();
|
||||
textShape.setText(text == null ? this._defaultText() : text);
|
||||
textShape.setText(text == null ? mindplot.TopicStyle.defaultText(this) : text);
|
||||
|
||||
if ($defined(updateModel) && updateModel) {
|
||||
var model = this.getModel();
|
||||
@ -480,7 +476,7 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
var result = model.getText();
|
||||
if (!$defined(result)) {
|
||||
result = this._defaultText();
|
||||
result = mindplot.TopicStyle.defaultText(this);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
@ -508,7 +504,7 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
var result = model.getBackgroundColor();
|
||||
if (!$defined(result)) {
|
||||
result = this._defaultBackgroundColor();
|
||||
result = mindplot.TopicStyle.defaultBackgroundColor(this);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
@ -536,7 +532,7 @@ mindplot.Topic = new Class({
|
||||
var model = this.getModel();
|
||||
var result = model.getBorderColor();
|
||||
if (!$defined(result)) {
|
||||
result = this._defaultBorderColor();
|
||||
result = mindplot.TopicStyle.defaultBorderColor(this);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
@ -1154,7 +1150,7 @@ mindplot.Topic = new Class({
|
||||
var textHeight = textShape.getHeight();
|
||||
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 ...
|
||||
var iconGroup = this.getOrBuildIconGroup();
|
||||
|
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
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user