You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by GitBox <gi...@apache.org> on 2021/10/27 14:34:26 UTC
[GitHub] [poi] komarovd95 opened a new pull request #270: Draw correct XDGF circular arc
komarovd95 opened a new pull request #270:
URL: https://github.com/apache/poi/pull/270
Hi, I faced an issue with drawing circular arcs provided from VSDX files (`ArcTo` geometry rows). The current implementation has some bugs: it tries to draw an elliptical arc (see arguments `width` and `height` of `Arc2D.Double` constructor) because chord length equals `2 * radius` only if this chord is a diameter. And it always draws a half of that ellipse (180 degrees angle extent).
The proposed fix uses 3 simple steps to draw an accurate circular arc:
1. Find a normal vector to the arc's chord.
2. Normalise the length of the normal vector (just divide by the length).
3. Set the origin of the normal vector to the midpoint of the chord.
4. Multiply the normal vector by the height of the arc (aka `a` parameter from the arc). Note that this parameter can be negative (like in example below).
5. The endpoint of this vector is the third point on the circle. Using these 3 points we can draw an elliptical arc by calling an existing method `EllipticalArcTo#createEllipticalArc`. Note that we need to set the parameter `d` of this method to 1 because we draw a circular arc.
This is how my shape is drawn with the current version of Apache POI:
<img width="344" alt="Screenshot 2021-10-27 at 15 55 30" src="https://user-images.githubusercontent.com/11631627/139085646-893d8637-75c0-4f9a-8087-525319fbcf6d.png">
This is how my shape is drawn after the patch (the shape looks like it looks in MS Visio):
<img width="356" alt="Screenshot 2021-10-27 at 16 19 49" src="https://user-images.githubusercontent.com/11631627/139085785-59110d1b-0c5e-4716-9d50-3a2f0340d0dc.png">
Also, I attached a VSDX file with that diagram (just rename it from `.zip` to `.vsdx`).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[GitHub] [poi] asfgit closed pull request #270: Draw correct XDGF circular arc
Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #270:
URL: https://github.com/apache/poi/pull/270
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[GitHub] [poi] pjfanning commented on pull request #270: Draw correct XDGF circular arc
Posted by GitBox <gi...@apache.org>.
pjfanning commented on pull request #270:
URL: https://github.com/apache/poi/pull/270#issuecomment-955378084
@komarovd95 thanks - we are finalising a release over the next few days - so I will wait to merge this until after that is complete
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[GitHub] [poi] pjfanning commented on pull request #270: Draw correct XDGF circular arc
Posted by GitBox <gi...@apache.org>.
pjfanning commented on pull request #270:
URL: https://github.com/apache/poi/pull/270#issuecomment-953069327
something basic is enough - ideally something that sets some values, saves the file (to an ByteArrayOutputStream) and read back into a XDGFDocument and assertions made against this
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[GitHub] [poi] pjfanning commented on pull request #270: Draw correct XDGF circular arc
Posted by GitBox <gi...@apache.org>.
pjfanning commented on pull request #270:
URL: https://github.com/apache/poi/pull/270#issuecomment-953019307
@komarovd95 would it be possible to add some unit test coverage?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[GitHub] [poi] komarovd95 commented on pull request #270: Draw correct XDGF circular arc
Posted by GitBox <gi...@apache.org>.
komarovd95 commented on pull request #270:
URL: https://github.com/apache/poi/pull/270#issuecomment-955226680
@pjfanning sorry for delay. I've added tests for ArcTo but I didn't find an easy way to create VSDX files on the flight
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[GitHub] [poi] komarovd95 commented on pull request #270: Draw correct XDGF circular arc
Posted by GitBox <gi...@apache.org>.
komarovd95 commented on pull request #270:
URL: https://github.com/apache/poi/pull/270#issuecomment-953060446
@pjfanning sure, will simple unit tests that assert path be enough? Or we need something more complex?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[GitHub] [poi] asfgit closed pull request #270: Draw correct XDGF circular arc
Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #270:
URL: https://github.com/apache/poi/pull/270
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org