Edge arrow colours and hover behaviour
I have two problems that may be related.
-
I draw edges in different colours if their "weight" is positive or negative. However, the edge arrows always appear in one colour. How can I fix this?
-
In the CSS, file there is a way to specify a hover behaviour for the vertices. I would like to do the same with the edges. How can I do this?
On a related note, it would be really nice to have a detailed manual of sorts.
Thanks, Ozan
Hi @ozan-k,
- I see my commit addressing #11 falls short on this necessity. There is only direct access to the arrow when using "actions" (e..g, clicks). Maybe I should have considered the styles of the edges and arrows as "the same" instead. I'll look into this in the following days. Until then, you can "hack" your way with the following snippet:
SmartStylableNode stylableEdge = graphView.getStylableEdge("0");
SmartGraphEdgeLine edge = (SmartGraphEdgeLine) stylableEdge; /* Hack: SmartGraphEdgeLine or SmartGraphEdgeCurve*/
SmartArrow stylabelArrow = edge.getAttachedArrow();
String style = "-fx-stroke: black; -fx-stroke-width: 3;";
stylableEdge.setStyleClass(style); /* Set your style to the edge and arrow simultaneously */
stylabelArrow.setStyleClass(style);
I'll reply to this issue again when it's solved. That will result in a new library version number, mind you.
- You can specify the hover pseudo-class for the edges as well, e.g.,
.edge:hover {
-fx-stroke-width: 4;
}
Please note that if you have parallel edges (this will result in "curved" edges), the result might not be as good, as they are drawn with a type of CubicCurve and the bounds of this component may activate the hover outside the line of the edge. If you have a single edge between a pair of vertices, you'll be fine.
I can work on the wiki in the following weeks, but at the moment I'm focusing on other two libraries I have. Nonetheless, I would expect that the Main example would provide most of the usage examples.
This has been fixed since version 2.0.0-rc2. Styles and hover effects are propagated automatically to the arrows. However, there is still the possibility to programmatically change styles for edges and arrows separately.
See smartgraph.css and Main.java