-
Notifications
You must be signed in to change notification settings - Fork 2
Code organization
This page explains how the code of this extension is organized.
This corresponds to the src/main/java/qupath/ext/omero folder.
The gui folder contains all UI elements of the extension (and only the UI, see the core section for the core functionalities). Each package of this folder corresponds to an action/menu installed in the Extension menu of QuPath.
- The
OmeroExtensionclass add actions and menus to the QuPathExtensionsmenu. - The
UiUtilitiesclass contains utility functions used by UI elements. - The
datatransporterspackage provides menus and UI elements to send/import annotations, image settings, and key value pairs of the current image to/from the corresponding OMERO server.- Each menu is represented by the
DataTransporterMenuclass. - A menu contains items represented by the
DataTransporterinterface.
- Each menu is represented by the
- The
browserpackage is used to create a new connection to an OMERO server or browse a connected OMERO server.- The
BrowseMenu/BrowseMenuModelrepresents the actual menu. See below for the available options it offers. - The
newserverfolder allows to add a connection to an OMERO server. It simply consists of a dialog. - The
serverbrowserfolder allows to browse a connected OMERO server.- The
BrowserCommandis the action that starts a browser (see below). - The
Browser/BrowserModelcontains a window allowing the user to browse an OMERO server, get information about OMERO entities and open OMERO images. - The
advancedinformationfolder contains a window that displays detailed information on an OMERO entity. This window can be launched from the browser. - The
advancedsearchfolder contains a window that allows to search for OMERO entities on a server. . It can also be launched from the browser. - The
hierarchyfolder contains classes used by the TreeView of the browser. This treeview shows the projects/datasets/images of a server. - The
settingsfolder contains a window that allows to set different settings related to a server.
- The
- The
- The
connectionsmanagerfolder contains UI elements to manage (connect to, disconnect from, remove) a connection to an OMERO server.- The
ConnectionsManagerCommandis the action that starts the connection manager (see below). - The
ConnectionsManager/ConnectionsManagerModelprovides a window that displays the connections to all servers. The user can connect, log in, log out, and remove a connection to a server. - The
connectionfolder contains a UI element used internally by the connection manager.
- The
A few things can be added:
- Data that the UI elements show comes from classes of the
corefolder, so when some data is updated, the changes must be propagated to the UI elements that show it. However, such data can be updated from any thread, and the UI elements can only be updated from the JavaFX thread. This is why some UI classes use aSomeClassModelclass. These classes are used to propagate changes of some data from any thread to the JavaFX thread. - All strings shown to the user are externalized, all UI elements are defined in FXML files, and a CSS stylesheet is used (see the
resourcessection).
The core folder contains everything else, i.e. the core functionalities of the extension.
- The
imageserverfolder contains the ImageServer used by any image opened from an OMERO server and its corresponding ImageServerBuilder. The functionalities of the image server (e.g. reading pixels, getting metadata) are mostly delegated to other functions present in thecorefolder. - The
WebClientsclass monitors all active connections to OMERO servers. A connection is represented by theWebClientclass, described below.WebClientsis the class to use when creating a newWebClientor removing an existing one, don't directly useWebClientto add/remove a connection. - The
WebClientclass represents a connection to an OMERO server. It handles creating a connection with an OMERO server and keeping the connection alive. It has a reference to aApisHandler(described below) which can be used to retrieve information from the OMERO server, and a reference to aServer(described below) which is the ancestor of all OMERO entities. -
RequestSenderis a utility class that sends web request and can convert HTTP responses to an understandable format (like JSON for example). -
WebUtilitiescontains utility methods for handling web requests. -
ClientsPreferencesManageris a utility class that handles client information stored in the QuPath preferences. - The
apisfolder contains classes that perform requests to the different web APIs.- Depending on the request, OMERO requires to use one of the different web APIs (IViewer, JSON, WebClient, or WebGateway API). Each of this API has a corresponding class in this folder to perform operations.
- The
ApisHandlerclass was created to simplify this use of several APIs. It redirects each web request to the appropriate API contained in this package, so this is the class that should be used outside of this folder. AApisHandleris not meant to be directly created, but rather accessed through aWebClient(described above). - The
ApiUtilitiesclass andutilitiesfolder contains utility functions used internally in this package. - The
authenticatorfolder contains classes to prompt the user for credentials. A window is used to get the credentials if the graphical user interface is used. Otherwise, the command line is used.
- The
pixelapiscontains different methods to read the pixel values of an image. As the time of writing, pixels can be accessed through the web API, the ICE API, or the ms pixel buffer API (see theweb,ice, andmspixelbufferfolders). Each new method should override the two interfaces present in this package.-
PixelAPIis an interface that provides information (e.g. types of image supported) on a specific API to access pixel values of an OMERO image. It can also be used to create aPixelAPIReader(described below) corresponding to this API. There is usually onePixelAPIperWebClient. -
PixelAPIReaderis an interface that allows to read pixel values from a tile request. It should only be created by the correspondingPixelAPI. There is onePixelAPIReaderperImageServer, so there can be severalPixelAPIReaderperWebClient(if multiple images coming from the same server are opened at the same time).
-
- The
entitiesfolder contains classes that represents objects required or returned by functions of theapisfolder. They are mainly used to represent data and don't contain much logic except for therepositoryentitiesfolder.- The
repositoryentitiesfolder contains elements belonging to the OMERO entity hierarchy (server -> orphaned folder / project -> dataset -> image and screen/plate/well). AServerallows to access all elements of an OMERO server. It can be retrieved through aWebClient.
- The
- Every package contains a
package-info.javafile that explains how the package is organized. - Each time a function takes some time to complete (for example when making HTTP requests), it is asynchronous using the Java CompletableFuture. The functions are then executed in a random thread.
- HTTP requests use the new Java HTTP client. It natively uses CompletableFutures.
- Unless explicitly written in the documentation, all public functions never return
null. When a function is not guaranteed to return a result, the Java Optional API is used or a documented exception is thrown.
This corresponds to the src/main/resources/qupath/ext/omero folder.
- The
styles.csscontains the CSS stylesheet of the extension. - The
strings.propertiesandstrings_fr.propertiescontains all strings shown to the user. - All other files of this folder are FXML files describing UI elements. All FXML file are located in folders that correspond to their Java controllers.
This corresponds to the src/test/java/qupath/ext/omero folder. Tests on one class Class are grouped into a TestClass class. Usually, most of the public functions of a class are tested. They are a good way to see how the functions of the extension should be used.
Unit tests have been implemented on functions not requiring access to an OMERO server and not part of the UI. They will always be executed when running tests.
Integration tests have been implemented on classes requiring access to an OMERO server. These classes extend the OmeroServer class which gives access to an OMERO server hosted on a local Docker container. If Docker can't be found on the host machine, all integration tests are skipped.
The TestContainer library is used to communicate with Docker. Three containers are installed:
- A postgres container (needed for the OMERO server).
- A redis container (needed for the OMERO Web server).
- An OMERO.web container (provides the web interface to the OMERO server).
- An OMERO.server container.
A bash script and some files in the src/test/resources/omero-server folder are transferred to the OMERO.server container. They are used to initialize the server with basic data (some datasets, images...). The files in src/test/resources/omero-web are used to initialize the web server (for example by installing the OMERO Pixel Data Microservice on it).
By default, a new local OMERO server will be created each time this command is run. As it takes a few minutes, you can instead create a local OMERO server by running the qupath-extension-omero/src/test/resources/server.sh script and setting the OmeroServer.IS_LOCAL_OMERO_SERVER_RUNNING variable to true (qupath-extension-omero/src/test/java/qupath/ext/omero/OmeroServer file). That way, unit tests will use the existing OMERO server instead of creating a new one.
- A
TestUtilitiesclass contains several utility functions used in tests.
The sample-scripts folder contains examples of scripts that use several functionalities of this extension.