Fix circular dependency

This commit is contained in:
Paulo Gustavo Veiga 2022-01-03 13:50:33 -08:00
parent d14c63c0e6
commit 849eabeb07
8 changed files with 5 additions and 197 deletions

View File

@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import FontPeer from './peer/svg/FontPeer';
import WorkspacePeer from './peer/svg/WorkspacePeer'; import WorkspacePeer from './peer/svg/WorkspacePeer';
import GroupPeer from './peer/svg/GroupPeer'; import GroupPeer from './peer/svg/GroupPeer';
import ElipsePeer from './peer/svg/ElipsePeer'; import ElipsePeer from './peer/svg/ElipsePeer';
@ -22,23 +23,11 @@ import LinePeer from './peer/svg/LinePeer';
import PolyLinePeer from './peer/svg/PolyLinePeer'; import PolyLinePeer from './peer/svg/PolyLinePeer';
import CurvedLinePeer from './peer/svg/CurvedLinePeer'; import CurvedLinePeer from './peer/svg/CurvedLinePeer';
import ArrowPeer from './peer/svg/ArrowPeer'; import ArrowPeer from './peer/svg/ArrowPeer';
// eslint-disable-next-line import/no-cycle
import TextPeer from './peer/svg/TextPeer'; import TextPeer from './peer/svg/TextPeer';
import ImagePeer from './peer/svg/ImagePeer'; import ImagePeer from './peer/svg/ImagePeer';
import RectPeer from './peer/svg/RectPeer'; 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 { class Toolkit {
static createFontByName(fontName) {
const font = fontName.replaceAll(' ', '');
return Toolkit[`create${font}Font`]();
}
static createWorkspace(element) { static createWorkspace(element) {
return new WorkspacePeer(element); return new WorkspacePeer(element);
} }
@ -68,7 +57,7 @@ class Toolkit {
} }
static createText(fontName) { static createText(fontName) {
const font = Toolkit.createFontByName(fontName); const font = new FontPeer(fontName);
return new TextPeer(font); return new TextPeer(font);
} }
@ -79,30 +68,6 @@ class Toolkit {
static createRect(arc) { static createRect(arc) {
return new RectPeer(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; export default Toolkit;

View File

@ -16,9 +16,9 @@
* limitations under the License. * limitations under the License.
*/ */
import { $defined } from '@wisemapping/core-js'; import { $defined } from '@wisemapping/core-js';
import FontPeer from './FontPeer';
import ElementPeer from './ElementPeer'; import ElementPeer from './ElementPeer';
import { getPosition } from '../utils/DomUtils'; import { getPosition } from '../utils/DomUtils';
import Toolkit from '../../Toolkit';
class TextPeer extends ElementPeer { class TextPeer extends ElementPeer {
constructor(fontPeer) { constructor(fontPeer) {
@ -86,7 +86,7 @@ class TextPeer extends ElementPeer {
setFont(fontName, size, style, weight) { setFont(fontName, size, style, weight) {
if ($defined(fontName)) { if ($defined(fontName)) {
this._font = Toolkit.createFontByName(fontName); this._font = new FontPeer(fontName);
} }
if ($defined(style)) { if ($defined(style)) {
@ -137,7 +137,7 @@ class TextPeer extends ElementPeer {
setFontName(fontName) { setFontName(fontName) {
const oldFont = this._font; const oldFont = this._font;
this._font = Toolkit.createFontByName(fontName); this._font = new FontPeer(fontName);
this._font.setSize(oldFont.getSize()); this._font.setSize(oldFont.getSize());
this._font.setStyle(oldFont.getStyle()); this._font.setStyle(oldFont.getStyle());
this._font.setWeight(oldFont.getWeight()); this._font.setWeight(oldFont.getWeight());

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;