Skip to content

Commit

Permalink
Merge pull request #75 from petebankhead/improved-tostring
Browse files Browse the repository at this point in the history
Improve Model.toString()
  • Loading branch information
alanocallaghan authored Sep 10, 2024
2 parents 2c37e2b + cf2ebe4 commit a42f781
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/qupath/ext/instanseg/core/InstanSegModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,14 @@ public Optional<Path> getPath() {

@Override
public String toString() {
// var path = getPath().orElse(null);
// if (path == null) {
// return getName() + " (not downloaded)";
// }
return getName();
String name = getName();
String parent = getPath().map(Path::getFileName).map(Path::toString).orElse(null);
String version = getModel().map(BioimageIoSpec.BioimageIoModel::getVersion).orElse(null);
if (parent != null && !Objects.equals(parent, name))
name = parent + "/" + name;
if (version != null)
name += "-" + version;
return name;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/qupath/ext/instanseg/ui/InstanSegUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/
class InstanSegUtils {

private InstanSegUtils() {
// Prevent instantiation
}

private static ObjectBinding<Path> modelDirectoryBinding = Bindings.createObjectBinding(
() -> tryToGetPath(InstanSegPreferences.modelDirectoryProperty().get()),
InstanSegPreferences.modelDirectoryProperty()
Expand Down

0 comments on commit a42f781

Please sign in to comment.