Skip to content

Commit

Permalink
Merge pull request #4182 from melissalinkert/gpl-warnings
Browse files Browse the repository at this point in the history
Fix Java 9+ warnings in formats-gpl component
  • Loading branch information
dgault authored Apr 30, 2024
2 parents e9d968a + af483e7 commit bf2c462
Show file tree
Hide file tree
Showing 65 changed files with 527 additions and 483 deletions.
13 changes: 7 additions & 6 deletions components/formats-gpl/src/loci/formats/in/AIMReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import java.io.IOException;

import loci.common.DataTools;
import loci.common.DateTools;
import loci.common.RandomAccessInputStream;
import loci.formats.CoreMetadata;
Expand Down Expand Up @@ -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);
}
}
}
Expand All @@ -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);
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions components/formats-gpl/src/loci/formats/in/AliconaReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import java.io.IOException;

import loci.common.DataTools;
import loci.common.RandomAccessInputStream;
import loci.formats.CoreMetadata;
import loci.formats.FormatException;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions components/formats-gpl/src/loci/formats/in/BDReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<getSeriesCount(); s++) {
Expand Down
29 changes: 15 additions & 14 deletions components/formats-gpl/src/loci/formats/in/BaseZeissReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ protected void fillMetadataPass7(MetadataStore store) throws FormatException, IO
exposure = exposureTime.values().iterator().next();
}
Double exp = 0d;
try { exp = new Double(exposure); }
try { exp = Double.parseDouble(exposure); }
catch (NumberFormatException e) { }
catch (NullPointerException e) { }
store.setPlaneExposureTime(new Time(exp, UNITS.SECOND), i, plane);
Expand Down Expand Up @@ -844,12 +844,13 @@ else if (key.equals("ImageHeight")) {
}

if (key.startsWith("ImageTile") && !(store instanceof DummyMetadata)) {
if (!tiles.containsKey(new Integer(value))) {
tiles.put(Integer.valueOf(value), 1);
Integer intValue = Integer.parseInt(value);
if (!tiles.containsKey(intValue)) {
tiles.put(intValue, 1);
}
else {
int v = tiles.get(new Integer(value)).intValue() + 1;
tiles.put(new Integer(value), new Integer(v));
int v = tiles.get(intValue).intValue() + 1;
tiles.put(intValue, Integer.valueOf(v));
}
}

Expand Down Expand Up @@ -909,7 +910,7 @@ else if (key.startsWith("NumberOfRawImages") && rawCount == 0)
}
else if (key.startsWith("Emission Wavelength")) {
if (cIndex != -1) {
Double wave = new Double(value);
Double wave = Double.parseDouble(value);
Length emission = FormatTools.getEmissionWavelength(wave);
if (emission != null) {
emWavelength.put(cIndex, emission);
Expand All @@ -918,7 +919,7 @@ else if (key.startsWith("Emission Wavelength")) {
}
else if (key.startsWith("Excitation Wavelength")) {
if (cIndex != -1) {
Double wave = new Double(Double.parseDouble(value));
Double wave = Double.parseDouble(value);
Length excitation = FormatTools.getExcitationWavelength(wave);
if (excitation != null) {
exWavelength.put(cIndex, excitation);
Expand All @@ -931,9 +932,9 @@ else if (key.startsWith("Channel Name")) {
}
}
else if (key.startsWith("Exposure Time [ms]")) {
if (exposureTime.get(new Integer(cIndex)) == null) {
if (exposureTime.get(Integer.valueOf(cIndex)) == null) {
double exp = Double.parseDouble(value) / 1000;
exposureTime.put(new Integer(cIndex), String.valueOf(exp));
exposureTime.put(Integer.valueOf(cIndex), String.valueOf(exp));
}
}
else if (key.startsWith("User Name")) {
Expand All @@ -960,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(new Double(value), 0, 0);
store.setObjectiveLensNA(Double.parseDouble(value), 0, 0);
}
else if (key.startsWith("Objective Name")) {
String[] tokens = value.split(" ");
Expand All @@ -971,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(new Double(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(new Double(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";
Expand All @@ -1004,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, new Double(value));
detectorGain.put(cIndex, Double.parseDouble(value));
}
else if (key.startsWith("Orca Analog Offset")) {
detectorOffset.put(cIndex, new Double(value));
detectorOffset.put(cIndex, Double.parseDouble(value));
}
else if (key.startsWith("Comments")) {
imageDescription = value;
Expand Down
21 changes: 11 additions & 10 deletions components/formats-gpl/src/loci/formats/in/BioRadReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.List;
import java.util.StringTokenizer;

import loci.common.DataTools;
import loci.common.Location;
import loci.common.RandomAccessInputStream;
import loci.common.xml.BaseHandler;
Expand Down Expand Up @@ -502,8 +503,8 @@ else if (list[i].endsWith("data.raw")) {
store.setObjectiveID(objectiveID, 0, 0);
store.setObjectiveSettingsID(objectiveID, 0);

store.setObjectiveLensNA(new Double(lens), 0, 0);
store.setObjectiveNominalMagnification(new Double(magFactor), 0, 0);
store.setObjectiveLensNA(Double.valueOf(lens), 0, 0);
store.setObjectiveNominalMagnification(Double.valueOf(magFactor), 0, 0);
store.setObjectiveCorrection(MetadataTools.getCorrection("Other"), 0, 0);
store.setObjectiveImmersion(MetadataTools.getImmersion("Other"), 0, 0);

Expand Down Expand Up @@ -673,7 +674,7 @@ else if (key.startsWith("SETTING")) {
while (nextDetector > offset.size()) {
offset.add(null);
}
offset.add(new Double(value));
offset.add(DataTools.parseDouble(value));
}
}
else if (key.endsWith("GAIN")) {
Expand All @@ -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++;
Expand All @@ -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);
Expand All @@ -722,15 +723,15 @@ 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);
}
}
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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 13 additions & 6 deletions components/formats-gpl/src/loci/formats/in/BioRadSCNReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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")) {
Expand Down
4 changes: 2 additions & 2 deletions components/formats-gpl/src/loci/formats/in/BrukerReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }

Expand Down
Loading

0 comments on commit bf2c462

Please sign in to comment.