Search code examples
javafxyfiles

How do I highlight the edge arrow with yFiles for JavaFX?


I am using yFiles for JavaFX and I need to highlight directed edges and their arrows. I am using HighlightIndicatorManager<IModelItem>.addHighlight(IModelItem) but it only highlights the edge line and leaves its arrow without highlight. Is it possible to highlight the arrows of edges?


Solution

  • Yes, that's possible.

    The default edge-highlight only highlights the path of the edge, no matter what labels, arrow heads, or stroking is used.

    You may use utility class EdgeStyleDecorationInstaller to wrap any IEdgeStyle implementation for use with the highlighting. In order to obtain a colored arrow head you can do this:

    IArrow arrow = new Arrow(ArrowType.DEFAULT, orangePen, Color.ORANGE, 0, 1); 
    

    And then use the HighlightDecorator to apply different or dynamic highlights to the various edges in your graph.

    The yFiles evaluation package contains a sample of this technique in the "GraphViewerApplication" in GraphViewerController#initializeHighlighting.