wisemapping-frontend/packages/mindplot/lib/components/TopicStyle.js

133 lines
3.3 KiB
JavaScript
Raw Normal View History

2021-07-16 16:41:58 +02:00
/*
* 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.
*/
const { TopicShape } = require('./model/INodeModel');
const TopicStyle = new Class({
2021-10-05 02:05:34 +02:00
Static: {
_getStyles(topic) {
$assert(topic, 'topic can not be null');
2021-07-16 16:41:58 +02:00
2021-10-05 02:05:34 +02:00
let result;
if (topic.isCentralTopic()) {
result = TopicStyle.STYLES.CENTRAL_TOPIC;
} else {
const targetTopic = topic.getOutgoingConnectedTopic();
if ($defined(targetTopic)) {
if (targetTopic.isCentralTopic()) {
result = TopicStyle.STYLES.MAIN_TOPIC;
} else {
result = TopicStyle.STYLES.SUB_TOPIC;
}
} else {
result = TopicStyle.STYLES.ISOLATED_TOPIC;
}
}
return result;
},
2021-07-16 16:41:58 +02:00
2021-10-05 02:05:34 +02:00
defaultText(topic) {
const { msgKey } = this._getStyles(topic);
return $msg(msgKey);
},
2021-07-16 16:41:58 +02:00
2021-10-05 02:05:34 +02:00
defaultFontStyle(topic) {
return this._getStyles(topic).fontStyle;
},
2021-07-16 16:41:58 +02:00
2021-10-05 02:05:34 +02:00
defaultBackgroundColor(topic) {
return this._getStyles(topic).backgroundColor;
},
2021-07-16 16:41:58 +02:00
2021-10-05 02:05:34 +02:00
defaultBorderColor(topic) {
return this._getStyles(topic).borderColor;
},
2021-07-16 16:41:58 +02:00
2021-10-05 02:05:34 +02:00
getInnerPadding(topic) {
return this._getStyles(topic).innerPadding;
},
2021-07-16 16:41:58 +02:00
2021-10-05 02:05:34 +02:00
defaultShapeType(topic) {
return this._getStyles(topic).shapeType;
2021-07-16 16:41:58 +02:00
},
2021-10-05 02:05:34 +02:00
},
2021-07-16 16:41:58 +02:00
});
TopicStyle.STYLES = {
2021-10-05 02:05:34 +02:00
CENTRAL_TOPIC: {
borderColor: 'rgb(57,113,177)',
backgroundColor: 'rgb(80,157,192)',
fontStyle: {
font: 'Verdana',
size: 10,
style: 'normal',
weight: 'bold',
color: '#ffffff',
2021-07-16 16:41:58 +02:00
},
2021-10-05 02:05:34 +02:00
msgKey: 'CENTRAL_TOPIC',
innerPadding: 11,
shapeType: TopicShape.ROUNDED_RECT,
},
2021-07-16 16:41:58 +02:00
2021-10-05 02:05:34 +02:00
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)',
2021-07-16 16:41:58 +02:00
},
2021-10-05 02:05:34 +02:00
msgKey: 'MAIN_TOPIC',
innerPadding: 3,
shapeType: TopicShape.LINE,
},
2021-07-16 16:41:58 +02:00
2021-10-05 02:05:34 +02:00
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)',
2021-07-16 16:41:58 +02:00
},
2021-10-05 02:05:34 +02:00
msgKey: 'SUB_TOPIC',
innerPadding: 3,
shapeType: TopicShape.LINE,
},
2021-07-16 16:41:58 +02:00
2021-10-05 02:05:34 +02:00
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)',
2021-07-16 16:41:58 +02:00
},
2021-10-05 02:05:34 +02:00
msgKey: 'ISOLATED_TOPIC',
innerPadding: 4,
shapeType: TopicShape.LINE,
},
2021-07-16 16:41:58 +02:00
};
export default TopicStyle;