mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-25 08:32:32 +00:00
Getting detection displays to work in FX GUI
This commit is contained in:
parent
d3d998ca87
commit
755ff7608d
@ -6,7 +6,7 @@
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Amazon Coretto 21">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-21.0.2.13-hotspot">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -877,7 +877,7 @@ final public class PamModel implements PamSettings {
|
||||
mi.setModulesMenuGroup(displaysGroup);
|
||||
mi.addGUICompatabilityFlag(PamGUIManager.FX);
|
||||
|
||||
mi = PamModuleInfo.registerControlledUnit("detectionPlotFX.DetectionDisplayControl", "Detection Display" );
|
||||
mi = PamModuleInfo.registerControlledUnit("detectionPlotFX.DetectionDisplayControl2", "Detection Display" );
|
||||
mi.setToolTipText("Display detection data");
|
||||
mi.setModulesMenuGroup(displaysGroup);
|
||||
mi.addGUICompatabilityFlag(PamGUIManager.FX);
|
||||
|
@ -74,7 +74,7 @@ import javax.swing.event.MenuListener;
|
||||
|
||||
import Acquisition.DaqSystemInterface;
|
||||
import annotation.tasks.AnnotationManager;
|
||||
import export.layoutFX.ExportOptions;
|
||||
import export.ExportOptions;
|
||||
import metadata.MetaDataContol;
|
||||
import pamViewFX.fxNodes.pamDialogFX.PamDialogFX2AWT;
|
||||
import performanceTests.PerformanceDialog;
|
||||
|
@ -313,7 +313,7 @@ public class DataModelPaneFX extends PamBorderPane {
|
||||
* data is changed in external dialogs.
|
||||
*/
|
||||
protected void dataModeltoPamModel() {
|
||||
// System.out.println("************DATAMODELTOPAMMODEL*************");
|
||||
System.out.println("************DATAMODELTOPAMMODEL*************");
|
||||
|
||||
if (disableNotification)
|
||||
return;
|
||||
@ -328,8 +328,8 @@ public class DataModelPaneFX extends PamBorderPane {
|
||||
childNode = (ModuleConnectionNode) dataModelPane.getConnectionNodes().get(i);
|
||||
if (childNode.getPamControlledUnit() == null)
|
||||
continue;
|
||||
// System.out.println("Children of " + ((ModuleConnectionNode)
|
||||
// dataModelPane.getConnectionNodes().get(i)).getPamControlledUnit().getUnitType());
|
||||
System.out.println("Children of " + ((ModuleConnectionNode)
|
||||
dataModelPane.getConnectionNodes().get(i)).getPamControlledUnit().getUnitType());
|
||||
checkParentChildConnections(childNode, true);
|
||||
}
|
||||
enableConectionListerner(true);
|
||||
@ -356,7 +356,7 @@ public class DataModelPaneFX extends PamBorderPane {
|
||||
* modules with dependencies are added.
|
||||
*/
|
||||
protected void pamModeltoDataModel(boolean disconnect) {
|
||||
// System.out.println("************PAMMODELTODATAMODEL*************");
|
||||
System.out.println("************PAMMODELTODATAMODEL*************");
|
||||
if (disableNotification)
|
||||
return;
|
||||
disableNotification = true;
|
||||
@ -367,10 +367,13 @@ public class DataModelPaneFX extends PamBorderPane {
|
||||
*/
|
||||
for (int i = 0; i < this.dataModelPane.getConnectionNodes().size(); i++) {
|
||||
childNode = (ModuleConnectionNode) dataModelPane.getConnectionNodes().get(i);
|
||||
System.out.println("Node " + i);
|
||||
|
||||
if (childNode.getPamControlledUnit() == null)
|
||||
continue;
|
||||
// System.out.println("Children of " + ((ModuleConnectionNode)
|
||||
// dataModelPane.getConnectionNodes().get(i)).getPamControlledUnit().getUnitType());
|
||||
System.out.println("Children of " + ((ModuleConnectionNode)
|
||||
dataModelPane.getConnectionNodes().get(i)).getPamControlledUnit().getUnitType());
|
||||
|
||||
checkModuleConnection(childNode);
|
||||
checkParentChildConnections(childNode, !disconnect);
|
||||
}
|
||||
@ -415,9 +418,9 @@ public class DataModelPaneFX extends PamBorderPane {
|
||||
|
||||
// System.out.println(" CHILD NODE: "
|
||||
// +childNode.getPamControlledUnit().getUnitName());
|
||||
// for (int i=0; i<parentNodes.size() ;i++){
|
||||
// for (int i=0; i<parentNodesS.size() ;i++){
|
||||
// System.out.println(" PARENTS NODE: "
|
||||
// +parentNodes.get(i).getPamControlledUnit().getUnitName());
|
||||
// + parentNodesS.get(i).getPamControlledUnit().getUnitName());
|
||||
// }
|
||||
// System.out.println(" ------------------------------------------");
|
||||
|
||||
@ -696,8 +699,8 @@ public class DataModelPaneFX extends PamBorderPane {
|
||||
|
||||
boolean connected = false;
|
||||
|
||||
// System.out.println("Attempting to connect: " + parentUnit.getUnitName() + "
|
||||
// to " + childUnit.getUnitName());
|
||||
System.out.println("Attempting to connect: " + parentUnit.getUnitName() +
|
||||
" to " + childUnit.getUnitName());
|
||||
|
||||
// First, are these modules already connected.
|
||||
if (modulesConnected(childNode, parentNode)) {
|
||||
|
@ -237,7 +237,7 @@ public class ModuleConnectionNode extends StandardConnectionNode implements PAMC
|
||||
removeButton.setGraphic(PamGlyphDude.createPamIcon("mdi2m-minus", Color.WHITE, PamGuiManagerFX.iconSize));
|
||||
removeButton.setMaxSize(Double.MAX_VALUE,Double.MAX_VALUE);
|
||||
removeButton.setOnAction((change)->{
|
||||
if (this.pamControlledUnit.getPamModuleInfo()== null || this.pamControlledUnit.getPamModuleInfo().canRemove()){
|
||||
if (this.pamControlledUnit==null || this.pamControlledUnit.getPamModuleInfo()== null || this.pamControlledUnit.getPamModuleInfo().canRemove()){
|
||||
connectionPane.removeModuleNode(this);
|
||||
}
|
||||
});
|
||||
|
@ -249,6 +249,7 @@ public class ModuleIconFactory {
|
||||
icon=ModuleIcon.TIME_DISPLAY;
|
||||
break;
|
||||
case "detectionPlotFX.DetectionDisplayControl":
|
||||
case "detectionPlotFX.DetectionDisplayControl2":
|
||||
icon=ModuleIcon.DETECTION_DISPLAY;
|
||||
break;
|
||||
case "dataMap.DataMapControl":
|
||||
|
@ -233,8 +233,6 @@ public class TDControlFX extends TDControl implements UserDisplayNodeFX {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The data observer monitors only the raw data source in real time
|
||||
* so that scrolling can take place. Need to set up a different
|
||||
@ -401,5 +399,9 @@ public class TDControlFX extends TDControl implements UserDisplayNodeFX {
|
||||
@Override
|
||||
public void newSelectedDetectionGroup(DetectionGroupSummary detectionGroup, TDGraphFX tdGraph) {
|
||||
System.out.println("New selected detection group: " + detectionGroup);
|
||||
|
||||
tdDisplayController.getDisplayDataBlock().clearAll();
|
||||
if (detectionGroup==null || detectionGroup.getDataList().size()<=0) return;
|
||||
tdDisplayController.getDisplayDataBlock().addPamData(detectionGroup.getDataList().get(detectionGroup.getFocusedIndex()));
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import dataPlotsFX.data.TDDataInfoFX;
|
||||
import dataPlotsFX.data.TDDataProviderFX;
|
||||
import dataPlotsFX.data.TDDataProviderRegisterFX;
|
||||
import detectionPlotFX.data.DDPlotRegister;
|
||||
import detectionPlotFX.rawDDPlot.ClickDDPlotProvider;
|
||||
import pamViewFX.PamControlledGUIFX;
|
||||
import userDisplayFX.UserDisplayControlFX;
|
||||
import userDisplayFX.UserDisplayNodeFX;
|
||||
@ -48,6 +50,8 @@ public class TDDisplayController extends UserDisplayControlFX {
|
||||
selectedDataUnits = new PamDataBlock(PamDataUnit.class, "Selected Data Units", getUserDisplayProcess() , Integer.MAX_VALUE); //TODO
|
||||
|
||||
getUserDisplayProcess().addOutputDataBlock(selectedDataUnits);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,5 +159,13 @@ public class TDDisplayController extends UserDisplayControlFX {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the datablock for selected data units from the display.
|
||||
* @return datablock for selected data units.
|
||||
*/
|
||||
public PamDataBlock getDisplayDataBlock() {
|
||||
return selectedDataUnits;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -253,7 +253,6 @@ public class OverlayGroupDisplay extends PamBorderPane {
|
||||
this.detectionsPane.setDetectionGroup(dataList);
|
||||
|
||||
|
||||
|
||||
if (superDets!=null) {
|
||||
this.superDetectionsDisplay.setDetectionGroup(new ArrayList<PamDataUnit>(superDets));
|
||||
}
|
||||
|
@ -119,8 +119,11 @@ public class DetectionDisplayControl extends UserDisplayControlFX {
|
||||
*/
|
||||
public boolean newDataBlockAdded(PamDataBlock pamDataBlock){
|
||||
|
||||
System.out.println("New datablock added: " + pamDataBlock.getDataName());
|
||||
|
||||
//now must find the data provider.
|
||||
//first get the list of dataInfos.
|
||||
|
||||
//22/05/206. Need to check we have the correct datablock before doing anything else. The datablock should
|
||||
//be null or of the correct type. If not need to keep the last connection.
|
||||
DDDataProvider newDataProviderFX=DDPlotRegister.getInstance().findDataProvider(pamDataBlock);
|
||||
@ -181,7 +184,7 @@ public class DetectionDisplayControl extends UserDisplayControlFX {
|
||||
|
||||
@Override
|
||||
public void addData(PamObservable o, PamDataUnit arg) {
|
||||
//System.out.println("DetectionDisplay: Incoming data unit: "+arg.getParentDataBlock().getDataName());
|
||||
System.out.println("DetectionDisplay: Incoming data unit: "+arg.getParentDataBlock().getDataName());
|
||||
//send the data unit to the display.
|
||||
//TODO-why?
|
||||
Platform.runLater(()->{
|
||||
|
157
src/detectionPlotFX/DetectionDisplayControl2.java
Normal file
157
src/detectionPlotFX/DetectionDisplayControl2.java
Normal file
@ -0,0 +1,157 @@
|
||||
package detectionPlotFX;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import PamController.PamControllerInterface;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import PamguardMVC.PamDataUnit;
|
||||
import PamguardMVC.PamObservable;
|
||||
import PamguardMVC.PamObserverAdapter;
|
||||
import userDisplayFX.UserDisplayControlFX;
|
||||
import userDisplayFX.UserDisplayNodeFX;
|
||||
|
||||
|
||||
/**
|
||||
* Detection plot which can display single or groups of detections.
|
||||
*
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class DetectionDisplayControl2 extends UserDisplayControlFX {
|
||||
|
||||
|
||||
/**
|
||||
* The display
|
||||
*/
|
||||
private DetectionGroupDisplay detectionDisplay;
|
||||
|
||||
/**
|
||||
* A list of displays-> really redundant as there is only ever one display.
|
||||
*/
|
||||
private ArrayList<UserDisplayNodeFX> displays;
|
||||
|
||||
/**
|
||||
* The data observer that
|
||||
*/
|
||||
private DetectionDataObserver detectionDataObserver;
|
||||
|
||||
|
||||
public DetectionDisplayControl2(String unitName) {
|
||||
super(unitName);
|
||||
//set which data blocks can connect as parents.
|
||||
setCompatibleDataUnits();
|
||||
//create the observer for the parent data block.
|
||||
detectionDataObserver=new DetectionDataObserver();
|
||||
setMultiParent(false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set compatible data units in the process for this display. This allows the data model to determine if connections can
|
||||
* be made to the display.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void setCompatibleDataUnits(){
|
||||
super.removeCompatibleDataUnits();
|
||||
super.addCompatibleUnit(PamDataUnit.class);
|
||||
|
||||
//also add data unit
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void notifyModelChanged(int type){
|
||||
System.out.println("NOTIFICATION: " + type);
|
||||
super.notifyModelChanged(type);
|
||||
switch (type){
|
||||
case PamControllerInterface.INITIALIZATION_COMPLETE:
|
||||
setCompatibleDataUnits();
|
||||
break;
|
||||
case PamControllerInterface.ADD_CONTROLLEDUNIT:
|
||||
setCompatibleDataUnits();
|
||||
break;
|
||||
case PamControllerInterface.CHANGED_PROCESS_SETTINGS:
|
||||
//this is were the data block may have been added. Need to add an observer to this data block to say when the thing has
|
||||
//thing has a new detection.
|
||||
displayToDataModel(this.getUserDisplayProcess().getParentDataBlock());
|
||||
break;
|
||||
}
|
||||
this.detectionDisplay.notifyModelChanged(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the display to show detections form the data block set in the data model-
|
||||
* i.e. show it's parent data block.
|
||||
*/
|
||||
protected void displayToDataModel(PamDataBlock parentDataBlock){
|
||||
//remove any TDDataInfos which are not present in the data block list
|
||||
//if the datablock the same do nothing
|
||||
newDataBlockAdded(parentDataBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever a new data block is added to the display.
|
||||
* Removes the observer from all other data blocks in the model
|
||||
* and then the adds the observer to that data block;
|
||||
* @return true if the parent has successfully been added.
|
||||
*/
|
||||
public boolean newDataBlockAdded(PamDataBlock pamDataBlock){
|
||||
|
||||
System.out.println("NEW DATA BLOCK DETECTION DISPLAY");
|
||||
|
||||
//if null then no parent- simply set the DDataInfo to null;
|
||||
if (pamDataBlock==null) {
|
||||
this.detectionDisplay.clearDisplay();
|
||||
return true;
|
||||
}
|
||||
|
||||
//now add the observer to the data block
|
||||
//System.out.println("DetectionDisplayControl: Adding observer to data block: "+ pamDataBlock.getDataName());
|
||||
pamDataBlock.addObserver(this.detectionDataObserver);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<UserDisplayNodeFX> getDisplays(){
|
||||
if (displays==null){
|
||||
detectionDisplay=new DetectionGroupDisplay();
|
||||
displays=new ArrayList<UserDisplayNodeFX>();
|
||||
displays.add(detectionDisplay);
|
||||
}
|
||||
return displays;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* The data observer monitors incoming data from data blocks.
|
||||
*
|
||||
* @author Doug Gillespie and Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
private class DetectionDataObserver extends PamObserverAdapter {
|
||||
|
||||
@Override
|
||||
public long getRequiredDataHistory(PamObservable o, Object arg) {
|
||||
return 1000; //no data histroy required for this click.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addData(PamObservable o, PamDataUnit arg) {
|
||||
System.out.println("DetectionDisplay: INCOMING data unit: "+arg.getParentDataBlock().getDataName());
|
||||
//send the data unit to the display.
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObserverName() {
|
||||
return "Detection Display FX";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -18,6 +18,7 @@ import javafx.geometry.Side;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import pamViewFX.PamGuiManagerFX;
|
||||
import pamViewFX.fxGlyphs.PamGlyphDude;
|
||||
@ -25,7 +26,10 @@ import pamViewFX.fxNodes.PamBorderPane;
|
||||
import pamViewFX.fxNodes.PamButton;
|
||||
import pamViewFX.fxNodes.PamHBox;
|
||||
import pamViewFX.fxNodes.hidingPane.HidingPane;
|
||||
import pamViewFX.fxNodes.internalNode.PamInternalPane;
|
||||
import pamViewFX.fxStyles.PamStylesManagerFX;
|
||||
import userDisplayFX.UserDisplayNodeFX;
|
||||
import userDisplayFX.UserDisplayNodeParams;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -35,7 +39,7 @@ import pamViewFX.fxStyles.PamStylesManagerFX;
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
public class DetectionGroupDisplay extends PamBorderPane {
|
||||
public class DetectionGroupDisplay extends PamBorderPane implements UserDisplayNodeFX {
|
||||
|
||||
/**
|
||||
* Index of the current normal unit with the detection summary.
|
||||
@ -98,11 +102,18 @@ public class DetectionGroupDisplay extends PamBorderPane {
|
||||
*/
|
||||
private HidingPane hidingPane;
|
||||
|
||||
/**
|
||||
* The detection pot paramters.
|
||||
*/
|
||||
DetectionPlotParams detectionPlotParams;
|
||||
|
||||
public DetectionGroupDisplay() {
|
||||
//create hash map to map DDDataInfos to datablocks for quick access.
|
||||
dDataInfoHashMap = new HashMap<PamDataBlock, DDDataInfo>();
|
||||
detectionPlotParams=new DetectionPlotParams();
|
||||
createDetectionDisplay();
|
||||
this.setCenter(detectionDisplayHolder);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -426,4 +437,66 @@ public class DetectionGroupDisplay extends PamBorderPane {
|
||||
return detectionGroup.get(currentUnitIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Detection Dsiplay";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region getNode() {
|
||||
// TODO Auto-generated method stub
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openNode() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStaticDisplay() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResizeableDisplay() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMinorDisplay() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestNodeSettingsPane() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeNode() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyModelChanged(int changeType) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDisplayNodeParams getDisplayParams() {
|
||||
return detectionPlotParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrameHolder(PamInternalPane internalFrame) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
20
src/detectionPlotFX/GeneralDDPlotProvider.java
Normal file
20
src/detectionPlotFX/GeneralDDPlotProvider.java
Normal file
@ -0,0 +1,20 @@
|
||||
package detectionPlotFX;
|
||||
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import detectionPlotFX.data.DDDataInfo;
|
||||
import detectionPlotFX.data.DDDataProvider;
|
||||
import detectionPlotFX.layout.DetectionPlotDisplay;
|
||||
|
||||
public class GeneralDDPlotProvider extends DDDataProvider {
|
||||
|
||||
public GeneralDDPlotProvider(PamDataBlock parentDataBlock) {
|
||||
super(parentDataBlock);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public DDDataInfo createDataInfo(DetectionPlotDisplay tdGraph) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -39,7 +39,7 @@ public class DetectionGroupSummary {
|
||||
private OverlayMark overlayMark;
|
||||
|
||||
/**
|
||||
* Thye currently selected or focused data unit;
|
||||
* The currently selected or focused data unit;
|
||||
*/
|
||||
private int focusedUnitIndex=0;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package export.layoutFX;
|
||||
package export;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.swing.JFrame;
|
||||
@ -7,11 +7,11 @@ import PamController.PamControlledUnitSettings;
|
||||
import PamController.PamSettingManager;
|
||||
import PamController.PamSettings;
|
||||
import PamController.StorageParameters;
|
||||
import export.PamExporterManager;
|
||||
import export.layoutFX.ExportParams;
|
||||
import export.swing.ExportProcessDialog;
|
||||
|
||||
/**
|
||||
* Manages opening settings dialog and saving settings.
|
||||
* Manages opening settings dialog and saving settings for both FX and Swing GUI's
|
||||
*
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
@ -57,7 +57,8 @@ public class ExportOptions implements PamSettings {
|
||||
if (exportProcessDialog==null) {
|
||||
exportProcessDialog= new ExportProcessDialog(exportManager);
|
||||
}
|
||||
this.exportProcessDialog.showOfflineDialog(parentFrame);
|
||||
|
||||
this.exportProcessDialog.showOfflineDialog(parentFrame, this.storageParameters);
|
||||
|
||||
// ExportParams newParams = StorageOptionsDialog.showDialog(parentFrame, storageParameters);
|
||||
// if (newParams != null) {
|
@ -137,6 +137,11 @@ public class MLDetectionsManager implements PamDataUnitExporter {
|
||||
return "file-matlab";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "MATLAB";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -39,5 +39,11 @@ public interface PamDataUnitExporter {
|
||||
*/
|
||||
public String getIconString();
|
||||
|
||||
/**
|
||||
* Get the name of the exporter
|
||||
* @return
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public class RExportManager implements PamDataUnitExporter {
|
||||
|
||||
@Override
|
||||
public String getFileExtension() {
|
||||
return ".RData";
|
||||
return "RData";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -152,6 +152,11 @@ public class RExportManager implements PamDataUnitExporter {
|
||||
return "file-r";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "R data";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,10 @@ public class ExportParams implements Serializable, Cloneable {
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public int exportChoice;
|
||||
/**
|
||||
* The index of the ex;port choice.
|
||||
*/
|
||||
public int exportChoice = 0;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -2,14 +2,30 @@ package export.swing;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JSpinner.DefaultEditor;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.SpinnerListModel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.TitledBorder;
|
||||
|
||||
import org.kordamp.ikonli.Ikon;
|
||||
import org.kordamp.ikonli.fileicons.FileIcons;
|
||||
@ -18,14 +34,19 @@ import org.kordamp.ikonli.materialdesign2.MaterialDesignF;
|
||||
import org.kordamp.ikonli.swing.FontIcon;
|
||||
|
||||
import PamController.PamController;
|
||||
import PamUtils.PamFileChooser;
|
||||
import PamView.dialog.PamButton;
|
||||
import PamView.dialog.PamGridBagContraints;
|
||||
import PamView.panel.PamPanel;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import export.PamExporterManager;
|
||||
import export.layoutFX.ExportParams;
|
||||
import offlineProcessing.OLProcessDialog;
|
||||
import offlineProcessing.OfflineTaskGroup;
|
||||
|
||||
/**
|
||||
* Processes exportying data.
|
||||
* Handles an offline dialog for processing offline data and exporting to bespoke file types.
|
||||
*
|
||||
* @author Jamie Macaulay
|
||||
*
|
||||
*/
|
||||
@ -37,13 +58,19 @@ public class ExportProcessDialog {
|
||||
*/
|
||||
private OfflineTaskGroup dlOfflineGroup;
|
||||
|
||||
private OLProcessDialog mtOfflineDialog;
|
||||
|
||||
private ExportOLDialog mtOfflineDialog;
|
||||
|
||||
/**
|
||||
* Reference to the export manager.
|
||||
*/
|
||||
private PamExporterManager exportManager;
|
||||
|
||||
/**
|
||||
* The current paramters.
|
||||
*/
|
||||
private ExportParams currentParams;
|
||||
|
||||
public ExportProcessDialog(PamExporterManager exportManager) {
|
||||
//create the offline task group.
|
||||
this.exportManager=exportManager;
|
||||
@ -68,7 +95,7 @@ public class ExportProcessDialog {
|
||||
}
|
||||
////---Swing stuff----/// should not be here but this is how PG works.
|
||||
|
||||
public void showOfflineDialog(Frame parentFrame) {
|
||||
public void showOfflineDialog(Frame parentFrame, ExportParams params) {
|
||||
|
||||
createExportGroup();
|
||||
|
||||
@ -78,10 +105,12 @@ public class ExportProcessDialog {
|
||||
dlOfflineGroup, "Export Data");
|
||||
//batchLocaliseDialog.setModalityType(Dialog.ModalityType.MODELESS);
|
||||
}
|
||||
mtOfflineDialog.setParams(params);
|
||||
mtOfflineDialog.enableControls();
|
||||
mtOfflineDialog.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom dialog which shows some extra options/
|
||||
* @author Jamie Macaulay
|
||||
@ -94,16 +123,35 @@ public class ExportProcessDialog {
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The current parameters for exporting.
|
||||
*/
|
||||
private ExportParams currentParams;
|
||||
|
||||
/**
|
||||
* The file chooser.
|
||||
*/
|
||||
private JFileChooser fc;
|
||||
|
||||
private JTextField exportTo;
|
||||
|
||||
/**
|
||||
* Spinner for setting the maximum file size.
|
||||
*/
|
||||
private JSpinner spinner;
|
||||
|
||||
|
||||
|
||||
public ExportOLDialog(Window parentFrame, OfflineTaskGroup taskGroup, String title) {
|
||||
super(parentFrame, taskGroup, title);
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
BorderLayout layout = new BorderLayout();
|
||||
PamPanel mainPanel = new PamPanel();
|
||||
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
|
||||
mainPanel.setBorder(new TitledBorder("Export Settings"));
|
||||
|
||||
ButtonGroup buttonGroup = new ButtonGroup();
|
||||
|
||||
|
||||
PamPanel buttonPanel = new PamPanel();
|
||||
ActionListener listener = actionEvent -> {
|
||||
System.out.println(actionEvent.getActionCommand() + " Selected");
|
||||
@ -111,12 +159,12 @@ public class ExportProcessDialog {
|
||||
|
||||
for (int i = 0; i < exportManager.getNumExporters(); i++) {
|
||||
JToggleButton b = new JToggleButton();
|
||||
b.setToolTipText("Export to " + exportManager.getExporter(i).getName() + " file (" + exportManager.getExporter(i).getFileExtension() + ")");
|
||||
|
||||
FontIcon icon = FontIcon.of(getIconFromString(exportManager.getExporter(i).getIconString()));
|
||||
icon.setIconSize(25);
|
||||
icon.setIconColor(Color.GRAY);
|
||||
|
||||
|
||||
b.setIcon(icon);
|
||||
|
||||
b.addActionListener(listener);
|
||||
@ -124,11 +172,66 @@ public class ExportProcessDialog {
|
||||
buttonPanel.add(b);
|
||||
}
|
||||
|
||||
mainPanel.add(buttonPanel, BorderLayout.CENTER);
|
||||
|
||||
//add the main panel at a diffderent index.
|
||||
getMainPanel().add(buttonPanel, 1);
|
||||
PamPanel p = new PamPanel(new GridBagLayout());
|
||||
GridBagConstraints c = new PamGridBagContraints();
|
||||
c.gridwidth = 3;
|
||||
c.gridx = 0;
|
||||
c.gridy = 0;
|
||||
|
||||
addComponent(p, exportTo = new JTextField(), c);
|
||||
exportTo.setMinimumSize(new Dimension(170, 25));
|
||||
exportTo.setPreferredSize(new Dimension(170, 25));
|
||||
|
||||
c.gridx +=3;
|
||||
c.gridwidth = 1;
|
||||
PamButton button = new PamButton("Browse...");
|
||||
|
||||
fc = new PamFileChooser();
|
||||
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
|
||||
button.addActionListener((action)->{
|
||||
int returnVal = fc.showSaveDialog(this);
|
||||
if(returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File yourFolder = fc.getSelectedFile();
|
||||
exportTo.setText(yourFolder.getAbsolutePath());
|
||||
exportTo.setToolTipText(yourFolder.getAbsolutePath());
|
||||
}
|
||||
});
|
||||
|
||||
addComponent(p, button, c);
|
||||
|
||||
c.gridx = 1;
|
||||
c.gridy++;
|
||||
c.gridwidth = 2;
|
||||
|
||||
JLabel label = new JLabel("Maximum file size", SwingConstants.RIGHT);
|
||||
addComponent(p, label, c);
|
||||
|
||||
c.gridwidth = 1;
|
||||
c.gridx +=2;
|
||||
|
||||
SpinnerListModel list = new SpinnerListModel(new Double[] {10.,30., 60., 100., 200., 300., 600., 1000.});
|
||||
|
||||
spinner = new JSpinner(list);
|
||||
//don't want the user to to able to set values
|
||||
((DefaultEditor) spinner.getEditor()).getTextField().setEditable(false);
|
||||
spinner.setBounds(50, 80, 70, 100);
|
||||
addComponent(p, spinner, c);
|
||||
|
||||
c.gridx ++;
|
||||
addComponent(p, new JLabel("MB"), c);
|
||||
|
||||
|
||||
|
||||
mainPanel.add(p);
|
||||
mainPanel.add(buttonPanel);
|
||||
|
||||
//add the main panel at a different index.
|
||||
getMainPanel().add(mainPanel, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Ikon getIconFromString(String iconString) {
|
||||
|
||||
@ -148,13 +251,30 @@ public class ExportProcessDialog {
|
||||
icon=MaterialDesignF.FILE_MUSIC;
|
||||
break;
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
public ExportParams getExportParams() {
|
||||
|
||||
|
||||
return currentParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getParams() {
|
||||
//make sure we update the current paramters before processing starts.
|
||||
this.currentParams = getExportParams();
|
||||
return super.getParams();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setParams(ExportParams params) {
|
||||
if (params ==null) currentParams = new ExportParams();
|
||||
currentParams = params.clone();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -174,4 +294,9 @@ public class ExportProcessDialog {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -79,7 +79,7 @@ public class WavFileExportManager implements PamDataUnitExporter {
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of ecporters that can export wav files from a data unit.
|
||||
* Get a list of exporters that can export wav files from a data unit.
|
||||
* @return the wav file exporters.
|
||||
*/
|
||||
public ArrayList<WavDataUnitExport> getWavDataUnitExporters() {
|
||||
@ -453,6 +453,13 @@ public class WavFileExportManager implements PamDataUnitExporter {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "raw sound";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// hello(){
|
||||
|
@ -64,9 +64,9 @@ public class NoiseBandProcess extends PamProcess {
|
||||
super.setupProcess();
|
||||
PamDataBlock sourceData = noiseBandControl.getPamConfiguration().getDataBlock(RawDataUnit.class, noiseBandControl.noiseBandSettings.rawDataSource);
|
||||
|
||||
System.out.println("********************************************************");
|
||||
System.out.println("NOISE BAND PROCESS: " + sourceData + " " + noiseBandControl.noiseBandSettings.rawDataSource);
|
||||
System.out.println("********************************************************");
|
||||
// System.out.println("********************************************************");
|
||||
// System.out.println("NOISE BAND PROCESS: " + sourceData + " " + noiseBandControl.noiseBandSettings.rawDataSource);
|
||||
// System.out.println("********************************************************");
|
||||
if (sourceData == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import PamView.panel.PamAlignmentPanel;
|
||||
import PamView.panel.PamPanel;
|
||||
import PamView.panel.PamProgressBar;
|
||||
import PamguardMVC.PamDataBlock;
|
||||
import export.layoutFX.ExportParams;
|
||||
import offlineProcessing.logging.OldTaskData;
|
||||
import offlineProcessing.logging.TaskLogging;
|
||||
import offlineProcessing.superdet.OfflineSuperDetFilter;
|
||||
@ -836,4 +837,5 @@ public class OLProcessDialog extends PamDialog {
|
||||
return this.taskGroup;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -344,6 +344,8 @@ public class DLSettingsPane extends SettingsPane<RawDLParams>{
|
||||
private void enableControls() {
|
||||
this.dataSelectorPane.setVisible(true);
|
||||
//only show the data selector box for detec tion data.
|
||||
if (sourcePane.getSource() == null) this.dataSelectorPane.setVisible(false);
|
||||
|
||||
if (sourcePane.getSource().getDataSelectCreator() instanceof NullDataSelectorCreator) {
|
||||
//^bit messy but cannot think of a better way to do it.
|
||||
this.dataSelectorPane.setVisible(false);
|
||||
|
Loading…
Reference in New Issue
Block a user