Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Alignment of nodes with the text inside (Read 400 times)
gaveen
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 1
Joined: Oct 11th, 2023
Alignment of nodes with the text inside
Oct 11th, 2023 at 12:34am
Print Post  
I'm trying to align the selected nodes (in this example, align left). Although the nodes are aligned properly, the text inside moves out of the shape (Originally it is in center of the shape). How to keep the text inside the shape

 
Code (Javascript)
Select All
alignLeft(): void {
    const selectedNodes = this.diagram?.selection.nodes

    if (selectedNodes && selectedNodes.length > 0) {
      let leftmostX = selectedNodes[0].bounds.x
      let leftmostY = selectedNodes[0].bounds.y
      let nodeWidth = selectedNodes[0].bounds.width
      let nodeHeight = selectedNodes[0].bounds.height
      const verticalSpacing = 8

      for (let i = 1; i < selectedNodes.length; i++) {
        const node = selectedNodes[i]

        if (node.bounds.x < leftmostX) {
          leftmostX = node.bounds.x
          leftmostY = node.bounds.y
        }
      }

      for (let i = 0; i < selectedNodes.length; i++) {
        const node = selectedNodes[i]
        node.setBounds(new MindfusionDrawing.Rect(leftmostX, leftmostY, nodeWidth, nodeHeight), true)

        leftmostY += verticalSpacing
      }

      this.diagram?.invalidate()
    }
  } 

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


tech.support

Posts: 3154
Joined: Oct 19th, 2005
Re: Alignment of nodes with the text inside
Reply #1 - Oct 11th, 2023 at 8:14am
Print Post  
With what kind of nodes and texts is that happening? E.g. NodeLabels, attached nodes to contain text, standard node.text property? We can't see any problems trying that with ShapeNodes and their text property.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint