Remove '* as web2d' import

This commit is contained in:
Paulo Gustavo Veiga 2021-12-19 08:31:29 -08:00
parent 38f4144c67
commit c97fa80925
19 changed files with 89 additions and 90 deletions

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as web2d from '@wisemapping/web2d';
import { Point } from '@wisemapping/web2d';
import { $assert } from '@wisemapping/core-js';
import Topic from './Topic';
import Shape from './util/Shape';
@ -42,11 +42,11 @@ class CentralTopic extends Topic {
}
/** */
updateTopicShape() {}
updateTopicShape() { }
_updatePositionOnChangeSize() {
// Center main topic ...
const zeroPoint = new web2d.Point(0, 0);
const zeroPoint = new Point(0, 0);
this.setPosition(zeroPoint);
}

View File

@ -17,7 +17,7 @@
*/
import { $assert, $defined } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
import { Point, CurvedLine, PolyLine, Line } from '@wisemapping/web2d';
import INodeModel, { TopicShape } from './model/INodeModel';
import TopicConfig from './TopicConfig';
@ -53,7 +53,7 @@ class ConnectionLine {
const srcPos = sourceNode.workoutOutgoingConnectionPoint(targetNode.getPosition());
const destPos = targetNode.workoutIncomingConnectionPoint(sourceNode.getPosition());
const deltaX = (srcPos.x - destPos.x) / 3;
return [new web2d.Point(deltaX, 0), new web2d.Point(-deltaX, 0)];
return [new Point(deltaX, 0), new Point(-deltaX, 0)];
}
_createLine(lineType, defaultStyle) {
@ -65,17 +65,17 @@ class ConnectionLine {
let line = null;
switch (lineType) {
case ConnectionLine.POLYLINE:
line = new web2d.PolyLine();
line = new PolyLine();
break;
case ConnectionLine.CURVED:
line = new web2d.CurvedLine();
line = new CurvedLine();
break;
case ConnectionLine.SIMPLE_CURVED:
line = new web2d.CurvedLine();
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
line = new CurvedLine();
line.setStyle(CurvedLine.SIMPLE_LINE);
break;
default:
line = new web2d.Line();
line = new Line();
break;
}
return line;
@ -109,7 +109,7 @@ class ConnectionLine {
line2d.setFrom(tPos.x, tPos.y);
line2d.setTo(sPos.x, sPos.y);
if (line2d.getType() == 'CurvedLine') {
if (line2d.getType() === 'CurvedLine') {
const ctrlPoints = this._getCtrlPoints(this._sourceTopic, this._targetTopic);
line2d.setSrcControlPoint(ctrlPoints[0]);
line2d.setDestControlPoint(ctrlPoints[1]);

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as web2d from '@wisemapping/web2d';
import { Elipse, Line, Point } from '@wisemapping/web2d';
import { $defined } from '@wisemapping/core-js';
import Shape from './util/Shape';
@ -23,7 +23,7 @@ import ActionDispatcher from './ActionDispatcher';
class ControlPoint {
constructor() {
const control1 = new web2d.Elipse({
const control1 = new Elipse({
width: 6,
height: 6,
stroke: '1 solid #6589de',
@ -32,7 +32,7 @@ class ControlPoint {
});
control1.setCursor('pointer');
const control2 = new web2d.Elipse({
const control2 = new Elipse({
width: 6,
height: 6,
stroke: '1 solid #6589de',
@ -43,8 +43,8 @@ class ControlPoint {
this._controlPointsController = [control1, control2];
this._controlLines = [
new web2d.Line({ strokeColor: '#6589de', strokeWidth: 1, opacity: 0.3 }),
new web2d.Line({ strokeColor: '#6589de', strokeWidth: 1, opacity: 0.3 }),
new Line({ strokeColor: '#6589de', strokeWidth: 1, opacity: 0.3 }),
new Line({ strokeColor: '#6589de', strokeWidth: 1, opacity: 0.3 }),
];
this._isBinded = false;
@ -112,17 +112,17 @@ class ControlPoint {
);
}
_removeLine() {}
_removeLine() { }
_mouseDown(event, point, me) {
if (!this._isBinded) {
this._isBinded = true;
this._mouseMoveFunction = function (event) {
this._mouseMoveFunction = function mouseMoveFunction(event) {
me._mouseMoveEvent(event, point, me);
};
this._workspace.getScreenManager().addEvent('mousemove', this._mouseMoveFunction);
this._mouseUpFunction = function (event) {
this._mouseUpFunction = function mouseUpFunction(event) {
me._mouseUp(event, point, me);
};
this._workspace.getScreenManager().addEvent('mouseup', this._mouseUpFunction);
@ -140,11 +140,11 @@ class ControlPoint {
if (point == 0) {
cords = Shape.calculateRelationShipPointCoordinates(this._line.getSourceTopic(), pos);
this._line.setFrom(cords.x, cords.y);
this._line.setSrcControlPoint(new web2d.Point(pos.x - cords.x, pos.y - cords.y));
this._line.setSrcControlPoint(new Point(pos.x - cords.x, pos.y - cords.y));
} else {
cords = Shape.calculateRelationShipPointCoordinates(this._line.getTargetTopic(), pos);
this._line.setTo(cords.x, cords.y);
this._line.setDestControlPoint(new web2d.Point(pos.x - cords.x, pos.y - cords.y));
this._line.setDestControlPoint(new Point(pos.x - cords.x, pos.y - cords.y));
}
this._controls[point].x = pos.x - cords.x;

View File

@ -503,9 +503,9 @@ class Designer extends Events {
/**
* @private
* @param {mindplot.Topic} topic the parent topic of the child to create the NodeModel for
* @param {web2d.Point} mousePos the mouse position
* @return {mindplot.NodeModel} the node model for the new child
* @param {Topic} topic the parent topic of the child to create the NodeModel for
* @param {Point} mousePos the mouse position
* @return {NodeModel} the node model for the new child
*/
_createChildModel(topic, mousePos) {
// Create a new node ...

View File

@ -16,7 +16,7 @@
* limitations under the License.
*/
import { $assert, $defined } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
import { Point, CurvedLine, Rect } from '@wisemapping/web2d';
import DragTopicConfig from './DragTopicConfig';
import Shape from './util/Shape';
@ -24,7 +24,7 @@ import INodeModel from './model/INodeModel';
class DragPivot {
constructor() {
this._position = new web2d.Point();
this._position = new Point();
this._size = DragTopicConfig.PIVOT_SIZE;
this._straightLine = this._buildStraightLine();
@ -44,8 +44,8 @@ class DragPivot {
}
_buildStraightLine() {
const line = new web2d.CurvedLine();
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
const line = new CurvedLine();
line.setStyle(CurvedLine.SIMPLE_LINE);
line.setStroke(1, 'solid', '#CC0033');
line.setOpacity(0.4);
line.setVisibility(false);
@ -53,8 +53,8 @@ class DragPivot {
}
_buildCurvedLine() {
const line = new web2d.CurvedLine();
line.setStyle(web2d.CurvedLine.SIMPLE_LINE);
const line = new CurvedLine();
line.setStyle(CurvedLine.SIMPLE_LINE);
line.setStroke(1, 'solid', '#CC0033');
line.setOpacity(0.4);
line.setVisibility(false);
@ -82,8 +82,8 @@ class DragPivot {
line.setFrom(pivotPoint.x, pivotPoint.y);
// Update rect position
const cx = position.x - parseInt(size.width) / 2;
const cy = position.y - parseInt(size.height) / 2;
const cx = position.x - parseInt(size.width, 10) / 2;
const cy = position.y - parseInt(size.height, 10) / 2;
pivotRect.setPosition(cx, cy);
// Make line visible only when the position has been already changed.
@ -110,7 +110,7 @@ class DragPivot {
height: size.height,
strokeColor: '#FF9933',
};
const rect = new web2d.Rect(0, rectAttributes);
const rect = new Rect(0, rectAttributes);
rect.setVisibility(false);
return rect;
}

View File

@ -16,7 +16,7 @@
* limitations under the License.
*/
import { $assert, $defined } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
import { Point } from '@wisemapping/web2d';
import ActionDispatcher from './ActionDispatcher';
import DragPivot from './DragPivot';
@ -31,7 +31,7 @@ class DragTopic {
this._order = null;
this._draggedNode = draggedNode;
this._layoutManager = layoutManger;
this._position = new web2d.Point();
this._position = new Point();
this._isInWorkspace = false;
this._isFreeLayoutEnabled = false;
}

View File

@ -16,12 +16,12 @@
* limitations under the License.
*/
import { $assert } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
import { Image } from '@wisemapping/web2d';
class Icon {
constructor(url) {
$assert(url, 'topic can not be null');
this._image = new web2d.Image();
this._image = new Image();
this._image.setHref(url);
this._image.setSize(Icon.SIZE, Icon.SIZE);
}

View File

@ -17,7 +17,7 @@
*/
// eslint-disable-next-line max-classes-per-file
import { $assert, $defined } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
import { Group, Rect, Line } from '@wisemapping/web2d';
import IconGroupRemoveTip from './IconGroupRemoveTip';
import Icon from './Icon';
@ -28,7 +28,7 @@ class IconGroup {
$assert($defined(iconSize), 'iconSize can not be null');
this._icons = [];
this._group = new web2d.Group({
this._group = new Group({
width: 0,
height: iconSize,
x: 0,

View File

@ -1,4 +1,5 @@
import * as web2d from '@wisemapping/web2d';
import { Group, Rect, Line } from '@wisemapping/web2d';
import $ from 'jquery';
import { $assert, $defined } from '@wisemapping/core-js';
export default class RemoveTip {
@ -92,7 +93,7 @@ export default class RemoveTip {
// eslint-disable-next-line class-methods-use-this
_buildWeb2d() {
const result = new web2d.Group({
const result = new Group({
width: 10,
height: 10,
x: 0,
@ -101,7 +102,7 @@ export default class RemoveTip {
coordSizeHeight: 10,
});
const outerRect = new web2d.Rect(0, {
const outerRect = new Rect(0, {
x: 0,
y: 0,
width: 10,
@ -112,7 +113,7 @@ export default class RemoveTip {
result.append(outerRect);
outerRect.setCursor('pointer');
const innerRect = new web2d.Rect(0, {
const innerRect = new Rect(0, {
x: 1,
y: 1,
width: 8,
@ -122,12 +123,12 @@ export default class RemoveTip {
});
result.append(innerRect);
const line = new web2d.Line({ stroke: '1 solid white' });
const line = new Line({ stroke: '1 solid white' });
line.setFrom(1, 1);
line.setTo(9, 9);
result.append(line);
const line2 = new web2d.Line({ stroke: '1 solid white' });
const line2 = new Line({ stroke: '1 solid white' });
line2.setFrom(1, 9);
line2.setTo(9, 1);
result.append(line2);

View File

@ -16,7 +16,7 @@
* limitations under the License.
*/
import { $assert, $defined } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
import { Point, Group } from '@wisemapping/web2d';
import Topic from './Topic';
import { TopicShape } from './model/INodeModel';
@ -56,7 +56,7 @@ class MainTopic extends Topic {
coordSizeWidth: 100,
coordSizeHeight: 100,
};
const group = new web2d.Group(groupAttributes);
const group = new Group(groupAttributes);
group.append(innerShape);
// Add Text ...
@ -127,7 +127,7 @@ class MainTopic extends Topic {
let result;
if (this.getShapeType() === TopicShape.LINE) {
result = new web2d.Point();
result = new Point();
const groupPosition = this._elem2d.getPosition();
const innerShareSize = this.getInnerShape().getSize();

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as web2d from '@wisemapping/web2d';
import { Arrow, Point } from '@wisemapping/web2d';
import { $assert, $defined } from '@wisemapping/core-js';
import ConnectionLine from './ConnectionLine';
@ -51,14 +51,14 @@ class Relationship extends ConnectionLine {
this._isInWorkspace = false;
this._controlPointsController = new ControlPoint();
this._startArrow = new web2d.Arrow();
this._startArrow = new Arrow();
this._startArrow.setStrokeColor(strokeColor);
this._startArrow.setStrokeWidth(2);
this.setShowStartArrow(true);
// Share style is disable ...
if (this._showEndArrow) {
this._endArrow = new web2d.Arrow();
this._endArrow = new Arrow();
this._endArrow.setStrokeColor(strokeColor);
this._endArrow.setStrokeWidth(2);
}
@ -106,11 +106,11 @@ class Relationship extends ConnectionLine {
ctrlPoints[1].y = defaultPoints[1].y;
}
const spoint = new web2d.Point();
const spoint = new Point();
spoint.x = parseInt(ctrlPoints[0].x, 10) + parseInt(sourcePosition.x, 10);
spoint.y = parseInt(ctrlPoints[0].y, 10) + parseInt(sourcePosition.y, 10);
const tpoint = new web2d.Point();
const tpoint = new Point();
tpoint.x = parseInt(ctrlPoints[1].x, 10) + parseInt(targetPosition.x, 10);
tpoint.y = parseInt(ctrlPoints[1].y, 10) + parseInt(targetPosition.y, 10);

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as web2d from '@wisemapping/web2d';
import { CurvedLine, Arrow, Point } from '@wisemapping/web2d';
import { $assert } from '@wisemapping/core-js';
import Relationship from './Relationship';
import INodeModel from './model/INodeModel';
@ -46,8 +46,8 @@ class RelationshipPivot {
const sourcePos = sourceTopic.getPosition();
const strokeColor = Relationship.getStrokeColor();
this._pivot = new web2d.CurvedLine();
this._pivot.setStyle(web2d.CurvedLine.SIMPLE_LINE);
this._pivot = new CurvedLine();
this._pivot.setStyle(CurvedLine.SIMPLE_LINE);
const fromPos = this._calculateFromPosition(sourcePos);
this._pivot.setFrom(fromPos.x, fromPos.y);
@ -56,7 +56,7 @@ class RelationshipPivot {
this._pivot.setStroke(2, 'solid', strokeColor);
this._pivot.setDashed(4, 2);
this._startArrow = new web2d.Arrow();
this._startArrow = new Arrow();
this._startArrow.setStrokeColor(strokeColor);
this._startArrow.setStrokeWidth(2);
this._startArrow.setFrom(sourcePos.x, sourcePos.y);
@ -136,7 +136,7 @@ class RelationshipPivot {
}
const controlPoint = Shape.calculateDefaultControlPoints(sourcePosition, toPosition);
const spoint = new web2d.Point();
const spoint = new Point();
spoint.x = parseInt(controlPoint[0].x, 10) + parseInt(sourcePosition.x, 10);
spoint.y = parseInt(controlPoint[0].y, 10) + parseInt(sourcePosition.y, 10);
return Shape.calculateRelationShipPointCoordinates(this._sourceTopic, spoint);

View File

@ -16,7 +16,7 @@
* limitations under the License.
*/
import { $assert } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
import { Point } from '@wisemapping/web2d';
class ScreenManager {
constructor(divElement) {
@ -136,7 +136,7 @@ class ScreenManager {
y += this._padding.y;
// Remove decimal part..
return new web2d.Point(x, y);
return new Point(x, y);
}
getContainer() {

View File

@ -15,14 +15,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as web2d from '@wisemapping/web2d';
import { Elipse } from '@wisemapping/web2d';
import TopicConfig from './TopicConfig';
import ActionDispatcher from './ActionDispatcher';
class ShirinkConnector {
constructor(topic) {
const ellipse = new web2d.Elipse(TopicConfig.INNER_RECT_ATTRIBUTES);
const ellipse = new Elipse(TopicConfig.INNER_RECT_ATTRIBUTES);
this._ellipse = ellipse;
ellipse.setFill('rgb(62,118,179)');

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { $defined } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
import { TransformUtil } from '@wisemapping/web2d';
import ActionDispatcher from './ActionDispatcher';
// FIXME: Not used!
@ -194,9 +194,8 @@ class TextEditor {
_setText(text) {
const inputField = this._getTextareaElem();
inputField.size = text.length + 1;
this._containerElem.style.width = `${
inputField.size * parseInt(inputField.style.fontSize, 10) + 100
}px`;
this._containerElem.style.width = `${inputField.size * parseInt(inputField.style.fontSize, 10) + 100
}px`;
const spanField = this._getSpanElem();
spanField.innerHTML = text;
inputField.value = text;
@ -216,7 +215,7 @@ class TextEditor {
_setEditorSize(width, height) {
const textShape = this._topic.getTextShape();
const scale = web2d.utils.TransformUtil.workoutScale(textShape.peer);
const scale = TransformUtil.workoutScale(textShape.peer);
this._size = { width: width * scale.width, height: height * scale.height };
this._containerElem.style.width = `${this._size.width * 2}px`;
this._containerElem.style.height = `${this._size.height}px`;

View File

@ -16,7 +16,7 @@
* limitations under the License.
*/
import { $assert, $defined } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
import { Rect, Image, Line, Text, Group } from '@wisemapping/web2d';
import $ from 'jquery';
import NodeGraph from './NodeGraph';
@ -146,7 +146,6 @@ class Topic extends NodeGraph {
return innerShape;
}
/** @return {web2d.Line|web2d.Rect|web2d.Image} inner shape of the topic */
getInnerShape() {
if (!$defined(this._innerShape)) {
// Create inner box.
@ -179,13 +178,13 @@ class Topic extends NodeGraph {
let result;
if (shapeType === TopicShape.RECTANGLE) {
result = new web2d.Rect(0, attributes);
result = new Rect(0, attributes);
} else if (shapeType === TopicShape.IMAGE) {
const model = this.getModel();
const url = model.getImageUrl();
const size = model.getImageSize();
result = new web2d.Image();
result = new Image();
result.setHref(url);
result.setSize(size.width, size.height);
@ -195,11 +194,11 @@ class Topic extends NodeGraph {
result.setPosition = function setPosition() { };
} else if (shapeType === TopicShape.ELLIPSE) {
result = new web2d.Rect(0.9, attributes);
result = new Rect(0.9, attributes);
} else if (shapeType === TopicShape.ROUNDED_RECT) {
result = new web2d.Rect(0.3, attributes);
result = new Rect(0.3, attributes);
} else if (shapeType === TopicShape.LINE) {
result = new web2d.Line({ strokeColor: '#495879', strokeWidth: 1 });
result = new Line({ strokeColor: '#495879', strokeWidth: 1 });
result.setSize = function setSize(width, height) {
this.size = { width, height };
result.setFrom(0, height);
@ -362,7 +361,7 @@ class Topic extends NodeGraph {
}
_buildTextShape(readOnly) {
const result = new web2d.Text();
const result = new Text();
const family = this.getFontFamily();
const size = this.getFontSize();
const weight = this.getFontWeight();
@ -592,7 +591,7 @@ class Topic extends NodeGraph {
coordSizeWidth: 100,
coordSizeHeight: 100,
};
const group = new web2d.Group(groupAttributes);
const group = new Group(groupAttributes);
this._set2DElement(group);
// Shape must be build based on the model width ...

View File

@ -16,7 +16,7 @@
* limitations under the License.
*/
import { $assert, $defined } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
import { Workspace as Workspace2D, Toolkit } from '@wisemapping/web2d';
class Workspace {
constructor(screenManager, zoom) {
@ -59,8 +59,8 @@ class Workspace {
fillColor: 'transparent',
strokeWidth: 0,
};
web2d.Toolkit.init();
return new web2d.Workspace(workspaceProfile);
Toolkit.init();
return new Workspace2D(workspaceProfile);
}
append(shape) {
@ -157,7 +157,7 @@ class Workspace {
const workspace = this._workspace;
const screenManager = this._screenManager;
const mWorkspace = this;
const mouseDownListener = function (event) {
const mouseDownListener = function mouseDownListener(event) {
if (!$defined(workspace._mouseMoveListener)) {
if (mWorkspace.isWorkspaceEventsEnabled()) {
mWorkspace.enableWorkspaceEvents(false);
@ -166,7 +166,7 @@ class Workspace {
const originalCoordOrigin = workspace.getCoordOrigin();
let wasDragged = false;
workspace._mouseMoveListener = function (event) {
workspace._mouseMoveListener = function _mouseMoveListener(event) {
const currentMousePosition = screenManager.getWorkspaceMousePosition(event);
const offsetX = currentMousePosition.x - mouseDownPosition.x;
@ -192,7 +192,7 @@ class Workspace {
screenManager.addEvent('mousemove', workspace._mouseMoveListener);
// Register mouse up listeners ...
workspace._mouseUpListener = function () {
workspace._mouseUpListener = function mouseUpListener() {
screenManager.removeEvent('mousemove', workspace._mouseMoveListener);
screenManager.removeEvent('mouseup', workspace._mouseUpListener);
workspace._mouseUpListener = null;

View File

@ -16,7 +16,7 @@
* limitations under the License.
*/
import { $assert, $defined, createDocument } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
import { Point } from '@wisemapping/web2d';
import Mindmap from '../model/Mindmap';
import INodeModel, { TopicShape } from '../model/INodeModel';
import TopicFeature from '../TopicFeature';
@ -456,10 +456,10 @@ class XMLSerializer_Pela {
const model = mindmap.createRelationship(srcId, destId);
model.setLineType(lineType);
if ($defined(srcCtrlPoint) && srcCtrlPoint !== '') {
model.setSrcCtrlPoint(web2d.Point.fromString(srcCtrlPoint));
model.setSrcCtrlPoint(Point.fromString(srcCtrlPoint));
}
if ($defined(destCtrlPoint) && destCtrlPoint !== '') {
model.setDestCtrlPoint(web2d.Point.fromString(destCtrlPoint));
model.setDestCtrlPoint(Point.fromString(destCtrlPoint));
}
model.setEndArrow('false');
model.setStartArrow('true');

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as web2d from '@wisemapping/web2d';
import { Point } from '@wisemapping/web2d';
import { $assert, $defined } from '@wisemapping/core-js';
import { TopicShape } from '../model/INodeModel';
import { CONNECTOR_WIDTH } from '../TopicConfig';
@ -33,7 +33,7 @@ const Shape = {
$assert($defined(isAtRight), 'isRight can not be null');
// Node is placed at the right ?
const result = new web2d.Point();
const result = new Point();
// This is used fix a minor difference ...z
const correctionHardcode = 2;
@ -86,7 +86,7 @@ const Shape = {
y = !disable ? position.y - (yGap / xGap) * (position.x - x) : position.y;
}
return new web2d.Point(x, y);
return new Point(x, y);
},
calculateDefaultControlPoints(srcPos, tarPos) {
@ -107,8 +107,8 @@ const Shape = {
const y2 = m * (x2 - tarPos.x) + tarPos.y;
return [
new web2d.Point(-srcPos.x + x1, -srcPos.y + y1),
new web2d.Point(-tarPos.x + x2, -tarPos.y + y2),
new Point(-srcPos.x + x1, -srcPos.y + y1),
new Point(-tarPos.x + x2, -tarPos.y + y2),
];
},