msagljs
msagljs copied to clipboard
No way to alter GeomGraph radX and radY effectively
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.
radXandradYinGeomGraphare assigned10in the constructor. The constructor then immediately uses these values to constructrrect: RRect.boundaryCurvecannot 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 existingRRect, which have previously been assigned10. - So changing
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:
- changing
radXorradYafter constructing aGeomGraphand then assigningboundingBoxshould create a boundaryCurve with the new radii. - or a more sophisticated API for either constructing
GeomGraphwith configurable corner radii - or assigning
radXandradYinvalidates the existingboundaryShape - 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;
}
Please create a pull request with a change that you prefer.