Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Node text doesn't appear if node-text width is more than node width. (Read 174 times)
vishalb
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 11
Joined: May 14th, 2020
Node text doesn't appear if node-text width is more than node width.
Sep 16th, 2020 at 8:19am
Print Post  
Hi,

I am creating one node with following snippet of code.

node: TableNode = this.diagram.getFactory().createTableNode(110, 80, 55, 30);
node.redimTable(0, 0);
node.setEnableStyledText(true);
node.setText('This is the node whose node text is not getting wrapped')
node.resizeToFitText(false, true);

Initially the node text doesn't appear, But when we increase the size of the node it appears.
I think its because we have width of node is less than the node text width.

As per the requirement we need fix width of the node.

I think after wrapping of the node text this will get resolved but i am not able to achieve wrapping of the node text with the above snippet of code.
Even though the same code works for cell text wrapping.


Can you please let me know how can we solve this issue?


  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2281
Joined: Oct 19th, 2005
Re: Node text doesn't appear if node-text width is more than node width.
Reply #1 - Sep 17th, 2020 at 5:26am
Print Post  
Hi,

Apparently the resize method returns directly if table is empty. Try something like this for time being -

Code
Select All
node.redimTable(1, 1);
node.resizeToFitText(false, true);
node.redimTable(0, 0); 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
vishalb
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 11
Joined: May 14th, 2020
Re: Node text doesn't appear if node-text width is more than node width.
Reply #2 - Sep 18th, 2020 at 6:53am
Print Post  
Hi,

It worked but now i am facing issue with node structure.
We need to split node between caption and row by default.

But now after this change the node changed with no split.

Please find attached image.
  

Node_Requirement.png ( 10 KB | 6 Downloads )
Node_Requirement.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2281
Joined: Oct 19th, 2005
Re: Node text doesn't appear if node-text width is more than node width.
Reply #3 - Sep 18th, 2020 at 9:11am
Print Post  
Try this method

Code
Select All
function fitTextEmptyTable(table, maxWidth, cellAreaHeight)
{
	var padding = table.getTextPadding();
	var diagram = table.parent;

	var layoutRect = new Rect(
		0, 0, maxWidth - padding.width(), Number.MAX_VALUE);
	var captionSize = diagram.measureString(
		table.getText(), table.getEffectiveFont(),
		layoutRect, table.getEnableStyledText());

	table.setCaptionHeight(
		captionSize.height + padding.height());

	var bounds = table.getBounds().clone();
	bounds.width = captionSize.width;
	bounds.height = table.getCaptionHeight() + cellAreaHeight;
	table.setBounds(bounds);
} 

  
Back to top
 
IP Logged
 
vishalb
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 11
Joined: May 14th, 2020
Re: Node text doesn't appear if node-text width is more than node width.
Reply #4 - Sep 18th, 2020 at 10:12am
Print Post  
Hi,

In the above example
fitTextEmptyTable(table, maxWidth, cellAreaHeight)

table represents "node"
and cellAreaHeight represents "node.getCell(1,1)" is it correct?

If yes i'm not able to find cellAreaHeight of cell. if not please let me know what is represents.

Even though tried with hardcoded values
e.g. fitTextEmptyTable(node, 55, 30), but its not working.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2281
Joined: Oct 19th, 2005
Re: Node text doesn't appear if node-text width is more than node width.
Reply #5 - Sep 18th, 2020 at 10:47am
Print Post  
The above was assuming you run it on empty table with 0 x 0 cols and rows as in your original code, and the height argument is how much space you want to leave for the empty space. If you want it to work for a 1 x 1 table, you will need to assign that value to the height field of the (only) row object.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint