Skip to content

Port of Java PR #267 - Clipping Path Name / Path Information Extraction #235

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

Merged
merged 4 commits into from
Nov 18, 2019
Merged

Port of Java PR #267 - Clipping Path Name / Path Information Extraction #235

merged 4 commits into from
Nov 18, 2019

Conversation

kwhopper
Copy link
Collaborator

Copy link
Owner

@drewnoakes drewnoakes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff, thanks! I added some comments about stylistic things you might like to consider, but nothing that would block the PR being merged.

/// </summary>
/// <param name="index">location of point to be added in points</param>
/// <param name="point">coordinate value to be added to points</param>
public void SetPoint(int index, double point)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These get and set methods could be replaces with an indexer property if you liked (not available in Java). Up to you.

/// Gets size of knots list
/// </summary>
/// <returns>size of knots List</returns>
public int Size()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a property. Alternatively, remove this Size member, make GetKnots an IReadOnlyList<Knot> and allow callers to use subPath.Knots.Count, which would feel more idiomatic in .NET. The name "size" is more Java-esque.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works, until NET3.5 compat kicks in - then it gets a little weird. I might change the name from GetKnots to Knots and "Size" to "KnotsCount". Otherwise, it has to be the Count() Linq method, which will cause an enumeration. I'll post it and see what you think.

/// <author>Kevin Mott https://github.com/kwhopper</author>
public class Subpath
{
private List<Knot> p_knots = new List<Knot>();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private List<Knot> p_knots = new List<Knot>();
private readonly List<Knot> p_knots = new List<Knot>();

- remove 'set' from Type property in Knot and Subpath classes
- replace Get/Set point methods with indexer in Knot class
- make some private variables readonly
- replace GetKnots() method with Knots property in Subpath
- replace Size() method with KnotCount property in Subpath
@kwhopper
Copy link
Collaborator Author

Tried to accommodate all your suggestions. Thanks

@@ -71,16 +72,22 @@ public DirectoryList Extract(SequentialReader reader, int length)
pos += 2;

// A variable number of bytes holding a pascal string (two leading bytes for length).
var descriptionLength = reader.GetByte();
int descriptionLength = reader.GetByte();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int descriptionLength = reader.GetByte();
byte descriptionLength = reader.GetByte();

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use the actual type here rather that widening to a signed type. It'll prevent wondering whether it may be less than zero below.

Copy link
Owner

@drewnoakes drewnoakes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Merge away 👍

- remove Int operation (adding pos) on descriptionLength to avoid casting issues
- use descriptionLength decrementing logic instead of adding pos first
- fix regression in setting clippingpath tag
@kwhopper
Copy link
Collaborator Author

Removed the int cast of descriptionLength. It initially had to be int because the Java code adds pos to it before entering the loop so it was either start with an int or cast pos. I removed that logic and used a decrement of descriptionLength in the loop instead. Also fixed a regression when using the new clippingpath constants.

If this looks ok to you, I'll go ahead and merge. Thanks!

@kwhopper kwhopper merged commit dd80aa9 into drewnoakes:master Nov 18, 2019
@drewnoakes
Copy link
Owner

Thanks again.

@kwhopper kwhopper deleted the java-port-267 branch November 30, 2019 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants