Skip to content
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

Svg elements order should be preserved #20

Open
dario-zamuner-trenolab opened this issue Apr 29, 2024 · 2 comments
Open

Svg elements order should be preserved #20

dario-zamuner-trenolab opened this issue Apr 29, 2024 · 2 comments

Comments

@dario-zamuner-trenolab
Copy link

In the case of multiple SVG elements layered on top of each other, the order is important. Currently, the elements are stored inside the Svg class as a HashSet. It should be a LinkedHashSet instead.

`public class Svg extends Component implements HasSize, HasStyle {

private static final long serialVersionUID = 4669224429512601365L;
private static final Logger log = Logger.getLogger(Svg.class.getName());

private Set<SvgElement> svgElements = new HashSet<>(); // this should be a LinkedHashSet
... 

}`

@netsrotr
Copy link

As I look at the code the SvgElement is immediatly added to the SVG DOM if you call Svg.add(element). The privately hold Hashset is only hold/used as lookup. So order should be preserved on client side.

@dario-zamuner-trenolab
Copy link
Author

I used this set to regenerate the svg server-side because I needed to manipulate and export the svg in multiple formats (png, pdf, jpg). I know the original scope of the HashSet was limited, but this is a case where the order is important. I solved my problem by extending the svg class, but it would have been nice not to have to.

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

No branches or pull requests

2 participants