Svggen: fix #122 (missing support for LinearGradientPaint and RadialGradientPaint)#123
Conversation
|
Thanks for the PR, I'd definitely want this functionality in EchoSVG. I'll look at the code during this weekend, in the meantime there are 5 checkstyle errors and 23 warnings; I'd suggest using What I do to get rid of those errors/warnings is to open the project with the Eclipse IDE, then organize the imports and use the automatic formatter ( |
carlosame
left a comment
There was a problem hiding this comment.
LGTM but there are a few nits (typos, checkstyle issues, etc.)
| return (SVGPaintDescriptor) descMap.computeIfAbsent(gradient, g -> createtSvgPaintDescriptor((LinearGradientPaint) g)); | ||
| } | ||
|
|
||
| private SVGPaintDescriptor createtSvgPaintDescriptor(LinearGradientPaint gradient) { |
There was a problem hiding this comment.
Typo: you probably wanted createSvgPaintDescriptor(
| return (SVGPaintDescriptor) descMap.computeIfAbsent(gradient, g -> createtSvgPaintDescriptor((RadialGradientPaint) g)); | ||
| } | ||
|
|
||
| private SVGPaintDescriptor createtSvgPaintDescriptor(RadialGradientPaint gradient) { |
There was a problem hiding this comment.
Typo: you probably wanted createSvgPaintDescriptor(
| * linearGradient definition and reference. | ||
| * | ||
| * @author <a href="mailto:cjolif@ilog.fr">Christophe Jolif</a> | ||
| * @author <a href="mailto:vhardy@eng.sun.com">Vincent Hardy</a> |
There was a problem hiding this comment.
Are you sure that you want those @author tags here?
| // Now, test cycling behavior | ||
| // | ||
| Paint nonCyclicGradient = new LinearGradientPaint(0, 0, 20, 0, new float[]{0f, 1f}, new Color[]{Color.red, Color.yellow}); | ||
| Paint cyclicGradient = new LinearGradientPaint(0, 0, 20, 0, new float[]{0f, 1f}, new Color[]{Color.red, Color.yellow}, MultipleGradientPaint.CycleMethod.REFLECT); |
There was a problem hiding this comment.
checkstyle warning: Line is longer than 130 characters (found 170). [LineLength]
| g.setPaint(labelColor); | ||
| g.drawString("Opacity in stop color", 10, 20); | ||
|
|
||
| Paint transparentGradient = new LinearGradientPaint(10, 30, 110, 30, new float[]{0f, 1f}, new Color[]{new Color(255, 0, 0, 0), Color.yellow}); |
There was a problem hiding this comment.
checkstyle warning: Line is longer than 130 characters (found 150). [LineLength]
| new float[]{0.0f, 0.5f, 1.0f}, | ||
| new Color[]{new Color(255, 0, 0, 0), new Color(255, 200, 0, 128), Color.yellow}, | ||
| MultipleGradientPaint.CycleMethod.NO_CYCLE); | ||
| ; |
There was a problem hiding this comment.
checkstyle warning: Empty statement. [EmptyStatement]
| * linearGradient definition and reference. | ||
| * | ||
| * @author <a href="mailto:cjolif@ilog.fr">Christophe Jolif</a> | ||
| * @author <a href="mailto:vhardy@eng.sun.com">Vincent Hardy</a> |
There was a problem hiding this comment.
I will fix the typos tomorrow. My wife is waiting 😄
There was a problem hiding this comment.
Thank you, there was no need to address the request immediately 🙂
In addition to the existing
SVGLinearGradient, two newSVGConvertershave been added: one forLinearGradientPaintand one forRadialGradientPaint. To make the naming more consistent, the existingSVGLinearGradienthas been renamedSVGGradient, and the two new ones are calledSVGLinearGradientandSVGRadialGradient.