Hello,
since my post about adding toolbar buttons from Groovy, I’ve been thinking about ways to add more complex / experimental controls to QuPath. A good place might be in the form of additional tabs to the analysis panel, like so:
The code to do this is not complex, but...
def customId = "custom_tab"
// Remove all the additions made to the analysis panel based on the id above
def RemoveTab(panel, id) {
while(1) {
hasElements = false
for (var tabItem : panel.getTabs()) {
if (tabItem.getId() == id) {
panel.getTabs().remove(tabItem)
hasElements = true
break
}
}
if (!hasElements) break
}
}
Platform.runLater {
gui = QuPathGUI.getInstance()
analysisPanel = gui.getAnalysisPanel()
RemoveTab(analysisPanel,customId)
BorderPane pane = new BorderPane()
Tab newTab = new Tab("CustomTab", pane)
newTab.setId(customId)
newTab.setTooltip(new Tooltip("This tab is Groovy :-)"))
analysisPanel.getTabs().add(newTab)
}
import javafx.application.Platform
import javafx.stage.Stage
import javafx.scene.Scene
import javafx.geometry.Insets
import javafx.geometry.Pos
import javafx.geometry.Orientation
import javafx.scene.control.*
import javafx.scene.layout.*
import javafx.scene.input.MouseEvent
import javafx.beans.value.ChangeListener
import javafx.scene.image.Image
import javafx.scene.image.ImageView
import qupath.lib.gui.QuPathGUI
It only works because I added the following public function to QuPathGUI.java:
/**
* Get the analysis panel.
* @return
*/
public TabPane getAnalysisPanel() {
return analysisPanel;
}
For a first test, I wasn’t sure whether I needed direct access to analysisPanel or not, but maybe returning analysisPanel.getTabs()
in the same way getToolbar() returns toolbar.getToolbar() makes better sense (and name the function getAnalysisTabs() ?).
Is this something you might consider adding to a next revision?
Thank you kindly