From 849eabeb0724538cd818ed5c49fb1ea4850b9061 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 3 Jan 2022 13:50:33 -0800 Subject: [PATCH] Fix circular dependency --- packages/web2d/src/components/Toolkit.js | 39 +------------------ .../web2d/src/components/peer/svg/TextPeer.js | 6 +-- .../src/components/peer/svg/font/ArialFont.js | 26 ------------- .../peer/svg/font/BrushScriptFont.js | 27 ------------- .../components/peer/svg/font/LuminariFont.js | 26 ------------- .../components/peer/svg/font/TahomaFont.js | 26 ------------- .../src/components/peer/svg/font/TimesFont.js | 26 ------------- .../components/peer/svg/font/VerdanaFont.js | 26 ------------- 8 files changed, 5 insertions(+), 197 deletions(-) delete mode 100644 packages/web2d/src/components/peer/svg/font/ArialFont.js delete mode 100644 packages/web2d/src/components/peer/svg/font/BrushScriptFont.js delete mode 100644 packages/web2d/src/components/peer/svg/font/LuminariFont.js delete mode 100644 packages/web2d/src/components/peer/svg/font/TahomaFont.js delete mode 100644 packages/web2d/src/components/peer/svg/font/TimesFont.js delete mode 100644 packages/web2d/src/components/peer/svg/font/VerdanaFont.js diff --git a/packages/web2d/src/components/Toolkit.js b/packages/web2d/src/components/Toolkit.js index db7bd42a..18e42d3a 100644 --- a/packages/web2d/src/components/Toolkit.js +++ b/packages/web2d/src/components/Toolkit.js @@ -15,6 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import FontPeer from './peer/svg/FontPeer'; import WorkspacePeer from './peer/svg/WorkspacePeer'; import GroupPeer from './peer/svg/GroupPeer'; import ElipsePeer from './peer/svg/ElipsePeer'; @@ -22,23 +23,11 @@ import LinePeer from './peer/svg/LinePeer'; import PolyLinePeer from './peer/svg/PolyLinePeer'; import CurvedLinePeer from './peer/svg/CurvedLinePeer'; import ArrowPeer from './peer/svg/ArrowPeer'; -// eslint-disable-next-line import/no-cycle import TextPeer from './peer/svg/TextPeer'; import ImagePeer from './peer/svg/ImagePeer'; import RectPeer from './peer/svg/RectPeer'; -import ArialFont from './peer/svg/font/ArialFont'; -import TimesFont from './peer/svg/font/TimesFont'; -import VerdanaFont from './peer/svg/font/VerdanaFont'; -import TahomaFont from './peer/svg/font/TahomaFont'; -import LuminariFont from './peer/svg/font/LuminariFont'; -import BrushScriptMTFont from './peer/svg/font/BrushScriptFont'; class Toolkit { - static createFontByName(fontName) { - const font = fontName.replaceAll(' ', ''); - return Toolkit[`create${font}Font`](); - } - static createWorkspace(element) { return new WorkspacePeer(element); } @@ -68,7 +57,7 @@ class Toolkit { } static createText(fontName) { - const font = Toolkit.createFontByName(fontName); + const font = new FontPeer(fontName); return new TextPeer(font); } @@ -79,30 +68,6 @@ class Toolkit { static createRect(arc) { return new RectPeer(arc); } - - static createArialFont() { - return new ArialFont(); - } - - static createTimesFont() { - return new TimesFont(); - } - - static createLuminariFont() { - return new LuminariFont(); - } - - static createVerdanaFont() { - return new VerdanaFont(); - } - - static createTahomaFont() { - return new TahomaFont(); - } - - static createBrushScriptMTFont() { - return new BrushScriptMTFont(); - } } export default Toolkit; diff --git a/packages/web2d/src/components/peer/svg/TextPeer.js b/packages/web2d/src/components/peer/svg/TextPeer.js index c9b64657..62575f83 100644 --- a/packages/web2d/src/components/peer/svg/TextPeer.js +++ b/packages/web2d/src/components/peer/svg/TextPeer.js @@ -16,9 +16,9 @@ * limitations under the License. */ import { $defined } from '@wisemapping/core-js'; +import FontPeer from './FontPeer'; import ElementPeer from './ElementPeer'; import { getPosition } from '../utils/DomUtils'; -import Toolkit from '../../Toolkit'; class TextPeer extends ElementPeer { constructor(fontPeer) { @@ -86,7 +86,7 @@ class TextPeer extends ElementPeer { setFont(fontName, size, style, weight) { if ($defined(fontName)) { - this._font = Toolkit.createFontByName(fontName); + this._font = new FontPeer(fontName); } if ($defined(style)) { @@ -137,7 +137,7 @@ class TextPeer extends ElementPeer { setFontName(fontName) { const oldFont = this._font; - this._font = Toolkit.createFontByName(fontName); + this._font = new FontPeer(fontName); this._font.setSize(oldFont.getSize()); this._font.setStyle(oldFont.getStyle()); this._font.setWeight(oldFont.getWeight()); diff --git a/packages/web2d/src/components/peer/svg/font/ArialFont.js b/packages/web2d/src/components/peer/svg/font/ArialFont.js deleted file mode 100644 index a627695f..00000000 --- a/packages/web2d/src/components/peer/svg/font/ArialFont.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright [2021] [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. - */ -import FontPeer from '../FontPeer'; - -class ArialFont extends FontPeer { - constructor() { - super('Arial'); - } -} - -export default ArialFont; diff --git a/packages/web2d/src/components/peer/svg/font/BrushScriptFont.js b/packages/web2d/src/components/peer/svg/font/BrushScriptFont.js deleted file mode 100644 index eff0f95d..00000000 --- a/packages/web2d/src/components/peer/svg/font/BrushScriptFont.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright [2021] [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. - */ -import FontPeer from '../FontPeer'; - -class BrushScriptMTFont extends FontPeer { - // eslint-disable-next-line class-methods-use-this - constructor() { - super('Brush Script MT'); - } -} - -export default BrushScriptMTFont; diff --git a/packages/web2d/src/components/peer/svg/font/LuminariFont.js b/packages/web2d/src/components/peer/svg/font/LuminariFont.js deleted file mode 100644 index cdc206e7..00000000 --- a/packages/web2d/src/components/peer/svg/font/LuminariFont.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright [2021] [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. - */ -import FontPeer from '../FontPeer'; - -class LuminariFont extends FontPeer { - constructor() { - super('Luminari'); - } -} - -export default LuminariFont; diff --git a/packages/web2d/src/components/peer/svg/font/TahomaFont.js b/packages/web2d/src/components/peer/svg/font/TahomaFont.js deleted file mode 100644 index cf64acb3..00000000 --- a/packages/web2d/src/components/peer/svg/font/TahomaFont.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright [2021] [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. - */ -import FontPeer from '../FontPeer'; - -class TahomaFont extends FontPeer { - constructor() { - super('Verdana'); - } -} - -export default TahomaFont; diff --git a/packages/web2d/src/components/peer/svg/font/TimesFont.js b/packages/web2d/src/components/peer/svg/font/TimesFont.js deleted file mode 100644 index 25a366d8..00000000 --- a/packages/web2d/src/components/peer/svg/font/TimesFont.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright [2021] [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. - */ -import FontPeer from '../FontPeer'; - -class TimesFont extends FontPeer { - constructor() { - super('Times'); - } -} - -export default TimesFont; diff --git a/packages/web2d/src/components/peer/svg/font/VerdanaFont.js b/packages/web2d/src/components/peer/svg/font/VerdanaFont.js deleted file mode 100644 index 5a152ee6..00000000 --- a/packages/web2d/src/components/peer/svg/font/VerdanaFont.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright [2021] [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. - */ -import FontPeer from '../FontPeer'; - -class VerdanaFont extends FontPeer { - constructor() { - super('Verdana'); - } -} - -export default VerdanaFont;