A script to adjust the line width in TrakEM2's Treeline, AreaTree types

Tags: #<Tag:0x00007fb87d779b28>


For TrakEM2 users:

With the “new” high-DPI screens, the default line width of 1 is often too thin.
TrakEM2 currently lacks a mechanism to adjust the line width, so here is a Jython script to do so:

from ini.trakem2.display import Display, DisplayCanvas
from java.lang.reflect import Field
from java.awt import BasicStroke

# Default thickness is 1.0
thickness = 4.0

f = DisplayCanvas.getDeclaredField("DEFAULT_STROKE")
stroke = BasicStroke(thickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER)
f.set(Display.getFront().getCanvas(), stroke)


Invoke the above script from Fiji’s Script Editor once TrakEM2 is open. Run the script as many times as you wish.

If you want a fancy slider, you could easily rework the above script as an additional tab in TrakEM2 containing e.g. a slider with values ranging from 1 to 20. See this related script as an example: http://imagej.net/TrakEM2_Scripting#Add_an_extra_tab_to_a_Display


I have pushed to TrakEM2’s master branch changes that add the ability to adjust the stroke width from the right-click popup menu for the Display properties.