mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 22:52:22 +00:00
click labelling
fixed a couple of problems in click labelling (Viewer mode) when clics were reassigned to different events.
This commit is contained in:
parent
0e5bca5198
commit
4856a827df
@ -26,6 +26,7 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
@ -1071,7 +1072,7 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
|
||||
subDet.removeSuperDetection(event);
|
||||
}
|
||||
}
|
||||
clickDetector.getOfflineEventDataBlock().remove(event);
|
||||
clickDetector.getOfflineEventDataBlock().remove(event, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1168,6 +1169,31 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
|
||||
return targetMotionLocaliser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove clicks from existing events, if they have any. They may not.
|
||||
* This is called whenever clicks are assigned to a new event to make
|
||||
* sure that they don't end up in two events.
|
||||
* @param markedClicks
|
||||
*/
|
||||
public void removeFromEvents(List<PamDataUnit> markedClicks) {
|
||||
if (markedClicks == null) {
|
||||
return;
|
||||
}
|
||||
for (PamDataUnit dataUnit : markedClicks) {
|
||||
OfflineEventDataUnit anEvent = (OfflineEventDataUnit) dataUnit.getSuperDetection(OfflineEventDataUnit.class);
|
||||
if (anEvent == null) {
|
||||
continue;
|
||||
}
|
||||
anEvent.removeSubDetection(dataUnit);
|
||||
if (anEvent.getSubDetectionsCount() == 0) {
|
||||
deleteEvent(anEvent);
|
||||
}
|
||||
else {
|
||||
anEvent.updateDataUnit(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reassign all the clicks on one event to a different event
|
||||
@ -1199,7 +1225,7 @@ public class ClickControl extends PamControlledUnit implements PamSettings {
|
||||
}
|
||||
clickEvent.setComment(clickEvent.getComment() + " Clicks reassigned to event " + reassignEvent.getEventId());
|
||||
offlineEventDataBlock.updatePamData(clickEvent, PamCalendar.getTimeInMillis());
|
||||
offlineEventDataBlock.remove(clickEvent);
|
||||
offlineEventDataBlock.remove(clickEvent, true);
|
||||
reassignEvent.sortSubDetections();
|
||||
offlineEventDataBlock.updatePamData(reassignEvent, now);
|
||||
if (ClickTrainDetection.class.isAssignableFrom(reassignEvent.getClass())) {
|
||||
|
@ -146,6 +146,7 @@ public class LabelClicksDialog extends PamDialog {
|
||||
* @param thenClose option to close dialog
|
||||
*/
|
||||
private void addClicksToEvent(OfflineEventDataUnit event, boolean thenClose) {
|
||||
removeFromOldEvent(markedClicks);
|
||||
event.addSubDetections(markedClicks);
|
||||
offlineEventListPanel.tableDataChanged();
|
||||
clickControl.setLatestOfflineEvent(event);
|
||||
@ -154,6 +155,15 @@ public class LabelClicksDialog extends PamDialog {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* clicks may have already been part of an event, so need to remove them from that
|
||||
* event first, and if there is nothing left in that event, delete the event.
|
||||
* @param markedClicks2
|
||||
*/
|
||||
private void removeFromOldEvent(List<PamDataUnit> markedClicks) {
|
||||
clickControl.removeFromEvents(markedClicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreDefaultSettings() {
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -51,7 +51,7 @@ public class OfflineClickLogging extends SQLLogging {
|
||||
tableDef.addTableItem(clickNumber = new PamTableItem("ClickNo", Types.INTEGER));
|
||||
tableDef.addTableItem(amplitude = new PamTableItem("Amplitude", Types.DOUBLE));
|
||||
tableDef.addTableItem(channelNumbers = new PamTableItem("Channels", Types.INTEGER));
|
||||
tableDef.setUseCheatIndexing(true);
|
||||
tableDef.setUseCheatIndexing(false);
|
||||
|
||||
setTableDefinition(tableDef);
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ public class PamSubtableDefinition extends PamTableDefinition {
|
||||
addTableItem(parentUID = new PamTableItem(PARENTUIDNAME, Types.BIGINT));
|
||||
addTableItem(longName = new PamTableItem(LONGDATANAME, Types.CHAR, DATANAME_LENGTH));
|
||||
addTableItem(binaryFilename = new PamTableItem(BINARYFILE, Types.CHAR, BINARY_FILE_NAME_LENGTH));
|
||||
setUseCheatIndexing(false);
|
||||
}
|
||||
|
||||
public PamTableItem getParentID() {
|
||||
|
Loading…
Reference in New Issue
Block a user