Skip to content

Commit

Permalink
Merge pull request ome#5761 from dominikl/shapedata_bugfix
Browse files Browse the repository at this point in the history
Shapedata bugfix
  • Loading branch information
joshmoore authored Jul 6, 2018
2 parents d61e7b8 + a0f1bd0 commit 69e49a7
Show file tree
Hide file tree
Showing 15 changed files with 563 additions and 67 deletions.
4 changes: 2 additions & 2 deletions components/blitz/src/omero/gateway/facility/ROIFacility.java
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,8 @@ public Collection<ROIData> saveROIs(SecurityContext ctx, long imageID,
for (int i = 0 ; i < serverRoi.sizeOfShapes(); i++) {
s = serverRoi.getShape(i);
if (s != null) {
z = 0;
t = 0;
z = -1;
t = -1;
if (s.getTheZ() != null) z = s.getTheZ().getValue();
if (s.getTheT() != null) t = s.getTheT().getValue();
serverCoordMap.put(new ROICoordinate(z, t), s);
Expand Down
5 changes: 5 additions & 0 deletions components/blitz/src/omero/gateway/model/LineData.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void setText(String text)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setTextValue(rtypes.rstring(text));
setDirty(true);
}

/**
Expand Down Expand Up @@ -128,6 +129,7 @@ public void setX1(double x1)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setX1(rtypes.rdouble(x1));
setDirty(true);
}

/**
Expand Down Expand Up @@ -156,6 +158,7 @@ public void setX2(double x2)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setX2(rtypes.rdouble(x2));
setDirty(true);
}

/**
Expand Down Expand Up @@ -184,6 +187,7 @@ public void setY1(double y1)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setY1(rtypes.rdouble(y1));
setDirty(true);
}

/**
Expand Down Expand Up @@ -212,6 +216,7 @@ public void setY2(double y2)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setY2(rtypes.rdouble(y2));
setDirty(true);
}

}
8 changes: 8 additions & 0 deletions components/blitz/src/omero/gateway/model/MaskData.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public void setText(String text)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setTextValue(rtypes.rstring(text));
setDirty(true);
}

/**
Expand Down Expand Up @@ -135,6 +136,7 @@ public void setX(double x)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setX(rtypes.rdouble(x));
setDirty(true);
}

/**
Expand Down Expand Up @@ -163,6 +165,7 @@ public void setY(double y)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setY(rtypes.rdouble(y));
setDirty(true);
}

/**
Expand Down Expand Up @@ -191,6 +194,7 @@ public void setWidth(double width)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setWidth(rtypes.rdouble(width));
setDirty(true);
}

/**
Expand Down Expand Up @@ -219,6 +223,7 @@ public void setHeight(double height)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setHeight(rtypes.rdouble(height));
setDirty(true);
}

/**
Expand All @@ -230,6 +235,7 @@ public void setMask(byte[] mask)
{
Mask shape = (Mask) asIObject();
shape.setBytes(mask);
setDirty(true);
}

/**
Expand All @@ -255,6 +261,7 @@ public void setMask(BufferedImage image)
}
setBit(data, (int)(y*getWidth()+x), 1);
}
setDirty(true);
}

/**
Expand Down Expand Up @@ -343,6 +350,7 @@ public void setBit(byte[] data, int bit, int val)
data[bytePosition] = (byte) ((byte)(data[bytePosition]&
(~(byte)(0x1<<bitPosition)))|
(byte)(val<<bitPosition));
setDirty(true);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions components/blitz/src/omero/gateway/model/PointData.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void setText(String text)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setTextValue(rtypes.rstring(text));
setDirty(true);
}


Expand Down Expand Up @@ -130,6 +131,7 @@ public void setX(double x)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setX(rtypes.rdouble(x));
setDirty(true);
}

/**
Expand Down Expand Up @@ -159,6 +161,7 @@ public void setY(double y)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setY(rtypes.rdouble(y));
setDirty(true);
}

}
2 changes: 2 additions & 0 deletions components/blitz/src/omero/gateway/model/PolygonData.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public void setText(String text)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setTextValue(rtypes.rstring(text));
setDirty(true);
}

/**
Expand Down Expand Up @@ -138,6 +139,7 @@ public void setPoints(List<Point2D.Double> points)
String pointsValues =
toPoints(points.toArray(new Point2D.Double[points.size()]));
shape.setPoints(rtypes.rstring(pointsValues));
setDirty(true);
}

}
2 changes: 2 additions & 0 deletions components/blitz/src/omero/gateway/model/PolylineData.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void setText(String text)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setTextValue(rtypes.rstring(text));
setDirty(true);
}

/**
Expand Down Expand Up @@ -129,5 +130,6 @@ public void setPoints(List<Point2D.Double> points)
String pointsValues =
toPoints(points.toArray(new Point2D.Double[points.size()]));
shape.setPoints(rtypes.rstring(pointsValues));
setDirty(true);
}
}
12 changes: 5 additions & 7 deletions components/blitz/src/omero/gateway/model/ROICoordinate.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2009 University of Dundee. All rights reserved.
* Copyright (C) 2006-2018 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -58,8 +58,8 @@ public ROICoordinate()
/**
* Creates a new instance.
*
* @param z The z-section.
* @param t The timepoint.
* @param z The z-section. (-1 == all z-sections)
* @param t The timepoint. (-1 == all timepoints)
*/
public ROICoordinate(int z, int t)
{
Expand All @@ -69,22 +69,21 @@ public ROICoordinate(int z, int t)

/**
* Returns the timepoint.
*
* (-1 == all timepoints)
* @return See above.
*/
public int getTimePoint() { return t; }

/**
* Returns the z-section.
*
* (-1 == all z-sections)
* @return See above.
*/
public int getZSection() { return z; }

/**
* Implemented as specified by the {@link Comparator} I/F.
* @see Comparator#compare(Object, Object)
* If any attribute == -1 it is not included in comparison.
*/
public int compare(Object o1, Object o2)
{
Expand All @@ -101,7 +100,6 @@ public int compare(Object o1, Object o2)

/**
* Overridden to control if the passed object equals the current one.
* If any attribute == -1 it is not included in comparison.
* @see java.lang.Object#equals(Object)
*/
public boolean equals(Object obj)
Expand Down
69 changes: 50 additions & 19 deletions components/blitz/src/omero/gateway/model/ROIData.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2016 University of Dundee. All rights reserved.
* Copyright (C) 2006-2018 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -207,17 +207,21 @@ public void removeShapeData(ShapeData shape)
if (roi == null)
throw new IllegalArgumentException("No Roi specified.");
ROICoordinate coord = shape.getROICoordinate();
List<ShapeData> shapeList;
shapeList = roiShapes.get(coord);
shapeList.remove(shape);
roi.removeShape((Shape) shape.asIObject());
setDirty(true);
List<ShapeData> shapeList = roiShapes.get(coord);
if (shapeList != null) {
shapeList.remove(shape);
roi.removeShape((Shape) shape.asIObject());
setDirty(true);
}
}

/**
* Returns the number of planes occupied by the ROI.
*
* @return See above.
* @deprecated Will be removed in future. Does not work as
* expected if the ROI contains shapes which are associated
* with all planes (Z, C, T == -1)
*/
public int getPlaneCount() { return roiShapes.size(); }

Expand Down Expand Up @@ -247,7 +251,19 @@ public int getShapeCount()
*/
public List<ShapeData> getShapes(int z, int t)
{
return roiShapes.get(new ROICoordinate(z, t));
List<ShapeData> res = roiShapes.get(new ROICoordinate(z, t));
if (res == null)
res = new ArrayList<ShapeData>();
List<ShapeData> allZT = roiShapes.get(new ROICoordinate(-1, -1));
if (allZT != null)
res.addAll(allZT);
List<ShapeData> allZ = roiShapes.get(new ROICoordinate(-1, t));
if (allZ != null)
res.addAll(allZ);
List<ShapeData> allT = roiShapes.get(new ROICoordinate(z, -1));
if (allT != null)
res.addAll(allT);
return res;
}

/**
Expand All @@ -260,38 +276,53 @@ public Iterator<List<ShapeData>> getIterator()
return roiShapes.values().iterator();
}

/**
/**
* Return the first plane that the ROI starts on.
*
* @return See above.
* @deprecated Will be removed in future. Does not work as
* expected if the ROI contains shapes which are associated
* with all planes (Z, C, T == -1)
*/
public ROICoordinate firstPlane()
{
public ROICoordinate firstPlane() {
return roiShapes.firstKey();
}

/**
/**
* Returns the last plane that the ROI ends on.
*
* @return See above.
* @deprecated Will be removed in future. Does not work as
* expected if the ROI contains shapes which are associated
* with all planes (Z, C, T == -1)
*/
public ROICoordinate lastPlane()
{
public ROICoordinate lastPlane() {
return roiShapes.lastKey();
}

/**
* Returns an iterator of the Shapes in the ROI in the range [start, end].
*
* @param start The starting plane where the Shapes should reside.
* @param end The final plane where the Shapes should reside.
* @param start
* The starting plane where the Shapes should reside.
* @param end
* The final plane where the Shapes should reside.
* @return See above.
* @deprecated Will be removed in future. Does not work as
* expected if the ROI contains shapes which are associated
* with all planes (Z, C, T == -1)
*/
public Iterator<List<ShapeData>> getShapesInRange(ROICoordinate start,
ROICoordinate end)
{
return roiShapes.subMap(start, end).values().iterator();
}
ROICoordinate end) {
List<List<ShapeData>> res = new ArrayList<List<ShapeData>>();
Collection<List<ShapeData>> inRange = roiShapes.subMap(start, end).values();
if (inRange != null)
res.addAll(inRange);
List<ShapeData> allRanges = roiShapes.get(new ROICoordinate(-1, -1));
if (allRanges != null)
res.add(allRanges);
return res.iterator();
}

/**
* Returns <code>true</code> if the object a client-side object,
Expand Down
5 changes: 5 additions & 0 deletions components/blitz/src/omero/gateway/model/RectangleData.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void setText(String text)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setTextValue(rtypes.rstring(text));
setDirty(true);
}

/**
Expand Down Expand Up @@ -130,6 +131,7 @@ public void setX(double x)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setX(rtypes.rdouble(x));
setDirty(true);
}

/**
Expand Down Expand Up @@ -160,6 +162,7 @@ public void setY(double y)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setY(rtypes.rdouble(y));
setDirty(true);
}

/**
Expand Down Expand Up @@ -188,6 +191,7 @@ public void setWidth(double width)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setWidth(rtypes.rdouble(width));
setDirty(true);
}

/**
Expand Down Expand Up @@ -216,6 +220,7 @@ public void setHeight(double height)
if (shape == null)
throw new IllegalArgumentException("No shape specified.");
shape.setHeight(rtypes.rdouble(height));
setDirty(true);
}

}
Loading

0 comments on commit 69e49a7

Please sign in to comment.