From f0e4cafdbb6e14cfad1baf92b6d5b1581a122a9a Mon Sep 17 00:00:00 2001 From: Dominik Lindner Date: Thu, 5 Dec 2024 14:36:28 +0000 Subject: [PATCH] Modify `parseOmeroMetadata` method in `ZarrReader.java` to handle type conversion properly. * Use `Number` type to handle both `Integer` and `Double`. * Convert `Number` to `Double` using `Number.doubleValue()`. --- src/loci/formats/in/ZarrReader.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/loci/formats/in/ZarrReader.java b/src/loci/formats/in/ZarrReader.java index 68a4a86..48e3756 100644 --- a/src/loci/formats/in/ZarrReader.java +++ b/src/loci/formats/in/ZarrReader.java @@ -1,4 +1,3 @@ - package loci.formats.in; /*- @@ -898,7 +897,7 @@ private void parseImageLabels(String root, Map attr) throws IOEx for (int p = 0; p < properties.size(); p++) { Map prop = (Map) properties.get(p); Integer labelValue = (Integer) prop.get("label-value"); - Double area = (Double) prop.get("area (pixels)"); + Number area = (Number) prop.get("area (pixels)"); String propClass = (String) prop.get("class"); } } @@ -925,17 +924,17 @@ public void parseOmeroMetadata(Map attr) throws IOException, For for (int i = 0; i < channels.size(); i++) { Map channel = (Map) channels.get(i); Boolean channelActive = (Boolean) channel.get("active"); - Double channelCoefficient = (Double) channel.get("coefficient"); + Number channelCoefficient = (Number) channel.get("coefficient"); String channelColor = (String) channel.get("color"); String channelFamily = (String) channel.get("family"); Boolean channelInverted = (Boolean) channel.get("inverted"); String channelLabel = (String) channel.get("label"); Map window = (Map)channel.get("window"); if (window != null) { - Double windowStart = getDouble(window, "start"); - Double windowEnd = getDouble(window, "end"); - Double windowMin = getDouble(window, "min"); - Double windowMax = getDouble(window, "max"); + Number windowStart = getDouble(window, "start"); + Number windowEnd = getDouble(window, "end"); + Number windowMin = getDouble(window, "min"); + Number windowMax = getDouble(window, "max"); } } Map rdefs = (Map)omeroMetadata.get("rdefs"); @@ -1107,7 +1106,7 @@ public static String getRowString(int rowIndex) { return sb.reverse().toString(); } - private Double getDouble(Map src, String key) { + private Number getDouble(Map src, String key) { Number val = (Number) src.get(key); if (val == null) { return null;