From 6bc132acac3676866401add2138f0c1bddda448e Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Fri, 12 Apr 2024 16:45:55 -0500 Subject: [PATCH 1/3] Fix Java 9+ warnings in formats-gpl component --- .../src/loci/formats/in/AIMReader.java | 13 +- .../src/loci/formats/in/AliconaReader.java | 7 +- .../src/loci/formats/in/BDReader.java | 12 +- .../src/loci/formats/in/BaseZeissReader.java | 34 +-- .../src/loci/formats/in/BioRadReader.java | 21 +- .../src/loci/formats/in/BioRadSCNReader.java | 19 +- .../src/loci/formats/in/BrukerReader.java | 4 +- .../src/loci/formats/in/CellSensReader.java | 44 ++-- .../src/loci/formats/in/CellWorxReader.java | 22 +- .../src/loci/formats/in/ColumbusReader.java | 22 +- .../loci/formats/in/DeltavisionReader.java | 24 +- .../src/loci/formats/in/Ecat7Reader.java | 6 +- .../src/loci/formats/in/FEITiffReader.java | 17 +- .../src/loci/formats/in/FV1000Reader.java | 4 +- .../src/loci/formats/in/FlexReader.java | 16 +- .../src/loci/formats/in/FluoviewReader.java | 21 +- .../src/loci/formats/in/GatanDM2Reader.java | 5 +- .../src/loci/formats/in/GelReader.java | 2 +- .../src/loci/formats/in/HRDGDFReader.java | 10 +- .../loci/formats/in/HamamatsuVMSReader.java | 11 +- .../src/loci/formats/in/HitachiReader.java | 4 +- .../src/loci/formats/in/IMODReader.java | 11 +- .../src/loci/formats/in/INRReader.java | 7 +- .../src/loci/formats/in/IPLabReader.java | 14 +- .../src/loci/formats/in/IPWReader.java | 2 +- .../src/loci/formats/in/ImarisHDFReader.java | 12 +- .../src/loci/formats/in/ImarisTiffReader.java | 5 +- .../src/loci/formats/in/InCellReader.java | 16 +- .../src/loci/formats/in/InveonReader.java | 15 +- .../src/loci/formats/in/IvisionReader.java | 11 +- .../src/loci/formats/in/KodakReader.java | 11 +- .../src/loci/formats/in/L2DReader.java | 2 +- .../src/loci/formats/in/LIFReader.java | 2 +- .../src/loci/formats/in/LeicaHandler.java | 53 ++-- .../src/loci/formats/in/LeicaReader.java | 16 +- .../src/loci/formats/in/LeicaSCNReader.java | 7 +- .../src/loci/formats/in/LiFlimReader.java | 10 +- .../src/loci/formats/in/MIASReader.java | 10 +- .../src/loci/formats/in/MetamorphHandler.java | 2 +- .../src/loci/formats/in/MetamorphReader.java | 8 +- .../src/loci/formats/in/MicroCTReader.java | 4 +- .../src/loci/formats/in/ND2Handler.java | 13 +- .../src/loci/formats/in/ND2Reader.java | 6 +- .../src/loci/formats/in/NDPIReader.java | 2 +- .../src/loci/formats/in/NiftiReader.java | 8 +- .../src/loci/formats/in/NikonTiffReader.java | 13 +- .../src/loci/formats/in/OIRReader.java | 4 +- .../loci/formats/in/OlympusTileReader.java | 4 +- .../src/loci/formats/in/OpenlabReader.java | 9 +- .../src/loci/formats/in/OperettaReader.java | 1 + .../src/loci/formats/in/PCORAWReader.java | 2 +- .../src/loci/formats/in/PDSReader.java | 4 +- .../loci/formats/in/PerkinElmerReader.java | 8 +- .../src/loci/formats/in/PrairieMetadata.java | 6 +- .../src/loci/formats/in/PrairieReader.java | 6 +- .../src/loci/formats/in/SBIGReader.java | 10 +- .../src/loci/formats/in/SDTInfo.java | 236 +++++++++--------- .../src/loci/formats/in/SVSReader.java | 6 +- .../src/loci/formats/in/ScanrReader.java | 12 +- .../loci/formats/in/SimplePCITiffReader.java | 5 +- .../loci/formats/in/SlidebookTiffReader.java | 5 +- .../src/loci/formats/in/SpiderReader.java | 2 +- .../src/loci/formats/in/TCSReader.java | 2 +- .../src/loci/formats/in/ZeissCZIReader.java | 125 +++++----- .../src/loci/formats/in/ZeissLSMReader.java | 10 +- 65 files changed, 547 insertions(+), 488 deletions(-) diff --git a/components/formats-gpl/src/loci/formats/in/AIMReader.java b/components/formats-gpl/src/loci/formats/in/AIMReader.java index d40c79bdb66..7f291eebc2b 100644 --- a/components/formats-gpl/src/loci/formats/in/AIMReader.java +++ b/components/formats-gpl/src/loci/formats/in/AIMReader.java @@ -27,6 +27,7 @@ import java.io.IOException; +import loci.common.DataTools; import loci.common.DateTools; import loci.common.RandomAccessInputStream; import loci.formats.CoreMetadata; @@ -152,13 +153,13 @@ else if (key.equals("Orig-ISQ-Dim-p")) { token = token.trim(); if (token.length() > 0) { if (xSize == null) { - xSize = new Double(token); + xSize = DataTools.parseDouble(token); } else if (ySize == null) { - ySize = new Double(token); + ySize = DataTools.parseDouble(token); } else if (zSize == null) { - zSize = new Double(token); + zSize = DataTools.parseDouble(token); } } } @@ -169,13 +170,13 @@ else if (key.equals("Orig-ISQ-Dim-um")) { token = token.trim(); if (token.length() > 0) { if (xLength == null) { - xLength = new Double(token); + xLength = DataTools.parseDouble(token); } else if (yLength == null) { - yLength = new Double(token); + yLength = DataTools.parseDouble(token); } else if (zLength == null) { - zLength = new Double(token); + zLength = DataTools.parseDouble(token); } } } diff --git a/components/formats-gpl/src/loci/formats/in/AliconaReader.java b/components/formats-gpl/src/loci/formats/in/AliconaReader.java index fffe5538280..fa9f85129bb 100644 --- a/components/formats-gpl/src/loci/formats/in/AliconaReader.java +++ b/components/formats-gpl/src/loci/formats/in/AliconaReader.java @@ -27,6 +27,7 @@ import java.io.IOException; +import loci.common.DataTools; import loci.common.RandomAccessInputStream; import loci.formats.CoreMetadata; import loci.formats.FormatException; @@ -238,7 +239,7 @@ else if (key.equals("DepthImageOffset")) { // used when the dataset was acquired, i.e. detector settings. if (voltage != null) { store.setDetectorSettingsVoltage( - new ElectricPotential(new Double(voltage), UNITS.VOLT), 0, 0); + new ElectricPotential(DataTools.parseDouble(voltage), UNITS.VOLT), 0, 0); // link DetectorSettings to an actual Detector String detectorID = MetadataTools.createLSID("Detector", 0, 0); @@ -253,11 +254,11 @@ else if (key.equals("DepthImageOffset")) { if (magnification != null) { store.setObjectiveCalibratedMagnification( - new Double(magnification), 0, 0); + DataTools.parseDouble(magnification), 0, 0); } if (workingDistance != null) { - store.setObjectiveWorkingDistance(new Length(new Double(workingDistance), UNITS.MICROMETER), 0, 0); + store.setObjectiveWorkingDistance(new Length(DataTools.parseDouble(workingDistance), UNITS.MICROMETER), 0, 0); } store.setObjectiveCorrection(MetadataTools.getCorrection("Other"), 0, 0); diff --git a/components/formats-gpl/src/loci/formats/in/BDReader.java b/components/formats-gpl/src/loci/formats/in/BDReader.java index 0d40fede37e..75a529c11d1 100644 --- a/components/formats-gpl/src/loci/formats/in/BDReader.java +++ b/components/formats-gpl/src/loci/formats/in/BDReader.java @@ -460,11 +460,11 @@ protected void initFile(String id) throws FormatException, IOException { } } - Double magnification = new Double(mag); + Double magnification = DataTools.parseDouble(mag); store.setObjectiveNominalMagnification(magnification, 0, 0); if (na != null) { na = na.substring(0, 1) + "." + na.substring(1); - store.setObjectiveLensNA(new Double(na), 0, 0); + store.setObjectiveLensNA(DataTools.parseDouble(na), 0, 0); } if (naIndex + 1 < tokens.length) { store.setObjectiveManufacturer(tokens[naIndex + 1], 0, 0); @@ -762,10 +762,10 @@ private void parseROIs(MetadataStore store) throws IOException { if (cols[2].trim().length() > 0) { String rectangleID = MetadataTools.createLSID("Shape", i - firstRow, 0); store.setRectangleID(rectangleID, i - firstRow, 0); - store.setRectangleX(new Double(cols[2]), i - firstRow, 0); - store.setRectangleY(new Double(cols[3]), i - firstRow, 0); - store.setRectangleWidth(new Double(cols[4]), i - firstRow, 0); - store.setRectangleHeight(new Double(cols[5]), i - firstRow, 0); + store.setRectangleX(DataTools.parseDouble(cols[2]), i - firstRow, 0); + store.setRectangleY(DataTools.parseDouble(cols[3]), i - firstRow, 0); + store.setRectangleWidth(DataTools.parseDouble(cols[4]), i - firstRow, 0); + store.setRectangleHeight(DataTools.parseDouble(cols[5]), i - firstRow, 0); String roiID = MetadataTools.createLSID("ROI", i - firstRow); store.setROIID(roiID, i - firstRow); for (int s=0; s offset.size()) { offset.add(null); } - offset.add(new Double(value)); + offset.add(DataTools.parseDouble(value)); } } else if (key.endsWith("GAIN")) { @@ -684,7 +685,7 @@ else if (key.endsWith("GAIN")) { while (nextDetector > gain.size()) { gain.add(null); } - gain.add(new Double(value)); + gain.add(DataTools.parseDouble(value)); } } nextDetector++; @@ -698,7 +699,7 @@ else if (key.endsWith("GAIN")) { int type = Integer.parseInt(values[0]); if (type == 257 && values.length >= 3) { // found length of axis in um - Double pixelSize = new Double(values[2]); + Double pixelSize = DataTools.parseDouble(values[2]); if (key.equals("AXIS_2")) { Length size = FormatTools.getPhysicalSizeX(pixelSize); @@ -722,7 +723,7 @@ else if (key.equals("AXIS_3")) { } else if (n.p.startsWith("AXIS_2")) { String[] values = n.p.split(" "); - Double pixelSize = new Double(values[3]); + Double pixelSize = DataTools.parseDouble(values[3]); Length size = FormatTools.getPhysicalSizeX(pixelSize); if (size != null) { store.setPixelsPhysicalSizeX(size, 0); @@ -730,7 +731,7 @@ else if (n.p.startsWith("AXIS_2")) { } else if (n.p.startsWith("AXIS_3")) { String[] values = n.p.split(" "); - Double pixelSize = new Double(values[3]); + Double pixelSize = DataTools.parseDouble(values[3]); Length size = FormatTools.getPhysicalSizeY(pixelSize); if (size != null) { store.setPixelsPhysicalSizeY(size, 0); @@ -754,7 +755,7 @@ else if (n.p.startsWith("AXIS_3")) { Double mag = Double.parseDouble(values[11]); store.setObjectiveNominalMagnification(mag, 0, 0); - Double sizeZ = new Double(values[14]); + Double sizeZ = DataTools.parseDouble(values[14]); Length size = FormatTools.getPhysicalSizeZ(sizeZ); if (size != null) { store.setPixelsPhysicalSizeZ(size, 0); @@ -851,8 +852,8 @@ else if (n.p.startsWith("AXIS_3")) { String detectorID = MetadataTools.createLSID("Detector", 0, i); store.setDetectorID(detectorID, 0, i); - store.setDetectorOffset(new Double(values[i * 3]), 0, i); - store.setDetectorGain(new Double(values[i * 3 + 1]), 0, i); + store.setDetectorOffset(DataTools.parseDouble(values[i * 3]), 0, i); + store.setDetectorGain(DataTools.parseDouble(values[i * 3 + 1]), 0, i); store.setDetectorType(MetadataTools.getDetectorType("Other"), 0, i); } break; diff --git a/components/formats-gpl/src/loci/formats/in/BioRadSCNReader.java b/components/formats-gpl/src/loci/formats/in/BioRadSCNReader.java index 2365f8b068c..ea107fb9107 100644 --- a/components/formats-gpl/src/loci/formats/in/BioRadSCNReader.java +++ b/components/formats-gpl/src/loci/formats/in/BioRadSCNReader.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.util.ArrayList; +import loci.common.DataTools; import loci.common.RandomAccessInputStream; import loci.common.xml.BaseHandler; import loci.common.xml.XMLTools; @@ -245,10 +246,10 @@ else if ("channel_count".equals(key)) { core.get(0).sizeC = Integer.parseInt(value); } else if ("application_gain".equals(key)) { - gain = new Double(value); + gain = DataTools.parseDouble(value); } else if ("exposure_time".equals(key)) { - exposureTime = new Double(value); + exposureTime = DataTools.parseDouble(value); } else if ("name".equals(key)) { imageName = value; @@ -287,12 +288,18 @@ else if (value <= 65535) { } else if (key.equals("size_mm")) { if (attrKey.equals("width")) { - physicalSizeX = new Double(attrValue) / getSizeX(); - physicalSizeX *= 1000; // convert from mm to um + Double size = DataTools.parseDouble(attrValue); + if (size != null) { + physicalSizeX = size / getSizeX(); + physicalSizeX *= 1000; // convert from mm to um + } } else if (attrKey.equals("height")) { - physicalSizeY = new Double(attrValue) / getSizeY(); - physicalSizeY *= 1000; // convert from mm to um + Double size = DataTools.parseDouble(attrValue); + if (size != null) { + physicalSizeY = size / getSizeY(); + physicalSizeY *= 1000; // convert from mm to um + } } } else if (key.equals("serial_number")) { diff --git a/components/formats-gpl/src/loci/formats/in/BrukerReader.java b/components/formats-gpl/src/loci/formats/in/BrukerReader.java index 25b61f669f9..d9d6ba5ec89 100644 --- a/components/formats-gpl/src/loci/formats/in/BrukerReader.java +++ b/components/formats-gpl/src/loci/formats/in/BrukerReader.java @@ -216,12 +216,12 @@ protected void initFile(String id) throws FormatException, IOException { public int compare(String s1, String s2) { Integer i1 = 0; try { - i1 = new Integer(s1); + i1 = Integer.parseInt(s1); } catch (NumberFormatException e) { } Integer i2 = 0; try { - i2 = new Integer(s2); + i2 = Integer.parseInt(s2); } catch (NumberFormatException e) { } diff --git a/components/formats-gpl/src/loci/formats/in/CellSensReader.java b/components/formats-gpl/src/loci/formats/in/CellSensReader.java index 0884c9b4767..0abf184a7cb 100644 --- a/components/formats-gpl/src/loci/formats/in/CellSensReader.java +++ b/components/formats-gpl/src/loci/formats/in/CellSensReader.java @@ -1746,7 +1746,7 @@ else if (extendedField && (realType == PROPERTY_SET_VOLUME || value = String.valueOf(vsi.readDouble()); break; case BOOLEAN: - value = new Boolean(vsi.readBoolean()).toString(); + value = Boolean.valueOf(vsi.readBoolean()).toString(); break; case TCHAR: case UNICODE_TCHAR: @@ -1884,72 +1884,72 @@ else if (tag == DEVICE_MANUFACTURER) { pyramid.deviceManufacturers.add(value); } else if (tag == EXPOSURE_TIME && tagPrefix.length() == 0) { - pyramid.exposureTimes.add(new Long(value)); + pyramid.exposureTimes.add(Long.parseLong(value)); } else if (tag == EXPOSURE_TIME) { - pyramid.defaultExposureTime = new Long(value); + pyramid.defaultExposureTime = Long.parseLong(value); pyramid.otherExposureTimes.add(pyramid.defaultExposureTime); } else if (tag == CREATION_TIME && pyramid.acquisitionTime == null) { - pyramid.acquisitionTime = new Long(value); + pyramid.acquisitionTime = Long.parseLong(value); } else if (tag == REFRACTIVE_INDEX) { - pyramid.refractiveIndex = new Double(value); + pyramid.refractiveIndex = DataTools.parseDouble(value); } else if (tag == OBJECTIVE_MAG) { - pyramid.magnification = new Double(value); + pyramid.magnification = DataTools.parseDouble(value); } else if (tag == NUMERICAL_APERTURE) { - pyramid.numericalAperture = new Double(value); + pyramid.numericalAperture = DataTools.parseDouble(value); } else if (tag == WORKING_DISTANCE) { - pyramid.workingDistance = new Double(value); + pyramid.workingDistance = DataTools.parseDouble(value); } else if (tag == OBJECTIVE_NAME) { pyramid.objectiveNames.add(value); } else if (tag == OBJECTIVE_TYPE) { - pyramid.objectiveTypes.add(new Integer(value)); + pyramid.objectiveTypes.add(Integer.parseInt(value)); } else if (tag == BIT_DEPTH) { - pyramid.bitDepth = new Integer(value); + pyramid.bitDepth = Integer.parseInt(value); } else if (tag == X_BINNING) { - pyramid.binningX = new Integer(value); + pyramid.binningX = Integer.parseInt(value); } else if (tag == Y_BINNING) { - pyramid.binningY = new Integer(value); + pyramid.binningY = Integer.parseInt(value); } else if (tag == CAMERA_GAIN) { - pyramid.gain = new Double(value); + pyramid.gain = DataTools.parseDouble(value); } else if (tag == CAMERA_OFFSET) { - pyramid.offset = new Double(value); + pyramid.offset = DataTools.parseDouble(value); } else if (tag == RED_GAIN) { - pyramid.redGain = new Double(value); + pyramid.redGain = DataTools.parseDouble(value); } else if (tag == GREEN_GAIN) { - pyramid.greenGain = new Double(value); + pyramid.greenGain = DataTools.parseDouble(value); } else if (tag == BLUE_GAIN) { - pyramid.blueGain = new Double(value); + pyramid.blueGain = DataTools.parseDouble(value); } else if (tag == RED_OFFSET) { - pyramid.redOffset = new Double(value); + pyramid.redOffset = DataTools.parseDouble(value); } else if (tag == GREEN_OFFSET) { - pyramid.greenOffset = new Double(value); + pyramid.greenOffset = DataTools.parseDouble(value); } else if (tag == BLUE_OFFSET) { - pyramid.blueOffset = new Double(value); + pyramid.blueOffset = DataTools.parseDouble(value); } else if (tag == VALUE) { if (tagPrefix.equals("Channel Wavelength ")) { - pyramid.channelWavelengths.add(new Double(value)); + pyramid.channelWavelengths.add(DataTools.parseDouble(value)); } else if (tagPrefix.startsWith("Objective Working Distance")) { - pyramid.workingDistance = new Double(value); + pyramid.workingDistance = DataTools.parseDouble(value); } else if (tagPrefix.equals("Z start position")) { pyramid.zStart = DataTools.parseDouble(value); diff --git a/components/formats-gpl/src/loci/formats/in/CellWorxReader.java b/components/formats-gpl/src/loci/formats/in/CellWorxReader.java index 244c81add99..1cd3593464d 100644 --- a/components/formats-gpl/src/loci/formats/in/CellWorxReader.java +++ b/components/formats-gpl/src/loci/formats/in/CellWorxReader.java @@ -149,7 +149,7 @@ else if (key.startsWith("WellsSelection")) { int row = Integer.parseInt(key.substring(14)) - 1; String[] mapping = value.split(","); for (int col=0; col 0) { int end = value.indexOf(" ", s + 2); - Double xSize = new Double(value.substring(0, s).trim()); - Double ySize = new Double(value.substring(s + 1, end).trim()); + Double xSize = DataTools.parseDouble(value.substring(0, s).trim()); + Double ySize = DataTools.parseDouble(value.substring(s + 1, end).trim()); Length x = FormatTools.getPhysicalSizeX(xSize / getSizeX()); Length y = FormatTools.getPhysicalSizeY(ySize / getSizeY()); @@ -827,7 +827,7 @@ else if (key.startsWith("Channel")) { token = token.trim(); if (token.startsWith("gain")) { String instrumentID = MetadataTools.createLSID("Instrument", 0); - Double gain = new Double(token.replaceAll("gain ", "")); + Double gain = DataTools.parseDouble(token.replaceAll("gain ", "")); String detectorID = MetadataTools.createLSID("Detector", 0, 0); store.setInstrumentID(instrumentID, 0); @@ -854,8 +854,8 @@ else if (token.startsWith("EX")) { } } - Double emission = new Double(em); - Double excitation = new Double(ex); + Double emission = DataTools.parseDouble(em); + Double excitation = DataTools.parseDouble(ex); Length exWave = FormatTools.getExcitationWavelength(excitation); Length emWave = FormatTools.getEmissionWavelength(emission); diff --git a/components/formats-gpl/src/loci/formats/in/ColumbusReader.java b/components/formats-gpl/src/loci/formats/in/ColumbusReader.java index fcf52845653..ff22e824c02 100644 --- a/components/formats-gpl/src/loci/formats/in/ColumbusReader.java +++ b/components/formats-gpl/src/loci/formats/in/ColumbusReader.java @@ -536,7 +536,7 @@ else if (name.equals("ChannelName")) { p.channelName = value; } else if (name.equals("ChannelColor")) { - Long color = new Long(value); + Long color = Long.parseLong(value); int blue = (int) ((color >> 24) & 0xff); int green = (int) ((color >> 16) & 0xff); int red = (int) ((color >> 8) & 0xff); @@ -548,36 +548,36 @@ else if (name.equals("ChannelColor")) { //p.channelColor = new Color(red, green, blue, alpha); } else if (name.equals("MeasurementTimeOffset")) { - p.deltaT = new Double(value); + p.deltaT = DataTools.parseDouble(value); } else if (name.equals("AbsTime")) { p.deltaT = new Timestamp(value).asInstant().getMillis() / 1000d; } else if (name.equals("MainEmissionWavelength")) { - p.emWavelength = new Double(value); + p.emWavelength = DataTools.parseDouble(value); } else if (name.equals("MainExcitationWavelength")) { - p.exWavelength = new Double(value); + p.exWavelength = DataTools.parseDouble(value); } else if (name.equals("ImageResolutionX")) { String unit = attrs.getNamedItem("Unit").getNodeValue(); - p.sizeX = correctUnits(new Double(value), unit); + p.sizeX = correctUnits(DataTools.parseDouble(value), unit); } else if (name.equals("ImageResolutionY")) { String unit = attrs.getNamedItem("Unit").getNodeValue(); - p.sizeY = correctUnits(new Double(value), unit); + p.sizeY = correctUnits(DataTools.parseDouble(value), unit); } else if (name.equals("PositionX")) { String unit = attrs.getNamedItem("Unit").getNodeValue(); - p.positionX = correctUnits(new Double(value), unit); + p.positionX = correctUnits(DataTools.parseDouble(value), unit); } else if (name.equals("PositionY")) { String unit = attrs.getNamedItem("Unit").getNodeValue(); - p.positionY = correctUnits(new Double(value), unit); + p.positionY = correctUnits(DataTools.parseDouble(value), unit); } else if (name.equals("PositionZ")) { String unit = attrs.getNamedItem("Unit").getNodeValue(); - p.positionZ = correctUnits(new Double(value), unit); + p.positionZ = correctUnits(DataTools.parseDouble(value), unit); } } @@ -725,10 +725,10 @@ else if (currentName.equals("Reference")) { metadataFiles.add(new Location(value).toString()); } else if (currentName.equals("PlateRows")) { - plateRows = new Integer(value); + plateRows = Integer.parseInt(value); } else if (currentName.equals("PlateColumns")) { - plateColumns = new Integer(value); + plateColumns = Integer.parseInt(value); } currentName = null; diff --git a/components/formats-gpl/src/loci/formats/in/DeltavisionReader.java b/components/formats-gpl/src/loci/formats/in/DeltavisionReader.java index f3cc590d4d1..4d415a6f837 100644 --- a/components/formats-gpl/src/loci/formats/in/DeltavisionReader.java +++ b/components/formats-gpl/src/loci/formats/in/DeltavisionReader.java @@ -859,17 +859,17 @@ protected void initExtraMetadata() throws FormatException, IOException { } } - Double x = new Double(pixX); + Double x = Double.valueOf(pixX); Length sizeX = FormatTools.getPhysicalSizeX(x); if (sizeX != null) { store.setPixelsPhysicalSizeX(sizeX, series); } - Double y = new Double(pixY); + Double y = Double.valueOf(pixY); Length sizeY = FormatTools.getPhysicalSizeY(y); if (sizeY != null) { store.setPixelsPhysicalSizeY(sizeY, series); } - Double z = new Double(pixZ); + Double z = Double.valueOf(pixZ); Length sizeZ = FormatTools.getPhysicalSizeZ(z); if (sizeZ != null) { store.setPixelsPhysicalSizeZ(sizeZ, series); @@ -948,12 +948,12 @@ else if (backwardsStageY && xTiles == 1) { DVExtHdrFields hdr = extHdrFields[getPlaneIndex(seriesIndex, i)]; if (expTime[coords[1]] == null) { - expTime[coords[1]] = new Double(hdr.expTime); + expTime[coords[1]] = Double.valueOf(hdr.expTime); } // plane timing store.setPlaneDeltaT( - new Time(new Double(hdr.timeStampSeconds), UNITS.SECOND), series, i); + new Time(Double.valueOf(hdr.timeStampSeconds), UNITS.SECOND), series, i); store.setPlaneExposureTime(new Time(expTime[coords[1]], UNITS.SECOND), series, i); // stage position @@ -967,9 +967,9 @@ else if (backwardsStageY && xTiles == 1) { int w = coords[1]; Length emission = - FormatTools.getEmissionWavelength(new Double(waves[w])); + FormatTools.getEmissionWavelength(Double.valueOf(waves[w])); Length excitation = - FormatTools.getExcitationWavelength(new Double(hdr.exWavelen)); + FormatTools.getExcitationWavelength(Double.valueOf(hdr.exWavelen)); if (emission != null) { store.setChannelEmissionWavelength(emission, series, w); @@ -977,7 +977,7 @@ else if (backwardsStageY && xTiles == 1) { if (excitation != null) { store.setChannelExcitationWavelength(excitation, series, w); } - if (ndFilters[w] == null) ndFilters[w] = new Double(hdr.ndFilter); + if (ndFilters[w] == null) ndFilters[w] = Double.valueOf(hdr.ndFilter); store.setChannelNDFilter(ndFilters[w], series, w); } } @@ -1262,14 +1262,14 @@ private boolean parseLogFile(MetadataStore store) } try { - Double mag = new Double(magnification); + Double mag = DataTools.parseDouble(magnification); store.setObjectiveNominalMagnification(mag, 0, 0); } catch (NumberFormatException e) { LOGGER.warn("Could not parse magnification '{}'", magnification); } try { - store.setObjectiveLensNA(new Double(na), 0, 0); + store.setObjectiveLensNA(DataTools.parseDouble(na), 0, 0); } catch (NumberFormatException e) { LOGGER.warn("Could not parse N.A. '{}'", na); @@ -1308,7 +1308,7 @@ else if (key.equals("Pixel Size")) { for (int q=0; q= 0) { store.setPointTheZ(new NonNegativeInteger( (int) points[obj][contour][i][2]), obj, nextShape); @@ -347,7 +348,7 @@ protected void initFile(String id) throws FormatException, IOException { store.setPolygonID(shapeID, obj, nextShape); store.setPolygonStrokeColor( new Color(r, g, b, 0xff), obj, nextShape); - l = new Length(new Double(lineWidth2D), UNITS.PIXEL); + l = new Length(Double.valueOf(lineWidth2D), UNITS.PIXEL); store.setPolygonStrokeWidth(l, obj, nextShape); if (lineStyle == 1) { store.setPolygonStrokeDashArray("5", obj, nextShape); @@ -363,7 +364,7 @@ protected void initFile(String id) throws FormatException, IOException { store.setPolylineID(shapeID, obj, nextShape); store.setPolylineStrokeColor( new Color(r, g, b, 0xff), obj, nextShape); - l = new Length(new Double(lineWidth2D), UNITS.PIXEL); + l = new Length(Double.valueOf(lineWidth2D), UNITS.PIXEL); store.setPolylineStrokeWidth(l, obj, nextShape); if (lineStyle == 1) { store.setPolylineStrokeDashArray("5", obj, nextShape); diff --git a/components/formats-gpl/src/loci/formats/in/INRReader.java b/components/formats-gpl/src/loci/formats/in/INRReader.java index f04b8ef4923..459145c6278 100644 --- a/components/formats-gpl/src/loci/formats/in/INRReader.java +++ b/components/formats-gpl/src/loci/formats/in/INRReader.java @@ -27,6 +27,7 @@ import java.io.IOException; +import loci.common.DataTools; import loci.common.RandomAccessInputStream; import loci.formats.CoreMetadata; import loci.formats.FormatException; @@ -131,13 +132,13 @@ else if (key.equals("PIXSIZE")) { nBits = Integer.parseInt(bits); } else if (key.equals("VX")) { - physicalSizeX = new Double(value); + physicalSizeX = DataTools.parseDouble(value); } else if (key.equals("VY")) { - physicalSizeY = new Double(value); + physicalSizeY = DataTools.parseDouble(value); } else if (key.equals("VZ")) { - physicalSizeZ = new Double(value); + physicalSizeZ = DataTools.parseDouble(value); } } } diff --git a/components/formats-gpl/src/loci/formats/in/IPLabReader.java b/components/formats-gpl/src/loci/formats/in/IPLabReader.java index 922e1bade09..3c0a740f715 100644 --- a/components/formats-gpl/src/loci/formats/in/IPLabReader.java +++ b/components/formats-gpl/src/loci/formats/in/IPLabReader.java @@ -302,10 +302,10 @@ else if (tag.equals("roi ") && int numRoiPts = in.readInt(); store.setRectangleID(MetadataTools.createLSID("Shape", 0, 0), 0, 0); - store.setRectangleX(new Double(roiLeft), 0, 0); - store.setRectangleY(new Double(roiTop), 0, 0); - store.setRectangleWidth(new Double(roiRight - roiLeft), 0, 0); - store.setRectangleHeight(new Double(roiBottom - roiTop), 0, 0); + store.setRectangleX(Double.valueOf(roiLeft), 0, 0); + store.setRectangleY(Double.valueOf(roiTop), 0, 0); + store.setRectangleWidth(Double.valueOf(roiRight - roiLeft), 0, 0); + store.setRectangleHeight(Double.valueOf(roiBottom - roiTop), 0, 0); String roiID = MetadataTools.createLSID("ROI", 0, 0); store.setROIID(roiID, 0); store.setImageROIRef(roiID, 0, 0); @@ -345,7 +345,7 @@ else if (tag.equals("unit")) { break; } - if (i == 0) pixelSize = new Double(unitsPerPixel); + if (i == 0) pixelSize = Double.valueOf(unitsPerPixel); addGlobalMetaList("UnitName", xUnitName); } @@ -396,11 +396,11 @@ else if (tagBytes[0] == 0x1a && tagBytes[1] == (byte) 0xd9 && for (int c=0; c 0) { value = value.substring(0, value.indexOf(' ')); } - Double size = new Double(value); + Double size = DataTools.parseDouble(value); size = 1.0 / (size * (1.0 / 25400)); Length sizeY = FormatTools.getPhysicalSizeY(size); @@ -227,7 +228,7 @@ else if (key.equals("Horizontal Resolution")) { if (value.indexOf(' ') > 0) { value = value.substring(0, value.indexOf(' ')); } - Double size = new Double(value); + Double size = DataTools.parseDouble(value); size = 1.0 / (size * (1.0 / 25400)); Length sizeX = FormatTools.getPhysicalSizeX(size); @@ -240,11 +241,11 @@ else if (key.equals("CCD Temperature")) { Matcher hexMatcher = Pattern.compile("0x([0-9A-F]+)").matcher(value); if (hexMatcher.matches()) { // CCD temperature stored as a hexadecimal string such as "0xEB". - temp = new Double(Integer.parseInt(hexMatcher.group(1), 16)); + temp = Double.valueOf(Integer.parseInt(hexMatcher.group(1), 16)); LOGGER.debug("CCD temperature detected as {}; assumed to be invalid", temp); } else { - temp = new Double(value.substring(0, value.indexOf(' '))); + temp = DataTools.parseDouble(value.substring(0, value.indexOf(' '))); store.setImagingEnvironmentTemperature( new Temperature(temp, UNITS.CELSIUS), 0); } diff --git a/components/formats-gpl/src/loci/formats/in/L2DReader.java b/components/formats-gpl/src/loci/formats/in/L2DReader.java index a55515d06bf..3f3efd4a379 100644 --- a/components/formats-gpl/src/loci/formats/in/L2DReader.java +++ b/components/formats-gpl/src/loci/formats/in/L2DReader.java @@ -353,7 +353,7 @@ else if (key.equals("ScanChannels")) { for (int q=0; q 0) { - bytesPerAxis.put(new Integer(bytes), "C"); + bytesPerAxis.put(Integer.valueOf(bytes), "C"); } } else if (qName.equals("DimensionDescription")) { @@ -415,7 +416,7 @@ else if (unit.equals("m")) { physicalLen *= 1000000; } - Double physicalSize = new Double(physicalLen); + Double physicalSize = Double.valueOf(physicalLen); CoreMetadata coreMeta = core.get(core.size() - 1); @@ -445,11 +446,11 @@ else if (unit.equals("m")) { if (coreMeta.sizeY != 0) { if (coreMeta.sizeZ == 1) { coreMeta.sizeZ = len; - bytesPerAxis.put(new Integer(nBytes), "Z"); + bytesPerAxis.put(Integer.valueOf(nBytes), "Z"); } else if (coreMeta.sizeT == 1) { coreMeta.sizeT = len; - bytesPerAxis.put(new Integer(nBytes), "T"); + bytesPerAxis.put(Integer.valueOf(nBytes), "T"); } } else { @@ -471,11 +472,11 @@ else if (coreMeta.sizeT == 1) { if (sizeY != null) { store.setPixelsPhysicalSizeY(sizeY, numDatasets); } - bytesPerAxis.put(new Integer(nBytes), "Y"); + bytesPerAxis.put(Integer.valueOf(nBytes), "Y"); } else { coreMeta.sizeZ = len; - bytesPerAxis.put(new Integer(nBytes), "Z"); + bytesPerAxis.put(Integer.valueOf(nBytes), "Z"); } break; case 4: // T axis @@ -488,11 +489,11 @@ else if (coreMeta.sizeT == 1) { if (sizeY != null) { store.setPixelsPhysicalSizeY(sizeY, numDatasets); } - bytesPerAxis.put(new Integer(nBytes), "Y"); + bytesPerAxis.put(Integer.valueOf(nBytes), "Y"); } else { coreMeta.sizeT = len; - bytesPerAxis.put(new Integer(nBytes), "T"); + bytesPerAxis.put(Integer.valueOf(nBytes), "T"); } break; default: @@ -511,10 +512,10 @@ else if (qName.equals("ScannerSettingRecord") && store.setMicroscopeType(MicroscopeType.OTHER, numDatasets); } else if (id.equals("dblPinhole")) { - pinhole = new Double(Double.parseDouble(value) * 1000000); + pinhole = Double.valueOf(Double.parseDouble(value) * 1000000); } else if (id.equals("dblZoom")) { - zoom = new Double(value); + zoom = DataTools.parseDouble(value); } else if (id.equals("dblStepSize")) { double zStep = Double.parseDouble(value) * 1000000; @@ -524,7 +525,7 @@ else if (id.equals("dblStepSize")) { } } else if (id.equals("nDelayTime_s")) { - Double timeIncrement = new Double(value); + Double timeIncrement = DataTools.parseDouble(value); if (timeIncrement != null) { store.setPixelsTimeIncrement(new Time(timeIncrement, UNITS.SECOND), numDatasets); } @@ -542,7 +543,7 @@ else if (id.indexOf("WFC") == 1) { if (channel == null) channel = new Channel(); if (id.endsWith("ExposureTime") && c < numChannels) { try { - Double exposureTime = new Double(value); + Double exposureTime = DataTools.parseDouble(value); if (exposureTime != null) { store.setPlaneExposureTime(new Time(exposureTime, UNITS.SECOND), numDatasets, c); } @@ -550,7 +551,7 @@ else if (id.indexOf("WFC") == 1) { catch (IndexOutOfBoundsException e) { } } else if (id.endsWith("Gain")) { - channel.gain = new Double(value); + channel.gain = DataTools.parseDouble(value); String detectorID = MetadataTools.createLSID("Detector", numDatasets, 0); @@ -559,7 +560,7 @@ else if (id.endsWith("Gain")) { store.setDetectorType(DetectorType.CCD, numDatasets, 0); } else if (id.endsWith("WaveLength")) { - Double exWave = new Double(value); + Double exWave = DataTools.parseDouble(value); Length ex = FormatTools.getExcitationWavelength(exWave); if (ex != null) { channel.exWave = ex; @@ -582,7 +583,7 @@ else if (qName.equals("FilterSettingRecord") && CoreMetadata coreMeta = core.get(numDatasets); if (attribute.equals("NumericalAperture")) { - store.setObjectiveLensNA(new Double(variant), numDatasets, 0); + store.setObjectiveLensNA(DataTools.parseDouble(variant), numDatasets, 0); } else if (attribute.equals("OrderNumber")) { store.setObjectiveSerialNumber(variant, numDatasets, 0); @@ -601,11 +602,11 @@ else if (objectClass.equals("CDetectionUnit")) { } else if (attribute.equals("HighVoltage")) { Detector d = detectors.get(detectors.size() - 1); - d.voltage = new Double(variant); + d.voltage = DataTools.parseDouble(variant); } else if (attribute.equals("VideoOffset")) { Detector d = detectors.get(detectors.size() - 1); - d.offset = new Double(variant); + d.offset = DataTools.parseDouble(variant); } } else if (attribute.equals("Objective")) { @@ -622,7 +623,7 @@ else if (attribute.equals("Objective")) { String na = token.substring(x + 1); store.setObjectiveNominalMagnification(mag, numDatasets, 0); - store.setObjectiveLensNA(new Double(na), numDatasets, 0); + store.setObjectiveLensNA(DataTools.parseDouble(na), numDatasets, 0); } else { model.append(token); @@ -664,7 +665,7 @@ else if (attribute.equals("RefractionIndex")) { String id = MetadataTools.createLSID("Objective", numDatasets, 0); store.setObjectiveID(id, numDatasets, 0); store.setObjectiveSettingsID(id, numDatasets); - store.setObjectiveSettingsRefractiveIndex(new Double(variant), + store.setObjectiveSettingsRefractiveIndex(DataTools.parseDouble(variant), numDatasets); } else if (attribute.equals("XPos")) { @@ -725,9 +726,9 @@ else if (attributes.getValue("Description").endsWith("(right)")) { } else if (qName.equals("Detector") && level != MetadataLevel.MINIMUM) { String v = attributes.getValue("Gain"); - Double gain = v == null ? null : new Double(v); + Double gain = v == null ? null : DataTools.parseDouble(v); v = attributes.getValue("Offset"); - Double offset = v == null ? null : new Double(v); + Double offset = v == null ? null : DataTools.parseDouble(v); boolean active = "1".equals(attributes.getValue("IsActive")); if (active) { @@ -832,7 +833,7 @@ else if (qName.equals("LaserLineSetting") && level != MetadataLevel.MINIMUM) l.index += (2 - (qualifier / 10)); if (l.index < 0) l.index = 0; l.id = MetadataTools.createLSID("LightSource", numDatasets, l.index); - l.wavelength = new Double(attributes.getValue("LaserLine")); + l.wavelength = DataTools.parseDouble(attributes.getValue("LaserLine")); while (l.index > laserCount) { String lsid = MetadataTools.createLSID("LightSource", numDatasets, laserCount); @@ -890,7 +891,7 @@ else if (qName.equals("RelTimeStamp") && level != MetadataLevel.MINIMUM) { CoreMetadata coreMeta = core.get(numDatasets); int nImages = coreMeta.sizeZ * coreMeta.sizeT * coreMeta.sizeC; if (count < nImages) { - Double time = new Double(attributes.getValue("Time")); + Double time = DataTools.parseDouble(attributes.getValue("Time")); if (time != null) { store.setPlaneDeltaT(new Time(time, UNITS.SECOND), numDatasets, count++); } @@ -919,11 +920,11 @@ else if (qName.equals("Vertex") && level != MetadataLevel.MINIMUM) { String y = attributes.getValue("y"); if (x != null) { x = x.replaceAll(",", "."); - roi.x.add(new Double(x)); + roi.x.add(DataTools.parseDouble(x)); } if (y != null) { y = y.replaceAll(",", "."); - roi.y.add(new Double(y)); + roi.y.add(DataTools.parseDouble(y)); } } else if (qName.equals("ROI")) { @@ -1038,7 +1039,7 @@ public void storeROI(MetadataStore store, int series, int roi) { store.setLabelFontSize(fontSize, roi, 0); } } - Length l = new Length(new Double(linewidth), UNITS.PIXEL); + Length l = new Length(Double.valueOf(linewidth), UNITS.PIXEL); store.setLabelStrokeWidth(l, roi, 0); if (!normalized) normalize(); diff --git a/components/formats-gpl/src/loci/formats/in/LeicaReader.java b/components/formats-gpl/src/loci/formats/in/LeicaReader.java index 2ec4d813d53..5f890fb32f5 100644 --- a/components/formats-gpl/src/loci/formats/in/LeicaReader.java +++ b/components/formats-gpl/src/loci/formats/in/LeicaReader.java @@ -211,7 +211,7 @@ public boolean isThisType(RandomAccessInputStream stream) throws IOException { TiffParser tp = new TiffParser(stream); IFD ifd = tp.getFirstIFD(); if (ifd == null) return false; - return ifd.containsKey(new Integer(LEICA_MAGIC_TAG)); + return ifd.containsKey(Integer.valueOf(LEICA_MAGIC_TAG)); } /* @see loci.formats.IFormatReader#get8BitLookupTable() */ @@ -1339,10 +1339,10 @@ private void parseInstrumentData(MetadataStore store, int blockNum) try { if (tokens[2].equals("VideoOffset")) { - detector.offset = new Double(data); + detector.offset = DataTools.parseDouble(data); } else if (tokens[2].equals("HighVoltage")) { - detector.voltage = new Double(data); + detector.voltage = DataTools.parseDouble(data); } else if (tokens[2].equals("State")) { detector.active = data.equals("Active"); @@ -1369,7 +1369,7 @@ else if (tokens[0].startsWith("CTurret")) { int objective = Integer.parseInt(tokens[3]); if (tokens[2].equals("NumericalAperture")) { - store.setObjectiveLensNA(new Double(data), series, objective); + store.setObjectiveLensNA(DataTools.parseDouble(data), series, objective); } else if (tokens[2].equals("Objective")) { String[] objectiveData = data.split(" "); @@ -1420,7 +1420,7 @@ else if (immersion == null) { store.setObjectiveCorrection( MetadataTools.getCorrection(correction), series, objective); store.setObjectiveModel(model.toString().trim(), series, objective); - store.setObjectiveLensNA(new Double(na), series, objective); + store.setObjectiveLensNA(DataTools.parseDouble(na), series, objective); Double magnification = Double.parseDouble(mag); store.setObjectiveNominalMagnification( @@ -1430,7 +1430,7 @@ else if (tokens[2].equals("OrderNumber")) { store.setObjectiveSerialNumber(data, series, objective); } else if (tokens[2].equals("RefractionIndex")) { - store.setObjectiveSettingsRefractiveIndex(new Double(data), series); + store.setObjectiveSettingsRefractiveIndex(DataTools.parseDouble(data), series); } // link Objective to Image @@ -1609,14 +1609,14 @@ else if (contentID.startsWith("nDelayTime")) { } } if (channel < emWaves[i].size()) { - Double wave = new Double(emWaves[i].get(channel).toString()); + Double wave = DataTools.parseDouble(emWaves[i].get(channel).toString()); Length emission = FormatTools.getEmissionWavelength(wave); if (emission != null) { store.setChannelEmissionWavelength(emission, i, channel); } } if (channel < exWaves[i].size()) { - Double wave = new Double(exWaves[i].get(channel).toString()); + Double wave = DataTools.parseDouble(exWaves[i].get(channel).toString()); Length ex = FormatTools.getExcitationWavelength(wave); if (ex != null) { store.setChannelExcitationWavelength(ex, i, channel); diff --git a/components/formats-gpl/src/loci/formats/in/LeicaSCNReader.java b/components/formats-gpl/src/loci/formats/in/LeicaSCNReader.java index f6e76d32afc..276cedf8c27 100644 --- a/components/formats-gpl/src/loci/formats/in/LeicaSCNReader.java +++ b/components/formats-gpl/src/loci/formats/in/LeicaSCNReader.java @@ -45,6 +45,7 @@ import ome.xml.model.enums.IlluminationType; import ome.xml.model.primitives.Timestamp; +import loci.common.DataTools; import loci.common.RandomAccessInputStream; import loci.common.xml.XMLTools; import loci.formats.CoreMetadata; @@ -395,8 +396,8 @@ protected void initMetadataStore() throws FormatException { // Leica units are nanometres; convert to µm double sizeX = i.vSizeX / 1000.0; double sizeY = i.vSizeY / 1000.0; - final Length offsetX = new Length(i.vOffsetX, UNITS.NM); - final Length offsetY = new Length(i.vOffsetY, UNITS.NM); + final Length offsetX = new Length(i.vOffsetX, UNITS.NANOMETER); + final Length offsetY = new Length(i.vOffsetY, UNITS.NANOMETER); double sizeZ = i.vSpacingZ / 1000.0; store.setPixelsPhysicalSizeX( @@ -422,7 +423,7 @@ protected void initMetadataStore() throws FormatException { Double mag = Double.parseDouble(i.objMag); store.setObjectiveNominalMagnification(mag, inst, objectiveidno); store.setObjectiveCalibratedMagnification(mag, inst, objectiveidno); - store.setObjectiveLensNA(new Double(i.illumNA), inst, objectiveidno); + store.setObjectiveLensNA(DataTools.parseDouble(i.illumNA), inst, objectiveidno); objectiveidno++; } diff --git a/components/formats-gpl/src/loci/formats/in/LiFlimReader.java b/components/formats-gpl/src/loci/formats/in/LiFlimReader.java index c3b5aaee6c2..828861b8095 100644 --- a/components/formats-gpl/src/loci/formats/in/LiFlimReader.java +++ b/components/formats-gpl/src/loci/formats/in/LiFlimReader.java @@ -390,7 +390,7 @@ else if (version.equals("2.0")){ addGlobalMeta(metaKey, value); if (metaKey.startsWith(TIMESTAMP_KEY)) { - Integer index = new Integer(metaKey.replaceAll(TIMESTAMP_KEY, "")); + Integer index = Integer.parseInt(metaKey.replaceAll(TIMESTAMP_KEY, "")); stampValues.put(index, value); } else if (metaKey.equals("ROI: INFO - numregions")) { @@ -401,7 +401,7 @@ else if (metaKey.startsWith("ROI: ROI") && { int start = metaKey.lastIndexOf("ROI") + 3; int end = metaKey.indexOf(" ", start); - Integer index = new Integer(metaKey.substring(start, end)); + Integer index = Integer.parseInt(metaKey.substring(start, end)); ROI roi = rois.get(index); if (roi == null) roi = new ROI(); @@ -410,7 +410,7 @@ else if (metaKey.startsWith("ROI: ROI") && } else if (metaKey.indexOf(" - p") >= 0) { String p = metaKey.substring(metaKey.indexOf(" - p") + 4); - roi.points.put(new Integer(p), value.replaceAll(" ", ",")); + roi.points.put(Integer.parseInt(p), value.replaceAll(" ", ",")); } rois.put(index, roi); } @@ -423,7 +423,7 @@ else if (metaKey.equals("ExposureTime")) { } else { exposureTimeUnit = UNITS.SECOND; } - exposureTime = new Double(expTime); + exposureTime = Double.valueOf(expTime); } } } @@ -567,7 +567,7 @@ private void initOMEMetadata() { } else { long ms = stamp - firstStamp; - deltaT = new Double(ms / 1000.0); + deltaT = Double.valueOf(ms / 1000.0); } for (int c=0; c columns, String[] data, int series, store.setEllipseID(MetadataTools.createLSID("Shape", roi, 0), roi, 0); store.setEllipseTheT(new NonNegativeInteger(time), roi, 0); store.setEllipseTheZ(new NonNegativeInteger(z), roi, 0); - store.setEllipseX(new Double(data[columns.indexOf("Col")]), roi, 0); - store.setEllipseY(new Double(data[columns.indexOf("Row")]), roi, 0); + store.setEllipseX(DataTools.parseDouble(data[columns.indexOf("Col")]), roi, 0); + store.setEllipseY(DataTools.parseDouble(data[columns.indexOf("Row")]), roi, 0); store.setEllipseText(data[columns.indexOf("Label")], roi, 0); double diam = Double.parseDouble(data[columns.indexOf("Cell Diam.")]); @@ -1085,10 +1085,10 @@ else if (key.equals("Carrier")) { store.setPlateName(value, 0); } else if (key.equals("Pixel_X")) { - physicalSizeX = new Double(value); + physicalSizeX = DataTools.parseDouble(value); } else if (key.equals("Pixel_Y")) { - physicalSizeY = new Double(value); + physicalSizeY = DataTools.parseDouble(value); } else if (key.equals("Objective_ID")) { store.setObjectiveID( @@ -1109,7 +1109,7 @@ else if (key.equals("Time")) { date += " " + value; } else if (key.equals("Exposure")) { - exposure = new Double(value); + exposure = DataTools.parseDouble(value); } } } diff --git a/components/formats-gpl/src/loci/formats/in/MetamorphHandler.java b/components/formats-gpl/src/loci/formats/in/MetamorphHandler.java index 8eff5190b52..e6bd7408ae3 100644 --- a/components/formats-gpl/src/loci/formats/in/MetamorphHandler.java +++ b/components/formats-gpl/src/loci/formats/in/MetamorphHandler.java @@ -256,7 +256,7 @@ else if (key.equals("stage-position-y")) { } } if (key.equals("wavelength")) { - wavelengths.add(new Integer(value)); + wavelengths.add(Integer.parseInt(value)); } else if (key.equals("acquisition-time-local")) { date = value; diff --git a/components/formats-gpl/src/loci/formats/in/MetamorphReader.java b/components/formats-gpl/src/loci/formats/in/MetamorphReader.java index 82b27902d0c..fa789935731 100644 --- a/components/formats-gpl/src/loci/formats/in/MetamorphReader.java +++ b/components/formats-gpl/src/loci/formats/in/MetamorphReader.java @@ -1170,7 +1170,7 @@ else if (commentEntry instanceof TiffIFDEntry) { line.lastIndexOf("\"", lastQuote - 1) + 1, lastQuote); if (key.equals("z-position")) { - xmlZPosition = new Double(value); + xmlZPosition = DataTools.parseDouble(value); } else if (key.equals("acquisition-time-local")) { timestamps.add(value); @@ -1473,7 +1473,7 @@ else if (key.equals("Gain")) { nextSpace = value.length(); } try { - gain = new Double(value.substring(space, nextSpace)); + gain = DataTools.parseDouble(value.substring(space, nextSpace)); } catch (NumberFormatException e) { } } @@ -2004,13 +2004,13 @@ else if (valOrOffset == 0 && getSizeZ() < mmPlanes) { if (value instanceof TiffRational) { sizeX = ((TiffRational) value).doubleValue(); } - else sizeX = new Double(value.toString()); + else sizeX = DataTools.parseDouble(value.toString()); } if ("YCalibration".equals(key) && value != null) { if (value instanceof TiffRational) { sizeY = ((TiffRational) value).doubleValue(); } - else sizeY = new Double(value.toString()); + else sizeY = DataTools.parseDouble(value.toString()); } } in.seek(saveLoc); diff --git a/components/formats-gpl/src/loci/formats/in/MicroCTReader.java b/components/formats-gpl/src/loci/formats/in/MicroCTReader.java index ab3b5cac95d..490d7143be2 100644 --- a/components/formats-gpl/src/loci/formats/in/MicroCTReader.java +++ b/components/formats-gpl/src/loci/formats/in/MicroCTReader.java @@ -236,7 +236,7 @@ else if (key.equals("bits")) { ms.pixelType = FormatTools.pixelTypeFromBytes(bits / 8, true, false); } else if (key.equals("elementsize")) { - Double size = new Double(value); + Double size = DataTools.parseDouble(value); // physical size is stored in mm, not um physicalSize = new PositiveFloat(size * 1000); } @@ -328,7 +328,7 @@ private void processKey(String key, String value) { addGlobalMeta(key, value); if (key.equals("Exposure Time (ms)")) { - exposureTime = new Double(value); + exposureTime = DataTools.parseDouble(value); exposureTime /= 1000.0; } else if (key.equals("Description.txt")) { diff --git a/components/formats-gpl/src/loci/formats/in/ND2Handler.java b/components/formats-gpl/src/loci/formats/in/ND2Handler.java index 53ec64c10cf..7a4dc80740f 100644 --- a/components/formats-gpl/src/loci/formats/in/ND2Handler.java +++ b/components/formats-gpl/src/loci/formats/in/ND2Handler.java @@ -154,7 +154,7 @@ public void populateROIs(MetadataStore store) { store.setLabelFontSize(new Length(fontSize, UNITS.POINT), r, 0); } store.setLabelText(roi.get("eval-text"), r, 0); - Length l = new Length(new Double(roi.get("line-width")), UNITS.PIXEL); + Length l = new Length(DataTools.parseDouble(roi.get("line-width")), UNITS.PIXEL); store.setLabelStrokeWidth(l, r, 0); String rectangle = roi.get("rectangle"); @@ -568,7 +568,7 @@ else if (qName.equals("dPinholeRadius")) { } else if (qName.endsWith("ChannelColor")) { String name = qName.substring(0, qName.indexOf("Channel")); - colors.put(name, new Integer(value)); + colors.put(name, Integer.parseInt(value)); } else if (qName.endsWith("DyeName")) { int channelIndex = qName.indexOf("Channel"); @@ -885,11 +885,11 @@ else if (key.equals("Line")) { } else if (key.equalsIgnoreCase("Emission wavelength")) { String[] v = value.split(" "); - emWave.add(new Double(v[0])); + emWave.add(DataTools.parseDouble(v[0])); } else if (key.equalsIgnoreCase("Excitation wavelength")) { String[] v = value.split(" "); - exWave.add(new Double(v[0])); + exWave.add(DataTools.parseDouble(v[0])); } else if (key.equals("Power")) { power.add(DataTools.parseDouble(value).intValue()); @@ -898,7 +898,10 @@ else if (key.equals("CameraUniqueName")) { cameraModel = value; } else if (key.equals("ExposureTime")) { - exposureTime.add(new Double(value) / 1000d); + Double time = DataTools.parseDouble(value); + if (time != null) { + exposureTime.add(time / 1000d); + } } else if (key.equals("sDate")) { date = DateTools.formatDate(value, DATE_FORMAT); diff --git a/components/formats-gpl/src/loci/formats/in/ND2Reader.java b/components/formats-gpl/src/loci/formats/in/ND2Reader.java index 01e7ce6ccdd..77b03b0cc64 100644 --- a/components/formats-gpl/src/loci/formats/in/ND2Reader.java +++ b/components/formats-gpl/src/loci/formats/in/ND2Reader.java @@ -713,7 +713,7 @@ else if (trueSizeY == 0) { lastImage = entry; - imageOffsets.add(new Long(entry.position + 16)); + imageOffsets.add(Long.valueOf(entry.position + 16)); int realLength = (int) Math.max(entry.name.length() + 1, nameLength); imageLengths.add(new long[] {realLength, entry.length - nameLength - 16, getSizeX() * getSizeY()}); imageNames.add(entry.name.substring(12)); @@ -2188,7 +2188,7 @@ private ArrayList iterateIn(RandomAccessInputStream in, Long stop, boole name = name.trim(); if (name.equals("bUseZ")) { - useZ = new Boolean(value.toString()); + useZ = Boolean.parseBoolean(value.toString()); } else if (name.equals("sDescription")) { if (currentColor != null) { @@ -2209,7 +2209,7 @@ else if (name.equals("EmWavelength")) { textEmissionWavelengths.add(wave); } else if (name.equals("dZStep")) { - trueSizeZ = new Double(value.toString()); + trueSizeZ = DataTools.parseDouble(value.toString()); } else if (name.equals("dZHigh")) { zHigh = DataTools.parseDouble(value.toString()); diff --git a/components/formats-gpl/src/loci/formats/in/NDPIReader.java b/components/formats-gpl/src/loci/formats/in/NDPIReader.java index 32fc44d20df..b17548bf03c 100644 --- a/components/formats-gpl/src/loci/formats/in/NDPIReader.java +++ b/components/formats-gpl/src/loci/formats/in/NDPIReader.java @@ -551,7 +551,7 @@ else if (s < pyramidHeight) { // key name not a typo if (key.equals("Objective.Lens.Magnificant") && magnification == null) { - magnification = new Double(value); + magnification = DataTools.parseDouble(value); } else if (key.equals("NDP.S/N")) { serialNumber = value; diff --git a/components/formats-gpl/src/loci/formats/in/NiftiReader.java b/components/formats-gpl/src/loci/formats/in/NiftiReader.java index b353b0d6171..7373933c23a 100644 --- a/components/formats-gpl/src/loci/formats/in/NiftiReader.java +++ b/components/formats-gpl/src/loci/formats/in/NiftiReader.java @@ -303,11 +303,11 @@ else if (checkSuffix(id, "nii")) { store.setImageDescription(description, 0); Length sizeX = - FormatTools.getPhysicalSizeX(new Double(voxelWidth), spatialUnit); + FormatTools.getPhysicalSizeX(Double.valueOf(voxelWidth), spatialUnit); Length sizeY = - FormatTools.getPhysicalSizeY(new Double(voxelHeight), spatialUnit); + FormatTools.getPhysicalSizeY(Double.valueOf(voxelHeight), spatialUnit); Length sizeZ = - FormatTools.getPhysicalSizeZ(new Double(sliceThickness), spatialUnit); + FormatTools.getPhysicalSizeZ(Double.valueOf(sliceThickness), spatialUnit); if (sizeX != null) { store.setPixelsPhysicalSizeX(sizeX, 0); @@ -318,7 +318,7 @@ else if (checkSuffix(id, "nii")) { if (sizeZ != null) { store.setPixelsPhysicalSizeZ(sizeZ, 0); } - store.setPixelsTimeIncrement(new Time(new Double(deltaT), timeUnit), 0); + store.setPixelsTimeIncrement(new Time(Double.valueOf(deltaT), timeUnit), 0); } } diff --git a/components/formats-gpl/src/loci/formats/in/NikonTiffReader.java b/components/formats-gpl/src/loci/formats/in/NikonTiffReader.java index 94f70bde608..737f282bcd6 100644 --- a/components/formats-gpl/src/loci/formats/in/NikonTiffReader.java +++ b/components/formats-gpl/src/loci/formats/in/NikonTiffReader.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.List; +import loci.common.DataTools; import loci.common.RandomAccessInputStream; import loci.formats.FormatException; import loci.formats.FormatTools; @@ -167,7 +168,7 @@ else if (key.equals("history objective Type")) { correction = value; } else if (key.equals("history objective Magnification")) { - magnification = new Double(value); + magnification = DataTools.parseDouble(value); } else if (key.equals("history objective NA")) { lensNA = Double.parseDouble(value); @@ -179,25 +180,25 @@ else if (key.equals("history objective Immersion")) { immersion = value; } else if (key.startsWith("history gain")) { - gain.add(new Double(value)); + gain.add(DataTools.parseDouble(value)); } else if (key.equals("history pinhole")) { - pinholeSize = new Double(value.substring(0, value.indexOf(' '))); + pinholeSize = DataTools.parseDouble(value.substring(0, value.indexOf(' '))); } else if (key.startsWith("history laser") && key.endsWith("wavelength")) { - wavelength.add(new Double(value.replaceAll("\\D", ""))); + wavelength.add(DataTools.parseDouble(value.replaceAll("\\D", ""))); } else if (key.startsWith("history laser") && key.endsWith("name")) { laserIDs.add(value); } else if (key.equals("sensor s_params LambdaEx")) { for (int i=nTokensInKey; i 0) { store.setPixelsPhysicalSizeX(FormatTools.getPhysicalSizeX(size), 0); store.setPixelsPhysicalSizeY(FormatTools.getPhysicalSizeY(size), 0); @@ -252,7 +253,7 @@ protected void initMetadataStore() throws FormatException { store.setObjectiveID(MetadataTools.createLSID("Objective", 0, 0), 0, 0); store.setObjectiveCorrection(MetadataTools.getCorrection("Other"), 0, 0); store.setObjectiveImmersion(MetadataTools.getImmersion("Other"), 0, 0); - store.setObjectiveNominalMagnification(new Double(mag), 0, 0); + store.setObjectiveNominalMagnification(DataTools.parseDouble(mag), 0, 0); } final Double xn = Double.valueOf(ifd.getIFDTextValue(X_POS_TAG)); diff --git a/components/formats-gpl/src/loci/formats/in/SpiderReader.java b/components/formats-gpl/src/loci/formats/in/SpiderReader.java index 1db9ed62015..f3e2d98e097 100644 --- a/components/formats-gpl/src/loci/formats/in/SpiderReader.java +++ b/components/formats-gpl/src/loci/formats/in/SpiderReader.java @@ -274,7 +274,7 @@ protected void initFile(String id) throws FormatException, IOException { } if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) { - Double size = new Double(pixelSize); + Double size = Double.valueOf(pixelSize); Length sizeX = FormatTools.getPhysicalSizeX(size, UNITS.ANGSTROM); Length sizeY = FormatTools.getPhysicalSizeY(size, UNITS.ANGSTROM); if (sizeX != null) { diff --git a/components/formats-gpl/src/loci/formats/in/TCSReader.java b/components/formats-gpl/src/loci/formats/in/TCSReader.java index 951a5fe05d2..e05296595f5 100644 --- a/components/formats-gpl/src/loci/formats/in/TCSReader.java +++ b/components/formats-gpl/src/loci/formats/in/TCSReader.java @@ -568,7 +568,7 @@ private void groupFiles() throws FormatException, IOException { String software = ifd.getIFDStringValue(IFD.SOFTWARE); if (software != null && software.trim().startsWith("TCS")) { - timestamps.put(file, new Long(stamp)); + timestamps.put(file, Long.valueOf(stamp)); } } } diff --git a/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java b/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java index c05d47da625..c84e5beb003 100644 --- a/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java +++ b/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java @@ -1424,7 +1424,7 @@ else if (extraIndex >= 0 && extraIndex < extraImages.size()) { if (airPressure != null) { store.setImagingEnvironmentAirPressure( - new Pressure(new Double(airPressure), UNITS.MILLIBAR), i); + new Pressure(DataTools.parseDouble(airPressure), UNITS.MILLIBAR), i); } if (co2Percent != null) { store.setImagingEnvironmentCO2Percent( @@ -1436,21 +1436,21 @@ else if (extraIndex >= 0 && extraIndex < extraImages.size()) { } if (temperature != null) { store.setImagingEnvironmentTemperature(new Temperature( - new Double(temperature), UNITS.CELSIUS), i); + DataTools.parseDouble(temperature), UNITS.CELSIUS), i); } if (objectiveSettingsID != null) { store.setObjectiveSettingsID(objectiveSettingsID, i); if (correctionCollar != null) { store.setObjectiveSettingsCorrectionCollar( - new Double(correctionCollar), i); + DataTools.parseDouble(correctionCollar), i); } if (medium != null) { store.setObjectiveSettingsMedium(MetadataTools.getMedium(medium), i); } if (refractiveIndex != null) { store.setObjectiveSettingsRefractiveIndex( - new Double(refractiveIndex), i); + DataTools.parseDouble(refractiveIndex), i); } } @@ -1687,7 +1687,7 @@ else if (getZCTCoords(plane)[2] < timestamps.size()) { String emWave = channels.get(c).emission; if (emWave != null) { - Double wave = new Double(emWave); + Double wave = DataTools.parseDouble(emWave); Length em = FormatTools.getEmissionWavelength(wave); if (em != null) { store.setChannelEmissionWavelength(em, i, c); @@ -1695,7 +1695,7 @@ else if (getZCTCoords(plane)[2] < timestamps.size()) { } String exWave = channels.get(c).excitation; if (exWave != null) { - Double wave = new Double(exWave); + Double wave = DataTools.parseDouble(exWave); Length ex = FormatTools.getExcitationWavelength(wave); if (ex != null) { store.setChannelExcitationWavelength(ex, i, c); @@ -1709,7 +1709,7 @@ else if (getZCTCoords(plane)[2] < timestamps.size()) { if (channels.get(c).pinhole != null) { store.setChannelPinholeSize( - new Length(new Double(channels.get(c).pinhole), UNITS.MICROMETER), i, c); + new Length(DataTools.parseDouble(channels.get(c).pinhole), UNITS.MICROMETER), i, c); } if (channels.get(c).acquisitionMode != null) { @@ -2509,7 +2509,7 @@ private void translateInformation(Element root) throws FormatException { String power = getFirstNodeValue(lightSource, "Power"); if ("Laser".equals(type)) { if (power != null) { - store.setLaserPower(new Power(new Double(power), UNITS.MILLIWATT), 0, i); + store.setLaserPower(new Power(DataTools.parseDouble(power), UNITS.MILLIWATT), 0, i); } store.setLaserLotNumber(lotNumber, 0, i); store.setLaserManufacturer(manufacturer, 0, i); @@ -2518,7 +2518,7 @@ private void translateInformation(Element root) throws FormatException { } else if ("Arc".equals(type)) { if (power != null) { - store.setArcPower(new Power(new Double(power), UNITS.MILLIWATT), 0, i); + store.setArcPower(new Power(DataTools.parseDouble(power), UNITS.MILLIWATT), 0, i); } store.setArcLotNumber(lotNumber, 0, i); store.setArcManufacturer(manufacturer, 0, i); @@ -2527,7 +2527,7 @@ else if ("Arc".equals(type)) { } else if ("LightEmittingDiode".equals(type)) { if (power != null) { - store.setLightEmittingDiodePower(new Power(new Double(power), UNITS.MILLIWATT), 0, i); + store.setLightEmittingDiodePower(new Power(DataTools.parseDouble(power), UNITS.MILLIWATT), 0, i); } store.setLightEmittingDiodeLotNumber(lotNumber, 0, i); store.setLightEmittingDiodeManufacturer(manufacturer, 0, i); @@ -2536,7 +2536,7 @@ else if ("LightEmittingDiode".equals(type)) { } else if ("Filament".equals(type)) { if (power != null) { - store.setFilamentPower(new Power(new Double(power), UNITS.MILLIWATT), 0, i); + store.setFilamentPower(new Power(DataTools.parseDouble(power), UNITS.MILLIWATT), 0, i); } store.setFilamentLotNumber(lotNumber, 0, i); store.setFilamentManufacturer(manufacturer, 0, i); @@ -2594,7 +2594,7 @@ else if ("Filament".equals(type)) { String offset = getFirstNodeValue(detector, "Offset"); if (offset != null && !offset.equals("")) { - store.setDetectorOffset(new Double(offset), 0, detectorIndex); + store.setDetectorOffset(DataTools.parseDouble(offset), 0, detectorIndex); } zoom = getFirstNodeValue(detector, "Zoom"); @@ -2609,7 +2609,7 @@ else if ("Filament".equals(type)) { String ampGain = getFirstNodeValue(detector, "AmplificationGain"); if (ampGain != null && !ampGain.equals("")) { - store.setDetectorAmplificationGain(new Double(ampGain), 0, detectorIndex); + store.setDetectorAmplificationGain(DataTools.parseDouble(ampGain), 0, detectorIndex); } String detectorType = getFirstNodeValue(detector, "Type"); @@ -2725,8 +2725,8 @@ else if ("Filament".equals(type)) { String cutIn = getFirstNodeValue(transmittance, "CutIn"); String cutOut = getFirstNodeValue(transmittance, "CutOut"); - Double inWave = cutIn == null ? 0 : new Double(cutIn); - Double outWave = cutOut == null ? 0 : new Double(cutOut); + Double inWave = cutIn == null ? 0 : DataTools.parseDouble(cutIn); + Double outWave = cutOut == null ? 0 : DataTools.parseDouble(cutOut); Length in = FormatTools.getCutIn(inWave); Length out = FormatTools.getCutOut(outWave); @@ -2743,13 +2743,13 @@ else if ("Filament".equals(type)) { getFirstNodeValue(transmittance, "CutOutTolerance"); if (inTolerance != null) { - Double cutInTolerance = new Double(inTolerance); + Double cutInTolerance = DataTools.parseDouble(inTolerance); store.setTransmittanceRangeCutInTolerance( new Length(cutInTolerance, UNITS.NANOMETER), 0, i); } if (outTolerance != null) { - Double cutOutTolerance = new Double(outTolerance); + Double cutOutTolerance = DataTools.parseDouble(outTolerance); store.setTransmittanceRangeCutOutTolerance( new Length(cutOutTolerance, UNITS.NANOMETER), 0, i); } @@ -2813,7 +2813,13 @@ private void translateScaling(Element root) { if (originalValue == null) { continue; } - Double value = new Double(originalValue) * 1000000; + Double value = DataTools.parseDouble(originalValue); + if (value != null) { + value *= 1000000; + } + else { + value = 0d; + } if (value > 0) { PositiveFloat size = new PositiveFloat(value); @@ -2940,20 +2946,23 @@ private void translateLayers(Element root) { String centerY = getFirstNodeValue(geometry, "CenterY"); if (length != null) { - Double halfLen = new Double(length) / 2; - if (centerX != null) { - store.setLineX1(new Double(centerX) - halfLen, roiCount, shape); - store.setLineX2(new Double(centerX) + halfLen, roiCount, shape); - - store.setLineX1(new Double(centerX), roiCount, shape + 1); - store.setLineX2(new Double(centerX), roiCount, shape + 1); - } - if (centerY != null) { - store.setLineY1(new Double(centerY), roiCount, shape); - store.setLineY2(new Double(centerY), roiCount, shape); + Double halfLen = DataTools.parseDouble(length); + if (halfLen != null) { + halfLen /= 2; + if (centerX != null) { + store.setLineX1(DataTools.parseDouble(centerX) - halfLen, roiCount, shape); + store.setLineX2(DataTools.parseDouble(centerX) + halfLen, roiCount, shape); + + store.setLineX1(DataTools.parseDouble(centerX), roiCount, shape + 1); + store.setLineX2(DataTools.parseDouble(centerX), roiCount, shape + 1); + } + if (centerY != null) { + store.setLineY1(DataTools.parseDouble(centerY), roiCount, shape); + store.setLineY2(DataTools.parseDouble(centerY), roiCount, shape); - store.setLineY1(new Double(centerY) - halfLen, roiCount, shape + 1); - store.setLineY2(new Double(centerY) + halfLen, roiCount, shape + 1); + store.setLineY1(DataTools.parseDouble(centerY) - halfLen, roiCount, shape + 1); + store.setLineY2(DataTools.parseDouble(centerY) + halfLen, roiCount, shape + 1); + } } } store.setLineText(getFirstNodeValue(textElements, "Text"), roiCount, shape); @@ -2983,16 +2992,16 @@ private void translateLayers(Element root) { String centerY = getFirstNodeValue(geometry, "CenterY"); if (radiusX != null) { - store.setEllipseRadiusX(new Double(radiusX), roiCount, shape); + store.setEllipseRadiusX(DataTools.parseDouble(radiusX), roiCount, shape); } if (radiusY != null) { - store.setEllipseRadiusY(new Double(radiusY), roiCount, shape); + store.setEllipseRadiusY(DataTools.parseDouble(radiusY), roiCount, shape); } if (centerX != null) { - store.setEllipseX(new Double(centerX), roiCount, shape); + store.setEllipseX(DataTools.parseDouble(centerX), roiCount, shape); } if (centerY != null) { - store.setEllipseY(new Double(centerY), roiCount, shape); + store.setEllipseY(DataTools.parseDouble(centerY), roiCount, shape); } store.setEllipseText( getFirstNodeValue(textElements, "Text"), roiCount, shape); @@ -3165,7 +3174,7 @@ private void translateHardwareSettings(Element root) throws FormatException { if (magnification != null) { try { store.setObjectiveNominalMagnification( - new Double(magnification), 0, i); + DataTools.parseDouble(magnification), 0, i); } catch (NumberFormatException e) { LOGGER.debug("Could not parse magnification", e); @@ -3173,7 +3182,7 @@ private void translateHardwareSettings(Element root) throws FormatException { } if (na != null) { try { - store.setObjectiveLensNA(new Double(na), 0, i); + store.setObjectiveLensNA(DataTools.parseDouble(na), 0, i); } catch (NumberFormatException e) { LOGGER.debug("Could not parse numerical aperture", e); @@ -3181,7 +3190,7 @@ private void translateHardwareSettings(Element root) throws FormatException { } if (wd != null) { try { - store.setObjectiveWorkingDistance(new Length(new Double(wd), UNITS.MICROMETER), 0, i); + store.setObjectiveWorkingDistance(new Length(DataTools.parseDouble(wd), UNITS.MICROMETER), 0, i); } catch (NumberFormatException e) { LOGGER.debug("Could not parse working distance", e); @@ -3209,10 +3218,10 @@ private int populateRectangles(NodeList rectangles, int roi, int shape) { if (left != null && top != null && width != null && height != null) { store.setRectangleID( MetadataTools.createLSID("Shape", roi, shape), roi, shape); - store.setRectangleX(new Double(left), roi, shape); - store.setRectangleY(new Double(top), roi, shape); - store.setRectangleWidth(new Double(width), roi, shape); - store.setRectangleHeight(new Double(height), roi, shape); + store.setRectangleX(DataTools.parseDouble(left), roi, shape); + store.setRectangleY(DataTools.parseDouble(top), roi, shape); + store.setRectangleWidth(DataTools.parseDouble(width), roi, shape); + store.setRectangleHeight(DataTools.parseDouble(height), roi, shape); String name = getFirstNodeValue(attributes, "Name"); String label = getFirstNodeValue(textElements, "Text"); @@ -3272,16 +3281,16 @@ private int populateLines(NodeList lines, int roi, int shape) { MetadataTools.createLSID("Shape", roi, shape), roi, shape); if (x1 != null) { - store.setLineX1(new Double(x1), roi, shape); + store.setLineX1(DataTools.parseDouble(x1), roi, shape); } if (x2 != null) { - store.setLineX2(new Double(x2), roi, shape); + store.setLineX2(DataTools.parseDouble(x2), roi, shape); } if (y1 != null) { - store.setLineY1(new Double(y1), roi, shape); + store.setLineY1(DataTools.parseDouble(y1), roi, shape); } if (y2 != null) { - store.setLineY2(new Double(y2), roi, shape); + store.setLineY2(DataTools.parseDouble(y2), roi, shape); } store.setLineText(getFirstNodeValue(textElements, "Text"), roi, shape); } @@ -3302,14 +3311,14 @@ private int populateCircles(NodeList circles, int roi, int shape) { String centerY = getFirstNodeValue(geometry, "CenterY"); if (radius != null) { - store.setEllipseRadiusX(new Double(radius), roi, shape); - store.setEllipseRadiusY(new Double(radius), roi, shape); + store.setEllipseRadiusX(DataTools.parseDouble(radius), roi, shape); + store.setEllipseRadiusY(DataTools.parseDouble(radius), roi, shape); } if (centerX != null) { - store.setEllipseX(new Double(centerX), roi, shape); + store.setEllipseX(DataTools.parseDouble(centerX), roi, shape); } if (centerY != null) { - store.setEllipseY(new Double(centerY), roi, shape); + store.setEllipseY(DataTools.parseDouble(centerY), roi, shape); } store.setEllipseText(getFirstNodeValue(textElements, "Text"), roi, shape); } @@ -3535,7 +3544,7 @@ private void translateExperiment(Element root) throws FormatException { try { if (exposure != null) { - channels.get(i).exposure = new Double(exposure); + channels.get(i).exposure = DataTools.parseDouble(exposure); } } catch (NumberFormatException e) { @@ -3543,7 +3552,7 @@ private void translateExperiment(Element root) throws FormatException { } try { if (gain != null) { - channels.get(i).gain = new Double(gain); + channels.get(i).gain = DataTools.parseDouble(gain); } } catch (NumberFormatException e) { @@ -3825,7 +3834,7 @@ private void parseObjectives(NodeList objectives) throws FormatException { String lensNA = getFirstNodeValue(objective, "LensNA"); if (lensNA != null) { - store.setObjectiveLensNA(new Double(lensNA), 0, i); + store.setObjectiveLensNA(DataTools.parseDouble(lensNA), 0, i); } String magnification = @@ -3833,7 +3842,7 @@ private void parseObjectives(NodeList objectives) throws FormatException { if (magnification == null) { magnification = getFirstNodeValue(objective, "Magnification"); } - Double mag = magnification == null ? null : new Double(magnification); + Double mag = magnification == null ? null : DataTools.parseDouble(magnification); if (mag != null) { store.setObjectiveNominalMagnification(mag, 0, i); @@ -3842,15 +3851,15 @@ private void parseObjectives(NodeList objectives) throws FormatException { getFirstNodeValue(objective, "CalibratedMagnification"); if (calibratedMag != null) { store.setObjectiveCalibratedMagnification( - new Double(calibratedMag), 0, i); + DataTools.parseDouble(calibratedMag), 0, i); } String wd = getFirstNodeValue(objective, "WorkingDistance"); if (wd != null) { - store.setObjectiveWorkingDistance(new Length(new Double(wd), UNITS.MICROMETER), 0, i); + store.setObjectiveWorkingDistance(new Length(DataTools.parseDouble(wd), UNITS.MICROMETER), 0, i); } String iris = getFirstNodeValue(objective, "Iris"); if (iris != null) { - store.setObjectiveIris(new Boolean(iris), 0, i); + store.setObjectiveIris(Boolean.parseBoolean(iris), 0, i); } } } @@ -4286,7 +4295,7 @@ else if (tagNode.getNodeName().equals("AcquisitionTime")) { timestamp = t.asInstant().getMillis() / 1000d; } else if (tagNode.getNodeName().equals("ExposureTime")) { - exposureTime = new Double(text); + exposureTime = DataTools.parseDouble(text); } } } diff --git a/components/formats-gpl/src/loci/formats/in/ZeissLSMReader.java b/components/formats-gpl/src/loci/formats/in/ZeissLSMReader.java index ed22ac83ba9..cf7e82bdce1 100644 --- a/components/formats-gpl/src/loci/formats/in/ZeissLSMReader.java +++ b/components/formats-gpl/src/loci/formats/in/ZeissLSMReader.java @@ -1486,7 +1486,7 @@ nextDetectChannel < getSizeC() && channel.acquire) String transmittance = channel.filter.substring(space + 1).trim(); String[] v = transmittance.split("-"); try { - final Double cutIn = new Double(v[0].trim()); + final Double cutIn = DataTools.parseDouble(v[0].trim()); Length in = FormatTools.getCutIn(cutIn); if (in != null) { store.setTransmittanceRangeCutIn(in, instrument, nextFilter); @@ -1495,7 +1495,7 @@ nextDetectChannel < getSizeC() && channel.acquire) catch (NumberFormatException e) { } if (v.length > 1) { try { - final Double cutOut = new Double(v[1].trim()); + final Double cutOut = DataTools.parseDouble(v[1].trim()); Length out = FormatTools.getCutOut(cutOut); if (out != null) { store.setTransmittanceRangeCutOut(out, instrument, nextFilter); @@ -2410,13 +2410,13 @@ protected void read() throws IOException { int slash = p.indexOf('/'); if (slash > 0) { try { - magnification = new Double(p.substring(0, slash - 1)); + magnification = DataTools.parseDouble(p.substring(0, slash - 1)); } catch (NumberFormatException e) { } } if (slash >= 0 && slash < p.length() - 1) { try { - lensNA = new Double(p.substring(slash + 1)); + lensNA = DataTools.parseDouble(p.substring(slash + 1)); } catch (NumberFormatException e) { } } @@ -2519,7 +2519,7 @@ protected void read() throws IOException { name = getStringValue(ILLUM_CHANNEL_NAME); try { - wavelength = new Double(name); + wavelength = DataTools.parseDouble(name); } catch (NumberFormatException e) { } } From 7865d78773015abbea3a5fd5c04eeec021949dd8 Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Mon, 22 Apr 2024 15:51:50 -0500 Subject: [PATCH 2/3] Use Double.parseDouble instead of DataTools.parseDouble to fix test failures --- .../src/loci/formats/in/BaseZeissReader.java | 21 ++- .../src/loci/formats/in/CellWorxReader.java | 14 +- .../src/loci/formats/in/ND2Handler.java | 11 +- .../src/loci/formats/in/ZeissCZIReader.java | 123 ++++++++---------- 4 files changed, 77 insertions(+), 92 deletions(-) diff --git a/components/formats-gpl/src/loci/formats/in/BaseZeissReader.java b/components/formats-gpl/src/loci/formats/in/BaseZeissReader.java index 4e116091e1b..6327b32f2e6 100644 --- a/components/formats-gpl/src/loci/formats/in/BaseZeissReader.java +++ b/components/formats-gpl/src/loci/formats/in/BaseZeissReader.java @@ -36,7 +36,6 @@ import java.util.ArrayList; import java.lang.Math; -import loci.common.DataTools; import loci.common.DateTools; import loci.formats.CoreMetadata; import loci.formats.FormatTools; @@ -401,12 +400,10 @@ protected void fillMetadataPass7(MetadataStore store) throws FormatException, IO exposure = exposureTime.values().iterator().next(); } Double exp = 0d; - try { exp = DataTools.parseDouble(exposure); } + try { exp = Double.parseDouble(exposure); } catch (NumberFormatException e) { } catch (NullPointerException e) { } - if (exp != null) { - store.setPlaneExposureTime(new Time(exp, UNITS.SECOND), i, plane); - } + store.setPlaneExposureTime(new Time(exp, UNITS.SECOND), i, plane); int posIndex = i * getImageCount() + plane; @@ -913,7 +910,7 @@ else if (key.startsWith("NumberOfRawImages") && rawCount == 0) } else if (key.startsWith("Emission Wavelength")) { if (cIndex != -1) { - Double wave = DataTools.parseDouble(value); + Double wave = Double.parseDouble(value); Length emission = FormatTools.getEmissionWavelength(wave); if (emission != null) { emWavelength.put(cIndex, emission); @@ -922,7 +919,7 @@ else if (key.startsWith("Emission Wavelength")) { } else if (key.startsWith("Excitation Wavelength")) { if (cIndex != -1) { - Double wave = DataTools.parseDouble(value); + Double wave = Double.parseDouble(value); Length excitation = FormatTools.getExcitationWavelength(wave); if (excitation != null) { exWavelength.put(cIndex, excitation); @@ -964,7 +961,7 @@ else if (key.startsWith("Objective ID")) { store.setObjectiveImmersion(MetadataTools.getImmersion("Other"), 0, 0); } else if (key.startsWith("Objective N.A.")) { - store.setObjectiveLensNA(DataTools.parseDouble(value), 0, 0); + store.setObjectiveLensNA(Double.parseDouble(value), 0, 0); } else if (key.startsWith("Objective Name")) { String[] tokens = value.split(" "); @@ -975,14 +972,14 @@ else if (key.startsWith("Objective Name")) { Double.parseDouble(tokens[q].substring(0, slash - q)); String na = tokens[q].substring(slash + 1); store.setObjectiveNominalMagnification(mag, 0, 0); - store.setObjectiveLensNA(DataTools.parseDouble(na), 0, 0); + store.setObjectiveLensNA(Double.parseDouble(na), 0, 0); store.setObjectiveCorrection(MetadataTools.getCorrection(tokens[q - 1]), 0, 0); break; } } } else if (key.startsWith("Objective Working Distance")) { - store.setObjectiveWorkingDistance(new Length(DataTools.parseDouble(value), UNITS.MICROMETER), 0, 0); + store.setObjectiveWorkingDistance(new Length(Double.parseDouble(value), UNITS.MICROMETER), 0, 0); } else if (key.startsWith("Objective Immersion Type")) { String immersion = "Other"; @@ -1008,10 +1005,10 @@ else if (key.startsWith("Stage Position Y")) { addGlobalMetaList("Y position for position", value); } else if (key.startsWith("Orca Analog Gain")) { - detectorGain.put(cIndex, DataTools.parseDouble(value)); + detectorGain.put(cIndex, Double.parseDouble(value)); } else if (key.startsWith("Orca Analog Offset")) { - detectorOffset.put(cIndex, DataTools.parseDouble(value)); + detectorOffset.put(cIndex, Double.parseDouble(value)); } else if (key.startsWith("Comments")) { imageDescription = value; diff --git a/components/formats-gpl/src/loci/formats/in/CellWorxReader.java b/components/formats-gpl/src/loci/formats/in/CellWorxReader.java index 1cd3593464d..4b603927a4d 100644 --- a/components/formats-gpl/src/loci/formats/in/CellWorxReader.java +++ b/components/formats-gpl/src/loci/formats/in/CellWorxReader.java @@ -778,8 +778,8 @@ protected void parseWellLogFile(int wellIndex, MetadataStore store) } else if (key.equals("Scan Origin")) { String[] axes = value.split(","); - Double posX = DataTools.parseDouble(axes[0]); - Double posY = DataTools.parseDouble(axes[1]); + Double posX = Double.parseDouble(axes[0]); + Double posY = Double.parseDouble(axes[1]); for (int fieldRow=0; fieldRow 0) { int end = value.indexOf(" ", s + 2); - Double xSize = DataTools.parseDouble(value.substring(0, s).trim()); - Double ySize = DataTools.parseDouble(value.substring(s + 1, end).trim()); + Double xSize = Double.parseDouble(value.substring(0, s).trim()); + Double ySize = Double.parseDouble(value.substring(s + 1, end).trim()); Length x = FormatTools.getPhysicalSizeX(xSize / getSizeX()); Length y = FormatTools.getPhysicalSizeY(ySize / getSizeY()); @@ -827,7 +827,7 @@ else if (key.startsWith("Channel")) { token = token.trim(); if (token.startsWith("gain")) { String instrumentID = MetadataTools.createLSID("Instrument", 0); - Double gain = DataTools.parseDouble(token.replaceAll("gain ", "")); + Double gain = Double.parseDouble(token.replaceAll("gain ", "")); String detectorID = MetadataTools.createLSID("Detector", 0, 0); store.setInstrumentID(instrumentID, 0); @@ -854,8 +854,8 @@ else if (token.startsWith("EX")) { } } - Double emission = DataTools.parseDouble(em); - Double excitation = DataTools.parseDouble(ex); + Double emission = Double.parseDouble(em); + Double excitation = Double.parseDouble(ex); Length exWave = FormatTools.getExcitationWavelength(excitation); Length emWave = FormatTools.getEmissionWavelength(emission); diff --git a/components/formats-gpl/src/loci/formats/in/ND2Handler.java b/components/formats-gpl/src/loci/formats/in/ND2Handler.java index 7a4dc80740f..48d11f30895 100644 --- a/components/formats-gpl/src/loci/formats/in/ND2Handler.java +++ b/components/formats-gpl/src/loci/formats/in/ND2Handler.java @@ -154,7 +154,7 @@ public void populateROIs(MetadataStore store) { store.setLabelFontSize(new Length(fontSize, UNITS.POINT), r, 0); } store.setLabelText(roi.get("eval-text"), r, 0); - Length l = new Length(DataTools.parseDouble(roi.get("line-width")), UNITS.PIXEL); + Length l = new Length(Double.parseDouble(roi.get("line-width")), UNITS.PIXEL); store.setLabelStrokeWidth(l, r, 0); String rectangle = roi.get("rectangle"); @@ -885,11 +885,11 @@ else if (key.equals("Line")) { } else if (key.equalsIgnoreCase("Emission wavelength")) { String[] v = value.split(" "); - emWave.add(DataTools.parseDouble(v[0])); + emWave.add(Double.parseDouble(v[0])); } else if (key.equalsIgnoreCase("Excitation wavelength")) { String[] v = value.split(" "); - exWave.add(DataTools.parseDouble(v[0])); + exWave.add(Double.parseDouble(v[0])); } else if (key.equals("Power")) { power.add(DataTools.parseDouble(value).intValue()); @@ -898,10 +898,7 @@ else if (key.equals("CameraUniqueName")) { cameraModel = value; } else if (key.equals("ExposureTime")) { - Double time = DataTools.parseDouble(value); - if (time != null) { - exposureTime.add(time / 1000d); - } + exposureTime.add(Double.parseDouble(value) / 1000d); } else if (key.equals("sDate")) { date = DateTools.formatDate(value, DATE_FORMAT); diff --git a/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java b/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java index c84e5beb003..db5d505a895 100644 --- a/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java +++ b/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java @@ -1424,7 +1424,7 @@ else if (extraIndex >= 0 && extraIndex < extraImages.size()) { if (airPressure != null) { store.setImagingEnvironmentAirPressure( - new Pressure(DataTools.parseDouble(airPressure), UNITS.MILLIBAR), i); + new Pressure(Double.parseDouble(airPressure), UNITS.MILLIBAR), i); } if (co2Percent != null) { store.setImagingEnvironmentCO2Percent( @@ -1436,21 +1436,21 @@ else if (extraIndex >= 0 && extraIndex < extraImages.size()) { } if (temperature != null) { store.setImagingEnvironmentTemperature(new Temperature( - DataTools.parseDouble(temperature), UNITS.CELSIUS), i); + Double.parseDouble(temperature), UNITS.CELSIUS), i); } if (objectiveSettingsID != null) { store.setObjectiveSettingsID(objectiveSettingsID, i); if (correctionCollar != null) { store.setObjectiveSettingsCorrectionCollar( - DataTools.parseDouble(correctionCollar), i); + Double.parseDouble(correctionCollar), i); } if (medium != null) { store.setObjectiveSettingsMedium(MetadataTools.getMedium(medium), i); } if (refractiveIndex != null) { store.setObjectiveSettingsRefractiveIndex( - DataTools.parseDouble(refractiveIndex), i); + Double.parseDouble(refractiveIndex), i); } } @@ -1687,7 +1687,7 @@ else if (getZCTCoords(plane)[2] < timestamps.size()) { String emWave = channels.get(c).emission; if (emWave != null) { - Double wave = DataTools.parseDouble(emWave); + Double wave = Double.parseDouble(emWave); Length em = FormatTools.getEmissionWavelength(wave); if (em != null) { store.setChannelEmissionWavelength(em, i, c); @@ -1695,7 +1695,7 @@ else if (getZCTCoords(plane)[2] < timestamps.size()) { } String exWave = channels.get(c).excitation; if (exWave != null) { - Double wave = DataTools.parseDouble(exWave); + Double wave = Double.parseDouble(exWave); Length ex = FormatTools.getExcitationWavelength(wave); if (ex != null) { store.setChannelExcitationWavelength(ex, i, c); @@ -1709,7 +1709,7 @@ else if (getZCTCoords(plane)[2] < timestamps.size()) { if (channels.get(c).pinhole != null) { store.setChannelPinholeSize( - new Length(DataTools.parseDouble(channels.get(c).pinhole), UNITS.MICROMETER), i, c); + new Length(Double.parseDouble(channels.get(c).pinhole), UNITS.MICROMETER), i, c); } if (channels.get(c).acquisitionMode != null) { @@ -2509,7 +2509,7 @@ private void translateInformation(Element root) throws FormatException { String power = getFirstNodeValue(lightSource, "Power"); if ("Laser".equals(type)) { if (power != null) { - store.setLaserPower(new Power(DataTools.parseDouble(power), UNITS.MILLIWATT), 0, i); + store.setLaserPower(new Power(Double.parseDouble(power), UNITS.MILLIWATT), 0, i); } store.setLaserLotNumber(lotNumber, 0, i); store.setLaserManufacturer(manufacturer, 0, i); @@ -2518,7 +2518,7 @@ private void translateInformation(Element root) throws FormatException { } else if ("Arc".equals(type)) { if (power != null) { - store.setArcPower(new Power(DataTools.parseDouble(power), UNITS.MILLIWATT), 0, i); + store.setArcPower(new Power(Double.parseDouble(power), UNITS.MILLIWATT), 0, i); } store.setArcLotNumber(lotNumber, 0, i); store.setArcManufacturer(manufacturer, 0, i); @@ -2527,7 +2527,7 @@ else if ("Arc".equals(type)) { } else if ("LightEmittingDiode".equals(type)) { if (power != null) { - store.setLightEmittingDiodePower(new Power(DataTools.parseDouble(power), UNITS.MILLIWATT), 0, i); + store.setLightEmittingDiodePower(new Power(Double.parseDouble(power), UNITS.MILLIWATT), 0, i); } store.setLightEmittingDiodeLotNumber(lotNumber, 0, i); store.setLightEmittingDiodeManufacturer(manufacturer, 0, i); @@ -2536,7 +2536,7 @@ else if ("LightEmittingDiode".equals(type)) { } else if ("Filament".equals(type)) { if (power != null) { - store.setFilamentPower(new Power(DataTools.parseDouble(power), UNITS.MILLIWATT), 0, i); + store.setFilamentPower(new Power(Double.parseDouble(power), UNITS.MILLIWATT), 0, i); } store.setFilamentLotNumber(lotNumber, 0, i); store.setFilamentManufacturer(manufacturer, 0, i); @@ -2594,7 +2594,7 @@ else if ("Filament".equals(type)) { String offset = getFirstNodeValue(detector, "Offset"); if (offset != null && !offset.equals("")) { - store.setDetectorOffset(DataTools.parseDouble(offset), 0, detectorIndex); + store.setDetectorOffset(Double.parseDouble(offset), 0, detectorIndex); } zoom = getFirstNodeValue(detector, "Zoom"); @@ -2609,7 +2609,7 @@ else if ("Filament".equals(type)) { String ampGain = getFirstNodeValue(detector, "AmplificationGain"); if (ampGain != null && !ampGain.equals("")) { - store.setDetectorAmplificationGain(DataTools.parseDouble(ampGain), 0, detectorIndex); + store.setDetectorAmplificationGain(Double.parseDouble(ampGain), 0, detectorIndex); } String detectorType = getFirstNodeValue(detector, "Type"); @@ -2725,8 +2725,8 @@ else if ("Filament".equals(type)) { String cutIn = getFirstNodeValue(transmittance, "CutIn"); String cutOut = getFirstNodeValue(transmittance, "CutOut"); - Double inWave = cutIn == null ? 0 : DataTools.parseDouble(cutIn); - Double outWave = cutOut == null ? 0 : DataTools.parseDouble(cutOut); + Double inWave = cutIn == null ? 0 : Double.parseDouble(cutIn); + Double outWave = cutOut == null ? 0 : Double.parseDouble(cutOut); Length in = FormatTools.getCutIn(inWave); Length out = FormatTools.getCutOut(outWave); @@ -2743,13 +2743,13 @@ else if ("Filament".equals(type)) { getFirstNodeValue(transmittance, "CutOutTolerance"); if (inTolerance != null) { - Double cutInTolerance = DataTools.parseDouble(inTolerance); + Double cutInTolerance = Double.parseDouble(inTolerance); store.setTransmittanceRangeCutInTolerance( new Length(cutInTolerance, UNITS.NANOMETER), 0, i); } if (outTolerance != null) { - Double cutOutTolerance = DataTools.parseDouble(outTolerance); + Double cutOutTolerance = Double.parseDouble(outTolerance); store.setTransmittanceRangeCutOutTolerance( new Length(cutOutTolerance, UNITS.NANOMETER), 0, i); } @@ -2813,13 +2813,7 @@ private void translateScaling(Element root) { if (originalValue == null) { continue; } - Double value = DataTools.parseDouble(originalValue); - if (value != null) { - value *= 1000000; - } - else { - value = 0d; - } + Double value = Double.parseDouble(originalValue) * 1000000; if (value > 0) { PositiveFloat size = new PositiveFloat(value); @@ -2946,23 +2940,20 @@ private void translateLayers(Element root) { String centerY = getFirstNodeValue(geometry, "CenterY"); if (length != null) { - Double halfLen = DataTools.parseDouble(length); - if (halfLen != null) { - halfLen /= 2; - if (centerX != null) { - store.setLineX1(DataTools.parseDouble(centerX) - halfLen, roiCount, shape); - store.setLineX2(DataTools.parseDouble(centerX) + halfLen, roiCount, shape); - - store.setLineX1(DataTools.parseDouble(centerX), roiCount, shape + 1); - store.setLineX2(DataTools.parseDouble(centerX), roiCount, shape + 1); - } - if (centerY != null) { - store.setLineY1(DataTools.parseDouble(centerY), roiCount, shape); - store.setLineY2(DataTools.parseDouble(centerY), roiCount, shape); + Double halfLen = Double.parseDouble(length) / 2; + if (centerX != null) { + store.setLineX1(Double.parseDouble(centerX) - halfLen, roiCount, shape); + store.setLineX2(Double.parseDouble(centerX) + halfLen, roiCount, shape); - store.setLineY1(DataTools.parseDouble(centerY) - halfLen, roiCount, shape + 1); - store.setLineY2(DataTools.parseDouble(centerY) + halfLen, roiCount, shape + 1); - } + store.setLineX1(Double.parseDouble(centerX), roiCount, shape + 1); + store.setLineX2(Double.parseDouble(centerX), roiCount, shape + 1); + } + if (centerY != null) { + store.setLineY1(Double.parseDouble(centerY), roiCount, shape); + store.setLineY2(Double.parseDouble(centerY), roiCount, shape); + + store.setLineY1(Double.parseDouble(centerY) - halfLen, roiCount, shape + 1); + store.setLineY2(Double.parseDouble(centerY) + halfLen, roiCount, shape + 1); } } store.setLineText(getFirstNodeValue(textElements, "Text"), roiCount, shape); @@ -2992,16 +2983,16 @@ private void translateLayers(Element root) { String centerY = getFirstNodeValue(geometry, "CenterY"); if (radiusX != null) { - store.setEllipseRadiusX(DataTools.parseDouble(radiusX), roiCount, shape); + store.setEllipseRadiusX(Double.parseDouble(radiusX), roiCount, shape); } if (radiusY != null) { - store.setEllipseRadiusY(DataTools.parseDouble(radiusY), roiCount, shape); + store.setEllipseRadiusY(Double.parseDouble(radiusY), roiCount, shape); } if (centerX != null) { - store.setEllipseX(DataTools.parseDouble(centerX), roiCount, shape); + store.setEllipseX(Double.parseDouble(centerX), roiCount, shape); } if (centerY != null) { - store.setEllipseY(DataTools.parseDouble(centerY), roiCount, shape); + store.setEllipseY(Double.parseDouble(centerY), roiCount, shape); } store.setEllipseText( getFirstNodeValue(textElements, "Text"), roiCount, shape); @@ -3174,7 +3165,7 @@ private void translateHardwareSettings(Element root) throws FormatException { if (magnification != null) { try { store.setObjectiveNominalMagnification( - DataTools.parseDouble(magnification), 0, i); + Double.parseDouble(magnification), 0, i); } catch (NumberFormatException e) { LOGGER.debug("Could not parse magnification", e); @@ -3182,7 +3173,7 @@ private void translateHardwareSettings(Element root) throws FormatException { } if (na != null) { try { - store.setObjectiveLensNA(DataTools.parseDouble(na), 0, i); + store.setObjectiveLensNA(Double.parseDouble(na), 0, i); } catch (NumberFormatException e) { LOGGER.debug("Could not parse numerical aperture", e); @@ -3190,7 +3181,7 @@ private void translateHardwareSettings(Element root) throws FormatException { } if (wd != null) { try { - store.setObjectiveWorkingDistance(new Length(DataTools.parseDouble(wd), UNITS.MICROMETER), 0, i); + store.setObjectiveWorkingDistance(new Length(Double.parseDouble(wd), UNITS.MICROMETER), 0, i); } catch (NumberFormatException e) { LOGGER.debug("Could not parse working distance", e); @@ -3218,10 +3209,10 @@ private int populateRectangles(NodeList rectangles, int roi, int shape) { if (left != null && top != null && width != null && height != null) { store.setRectangleID( MetadataTools.createLSID("Shape", roi, shape), roi, shape); - store.setRectangleX(DataTools.parseDouble(left), roi, shape); - store.setRectangleY(DataTools.parseDouble(top), roi, shape); - store.setRectangleWidth(DataTools.parseDouble(width), roi, shape); - store.setRectangleHeight(DataTools.parseDouble(height), roi, shape); + store.setRectangleX(Double.parseDouble(left), roi, shape); + store.setRectangleY(Double.parseDouble(top), roi, shape); + store.setRectangleWidth(Double.parseDouble(width), roi, shape); + store.setRectangleHeight(Double.parseDouble(height), roi, shape); String name = getFirstNodeValue(attributes, "Name"); String label = getFirstNodeValue(textElements, "Text"); @@ -3281,16 +3272,16 @@ private int populateLines(NodeList lines, int roi, int shape) { MetadataTools.createLSID("Shape", roi, shape), roi, shape); if (x1 != null) { - store.setLineX1(DataTools.parseDouble(x1), roi, shape); + store.setLineX1(Double.parseDouble(x1), roi, shape); } if (x2 != null) { - store.setLineX2(DataTools.parseDouble(x2), roi, shape); + store.setLineX2(Double.parseDouble(x2), roi, shape); } if (y1 != null) { - store.setLineY1(DataTools.parseDouble(y1), roi, shape); + store.setLineY1(Double.parseDouble(y1), roi, shape); } if (y2 != null) { - store.setLineY2(DataTools.parseDouble(y2), roi, shape); + store.setLineY2(Double.parseDouble(y2), roi, shape); } store.setLineText(getFirstNodeValue(textElements, "Text"), roi, shape); } @@ -3311,14 +3302,14 @@ private int populateCircles(NodeList circles, int roi, int shape) { String centerY = getFirstNodeValue(geometry, "CenterY"); if (radius != null) { - store.setEllipseRadiusX(DataTools.parseDouble(radius), roi, shape); - store.setEllipseRadiusY(DataTools.parseDouble(radius), roi, shape); + store.setEllipseRadiusX(Double.parseDouble(radius), roi, shape); + store.setEllipseRadiusY(Double.parseDouble(radius), roi, shape); } if (centerX != null) { - store.setEllipseX(DataTools.parseDouble(centerX), roi, shape); + store.setEllipseX(Double.parseDouble(centerX), roi, shape); } if (centerY != null) { - store.setEllipseY(DataTools.parseDouble(centerY), roi, shape); + store.setEllipseY(Double.parseDouble(centerY), roi, shape); } store.setEllipseText(getFirstNodeValue(textElements, "Text"), roi, shape); } @@ -3544,7 +3535,7 @@ private void translateExperiment(Element root) throws FormatException { try { if (exposure != null) { - channels.get(i).exposure = DataTools.parseDouble(exposure); + channels.get(i).exposure = Double.parseDouble(exposure); } } catch (NumberFormatException e) { @@ -3552,7 +3543,7 @@ private void translateExperiment(Element root) throws FormatException { } try { if (gain != null) { - channels.get(i).gain = DataTools.parseDouble(gain); + channels.get(i).gain = Double.parseDouble(gain); } } catch (NumberFormatException e) { @@ -3834,7 +3825,7 @@ private void parseObjectives(NodeList objectives) throws FormatException { String lensNA = getFirstNodeValue(objective, "LensNA"); if (lensNA != null) { - store.setObjectiveLensNA(DataTools.parseDouble(lensNA), 0, i); + store.setObjectiveLensNA(Double.parseDouble(lensNA), 0, i); } String magnification = @@ -3842,7 +3833,7 @@ private void parseObjectives(NodeList objectives) throws FormatException { if (magnification == null) { magnification = getFirstNodeValue(objective, "Magnification"); } - Double mag = magnification == null ? null : DataTools.parseDouble(magnification); + Double mag = magnification == null ? null : Double.parseDouble(magnification); if (mag != null) { store.setObjectiveNominalMagnification(mag, 0, i); @@ -3851,11 +3842,11 @@ private void parseObjectives(NodeList objectives) throws FormatException { getFirstNodeValue(objective, "CalibratedMagnification"); if (calibratedMag != null) { store.setObjectiveCalibratedMagnification( - DataTools.parseDouble(calibratedMag), 0, i); + Double.parseDouble(calibratedMag), 0, i); } String wd = getFirstNodeValue(objective, "WorkingDistance"); if (wd != null) { - store.setObjectiveWorkingDistance(new Length(DataTools.parseDouble(wd), UNITS.MICROMETER), 0, i); + store.setObjectiveWorkingDistance(new Length(Double.parseDouble(wd), UNITS.MICROMETER), 0, i); } String iris = getFirstNodeValue(objective, "Iris"); if (iris != null) { @@ -4295,7 +4286,7 @@ else if (tagNode.getNodeName().equals("AcquisitionTime")) { timestamp = t.asInstant().getMillis() / 1000d; } else if (tagNode.getNodeName().equals("ExposureTime")) { - exposureTime = DataTools.parseDouble(text); + exposureTime = Double.parseDouble(text); } } } From af483e7f79fc011c4adea0ab05918f374f6df348 Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Wed, 24 Apr 2024 11:09:35 -0500 Subject: [PATCH 3/3] Use Double.parseDouble instead of DataTools.parseDouble to fix one more test failure --- .../formats-gpl/src/loci/formats/in/FlexReader.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/formats-gpl/src/loci/formats/in/FlexReader.java b/components/formats-gpl/src/loci/formats/in/FlexReader.java index 01c9f06de9c..fa52973495f 100644 --- a/components/formats-gpl/src/loci/formats/in/FlexReader.java +++ b/components/formats-gpl/src/loci/formats/in/FlexReader.java @@ -1552,7 +1552,7 @@ else if (qName.equals("Barcode")) { else if (qName.equals("Wavelength") && populateCore) { String lsid = MetadataTools.createLSID("LightSource", 0, nextLaser); store.setLaserID(lsid, 0, nextLaser); - Double wavelength = DataTools.parseDouble(value); + Double wavelength = Double.parseDouble(value); Length wave = FormatTools.getWavelength(wavelength); if (wave != null) { store.setLaserWavelength(wave, 0, nextLaser); @@ -1566,11 +1566,11 @@ else if (qName.equals("Wavelength") && populateCore) { } } else if (qName.equals("Magnification") && populateCore) { - store.setObjectiveCalibratedMagnification(DataTools.parseDouble(value), 0, + store.setObjectiveCalibratedMagnification(Double.parseDouble(value), 0, nextObjective); } else if (qName.equals("NumAperture") && populateCore) { - store.setObjectiveLensNA(DataTools.parseDouble(value), 0, nextObjective); + store.setObjectiveLensNA(Double.parseDouble(value), 0, nextObjective); } else if (qName.equals("Immersion") && populateCore) { String immersion = "Other"; @@ -1656,10 +1656,10 @@ else if (qName.equals("PositionZ")) { } } else if (qName.equals("TimepointOffsetUsed")) { - planeDeltaT.add(DataTools.parseDouble(value)); + planeDeltaT.add(Double.parseDouble(value)); } else if (qName.equals("CameraExposureTime")) { - planeExposureTime.add(DataTools.parseDouble(value)); + planeExposureTime.add(Double.parseDouble(value)); } else if (qName.equals("LightSourceCombinationRef")) { lightSourceCombinationRefs.add(value);