Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » GEF5 FX: Using Connection(How do I add Label and Color to a Connection?)
GEF5 FX: Using Connection [message #1840411] Wed, 14 April 2021 18:12 Go to next message
Mirko Fisher is currently offline Mirko FisherFriend
Messages: 2
Registered: April 2021
Junior Member
Im just began using the framework GEF by following the Guide on Itemis with the title "Getting started with GEF" (cant post links new account).
In this guide a mindmap is created step by step. The Tutorial uses org.eclipse.gef.fx.nodes.Connection as the Connection visual between Nodes.

My Problem is, that i want to modify the Color of these Connections and add a Label to the Connection, that is set to the middle of the Connection. But looking at the Class, I cant find a way to do that. The Connection class does have functions setStartDecoration() and setEndDecoration(), but thats all i was able to find for modifying the appearance of a Connection.

Im still very limited in my skills and maybe im missing something. Help would be appreciated.
Re: GEF5 FX: Using Connection [message #1840431 is a reply to message #1840411] Thu, 15 April 2021 07:16 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi,

The Connection contains a JavaFX Node for its rendering; this is the node you need to customize. For example:

Node curve = connection.getCurve();
if (curve instanceof GeometryNode) {
	((GeometryNode<?>) curve).setStroke(lineColor);
}


Labels can be added as children of the Connection Part, and/or anchored to the connection

HTH,
Camille


Camille Letavernier
Re: GEF5 FX: Using Connection [message #1840465 is a reply to message #1840431] Thu, 15 April 2021 19:35 Go to previous messageGo to next message
Mirko Fisher is currently offline Mirko FisherFriend
Messages: 2
Registered: April 2021
Junior Member
Hey,
thanks for your reply! Im now able to set the color of connections.
Im still struggling with adding Text to a Connection though. I tried using AnchorKey and DynamicAnchor, but it seems like too many not fully understood things are involved and no attempt has worked out yet.

Quote:
Labels can be added as children of the Connection Part, and/or anchored to the connection


If I understand this correctly:
I dont think the text needs its own ContentPart and be added as child to the ConnectionPart.
So anchoring it dynamically to the center of the connection should be enough.
A slightly detailed explanation on how to do such thing would be very helpful.
Re: GEF5 FX: Using Connection [message #1840479 is a reply to message #1840411] Fri, 16 April 2021 06:55 Go to previous message
Alexander Nyssen is currently offline Alexander NyssenFriend
Messages: 244
Registered: July 2009
Location: Lünen
Senior Member
Usually, you do not want to comprise the label within the connection figure, as you want it be controlled by its own VisualPart (so you can drag it independent on the connection). GEF MVC uses the concept of "anchoring" VisualParts to others to realize this, we also provide a specific "link-feedback"-concept to highlight the relationship. Even if you do not want to drag it individually, you can use the anchoring concept to have an own VisualPart for it, which is helpful for anchoring selection feedback in this case.

I recommend you take a look at the FX examples ( https://github.com/eclipse/gef/wiki/FX-Examples#examples-undeployed) and the Zest examples (https://github.com/eclipse/gef/wiki/Zest-Examples#examples-undeployed).

[Updated on: Fri, 16 April 2021 06:57]

Report message to a moderator

Previous Topic:Please ADD information about "GEF DOT End-User Tools" settings
Next Topic:Exception in gef shapes example:java.lang.NoClassDefFoundError: Could not initialize class org.eclip
Goto Forum:
  


Current Time: Fri Apr 26 04:04:34 GMT 2024

Powered by FUDForum. Page generated in 0.02547 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top