GeomGraph has public attributes radX and radY which contain the corner radius of the graph's bounding rectangle, used when determining the boundaryCurve for the graph.
radX and radY in GeomGraph are assigned 10 in the constructor. The constructor then immediately uses these values to construct rrect: RRect.
boundaryCurve cannot be altered directly: the setter throws an exception.
- It can be altered by assigning
boundingBox, but in this case it copies the corner radii from the existing RRect, which have previously been assigned 10.
- So changing
radX and radY after constructing the graph does not affect subsequence alterations of boundingBox: they continue to use the values embedded in the boundingBox RRect.
This leaves no apparent API for altering the corner radii.
Expected behavior:
- changing
radX or radY after constructing a GeomGraph and then assigning boundingBox should create a boundaryCurve with the new radii.
- or a more sophisticated API for either constructing
GeomGraph with configurable corner radii
- or assigning
radX and radY invalidates the existing boundaryShape
- or allow a direct assignment of
rrect.
My current workaround uses the last method (which breaks encapsulation):
function setCornerRadius(graph: GeomGraph, radius: number) {
const bounds = graph.boundingBox;
const rrect = new RRect({left: bounds.left, top: bounds.top, right: bounds.right, bottom: bounds.bottom, radX: radius, radY: radius});
(graph as any).rrect = rrect;
}
GeomGraphhas public attributesradXandradYwhich contain the corner radius of the graph's bounding rectangle, used when determining theboundaryCurvefor the graph.radXandradYinGeomGraphare assigned10in the constructor. The constructor then immediately uses these values to constructrrect: RRect.boundaryCurvecannot be altered directly: the setter throws an exception.boundingBox, but in this case it copies the corner radii from the existingRRect, which have previously been assigned10.radXandradYafter constructing the graph does not affect subsequence alterations ofboundingBox: they continue to use the values embedded in theboundingBoxRRect.This leaves no apparent API for altering the corner radii.
Expected behavior:
radXorradYafter constructing aGeomGraphand then assigningboundingBoxshould create a boundaryCurve with the new radii.GeomGraphwith configurable corner radiiradXandradYinvalidates the existingboundaryShaperrect.My current workaround uses the last method (which breaks encapsulation):