#1077: PdfPrinterGraphics2D does not override create #1093
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the new Feature/Bugfix
Override
create()
inPdfPrinterGraphics2D
.Introduces a copy constructor and a protected
createChild
method for this purpose. ThecreateChild
method only creates the new copy using the copy constructor, whereascreate
callscreateChild
and then adds the new copy to itskids
before returning it.This is just one of many possible designs. For example, a copyFrom (or copyTo) method could be used instead of a copy constructor, or we could delegate to the clone mechanism. Also, it would have been possible to add the kid directly in the copy constructor, so the createChild method would not be needed. However, I didn't like the idea of mutating the parameter of the copy constructor.
So in the end I chose this design because I think it this is the cleanest option, but of course it's up to you to change anything.
Related Issue: #1077
Unit-Tests for the new Feature/Bugfix