mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-19 04:57:51 +00:00
Compact to DrawingWidget
This commit is contained in:
parent
e581f933bc
commit
fa38d6bdf2
@ -8,10 +8,15 @@ import { ImageDrawingWidget } from "./drawings/image-drawing";
|
||||
import { RectDrawingWidget } from "./drawings/rect-drawing";
|
||||
import { LineDrawingWidget } from "./drawings/line-drawing";
|
||||
import { EllipseDrawingWidget } from "./drawings/ellipse-drawing";
|
||||
import { DrawingWidget } from "./drawings/drawing-widget";
|
||||
|
||||
|
||||
export class DrawingsWidget implements Widget {
|
||||
private svgToDrawingConverter: SvgToDrawingConverter;
|
||||
private drawingWidgets: DrawingWidget[] = [
|
||||
new TextDrawingWidget(), new ImageDrawingWidget(), new RectDrawingWidget(),
|
||||
new LineDrawingWidget(), new EllipseDrawingWidget()
|
||||
];
|
||||
|
||||
constructor() {
|
||||
this.svgToDrawingConverter = new SvgToDrawingConverter();
|
||||
@ -42,20 +47,9 @@ export class DrawingsWidget implements Widget {
|
||||
return `translate(${d.x},${d.y})`;
|
||||
});
|
||||
|
||||
const text_drawing = new TextDrawingWidget();
|
||||
text_drawing.draw(drawing_merge);
|
||||
|
||||
const image_drawing = new ImageDrawingWidget();
|
||||
image_drawing.draw(drawing_merge);
|
||||
|
||||
const rect_drawing = new RectDrawingWidget();
|
||||
rect_drawing.draw(drawing_merge);
|
||||
|
||||
const line_drawing = new LineDrawingWidget();
|
||||
line_drawing.draw(drawing_merge);
|
||||
|
||||
const ellipse_drawing = new EllipseDrawingWidget();
|
||||
ellipse_drawing.draw(drawing_merge);
|
||||
this.drawingWidgets.forEach((widget) => {
|
||||
widget.draw(drawing_merge);
|
||||
});
|
||||
|
||||
drawing
|
||||
.exit()
|
||||
|
@ -0,0 +1,5 @@
|
||||
import { SVGSelection } from "../../models/types";
|
||||
|
||||
export interface DrawingWidget {
|
||||
draw(view: SVGSelection);
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
import { SVGSelection } from "../../models/types";
|
||||
import { Drawing } from "../../models/drawing";
|
||||
import { EllipseElement } from "../../models/drawings/ellipse-element";
|
||||
import { DrawingWidget } from "./drawing-widget";
|
||||
|
||||
|
||||
export class EllipseDrawingWidget {
|
||||
export class EllipseDrawingWidget implements DrawingWidget {
|
||||
public draw(view: SVGSelection) {
|
||||
const drawing = view
|
||||
.selectAll<SVGEllipseElement, EllipseElement>('ellipse.ellipse_element')
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { SVGSelection } from "../../models/types";
|
||||
import { Drawing } from "../../models/drawing";
|
||||
import { ImageElement } from "../../models/drawings/image-element";
|
||||
import { DrawingWidget } from "./drawing-widget";
|
||||
|
||||
|
||||
export class ImageDrawingWidget {
|
||||
export class ImageDrawingWidget implements DrawingWidget {
|
||||
public draw(view: SVGSelection) {
|
||||
const drawing = view
|
||||
.selectAll<SVGImageElement, ImageElement>('image.image_element')
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { SVGSelection } from "../../models/types";
|
||||
import { Drawing } from "../../models/drawing";
|
||||
import { LineElement } from "../../models/drawings/line-element";
|
||||
import { DrawingWidget } from "./drawing-widget";
|
||||
|
||||
|
||||
export class LineDrawingWidget {
|
||||
export class LineDrawingWidget implements DrawingWidget {
|
||||
public draw(view: SVGSelection) {
|
||||
const drawing = view
|
||||
.selectAll<SVGLineElement, LineElement>('line.line_element')
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { SVGSelection } from "../../models/types";
|
||||
import { Drawing } from "../../models/drawing";
|
||||
import { RectElement } from "../../models/drawings/rect-element";
|
||||
import { DrawingWidget } from "./drawing-widget";
|
||||
|
||||
|
||||
export class RectDrawingWidget {
|
||||
export class RectDrawingWidget implements DrawingWidget {
|
||||
public draw(view: SVGSelection) {
|
||||
const drawing = view
|
||||
.selectAll<SVGRectElement, RectElement>('rect.rect_element')
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { SVGSelection } from "../../models/types";
|
||||
import { TextElement } from "../../models/drawings/text-element";
|
||||
import { Drawing } from "../../models/drawing";
|
||||
import { DrawingWidget } from "./drawing-widget";
|
||||
|
||||
|
||||
export class TextDrawingWidget {
|
||||
export class TextDrawingWidget implements DrawingWidget {
|
||||
public draw(view: SVGSelection) {
|
||||
const drawing = view
|
||||
.selectAll<SVGTextElement, TextElement>('text.text_element')
|
||||
|
Loading…
Reference in New Issue
Block a user