Closed winnall closed 4 years ago
Currently, this is not supported, but let me think about it
Thanks for the rapid response. Where are the class attributes on
I just found this: https://stackoverflow.com/questions/47146706/how-do-i-associate-svg-elements-generated-by-graphviz-to-elements-in-the-dot-sou#answer-61912397 This solves your issue, right?
Thanks. That does what I am looking for. But I don't have a dot file, I generate the diagrams in Java. Does that mean I have to modify AttributeConfigs
? Or define my own class that implements Attributes
?
OK, I've worked it out. I implemented a class as follows:
public class CSSAttributes implements Attributes<For> {
@Override
public Attributes<? super For> applyTo( MapAttributes<? super For> attrs ) {
throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates.
}
static Attributes<? extends ForNode> className( String name ) {
MapAttributes<ForNode> result = new MapAttributes<>();
result.add( "class", name );
return result;
}
}
and called
node( "node" ).with(CSSAttributes.className("value")
,
which does what I want.
Thanks for your help.
In a more ad hoc way, you could also use .with("class", "...")
or .with(Attributes.attr("class","..."))
I think I'm going to make SingleAttributes
public, so this will be possible:
class Css extends SingleAttributes<String, ForAll> {
private Css(String key, String value) {
super(key, value);
}
static Css className(String name) {
return new Css("class", name);
}
}
Is there any way of generating a class attribute on SVG elements? I'm using Graphviz-Java to generate SVG for use in a website and want to control the style with CSS, so class attributes are pretty important to me.
Steve