2021-07-16 11:41:58 -03:00
|
|
|
/*
|
2021-12-25 14:39:34 -08:00
|
|
|
* Copyright [2021] [wisemapping]
|
2021-07-16 11:41:58 -03:00
|
|
|
*
|
|
|
|
* 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-19 08:31:29 -08:00
|
|
|
import { Point } from '@wisemapping/web2d';
|
2021-12-19 00:44:08 -08:00
|
|
|
import { $assert } from '@wisemapping/core-js';
|
2021-12-02 00:41:56 +00:00
|
|
|
import Topic from './Topic';
|
|
|
|
import Shape from './util/Shape';
|
2021-07-16 11:41:58 -03:00
|
|
|
|
2021-12-04 15:39:20 -08:00
|
|
|
class CentralTopic extends Topic {
|
2022-02-05 21:28:35 -08:00
|
|
|
_buildDragShape() {
|
|
|
|
// Ignore ..
|
|
|
|
}
|
|
|
|
|
|
|
|
_registerEvents(): void {
|
2021-12-04 15:39:20 -08:00
|
|
|
super._registerEvents();
|
2021-07-16 11:41:58 -03:00
|
|
|
|
2021-12-04 15:39:20 -08:00
|
|
|
// This disable the drag of the central topic.
|
|
|
|
// But solves the problem of deselecting the nodes when the screen is clicked.
|
|
|
|
this.addEvent('mousedown', (event) => {
|
|
|
|
event.stopPropagation();
|
|
|
|
});
|
|
|
|
}
|
2021-07-16 11:41:58 -03:00
|
|
|
|
2022-02-05 21:28:35 -08:00
|
|
|
workoutIncomingConnectionPoint(): Point {
|
2021-12-04 15:39:20 -08:00
|
|
|
return this.getPosition();
|
|
|
|
}
|
2021-07-16 11:41:58 -03:00
|
|
|
|
2022-02-05 21:28:35 -08:00
|
|
|
setCursor(type: string) {
|
2021-12-04 15:39:20 -08:00
|
|
|
super.setCursor(type === 'move' ? 'default' : type);
|
|
|
|
}
|
2021-07-16 11:41:58 -03:00
|
|
|
|
2022-01-24 11:24:16 -08:00
|
|
|
updateTopicShape() {
|
|
|
|
// Overwite behaviour ...
|
|
|
|
}
|
2021-07-16 11:41:58 -03:00
|
|
|
|
2021-12-04 15:39:20 -08:00
|
|
|
_updatePositionOnChangeSize() {
|
|
|
|
// Center main topic ...
|
2021-12-19 08:31:29 -08:00
|
|
|
const zeroPoint = new Point(0, 0);
|
2021-12-04 15:39:20 -08:00
|
|
|
this.setPosition(zeroPoint);
|
|
|
|
}
|
2021-07-16 11:41:58 -03:00
|
|
|
|
2021-12-04 15:39:20 -08:00
|
|
|
/** */
|
|
|
|
getShrinkConnector() {
|
|
|
|
return null;
|
|
|
|
}
|
2021-07-16 11:41:58 -03:00
|
|
|
|
2021-12-04 15:39:20 -08:00
|
|
|
/** */
|
2022-02-05 21:28:35 -08:00
|
|
|
workoutOutgoingConnectionPoint(targetPosition: Point) {
|
2021-12-04 15:39:20 -08:00
|
|
|
$assert(targetPosition, 'targetPoint can not be null');
|
|
|
|
const pos = this.getPosition();
|
|
|
|
const isAtRight = Shape.isAtRight(targetPosition, pos);
|
|
|
|
const size = this.getSize();
|
|
|
|
return Shape.calculateRectConnectionPoint(pos, size, !isAtRight);
|
|
|
|
}
|
|
|
|
}
|
2021-07-16 11:41:58 -03:00
|
|
|
|
|
|
|
export default CentralTopic;
|