Skip to content

Commit

Permalink
Don't throw an exception if Shape.The* is negative
Browse files Browse the repository at this point in the history
  • Loading branch information
melissalinkert committed May 24, 2024
1 parent 5b1da7c commit 53b56a6
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/main/java/com/glencoesoftware/roitool/ROIMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import ome.xml.model.primitives.Color;
import ome.xml.model.primitives.NonNegativeInteger;

import omero.RInt;
import omero.RString;
import omero.model.Annotation;
import omero.model.Ellipse;
Expand Down Expand Up @@ -325,25 +326,37 @@ private <X extends Shape> Length getShapeStrokeWidth(int ROIIndex, int shapeInde
private <X extends Shape> NonNegativeInteger getShapeTheC(int ROIIndex, int shapeIndex, Class<X> expectedSubclass) {
final X shape = getShape(ROIIndex, shapeIndex, expectedSubclass);
if (shape == null) {
return null;
return null;
}
RInt theC = shape.getTheC();
if (theC == null || fromRType(theC) < 0) {
return null;
}
return toNonNegativeInteger(shape.getTheC());
return toNonNegativeInteger(theC);
}

private <X extends Shape> NonNegativeInteger getShapeTheT(int ROIIndex, int shapeIndex, Class<X> expectedSubclass) {
final X shape = getShape(ROIIndex, shapeIndex, expectedSubclass);
if (shape == null) {
return null;
}
return toNonNegativeInteger(shape.getTheT());
RInt theT = shape.getTheT();
if (theT == null || fromRType(theT) < 0) {
return null;
}
return toNonNegativeInteger(theT);
}

private <X extends Shape> NonNegativeInteger getShapeTheZ(int ROIIndex, int shapeIndex, Class<X> expectedSubclass) {
final X shape = getShape(ROIIndex, shapeIndex, expectedSubclass);
if (shape == null) {
return null;
}
return toNonNegativeInteger(shape.getTheZ());
RInt theZ = shape.getTheZ();
if (theZ == null || fromRType(theZ) < 0) {
return null;
}
return toNonNegativeInteger(theZ);
}

private <X extends Shape> AffineTransform getShapeTransform(int ROIIndex, int shapeIndex, Class<X> expectedSubclass) {
Expand Down

0 comments on commit 53b56a6

Please sign in to comment.