Jump to: navigation, search


< GEF‎ | GEF4

Note to non-wiki readers: This documentation is generated from the Eclipse wiki - if you have corrections or additions it would be awesome if you added them in the original wiki page.


The GEF4 FX component provides useful additions for JavaFX, like visual anchors, gesture listeners, a connection implementation, or an IGeometry-based shape implementation.


To manage dynamic positioning of visuals in dependence of one another, the GEF4 FX component provides an anchor mechanism.

* IFXAnchor
* FXStaticAnchor
* FXChopBoxAnchor

In general, an anchor is associated with one anchorage visual and can provide positions for several anchored visuals.


The FXChopBoxAnchor uses reference points to compute the anchor position for the anchored visuals. One reference point is referred to as the anchorage reference point. This point is the same for every anchored. It is computed based on the geometry of the anchorage. In addition, every anchored specifies one reference point. One anchor position is computed for each pair of (anchorage-reference-point, anchored-reference-point). The following paragraphs describe the anchor computation in detail.


Here you can see how a connection is rendered with the FXChopBoxAnchor. The E letter shape is the anchorage visual. The blue point is the anchored visual. The green line is the connection from the anchored to the anchorage. Note that the connection is not drawn inside of the anchorage, but ends on its outline. We will see how this is implemented.


In addition to the previous screenshot, you can see the center point of the anchorage bounds here. When this point is inside of the anchorage, it is used as the anchorage reference point. If it would be used as the anchorage reference point in this case, then the connection would end at that point, i.e. in the middle of nowhere. That's why a better anchorage reference point has to be computed.


In order to find an anchorage reference point that actually is inside of the anchorage, the shape vertices of the anchorage are taken into consideration. You can see that the connection ends at one of those vertices. You may wonder how the vertex to use as the anchorage reference point is determined.


In addition to the vertices, you can see lines connecting the center of the bounds with each vertex. The lines indicate the distance of each vertex to the center. The vertex that is closest to the center is used as the anchorage reference point.


Two of the lines are highlighted and their distance is shown. The anchorage reference point is now determined (orange).


A second anchored reference point is added to demonstrate how the actual anchor position is determined. A line from each anchored reference point to the anchorage reference point is constructed and intersected with the anchorage's outline. The intersection point that is closest to the anchored reference point is used as the anchor position.


Several atomic JavaFX events can form a gesture. The FX component provides a FXMouseDragGesture and a FXPinchSpreadGesture.


The GEF4 FX component provides a VisualChangeListener which can be used to listen to visual changes of a JavaFX Node.


* Adaptation of GEF4 Geometry to JavaFX Node: FXGeometryNode
* Connection abstraction using anchor mechanism: FXConnection