mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-02-28 04:02:32 +00:00
convert the qt value into the stroke dasharray
This commit is contained in:
parent
22ef305e81
commit
5bee5deb22
@ -14,9 +14,11 @@ export class QtDasharrayFixer {
|
||||
};
|
||||
|
||||
public fix(dasharray: string): string {
|
||||
if(dasharray || dasharray == '' ){
|
||||
if (dasharray in QtDasharrayFixer.MAPPING) {
|
||||
return QtDasharrayFixer.MAPPING[dasharray];
|
||||
}
|
||||
return dasharray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import { MatDialogRef } from '@angular/material/dialog';
|
||||
import { DrawingToMapDrawingConverter } from '../../../../cartography/converters/map/drawing-to-map-drawing-converter';
|
||||
import { MapDrawingToSvgConverter } from '../../../../cartography/converters/map/map-drawing-to-svg-converter';
|
||||
import { DrawingsDataSource } from '../../../../cartography/datasources/drawings-datasource';
|
||||
import { QtDasharrayFixer } from '../../../../cartography/helpers/qt-dasharray-fixer';
|
||||
import { Drawing } from '../../../../cartography/models/drawing';
|
||||
import { EllipseElement } from '../../../../cartography/models/drawings/ellipse-element';
|
||||
import { LineElement } from '../../../../cartography/models/drawings/line-element';
|
||||
@ -27,12 +28,12 @@ export class StyleEditorDialogComponent implements OnInit {
|
||||
element: ElementData;
|
||||
formGroup: FormGroup;
|
||||
borderTypes = [
|
||||
{ value: 'none', name: 'Solid' },
|
||||
{ value: '15 3', name: 'Dash' },
|
||||
{ value: '5', name: 'Dot' },
|
||||
{ value: '15 2 7 2', name: 'Dash Dot' },
|
||||
{ value: '15 2 7 2 7 2', name: 'Dash Dot Dot' },
|
||||
{ value: '', name: 'No border' },
|
||||
{qt:'none', value: 'none', name: 'Solid' },
|
||||
{qt:'10, 2', value: '25, 25', name: 'Dash' },
|
||||
{qt:'4, 2', value: '5, 25', name: 'Dot' },
|
||||
{qt:'5, 5, 1, 5', value: '5, 25, 25', name: 'Dash Dot' },
|
||||
{qt:'5, 2, 5, 2, 5', value: '25, 25, 5, 25, 5', name: 'Dash Dot Dot' },
|
||||
{qt:'', value: '', name: 'No border' },
|
||||
];
|
||||
|
||||
constructor(
|
||||
@ -44,7 +45,8 @@ export class StyleEditorDialogComponent implements OnInit {
|
||||
private formBuilder: FormBuilder,
|
||||
private toasterService: ToasterService,
|
||||
private nonNegativeValidator: NonNegativeValidator,
|
||||
private rotationValidator: RotationValidator
|
||||
private rotationValidator: RotationValidator,
|
||||
private qtDasharrayFixer: QtDasharrayFixer
|
||||
) {
|
||||
this.formGroup = this.formBuilder.group({
|
||||
borderWidth: new FormControl('', [Validators.required, nonNegativeValidator.get]),
|
||||
@ -53,15 +55,28 @@ export class StyleEditorDialogComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
let dasharray_find_value;
|
||||
this.element = new ElementData();
|
||||
if (this.drawing.element instanceof RectElement || this.drawing.element instanceof EllipseElement) {
|
||||
this.element.fill = this.drawing.element.fill;
|
||||
this.element.stroke = this.drawing.element.stroke;
|
||||
this.element.stroke_dasharray = this.drawing.element.stroke_dasharray ?? 'none';
|
||||
let dasharray_value = this.drawing.element.stroke_dasharray;
|
||||
this.borderTypes.map((_) => {
|
||||
if (_.qt == dasharray_value) {
|
||||
dasharray_find_value = _.value;
|
||||
}
|
||||
});
|
||||
this.element.stroke_dasharray = dasharray_find_value ?? 'none';
|
||||
this.element.stroke_width = this.drawing.element.stroke_width;
|
||||
} else if (this.drawing.element instanceof LineElement) {
|
||||
this.element.stroke = this.drawing.element.stroke;
|
||||
this.element.stroke_dasharray = this.drawing.element.stroke_dasharray ?? 'none';
|
||||
let dasharray_value = this.drawing.element.stroke_dasharray;
|
||||
this.borderTypes.map((_) => {
|
||||
if (_.qt == dasharray_value) {
|
||||
dasharray_find_value = _.value;
|
||||
}
|
||||
});
|
||||
this.element.stroke_dasharray = dasharray_find_value ?? 'none';
|
||||
this.element.stroke_width = this.drawing.element.stroke_width;
|
||||
}
|
||||
|
||||
@ -87,7 +102,7 @@ export class StyleEditorDialogComponent implements OnInit {
|
||||
if (this.drawing.element instanceof RectElement || this.drawing.element instanceof EllipseElement) {
|
||||
this.drawing.element.fill = this.element.fill;
|
||||
this.drawing.element.stroke = this.element.stroke;
|
||||
this.drawing.element.stroke_dasharray = this.element.stroke_dasharray;
|
||||
this.drawing.element.stroke_dasharray = this.qtDasharrayFixer.fix(this.element.stroke_dasharray);
|
||||
this.drawing.element.stroke_width = this.element.stroke_width;
|
||||
} else if (this.drawing.element instanceof LineElement) {
|
||||
this.drawing.element.stroke = this.element.stroke;
|
||||
|
Loading…
x
Reference in New Issue
Block a user