msagljs icon indicating copy to clipboard operation
msagljs copied to clipboard

No way to alter GeomGraph radX and radY effectively

Open wolfmcnally opened this issue 1 year ago • 1 comments

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;
}

wolfmcnally avatar Aug 09 '24 06:08 wolfmcnally

Please create a pull request with a change that you prefer.

levnach avatar Aug 09 '24 15:08 levnach