-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wip: Consider arrowhead for label position #1192
base: master
Are you sure you want to change the base?
wip: Consider arrowhead for label position #1192
Conversation
@alixander the logic of this pr focus on previously, we got in this pr, we need to consider
what do you think? |
no, only for dagre and elk. TALA places it anywhere along the connection. e.g. notice "turn into target" is closer to the destination |
ohh, i see. don't know how TALA is integrated. i used to assume all my work is for dagre and elk engine. so i'd better to try construct target route and calc labelPosition base on that right? ( in my opinion, just add some adjustment should be ok) and i want to ask is there any chance the rendering path may longer than the real route? now i see all the adjustment make it shorter |
yeah actually i don't think you'd need to do anything for TALA. will take a look at this PR shortly |
|
||
srcAdjDistance := geo.EuclideanDistance(srcAdj.X, srcAdj.Y, 0, 0) + srcArrowWidth | ||
dstAdjDistance := geo.EuclideanDistance(dstAdj.X, dstAdj.Y, 0, 0) + dstArrowWidth | ||
labelTL = connection.GetLabelTopLeft(srcAdjDistance, dstAdjDistance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of updating GetLabelTopLeft
, and GetPointOnRoute
, I think it might be better to temporarily move the route start and end points to begin after the arrowheads (e.g. connection.Route[0].X += srcAdj.X
) and then revert this after getting the label position on the route between arrowheads. This avoids the extra complexity in the GetPointOnRoute
funcs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to temporarily construct the route, we can't just add a start and end point to original route, but also we need to remove the extra points before and after, can this be done by calcing the distance along the route? what if the connection is a curve?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant just you could modify the first and last points in the route to start after the arrowheads. Similar to how we adjust them here to account for the arrowhead+shape stroke widths:
Lines 377 to 380 in bce9b1a
path = append(path, fmt.Sprintf("M %f %f", | |
route[0].X+srcAdj.X, | |
route[0].Y+srcAdj.Y, | |
)) |
after computing the label position on the adjusted route, apply the -adjustments to get the original back going forwards
you can compute the adjustment similar to this:
Lines 357 to 358 in bce9b1a
v := geo.NewVector(end.X-start.X, end.Y-start.Y) | |
return v.Unit().Multiply(-distance).ToPoint() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if there are multiple points between original point and new point? if so there would still be issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's true but there shouldn't be multiple points within the length of the arrowhead. It will be more robust to account for that though in case it does come up.
also @donglixiaoche just a heads up that @gavin-ts is working on a cousin issue of this, which is adjusting arrowhead labels (different from yours, but related). might be worth taking a look at his to see potential merge conflicts that i think will arise: #1207 |
copy, will try to figure out the a proper way to do it |
@donglixiaoche sorry for the many merge conflicts here. whenever you want to move this forward and resolve those, feel free to ping me to take another look |
#793
consider testcase
arrowhead_labels
, before this pr, the result svg will bebecause we didn't consider arrowhead for labelPosition, the position will be a little be downward along the rendering path
after this pr,
srcAdj
,dstAdj
,srcArrowhead
,dstArrowhead
will have an effect on labelPostion