How to apply css for gef geometry [message #1753534] |
Tue, 07 February 2017 10:03  |
Eclipse User |
|
|
|
Hi,
I am trying to apply styling from a css file for GeometryNode. For example, I would like to draw a red line (org.eclipse.gef.geometry.planar.Line).
Point start = new Point(5, 5);
Point end = new Point(10, 10);
Line line = new Line(start, end);
GeometryNode<Line> lineNode = new GeometryNode<Line>(line);
lineNode.setId("my-line");
With inline code it works.
lineNode.setStroke(Color.RED);
But I want to define styling in css file like this. It doesn't work.
#my-line{
-fx-stroke: red;
}
Does someone have a solution?
I appreciate any hints. Thanks
Bests
Shenwei
|
|
|
Re: How to apply css for gef geometry [message #1753551 is a reply to message #1753534] |
Tue, 07 February 2017 11:22  |
Eclipse User |
|
|
|
Hi Shenwei,
unlike CSS class and inline style, the CSS ID is not forwarded by GeometryNode to the JavaFX Path that is used for displaying the geometry, because the setter is declared final and the CSS ID should be unique, i.e. GeometryNode and the wrapped Path cannot have the same ID (styling will not work if the ID is not unique, although uniqueness is not enforced). Therefore, you need to select that Path manually within the stylesheet, as follows:
#my-line Path {
-fx-stroke-width: 3px;
-fx-stroke: red;
}
Best regards,
Matthias
|
|
|
Powered by
FUDForum. Page generated in 0.08120 seconds