Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic line texts crossing (Read 7203 times)
kirri
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: May 18th, 2011
line texts crossing
Jun 1st, 2011 at 1:31pm
Print Post  
Hi,
is it possible to somehow avoid text overlapping? If I have two lines next to each other and both have their own text attached (I use link.setTextStyle(LinkTextStyle.Center)) their texts cross each other. I would like, for example, to write the text of the left line on it's left side and righ line's text on the right side of this line. Is it possible or is there another solution?
I know there are other TextStyles(eg LinkTextStyle.Rotate)  but some of my texts are very long and then I must create very long lines to prevent the text overlapping nodes.

Thank you for you help

Michal
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: line texts crossing
Reply #1 - Jun 1st, 2011 at 3:14pm
Print Post  
Hi,

You could handle the drawLink event to draw the label where you want it, or use a text-only node attached to the link to act as link label. The latter option lets you control the text position by setting the node's Bounds, and also the users will be able to move labels to any position they like:

Code
Select All
ShapeNode label = diagram.getFactory().createShapeNode(rectNearTheLink);
label.attachTo(link, ...);
label.setTransparent(true);
label.setText("...");
label.setIgnoreLayout(true);
//label.setLocked(true); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
kirri
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: May 18th, 2011
Re: line texts crossing
Reply #2 - Jun 2nd, 2011 at 7:47am
Print Post  
How can I define rectNearTheLink? I mean how can I found the place that is near the link to attach this label node to it?
ShapeNode label = diagram.getFactory().createShapeNode(?,?,width,height)
Do I have to somehow calculate these coordinations programatically or is there simpler way?

Thanks for your help again

Michal
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: line texts crossing
Reply #3 - Jun 2nd, 2011 at 8:12am
Print Post  
In the general case, set it at the middle of the link, e.g. at the middle control point. Then if getCommonLinks() finds more than one link between the same nodes, you can call resizeToFitText for all labels, sort them by Y, and pull them apart by setting Y for each next node to be at some distance below the previous node.

For that matter, instead of custom drawing or label nodes, you could pull the common links further apart by measuring their text via Diagram.measureString and leaving as much distance between adjacent links. I.e. modify the pairOffset value from diagram_LinkCreated to be big enough for the text, instead of fixed 5 millimeters.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
kirri
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: May 18th, 2011
Re: line texts crossing
Reply #4 - Jun 3rd, 2011 at 11:56am
Print Post  
Thanks.
I am trying to do it like that but it is  difficult to create some universal algorithm that will work for each diagram...  Sad
I must create my diagrams as small as possible bucause they will be put in a very small window at the end.
  
Back to top
 
IP Logged
 
kirri
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: May 18th, 2011
Re: line texts crossing
Reply #5 - Jun 3rd, 2011 at 12:13pm
Print Post  
When I use LinkTextStyle.Center, is it possible to get the exact place where the text is placed on the link and than to shift it if necessary?
It can help me a lot if I can move the text by the line

Thanks for your answer, I hope you understand what I mean Smiley

Michal
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: line texts crossing
Reply #6 - Jun 3rd, 2011 at 12:49pm
Print Post  
Sorry, there's nothing built-in. We already have some custom label positioning available in the ActiveX control though, we'll try to port it to Java in the next week or two.

Stoyan
  
Back to top
 
IP Logged
 
kirri
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 19
Joined: May 18th, 2011
Re: line texts crossing
Reply #7 - Jun 7th, 2011 at 8:29am
Print Post  
Hi,

I have one more simple idea. Is it possible to use text wrapping on a text that is attached to a line? (I use DiagramLink.setText and LinkTextStyle.Center). Some of my texts are very long and this can solve the problem easily, I hope

Thanks for your help

Michal
« Last Edit: Jun 7th, 2011 at 10:10am by kirri »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: line texts crossing
Reply #8 - Jun 7th, 2011 at 3:23pm
Print Post  
You can still do that with custom drawing or attached label nodes. We'll see if we can add some automatic wrapping based on the link length for the next release.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: line texts crossing
Reply #9 - Jun 13th, 2011 at 6:26am
Print Post  
We are going to combine this with another feature request we have for jdiagram - displaying multiple labels on links. You could try this preview version:
https://mindfusion.eu/_beta/jdiag_labels.zip

Now you can call link.addLabel() to add a standard LinkLabel object, or link.addLabel(label) to add a derived one, e.g.:

Code
Select All
LinkLabel label = link.addLabel(veryLongString);
label.setEnableWrap(true);
label.setMaxWidth(30);
label.setHorizontalAlign(Align.Center); 



If you derive from LinkLabel, you could override its draw method to decide where to draw the text in runtime.

The LinkLabel class now provides methods for associating the label with a specific control point or segment, and if you pass a negative value that's counted as a point or segment in destination to origin direction. We'll also try to implement some dynamic layout for the official release, so that labels avoid overlapping nodes and other labels.

I hope that helps,
Stoyan
« Last Edit: Jun 13th, 2011 at 8:03am by Stoyo »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint