Skip to content

Commit

Permalink
Bug 1840256: Fix for re-display of EventSources with links in topology
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-phillips-18 committed May 26, 2020
1 parent fc3892a commit a9e0925
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions frontend/packages/topology/src/anchors/SVGAnchor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export default class SVGAnchor extends AbstractAnchor {
}

getCircleLocation(circle: SVGCircleElement, reference: Point): Point {
if (!circle.viewportElement) {
return this.owner.getBounds().getCenter();
}

const center: Point = new Point(circle.cx.baseVal.value, circle.cy.baseVal.value);
this.owner.translateToParent(center);
const diameter = circle.r.baseVal.value * 2 + this.offset * 2;
Expand All @@ -25,6 +29,10 @@ export default class SVGAnchor extends AbstractAnchor {
}

getEllipseLocation(ellipse: SVGEllipseElement, reference: Point): Point {
if (!ellipse.viewportElement) {
return this.owner.getBounds().getCenter();
}

const center: Point = new Point(ellipse.cx.baseVal.value, ellipse.cy.baseVal.value);
this.owner.translateToParent(center);
const offset2x = this.offset * 2;
Expand All @@ -35,6 +43,10 @@ export default class SVGAnchor extends AbstractAnchor {
}

getRectLocation(rect: SVGRectElement, reference: Point): Point {
if (!rect.viewportElement) {
return this.owner.getBounds().getCenter();
}

const width = rect.width.baseVal.value;
const height = rect.height.baseVal.value;

Expand All @@ -49,6 +61,10 @@ export default class SVGAnchor extends AbstractAnchor {
}

getPathLocation(path: SVGPathElement, reference: Point): Point {
if (!path.viewportElement) {
return this.owner.getBounds().getCenter();
}

const translatedRef = reference.clone();
this.owner.translateFromParent(translatedRef);
const anchorPoint = getPathAnchorPoint(path, translatedRef);
Expand All @@ -57,6 +73,10 @@ export default class SVGAnchor extends AbstractAnchor {
}

getPolygonLocation(polygon: SVGPolygonElement, reference: Point): Point {
if (!polygon.viewportElement) {
return this.owner.getBounds().getCenter();
}

const translatedRef = reference.clone();
this.owner.translateFromParent(translatedRef);
const anchorPoint = getPolygonAnchorPoint(polygon, translatedRef);
Expand Down Expand Up @@ -90,11 +110,12 @@ export default class SVGAnchor extends AbstractAnchor {

getReferencePoint(): Point {
if (
this.svgElement instanceof SVGCircleElement ||
this.svgElement instanceof SVGEllipseElement ||
this.svgElement instanceof SVGRectElement ||
this.svgElement instanceof SVGPathElement ||
this.svgElement instanceof SVGPolygonElement
this.svgElement?.viewportElement &&
(this.svgElement instanceof SVGCircleElement ||
this.svgElement instanceof SVGEllipseElement ||
this.svgElement instanceof SVGRectElement ||
this.svgElement instanceof SVGPathElement ||
this.svgElement instanceof SVGPolygonElement)
) {
const bbox = this.svgElement.getBBox();
const ref = new Point(bbox.x + bbox.width / 2, bbox.y + bbox.height / 2);
Expand Down

0 comments on commit a9e0925

Please sign in to comment.