Skip to content

Commit 85c85bb

Browse files
committed
Fixed point rendering in ManuallyIdentifyObjects
1 parent 7e33eb1 commit 85c85bb

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

mia-plugin/src/main/java/io/github/mianalysis/mia/process/selectors/ObjectSelector.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ public String[] getAutoClassModes() {
256256

257257
int i = 2;
258258
for (String className : classSelector.getAllClasses())
259-
autoClassModes[i++] = "Apply " + className;
259+
autoClassModes[i++] = "Apply \"" + className + "\"";
260260

261261
return autoClassModes;
262262

@@ -823,9 +823,10 @@ public void addSingleRoi(Roi roi) {
823823

824824
}
825825
assignedClass = classSelector.getLastSelectedClass();
826-
break;
826+
break;
827827
default:
828-
assignedClass = ((String) autoClassMode.getSelectedItem()).substring(6);
828+
String selectedClass = (String) autoClassMode.getSelectedItem();
829+
assignedClass = selectedClass.substring(7, selectedClass.length() - 1);
829830
break;
830831
}
831832

@@ -1152,6 +1153,11 @@ public void addToOverlay(ObjRoi objRoi) {
11521153
overlayRoi.setStrokeColor(new Color(colour.getRed(), colour.getGreen(), colour.getBlue(), 64));
11531154
break;
11541155

1156+
case Roi.POINT:
1157+
((PointRoi) overlayRoi).setSize(3);
1158+
overlayRoi.setStrokeColor(colour);
1159+
break;
1160+
11551161
// Everything else is rendered as the normal fill or outlines
11561162
default:
11571163
switch ((String) overlayMode.getSelectedItem()) {
@@ -1170,9 +1176,21 @@ public void addToOverlay(ObjRoi objRoi) {
11701176

11711177
// Adding label (if necessary)
11721178
if (labelCheck.isSelected()) {
1173-
double[] centroid = roi.getContourCentroid();
11741179
int fontSize = Integer.parseInt(labelFontSize.getText());
11751180

1181+
double[] centroid = roi.getContourCentroid();
1182+
if (roi instanceof PointRoi) {
1183+
Point[] points = ((PointRoi) roi).getContainedPoints();
1184+
centroid[0] = 0;
1185+
centroid[1] = 0;
1186+
for (Point point : points) {
1187+
centroid[0] = +point.getX();
1188+
centroid[1] = +point.getY();
1189+
}
1190+
centroid[0] = (centroid[0] / points.length) + fontSize*0.5;
1191+
centroid[1] = (centroid[1] / points.length) + fontSize*0.5;
1192+
}
1193+
11761194
TextRoi text = new TextRoi(centroid[0], centroid[1], String.valueOf(ID),
11771195
new Font(Font.SANS_SERIF, Font.PLAIN, fontSize));
11781196

0 commit comments

Comments
 (0)