mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2025-01-10 20:25:12 +01:00
28 lines
759 B
TypeScript
28 lines
759 B
TypeScript
import { $assert } from '@wisemapping/core-js';
|
|
|
|
import CentralTopic from './CentralTopic';
|
|
import MainTopic from './MainTopic';
|
|
import NodeModel from './model/NodeModel';
|
|
import Topic from './Topic';
|
|
|
|
class TopicFactory {
|
|
static create(nodeModel: NodeModel, options: object): Topic {
|
|
$assert(nodeModel, 'Model can not be null');
|
|
|
|
const type = nodeModel.getType();
|
|
$assert(type, 'Node model type can not be null');
|
|
|
|
let result: Topic;
|
|
if (type === 'CentralTopic') {
|
|
result = new CentralTopic(nodeModel, options);
|
|
} else if (type === 'MainTopic') {
|
|
result = new MainTopic(nodeModel, options);
|
|
} else {
|
|
$assert(false, `unsupported node type:${type}`);
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
export default TopicFactory;
|