Skip to content

Svggen: fix #122 (missing support for LinearGradientPaint and RadialGradientPaint)#123

Merged
carlosame merged 6 commits intocss4j:masterfrom
jens-kaiser:svggen-add-gradients
Nov 8, 2025
Merged

Svggen: fix #122 (missing support for LinearGradientPaint and RadialGradientPaint)#123
carlosame merged 6 commits intocss4j:masterfrom
jens-kaiser:svggen-add-gradients

Conversation

@jens-kaiser
Copy link
Contributor

In addition to the existing SVGLinearGradient, two new SVGConverters have been added: one for LinearGradientPaint and one for RadialGradientPaint. To make the naming more consistent, the existing SVGLinearGradient has been renamed SVGGradient, and the two new ones are called SVGLinearGradient and SVGRadialGradient.

@carlosame
Copy link
Member

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 ./gradlew check or even ./gradlew build to reproduce them.

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 (Format context menu) on the offending classes/packages. At some point I should include a project-endorsed CodeFormatterProfile xml file in the repository, but IIRC it is mostly the Eclipse defaults with a smaller code line length.

@carlosame carlosame added the enhancement New feature or request label Nov 7, 2025
@carlosame carlosame added this to the 2.3 milestone Nov 7, 2025
@carlosame carlosame linked an issue Nov 7, 2025 that may be closed by this pull request
Copy link
Member

@carlosame carlosame left a comment

Choose a reason for hiding this comment

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

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) {
Copy link
Member

Choose a reason for hiding this comment

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

Typo: you probably wanted createSvgPaintDescriptor(

return (SVGPaintDescriptor) descMap.computeIfAbsent(gradient, g -> createtSvgPaintDescriptor((RadialGradientPaint) g));
}

private SVGPaintDescriptor createtSvgPaintDescriptor(RadialGradientPaint gradient) {
Copy link
Member

Choose a reason for hiding this comment

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

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>
Copy link
Member

Choose a reason for hiding this comment

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

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);
Copy link
Member

Choose a reason for hiding this comment

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

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});
Copy link
Member

Choose a reason for hiding this comment

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

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);
;
Copy link
Member

Choose a reason for hiding this comment

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

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>
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure that you want those @author tags here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will fix the typos tomorrow. My wife is waiting 😄

Copy link
Member

Choose a reason for hiding this comment

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

Thank you, there was no need to address the request immediately 🙂

@carlosame carlosame merged commit fca0134 into css4j:master Nov 8, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

echosvg-svggen: support LinearGradientPaint and RadialGradientPaint

2 participants