-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathIncreaseNodeWidth.groovy
More file actions
40 lines (31 loc) · 1.12 KB
/
Copy pathIncreaseNodeWidth.groovy
File metadata and controls
40 lines (31 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// @ExecutionModes({on_single_node="/menu_bar/format/menu_coreFormat/NodeWidth"})
/*
Author: lilive
Licence: WTFPL 2
Increase the minimal node width of each selected node by a "step" amount.
If more than one node is selected, the minimum with for each node is set
to the minimum width of the larger one (after increment).
Ensure that the new minimal width is a multiple of the step.
Based on zipizap script for same purpose,
and nnako "toggle block view for all siblings" script.
*/
import org.freeplane.view.swing.map.NodeView
// Increase the width by this amount (you can change it)
int step = 20
// Get all selected nodes
def nodes = c.getSelecteds()
// Find the width of the larger node
float maxDisplayWidth = -1
nodes.each{
nodeView = it.delegate.viewers.find() {it instanceof NodeView}
width = nodeView?.mainView?.width
if( width > maxDisplayWidth ) maxDisplayWidth = width
}
// Compute the new width to apply
int newWidth = maxDisplayWidth / c.zoom
newWidth = (int)( newWidth / step ) * step + step
// Change all nodes minimum width
nodes.each{
it.style.minNodeWidth = newWidth
it.style.maxNodeWidth = newWidth
}