-
Notifications
You must be signed in to change notification settings - Fork 751
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
XDGF: replace an elliptical arc with a line when a control point is co-linear with begin and end #601
Conversation
…near, replace an arc with a line
@@ -40,9 +39,9 @@ public void setDebugAcceptor(ShapeVisitorAcceptor acceptor) { | |||
} | |||
|
|||
@Override | |||
protected Path2D drawPath(XDGFShape shape) { |
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.
does this compile? Regardless, I don't think we should change protected method signatures in a patch release. Could you consider adding new private methods and leave the protected methods alone?
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.
Hey @pjfanning! Good catch. I completely forgot that ShapeRenderer
class might be used outside of poi
codebase itself.
Can you please check out the last revision? I reverted changing the method signature and preserved its behaviour. Now, it draws all the sections but returns only first drawn path.
Hi @pjfanning! Can you please take a look one more time? |
@@ -0,0 +1,76 @@ | |||
package org.apache.poi.xdgf.usermodel.section.geometry; |
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.
could you add license headers to the new files?
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.
Just pushed the changes. Headers are added to this file and TestGeometryUtils.java
.
thanks - merged |
We've faced an issue with elliptical arcs in VSDX files - when a control point of the elliptic arc is co-linear (i.e. lies on the same line) with begin and end points of the arc, it leads to very huge numbers when calculating coordinates of the center of the arc.
It happens because slopes of two tangents (class
EllipticalArcTo
lines 198 and 201) are equal to each other which leads to division by zero (or by value that is very near to zero).As the solution it's proposed to check co-linearity before calculating an arc. I added this condition check into
EllipticalArcTo#createEllipticalArc
method to also cover corner-cases withArcTo
(which uses the method under the hood) and withRelEllipticalArcTo
.Below you can find an example that high-lights the problem.
![Screenshot 2024-02-29 at 16 11 00](https://cdn.statically.io/img/private-user-images.githubusercontent.com/11631627/308996141-9b4cd6f8-f453-407c-b91e-db23b41df9d8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM1MDM4ODMsIm5iZiI6MTcyMzUwMzU4MywicGF0aCI6Ii8xMTYzMTYyNy8zMDg5OTYxNDEtOWI0Y2Q2ZjgtZjQ1My00MDdjLWI5MWUtZGIyM2I0MWRmOWQ4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODEyVDIyNTk0M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBmZTY1YjI5ODczMmYwMjljZDI2ZTgwYjFjNmU1OWVkOGQ2NTllODA0NGU5MjZhOWNjOGY3MGI5Njc1YWU0ODcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.m_Y5FLb1y81CX-mkPnla9WdvGokTtrC1w9LDuLcMufI)
And after the fix:
![Screenshot 2024-02-29 at 16 12 11](https://cdn.statically.io/img/private-user-images.githubusercontent.com/11631627/308996164-147ababc-cdd8-4311-8c35-decc7749cd7b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM1MDM4ODMsIm5iZiI6MTcyMzUwMzU4MywicGF0aCI6Ii8xMTYzMTYyNy8zMDg5OTYxNjQtMTQ3YWJhYmMtY2RkOC00MzExLThjMzUtZGVjYzc3NDljZDdiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODEyVDIyNTk0M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY3OTJlMzY3MGE4YmQyMWQ3MGY4Mzc0MjA0MTIyY2VhMGYwMWE3NjFjNTVkN2YxYTg4NTVjODMxMGFhMzU2ZWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.imb7dJSiiuHmezlIG3OGROfpZZtMpYqpxaKnBczRxlo)
The file itself (just change extension to
.vsdx
since GitHub does not allow to upload VSDX files)Single Icon.zip