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

Child elements in primitives (e.g. title tag) #64

Closed
rorso opened this issue Dec 26, 2018 · 4 comments
Closed

Child elements in primitives (e.g. title tag) #64

rorso opened this issue Dec 26, 2018 · 4 comments
Labels
enhancement Improvement to an existing feature

Comments

@rorso
Copy link

rorso commented Dec 26, 2018

The graphical primitives allow for sub elements like "title". The latter usually will be used as tooltip when hovering above the element.

I cannot add a "title" to a SVGCircle, as this is not based on SVGNodeContainer but onSVGNode.

After I changed the inheritance to "SVGNodeContainer", I can successfully add a "title" that renders as expected.

$title = new SVGTitle;
$title->setValue("this is a tooltip title");
$circle->addChild($title);

However SVGTitle too lacks a good

__construct($txt="")
to be rally useful

I' opt for generally inherit the primitives from SVGNodeContainer, as this does no harm.

@meyfa meyfa changed the title Unable to add "title" to element Child elements in primitives (e.g. title tag) Jul 30, 2019
@meyfa meyfa added the enhancement Improvement to an existing feature label Jul 30, 2019
@meyfa
Copy link
Owner

meyfa commented Jul 30, 2019

I see your point. It would probably make sense to merge the SVGNodeContainer features into SVGNode then, as there would be no real need for completely child-less elements, right?

P.S. SVGTitle constructor added in 34401ed.

@rorso
Copy link
Author

rorso commented Aug 1, 2019

Unfortunately there is no official XML Schema declaration for SVG 1.1 which would define which elements may contain which sub elements - or not.

But there is a DTD available to check the validity of the resulting SVG.
https://www.w3.org/TR/SVG11/svgdtd.html

I don't see a real problem allowing sub elements on every object, even if they would not result in a renderable SVG property. After all, it's all XML and the elements might serve for "internal use" without interfering with the validity of the produced SVG file.

if you want to check how this feature is used, please visit https://sterntaufe.astronomie.at and click any of the "Vorschau im Browser (SVG)" links. Objecs are tagged with "title" elements to show their name on hovering.

I meanwhile have extended the classes for some useful (for me) spline calculations. I send you my code. Maybe you find something suitable for general use.

@rorso
Copy link
Author

rorso commented Aug 1, 2019

... it's on this page: https://sterntaufe.astronomie.at/select.php

@meyfa meyfa closed this as completed in b07cbcb Aug 2, 2019
@meyfa
Copy link
Owner

meyfa commented Aug 2, 2019

That's a nice project you got there!

I looked through the DTD and couldn't find any element type that forbids child nodes, so I went ahead and made them all inherit from SVGNodeContainer as you proposed. Getting rid of the SVGNode/SVGNodeContainer separation altogether would make sense but it'd require a rather big refactoring and isn't strictly necessary right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants