Link Curviness

Ok… first of all, I’m a JGoNewbie().setLevel(JUST_STARTED)…

I was able to start using JGoSWT fairly quickly by looking at the examples and modding them to see what happens… but now I have gotten to a point of being pretty confused, more so then normal. "; )

Here is the problem: I am using GeneralNode (from examples) as the basis for all my nodes but I have modified it to extend JGoBasicNode since I wanted to be able to use JGoRoundRect as my node “icon” if none was defined. The problem is that links now don’t have the “curvy” property even when I set them as follows:

public void viewChanged(JGoViewEvent evt) {
: : : :
public void documentChanged(JGoDocumentEvent evt) {
if (evt.getHint() == JGoDocumentEvent.INSERTED && (evt.getJGoObject() instanceof JGoLink)) {
JGoLink link = (JGoLink)evt.getJGoObject();
link.setPen(JGoPen.make(JGoPen.SOLID, 4, JGoBrush.ColorBlack));
link.setBrush(JGoBrush.black);
link.setHighlight( JGoPen.make(JGoPen.SOLID, 6, JGoBrush.ColorDarkGray) );
link.setAdjustingStyle( JGoLink.AdjustingStyleEnd );
link.setCubic(true);
link.calculateStroke();
link.setArrowHeads(false, true);
}
: : : :

The link that I get only has two points (looks like endpoints)… what I’m I doing wrong???

dWiGhT

I just copied and pasted your code, and it worked fine.
Might there be other code that is resetting the Cubic property?

Hmmm… so you are seeing multiple points when you select a link?

I used the GeneralNode* stuff as a basis for my multiport nodes…

I did add the following code in:

public void viewChanged(JGoViewEvent evt) {
: : : :
if (evt.getHint() == JGoViewEvent.INSERTED) {
if (evt.getJGoObject() instanceof JGoLink) {
JGoLink link = (JGoLink) evt.getJGoObject();
System.err.println(“INSERTED LINK–Cubic=” + link.isCubic());
}
: : : :

and got the following output:
INSERTED LINK–Cubic=false

I did a grep on the project code and only found setCubic(true); in my code. What could change the Cubic flag??? I even tried removing the calculateStroke() calls and get the same results.

dWiGhT

Wait – are you confusing view objects with document objects? I.e. JGoViewListener vs JGoDocumentListener, or JGoViewEvent vs JGoDocumentEvent?
You can add JGoObjects to either JGoViews (in which case they become “view objects”) or to JGoDocuments (in which case they become “document objects”). The latter is by far the most common case for programmers. You should be adding your nodes and links to the JGoDocument, either directly or to a particular document JGoLayer if that matters to you.

I actually do add all my nodes and links to the document layer. I have a documentChanged() listener that I set up the link in.

I just was catching a “link clicked on” event so that I could show the isCubic() value which I assume isn’t giving me the info that I was actually looking for.

I compared what I am doing to what is in the “BasicApp” example and even changed my link creation to exactly the same order. Still only getting two selection points (in the BasicApp demo you get four). Is there anything that could be changing the cubic() value??? Or could GeneralNodePort be doing something to the links selection points?

dWiGhT

For cubic/Bezier links to have four selection handles, you need to have both ports have their FromSpot and ToSpot properties set to JGoObject.NoSpot.
However, if you are using GeneralNode in the normal manner, that will mean that users will be able to have links crossing over the node to which they are connected, without the link point being on the “outside” of the port.

I just set the to/fromSpot to NoSpot and it now works the way I expected them to work. I do lose the ability to change the direction of the little triangle but this is more important to have…

thanks!!!

dWiGhT