Skip to content

Commit 7dda43c

Browse files
committed
Fix sonar issues
1 parent 4e4529c commit 7dda43c

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/mpr/cmpr/CurvedMprAxis.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public DebugCurveData(
7878
private CurvedMprImageIO io;
7979
private DicomImageElement imageElement;
8080
private CurvedMprView view;
81-
private volatile DebugCurveData debugData;
81+
private volatile DebugCurveData debugData; // NOSONAR guarantees visibility of the reference
8282

8383
// Live-edit binding to the source polyline. Optional.
8484
private MprView sourceView;

weasis-dicom/weasis-dicom-viewer2d/src/main/java/org/weasis/dicom/viewer2d/mpr/cmpr/CurvedMprView.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,17 @@ private void addStepSlider(JPanel panel, double pixelMm, String unitLabel) {
202202
}
203203

204204
private String unitAbbreviation() {
205-
DicomImageElement img = curvedMprAxis == null ? null : curvedMprAxis.getImageElement();
206-
Unit unit = img == null ? Unit.MILLIMETER : img.getPixelSpacingUnit();
207-
return unit == null ? Unit.MILLIMETER.getAbbreviation() : unit.getAbbreviation();
205+
Unit unit = Unit.MILLIMETER;
206+
if (curvedMprAxis != null) {
207+
DicomImageElement img = curvedMprAxis.getImageElement();
208+
if (img != null) {
209+
Unit spacingUnit = img.getPixelSpacingUnit();
210+
if (spacingUnit != null) {
211+
unit = spacingUnit;
212+
}
213+
}
214+
}
215+
return unit.getAbbreviation();
208216
}
209217

210218
/** Fall back to 1.0 if the volume reports a degenerate (0 or negative) pixel spacing. */

0 commit comments

Comments
 (0)