Fix binned output

couple of fixes in binned output
This commit is contained in:
Douglas Gillespie 2023-09-11 21:52:46 +01:00
parent 65dfb5688b
commit 85fd84d18a
5 changed files with 51 additions and 25 deletions

View File

@ -596,17 +596,20 @@ public class TethysControl extends PamControlledUnit implements PamSettings, Tet
PamFileFilter fileFilter = new PamFileFilter("XML documents", ".xml");
// fileFilter
JFileChooser fileChooser = new PamFileChooser();
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileFilter(fileFilter);
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
// make a default name based on the document id and the dataset directory.
String defFolder = PamFolders.getDefaultProjectFolder();
File defFile = null;
if (defFolder != null) {
defFolder = String.format("%s%s%s.xml", defFolder,File.separator,documentId);
File defFile = new File(defFolder);
fileChooser.setSelectedFile(defFile);
defFolder = String.format("%s%s%s_%s.xml", defFolder,File.separator,collection,documentId);
defFile = new File(defFolder);
fileChooser.setAcceptAllFileFilterUsed(true);
fileChooser.setSelectedFile(defFile);
// fileChooser.setSelectedFile(new File(String.format("%s.xml", documentId)));
// fileChooser.set
}
int state = fileChooser.showSaveDialog(getGuiFrame());
if (state != JFileChooser.APPROVE_OPTION) return;

View File

@ -88,6 +88,7 @@ public class BinnedGranularityHandler extends GranularityHandler {
Detection[] detections = null;
if (dataUnit.getTimeMilliseconds() >= binEndMillis) {
detections = closeBins(dataUnit.getTimeMilliseconds());
prepare(dataUnit.getTimeMilliseconds());
}
String speciesCode = speciesManager.getSpeciesCode(dataUnit);
Detection det = currentDetections.get(speciesCode);
@ -140,8 +141,6 @@ public class BinnedGranularityHandler extends GranularityHandler {
}
// finally, start new bins (not really needed on last call, but do anyway).
startBin(binEndMillis);
/*
* Clean up the end of the array and return detections that have enough calls.

View File

@ -132,26 +132,29 @@ public class TethysParameterPacker {
* first do the data filter. I can't see any way of doing this
* without creating a doc as was in the helper example.
*/
QName qnamef = new QName(MarshalXML.schema, "datafilter", "ty");
JAXBElement<String> jaxelf = new JAXBElement<String>(
qnamef, String.class, parameterSet.getParentObject().getClass().getCanonicalName());
Document docf = null;
try {
docf = marshaller.marshalToDOM(jaxelf);
} catch (JAXBException | ParserConfigurationException e1) {
e1.printStackTrace();
}
Element elf = docf.getDocumentElement();
elList.add(elf);/**
* Is there a data filter ? If so, write it's
* XML parameters out here.
*/
DataSelector dataSelector = pamDataBlock.getDataSelector(tethysControl.getDataSelectName(), false);
if (dataSelector != null) {
DataSelectParams filterParams = dataSelector.getParams();
if (filterParams != null) {
Element pEl = xmlWriter.writeObjectData(docf, elf, filterParams, null);
// if (pEl != null) {
int selected = filterParams.getCombinationFlag();
if (selected != DataSelectParams.DATA_SELECT_DISABLE) {
QName qnamef = new QName(MarshalXML.schema, "datafilter", "ty");
JAXBElement<String> jaxelf = new JAXBElement<String>(
qnamef, String.class, parameterSet.getParentObject().getClass().getCanonicalName());
Document docf = null;
try {
docf = marshaller.marshalToDOM(jaxelf);
} catch (JAXBException | ParserConfigurationException e1) {
e1.printStackTrace();
}
Element elf = docf.getDocumentElement();
elList.add(elf);/**
* Is there a data filter ? If so, write it's
* XML parameters out here.
*/
Element pEl = xmlWriter.writeObjectData(docf, elf, filterParams, null);
}
// if (pEl != null) {
//// filterEl.appendChild(pEl);
// elf.appendChild(filterEl);
// }

View File

@ -17,6 +17,8 @@ import javax.swing.JTable;
import javax.swing.border.TitledBorder;
import javax.swing.table.AbstractTableModel;
import PamView.PamGui;
import PamView.dialog.warn.WarnOnce;
import PamView.tables.SwingTableColumnWidths;
import PamguardMVC.PamDataBlock;
import nilus.DetectionEffortKind;
@ -120,7 +122,7 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
JPopupMenu popMenu = new JPopupMenu();
JMenuItem menuItem = new JMenuItem("Delete " + pDets.detections.getId());
JMenuItem menuItem = new JMenuItem("Delete document " + pDets.detections.getId());
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@ -129,7 +131,7 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
});
popMenu.add(menuItem);
menuItem = new JMenuItem("Display " + pDets.detections.getId());
menuItem = new JMenuItem("Display document " + pDets.detections.getId());
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@ -138,6 +140,15 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
});
popMenu.add(menuItem);
menuItem = new JMenuItem("Export document " + pDets.detections.getId());
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
exportDocument(pDets);
}
});
popMenu.add(menuItem);
popMenu.show(e.getComponent(), e.getX(), e.getY());
@ -145,6 +156,11 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
}
protected void deleteDocument(PDetections pDets) {
String msg = String.format("Are you sure you want to delete the Detections document %s ?", pDets.detections.getId());
int ans = WarnOnce.showWarning(PamGui.findComponentWindow(mainPanel), "Delete Document", msg, WarnOnce.OK_CANCEL_OPTION);
if (ans != WarnOnce.OK_OPTION) {
return;
}
try {
getTethysControl().getDbxmlConnect().deleteDocument(pDets.detections);
} catch (TethysException e) {
@ -159,6 +175,11 @@ public class DatablockDetectionsPanel extends TethysGUIPanel implements StreamTa
}
private void exportDocument(PDetections pDets) {
getTethysControl().exportDocument(TethysCollections.Detections.toString(), pDets.detections.getId());
}
private PDetections detectionsForRow(int iRow) {
if (streamDetectionsSummary == null || streamDetectionsSummary.detectionsDocs == null) {
return null;

View File

@ -134,7 +134,7 @@ public class PAMGuardDeploymentsTable extends TethysGUIPanel {
}
if (matchedDeployments.size() == 1) {
JPopupMenu popMenu = new JPopupMenu();
JMenuItem menuItem = new JMenuItem("Remove deployment document " + matchedDeployments.get(0));
JMenuItem menuItem = new JMenuItem("Delete deployment document " + matchedDeployments.get(0));
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {