Commit 6f2892c1 by Josef Kufner

Change all getters to methods

parent 65f50197
Pipeline #656 failed with stages
in 53 seconds
......@@ -156,36 +156,36 @@ export default class GBoundingBox
if (p.ref !== this.ref) {
p = p.toRef(this.ref);
}
let w = this.width / 2;
let h = this.height / 2;
let w = this.width() / 2;
let h = this.height() / 2;
return new GBoundingBox(p.x - w, p.y - h, p.x + w, p.y + h, this.ref);
}
get center(): GPoint
center(): GPoint
{
return new GPoint((this.tlx + this.brx) / 2, (this.tly + this.bry) / 2, this.ref);
}
get width(): number
width(): number
{
return this.brx - this.tlx;
}
get height(): number
height(): number
{
return this.bry - this.tly;
}
get boundingBox(): GBoundingBox
boundingBox(): GBoundingBox
{
return this;
}
get aspectRatio(): number
aspectRatio(): number
{
return (this.bry != this.tly) ? Math.abs((this.brx - this.tlx) / (this.bry - this.tly)) : Infinity;
}
......
......@@ -117,8 +117,8 @@ export default class GGraphView
if (!gbb.isValid()) {
throw "Failed to calculate graph bounding box.";
}
this.svgElement.setAttribute('width', Math.ceil(gbb.width + 2).toString());
this.svgElement.setAttribute('height', Math.ceil(gbb.height + 2).toString());
this.svgElement.setAttribute('width', Math.ceil(gbb.width() + 2).toString());
this.svgElement.setAttribute('height', Math.ceil(gbb.height() + 2).toString());
return this.renderer.renderGraph(this.svg, this.graph, new GTransformation(-gbb.tlx, -gbb.tly));
}
......
......@@ -72,7 +72,7 @@ export default class GNode extends GElement
}
get shapeName(): string
shapeName(): string
{
return this.attr('shape', this.nestedGraph === null ? 'rect' : 'nested_graph');
}
......
......@@ -431,14 +431,14 @@ export default class GRenderer
arrowOutline['stroke'] = color;
arrowOutline['fill'] = 'none';
arrowOutline['transform'] = 'translate(' + v.end.toCss() + ')'
+ ' rotate(' + (180 + v.angleDeg) + ')';
+ ' rotate(' + (180 + v.angleDeg()) + ')';
arrowFill['d'] = pathF;
arrowFill['stroke-width'] = stroke_width;
arrowFill['stroke'] = color;
arrowFill['fill'] = color;
arrowFill['transform'] = 'translate(' + v.end.toCss() + ')'
+ ' rotate(' + (180 + v.angleDeg) + ')';
+ ' rotate(' + (180 + v.angleDeg()) + ')';
return offset;
}
......
......@@ -29,12 +29,12 @@ export default class GShapeBpmnTask extends GShapePath
{
let bb = this.getBoundingBox(node);
let r = this.get1em(node);
let h = bb.height / 2;
let w = bb.width / 2
let h = bb.height() / 2;
let w = bb.width() / 2
// Ends of straight line before the arc
let ew = bb.width / 2 - r;
let eh = bb.height / 2 - r;
let ew = bb.width() / 2 - r;
let eh = bb.height() / 2 - r;
return new GSvgPath(+ew, -h)
.A(r, r, 0, false, true, +w, -eh).L(+w, +eh)
......
......@@ -29,8 +29,8 @@ export default class GShapeDiamond extends GShapePolygon
protected getSvgPolygonPoints(node: GNode): number[][]
{
let bb = this.getBoundingBox(node);
let w = bb.width / 2;
let h = bb.height / 2;
let w = bb.width() / 2;
let h = bb.height() / 2;
return [
[ 0, -h ],
......
......@@ -30,8 +30,8 @@ export default class GShapeEllipse extends GShape
public renderElements(svg: GSvg, node: GNode): any[]
{
let bb = this.getBoundingBox(node);
let width = bb.width;
let height = bb.height;
let width = bb.width();
let height = bb.height();
return [
svg.ellipse({
......@@ -51,9 +51,9 @@ export default class GShapeEllipse extends GShape
protected getSvgIntersectionsShapes(node: GNode): any[]
{
let bb = this.getBoundingBox(node);
let c = bb.center;
let c = bb.center();
return [
[ "ellipse", { cx: 0, cy: 0, rx: bb.width / 2, ry: bb.height / 2 } ]
[ "ellipse", { cx: 0, cy: 0, rx: bb.width() / 2, ry: bb.height() / 2 } ]
];
}
......
......@@ -31,8 +31,8 @@ export default class GShapeNestedGraph extends GShapeRect
public renderElements(svg: GSvg, node: GNode): any[]
{
let bb = this.getBoundingBox(node);
let width = bb.width;
let height = bb.height;
let width = bb.width();
let height = bb.height();
return [
svg.rect({
......@@ -52,7 +52,7 @@ export default class GShapeNestedGraph extends GShapeRect
public getWidth(node: GNode): number
{
if (node.hasNestedGraph()) {
return node.getNestedGraph().getBoundingBox().width;
return node.getNestedGraph().getBoundingBox().width();
} else {
return super.getWidth(node);
}
......@@ -62,7 +62,7 @@ export default class GShapeNestedGraph extends GShapeRect
public getHeight(node: GNode): number
{
if (node.hasNestedGraph()) {
return node.getNestedGraph().getBoundingBox().height;
return node.getNestedGraph().getBoundingBox().height();
} else {
return super.getHeight(node);
}
......
......@@ -26,8 +26,8 @@ export default class GShapeRound extends GShapePath
protected getSvgPath(node: GNode): GSvgPath
{
let bb = this.getBoundingBox(node);
let w = bb.width / 2;
let h = bb.height / 2;
let w = bb.width() / 2;
let h = bb.height() / 2;
let c = this.get1em(node);
return new GSvgPath(-w, -h).L(w - c, -h).L(w, -h + c).L(w, h).L(-w, h).Z()
......
......@@ -30,8 +30,8 @@ export default class GShapePath extends GShape
{
// Fallback to a rectangle
let bb = this.getBoundingBox(node);
let w = bb.width / 2;
let h = bb.height / 2;
let w = bb.width() / 2;
let h = bb.height() / 2;
return new GSvgPath(-w, -h).L(-w, +h).L(+w, +h).L(+w, -h).Z();
}
......
......@@ -33,8 +33,8 @@ export default class GShapePolygon extends GShape
} else {
// Fallback to a square
let bb = this.getBoundingBox(node);
let w = bb.width / 2;
let h = bb.height / 2;
let w = bb.width() / 2;
let h = bb.height() / 2;
return [
[ -w, -h ],
[ -w, +h ],
......
......@@ -48,7 +48,7 @@ export default class GShapeRegularPolygon extends GShapePolygon
return points;
} else {
let bb = this.getBoundingBox(node);
let r = Math.max(bb.width, bb.height) / 2;
let r = Math.max(bb.width(), bb.height()) / 2;
let n = this.getEdgeCount(node);
let a = 2 * Math.PI / n;
let rot = this.getRotation(node, a, n);
......
......@@ -26,8 +26,8 @@ export default class GShapeRound extends GShapePath
protected getSvgPath(node: GNode): GSvgPath
{
let bb = this.getBoundingBox(node);
let w = bb.width / 2;
let h = bb.height / 2;
let w = bb.width() / 2;
let h = bb.height() / 2;
if (w > h) {
let r = h;
......
......@@ -69,20 +69,20 @@ export default class GVector
}
get size(): number
size(): number
{
let dx = this.end.x - this.start.x;
let dy = this.end.y - this.start.y;
return Math.sqrt(dx * dx + dy * dy);
}
get angleRad(): number
angleRad(): number
{
return Math.atan2(this.end.y - this.start.y, this.end.x - this.start.x);
}
get angleDeg(): number
angleDeg(): number
{
return 180. * Math.atan2(this.end.y - this.start.y, this.end.x - this.start.x) / Math.PI;
}
......@@ -90,8 +90,8 @@ export default class GVector
addToSize(add: number): GVector
{
var s = this.size + add;
var a = this.angleRad;
var s = this.size() + add;
var a = this.angleRad();
return new GVector(this.start, new GPoint(this.start.x + s * Math.cos(a), this.start.y + s * Math.sin(a), this.start.ref), this.ref);
}
......@@ -99,13 +99,13 @@ export default class GVector
getPointFromStart(distance: number): GPoint
{
var a = this.angleRad;
var a = this.angleRad();
return new GPoint(this.start.x + distance * Math.cos(a), this.start.y + distance * Math.sin(a), this.ref)
}
getPointFromEnd(distance: number): GPoint
{
var a = this.angleRad;
var a = this.angleRad();
return new GPoint(this.end.x - distance * Math.cos(a), this.end.y - distance * Math.sin(a), this.ref)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment