Skip to content

Commit

Permalink
Update for Help link
Browse files Browse the repository at this point in the history
To a still empty readme.
  • Loading branch information
MichaelSNelson committed Dec 1, 2023
1 parent 9199301 commit f654c70
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class BasicStitchingExtension implements QuPathExtension {

private void addMenuItem(QuPathGUI qupath) {
def menu = qupath.getMenu("Extensions>${name}", true)
def fileNameStitching = new MenuItem("Stitching using coordinates in file names")
// TODO tooltip "Coordinates are expected to be in the format ImageName[xCoordinateInMicrons, yCoordinateInMicrons].tif"
def fileNameStitching = new MenuItem("Basic Stitching Extension")
fileNameStitching.setOnAction(e -> {
stitchingGUI.createGUI()

Expand All @@ -64,22 +63,3 @@ class BasicStitchingExtension implements QuPathExtension {
}

}
//@ActionMenu("Extensions")
//public class BSCommands {
//
// @ActionMenu("BasicStitching")
// @ActionDescription("Launch BasicStitching dialog.")
// public final Action BSCommand;
//
// /**
// * Constructor.
// *
// * @param qupath
// * The QuPath GUI.
// */
// private BSCommands(QuPathGUI qupath) {
// BSMainCommand bsCommand = new BSMainCommand(qupath);
// actionBSCommand = new Action(event -> bsCommand.run());
// }
//
//}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import javafx.stage.Modality
import javafx.stage.DirectoryChooser
import qupath.lib.gui.scripting.QPEx

//import java.nio.file.Paths
import java.awt.Desktop;


import org.slf4j.Logger
import org.slf4j.LoggerFactory
Expand All @@ -31,6 +32,7 @@ class stitchingGUI {
static Label pixelSizeLabel = new Label("Pixel size, microns:");
static Label downsampleLabel = new Label("Downsample:");
static Label matchStringLabel = new Label("Matching string:");
static Hyperlink githubLink = new Hyperlink("GitHub ReadMe");

// Map to hold the positions of each GUI element
private static Map<Node, Integer> guiElementPositions = new HashMap<>();
Expand Down Expand Up @@ -85,7 +87,7 @@ class stitchingGUI {
addPixelSizeComponents(pane);
addDownsampleComponents(pane);
addMatchStringComponents(pane);

addGitHubLinkComponent(pane); // Add the hyperlink component
// Call once to set initial visibility of components
updateComponentsBasedOnSelection(pane);

Expand All @@ -102,6 +104,18 @@ class stitchingGUI {
logger.error("Row index not found for component: " + label);
}
}
// Method to add the GitHub link component
private static void addGitHubLinkComponent(GridPane pane) {
githubLink.setOnAction(e -> {
try {
Desktop.getDesktop().browse(new URI("https://github.com/MichaelSNelson/BasicStitching"));
} catch (Exception ex) {
logger.error("Error opening link", ex);
}
});
Integer rowIndex = guiElementPositions.get(githubLink); // Default to a high number if not set
pane.add(githubLink, 0, rowIndex, 2, 1); // Span 2 columns
}

private static void initializePositions() {
// Reset position counter
Expand All @@ -114,8 +128,14 @@ class stitchingGUI {
guiElementPositions.put(pixelSizeLabel, currentPosition++);
guiElementPositions.put(downsampleLabel, currentPosition++);
guiElementPositions.put(matchStringLabel, currentPosition++);
guiElementPositions.put(githubLink, currentPosition++); // Assign position to hyperlink
// Add more components as needed
}





// Method to add stitching grid components
private static void addStitchingGridComponents(GridPane pane) {
stitchingGridBox.getItems().clear() // Clear existing items before adding new ones
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,67 @@ package qupath.ext.basicstitching.utilities

import org.slf4j.LoggerFactory
import qupath.lib.gui.QuPathGUI
import qupath.lib.gui.dialogs.Dialogs
import qupath.lib.images.writers.ome.OMEPyramidWriter
import org.slf4j.Logger
import javax.imageio.ImageIO
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths



/**
* Class containing utility functions used throughout the application.
*/
class utilityFunctions {

/**
* Gets the compression type for OMEPyramidWriter based on the selected option.
*
* @param selectedOption The selected compression option as a string.
* @return The corresponding OMEPyramidWriter.CompressionType.
*/
static OMEPyramidWriter.CompressionType getCompressionType(String selectedOption) {
switch (selectedOption) {
case "Lossy compression":
return OMEPyramidWriter.CompressionType.J2K_LOSSY
case "Lossless compression":
return OMEPyramidWriter.CompressionType.J2K
default:
return null // or a default value
// Consider providing a default compression type or handling this case
return null
}
}

/**
* Retrieves the dimensions (width and height) of a TIFF image file.
*
* @param filePath The file path of the TIFF image.
* @return A map containing the 'width' and 'height' of the image, or null if an error occurs.
*/
static Map<String, Integer> getTiffDimensions(File filePath) {
def logger = LoggerFactory.getLogger(QuPathGUI.class)

// Check if the file exists
if (!filePath.exists()) {
logger.info("File not found: $filePath")
return null
}

try {
// Read the image file
def image = ImageIO.read(filePath)
if (image == null) {
logger.info("ImageIO returned null for file: $filePath")
return null
}

// Return the image dimensions as a map
return [width: image.getWidth(), height: image.getHeight()]
} catch (IOException e) {
// Log and handle the error
logger.info("Error reading the image file $filePath: ${e.message}")
return null
}
}
}

//TODO Move this somewhere
// List<Map> prepareStitching(String folderPath, double pixelSizeInMicrons, double baseDownsample, String matchingString) {
// def logger = LoggerFactory.getLogger(QuPathGUI.class)
Expand All @@ -62,4 +85,4 @@ class utilityFunctions {
//
// allFileRegionMaps
// }
}
//}

0 comments on commit f654c70

Please sign in to comment.