Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 497076

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 FXAssignee: 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 CLA 2016-06-30 07:09:50 EDT
Currently, the GeometryNode consists of a JavaFX Group that contains a JavaFX Path that displays a geometry. The value of the Group's "style" property is copied into the Path's "style" property. Therefore, some style values are applied twice, to the Group and to the Path. This results in a wrong appearance for some properties, e.g. opacity.

The style property of the Group should not be accessible. Instead, when the GeometryNode's style is set, it should only be applied to the Path.
Comment 1 Matthias Wienand CLA 2016-07-19 08:37:35 EDT
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.
Comment 2 Matthias Wienand CLA 2017-02-13 04:26:52 EST
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.
Comment 3 Matthias Wienand CLA 2017-02-13 04:50:15 EST
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.
Comment 4 Matthias Wienand CLA 2017-02-13 12:10:06 EST
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).
Comment 5 Matthias Wienand CLA 2017-02-20 08:56:16 EST
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.