| Summary: | Expose the Path that is used to render a GeometryNode so that it can be properly styled | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Matthias Wienand <matthias.wienand> |
| Component: | GEF FX | Assignee: | Matthias Wienand <matthias.wienand> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 1.0.0 | ||
| Target Milestone: | 5.0.0 (Oxygen) M6 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Matthias Wienand
The JavaFX property accessors, getters, and setters are declared final. Therefore, the GeometryNode cannot forward the styleProperty() of itself to its shape. However, after checking the JavaFX CSS reference, opacity seems to be the only CSS style property that affects both the shape and its parent. Therefore, you can use the following workaround to ensure that the opacity is not applied twice when set via CSS styling:
// ensure opacity is not doubled when set via CSS styling
geometryNode.opacityProperty().bind(new DoubleBinding() {
@Override
protected double computeValue() {
return 1;
}
});
With JavaFX 8 we could create properties within GeometryNode for all CSS properties that are available for JavaFX Shape but not for JavaFX Region. These could then be forwarded to the shape. All properties that are available for both, the shape and the region, do not have to be forwarded as they will be inherited by the shape anyway.
Alternatively, we could expose the shape, so that no properties need to be forwarded, and the user can simply apply styles to the shape.
I came to the conclusion that we should expose the Path to the user (i.e. provide accessor methods) so that the Path can be properly styled, i.e. inline styles are not duplicated (e.g. opacity), and an id can be set for the Path so that it can be selected in CSS style sheets. Consequently, we should remove all accessor methods for shape properties from GeometryNode (fillProperty, setFill, setStroke, strokeProperty, etc.), as well as the property bindings that forward to the Path. After removing the forwarding of stroke, fill, etc., I was unsatisfied with the code that uses GeometryNode, because the Path needs to be accessed so often that the change disfigures it. Therefore, I will develop another solution (e.g. provide extra CSS properties forwarding to the Path). I added a method GeometryNode#getPath() that can be used to access the JavaFX Path that is used to render the IGeometry. The code is published on the master branch, therefore, I resolve this ticket as fixed for 5.0.0 M6. |