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

132 lines
3.4 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.
*/
2021-12-04 01:11:17 +01:00
import { $assert, $defined } from '@wisemapping/core-js';
import { TopicShape } from './model/INodeModel';
2021-07-16 16:41:58 +02:00
const TopicStyle = new Class({});
2021-07-16 16:41:58 +02:00
TopicStyle._getStyles = function _getStyles(topic) {
$assert(topic, 'topic can not be null');
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;
2021-10-05 02:05:34 +02:00
} else {
result = TopicStyle.STYLES.SUB_TOPIC;
2021-10-05 02:05:34 +02:00
}
} else {
result = TopicStyle.STYLES.ISOLATED_TOPIC;
}
}
return result;
};
2021-07-16 16:41:58 +02:00
TopicStyle.defaultText = function defaultText(topic) {
const { msgKey } = this._getStyles(topic);
return $msg(msgKey);
};
2021-07-16 16:41:58 +02:00
TopicStyle.defaultFontStyle = function defaultFontStyle(topic) {
return this._getStyles(topic).fontStyle;
};
2021-07-16 16:41:58 +02:00
TopicStyle.defaultBackgroundColor = function defaultBackgroundColor(topic) {
return this._getStyles(topic).backgroundColor;
};
2021-07-16 16:41:58 +02:00
TopicStyle.defaultBorderColor = function defaultBorderColor(topic) {
return this._getStyles(topic).borderColor;
};
2021-07-16 16:41:58 +02:00
TopicStyle.getInnerPadding = function getInnerPadding(topic) {
return this._getStyles(topic).innerPadding;
};
2021-07-16 16:41:58 +02:00
TopicStyle.defaultShapeType = function defaultShapeType(topic) {
return this._getStyles(topic).shapeType;
};
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;