Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define word wrapping for a SimpleLabelStyle

Tags:

html

yfiles

I am trying to create a SimpleLabelStyle with the word wrapping enabled, as the second box of the interactive demo. However, I am not able to reproduce it.

I am trying:

var /**yfiles.drawing.SimpleLabelStyle*/ simpleLabelStyle = new yfiles.drawing.SimpleLabelStyle();
simpleLabelStyle.trimming = yfiles.system.StringTrimming.WORD;

But it's not working. In fact, in the documentation, I see that trimming "gets the value that determines how to trim the text." (it just says "gets" and not "sets").

Any help is appreciated!

like image 563
Andrea Avatar asked Aug 01 '16 06:08

Andrea


People also ask

What is meant by word wrapping Short answer?

Definition of word wrap : a word processing feature that automatically transfers a word for which there is insufficient space from the end of one line of text to the beginning of the next.

What do you mean by the term word wrapping class 9?

uncountable noun. In computing, word wrapping is a process by which a word which comes at the end of a line is automatically moved onto a new line in order to keep the text within the margins.


1 Answers

Actually you can set the value - this documentation is misleading here. The property is declared READ-ONLY in the interface (see the badge):

ISimpleLabelStyle.trimming API

But the instance that you have instanciated implements the interface and makes the property READ-WRITE. Unfortunately the documentation is inherited from the interface and the only indication that the property is READ-WRITE is that the READ-ONLY badge is missing in the API browser. Any property that is not READ-ONLY or WRITE-ONLY is implicitly readable and writable so setting the value will work using the property on the instance (SimpleLabelStyle.trimming API)

Note that if you are changing the value for an existing style, the change will not immediately be visible. You should invalidate the graph's displays using the IGraph.invalidateDisplays() API

var style = new yfiles.drawing.SimpleLabelStyle() 
style.trimming = yfiles.system.StringTrimming.ELLIPSIS_WORD;
graph.setLabelStyle(label, style);

// and later
style.trimming = yfiles.system.StringTrimming.ELLIPSIS_CHARACTER;
graph.invalidateDisplays();
like image 69
Sebastian Avatar answered Sep 27 '22 20:09

Sebastian