From f42f092f4a36f63f51b9ea8dd4572e2d0e2a53ba Mon Sep 17 00:00:00 2001 From: Jamie Mac Date: Thu, 21 Mar 2024 16:56:09 +0000 Subject: [PATCH] Getting detection plots properly working in the FX display. --- src/dataMap/layoutFX/DataMapPaneFX.java | 7 + src/dataMap/layoutFX/ScrollingDataPaneFX.java | 2 +- src/dataModelFX/DataModelConnectPane.java | 14 +- src/dataModelFX/DataModelPaneFX.java | 20 +- .../DisplayConnectionNode.java | 13 +- .../connectionNodes/ModuleConnectionNode.java | 10 +- .../connectionNodes/ModuleIconFactory.java | 2 +- src/dataPlotsFX/TDControlFX.java | 18 +- .../DetectionDisplayControl.java | 10 +- .../DetectionDisplayControl2.java | 247 +++++++++--------- .../DetectionGroupDisplay.java | 75 +----- .../DetectionGroupDisplayFX.java | 200 ++++++++++++++ src/detectionPlotFX/DetectionPlotParams.java | 34 ++- .../layout/DetectionPlotDisplay.java | 94 ++----- src/generalDatabase/LogSettings.java | 6 +- src/pamViewFX/PamGuiFX.java | 15 ++ src/pamViewFX/PamGuiManagerFX.java | 8 +- src/pamViewFX/PamGuiTabFX.java | 2 +- src/userDisplayFX/SwingDisplayNodeFX.java | 6 + src/userDisplayFX/UserDisplayNodeFX.java | 7 + 20 files changed, 492 insertions(+), 298 deletions(-) create mode 100644 src/detectionPlotFX/DetectionGroupDisplayFX.java diff --git a/src/dataMap/layoutFX/DataMapPaneFX.java b/src/dataMap/layoutFX/DataMapPaneFX.java index fd58a800..82834eae 100644 --- a/src/dataMap/layoutFX/DataMapPaneFX.java +++ b/src/dataMap/layoutFX/DataMapPaneFX.java @@ -21,6 +21,7 @@ import pamViewFX.fxNodes.hidingPane.HidingPane; import pamViewFX.fxNodes.internalNode.PamInternalPane; import pamViewFX.fxNodes.pamAxis.PamDateAxis; import pamViewFX.fxStyles.PamStylesManagerFX; +import userDisplayFX.UserDisplayControlFX; import userDisplayFX.UserDisplayNodeFX; import userDisplayFX.UserDisplayNodeParams; @@ -296,4 +297,10 @@ public class DataMapPaneFX extends PamBorderPane implements UserDisplayNodeFX { } + @Override + public UserDisplayControlFX getUserDisplayControl() { + // TODO Auto-generated method stub + return null; + } + } diff --git a/src/dataMap/layoutFX/ScrollingDataPaneFX.java b/src/dataMap/layoutFX/ScrollingDataPaneFX.java index 51b5715d..2faffbdb 100644 --- a/src/dataMap/layoutFX/ScrollingDataPaneFX.java +++ b/src/dataMap/layoutFX/ScrollingDataPaneFX.java @@ -285,7 +285,7 @@ public class ScrollingDataPaneFX extends PamBorderPane { dateAxis.setUpperBound(screenEndMillis); dateAxis.setLowerBound(screenStartMillis); double[] ticks = dateAxis.recalculateTicks(); - System.out.println("Ticks: " + (ticks[3]/1000/3600) + "hours"); +// System.out.println("Ticks: " + (ticks[3]/1000/3600) + "hours"); dateAxis.setTickUnit(ticks[3]); } diff --git a/src/dataModelFX/DataModelConnectPane.java b/src/dataModelFX/DataModelConnectPane.java index 21883cb6..a7315723 100644 --- a/src/dataModelFX/DataModelConnectPane.java +++ b/src/dataModelFX/DataModelConnectPane.java @@ -174,7 +174,7 @@ public class DataModelConnectPane extends ConnectionPane { PamController pamController = PamController.getInstance(); ArrayList connectionNodes = getAllConnectionNodes(); - System.out.println("checkModulesAdded: Number of controlled units: " + pamController.getNumControlledUnits() ); + //System.out.println("checkModulesAdded: Number of controlled units: " + pamController.getNumControlledUnits() ); for (int i = 0; i <= pamController.getNumControlledUnits(); i++) { checkModuleAdded(pamController.getControlledUnit(i), connectionNodes); } @@ -190,7 +190,7 @@ public class DataModelConnectPane extends ConnectionPane { */ public boolean checkModuleAdded(PamControlledUnit pamControlledUnit, ArrayList connectionNodes) { - System.out.println("datamodelConnectPane: checkModuleAdded: " + pamControlledUnit + " No. nodes: " + connectionNodes.size()); + //System.out.println("datamodelConnectPane: checkModuleAdded: " + pamControlledUnit + " No. nodes: " + connectionNodes.size()); if (pamControlledUnit==null) return false; @@ -204,17 +204,17 @@ public class DataModelConnectPane extends ConnectionPane { ModuleConnectionNode moduleConnectionNode; for (int j = 0; j < connectionNodes.size(); j++) { moduleConnectionNode = (ModuleConnectionNode) connectionNodes.get(j); - System.out.println("Looking for node: " + moduleConnectionNode.getPamControlledUnit()); + //System.out.println("Looking for node: " + moduleConnectionNode.getPamControlledUnit()); if (moduleConnectionNode.getPamControlledUnit()!=null && moduleConnectionNode.getPamControlledUnit().equals(pamControlledUnit)) { - System.out.println("There is already a node for : " + moduleConnectionNode.getPamControlledUnit().getUnitName()); + //System.out.println("There is already a node for : " + moduleConnectionNode.getPamControlledUnit().getUnitName()); return true; } else if (moduleConnectionNode.getConnectionNodeParams()!=null && moduleConnectionNode.getConnectionNodeParams().unitName!=null && moduleConnectionNode.getConnectionNodeParams().unitName.equals(pamControlledUnit.getUnitName())){ //set the pamcontrolled unit reference within the connection node. node. moduleConnectionNode.setPamControlledUnit(pamControlledUnit); - System.out.println("There is already a node waiting for : " + moduleConnectionNode.getPamControlledUnit().getUnitName()); + //System.out.println("There is already a node waiting for : " + moduleConnectionNode.getPamControlledUnit().getUnitName()); if (PamController.getInstance().isInitializationComplete()) { //only to be used on drag and dropped nodes. @@ -224,7 +224,7 @@ public class DataModelConnectPane extends ConnectionPane { } } - System.out.println("Could not find the node: " + pamControlledUnit.getUnitName()); + //System.out.println("Could not find the node: " + pamControlledUnit.getUnitName()); //possibility 3 ModuleConnectionNode newNode; @@ -309,7 +309,7 @@ public class DataModelConnectPane extends ConnectionPane { * Check module connections. Attempts to make the GUI data model reflect the current pamDataModel. For example * use this function if source data is changed in external dialogs. */ - protected void dataModeltoPamModel(){ + public void dataModeltoPamModel(){ dataModelPaneFX.dataModeltoPamModel(); } diff --git a/src/dataModelFX/DataModelPaneFX.java b/src/dataModelFX/DataModelPaneFX.java index 05312b5f..74635850 100644 --- a/src/dataModelFX/DataModelPaneFX.java +++ b/src/dataModelFX/DataModelPaneFX.java @@ -312,8 +312,8 @@ public class DataModelPaneFX extends PamBorderPane { * reflect the current pamDataModel. For example use this function if source * data is changed in external dialogs. */ - protected void dataModeltoPamModel() { - System.out.println("************DATAMODELTOPAMMODEL*************"); + public void 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,12 +367,12 @@ 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); +// 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); @@ -699,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)) { diff --git a/src/dataModelFX/connectionNodes/DisplayConnectionNode.java b/src/dataModelFX/connectionNodes/DisplayConnectionNode.java index 6dac3747..e40fc78d 100644 --- a/src/dataModelFX/connectionNodes/DisplayConnectionNode.java +++ b/src/dataModelFX/connectionNodes/DisplayConnectionNode.java @@ -39,22 +39,25 @@ public class DisplayConnectionNode extends ModuleConnectionNode { this.setAutoConnect(false); } + @Override protected void connectionListenerTriggered(ConnectorNode shape, ConnectorNode foundShape, int type){ +// System.out.println(" DisplayConnectionNode connection listener " +this.getPamControlledUnit()); + switch(type){ case ConnectorNode.NO_CONNECTION: - //System.out.println(" DisplayConnectionNode. NO_CONNECTION " +this.getPamControlledUnit()+" "+shape+" " +foundShape ); if (lastConnectedPlug!=null && lastConnectedPlug.getConnectedShape()==null){ //want to remove any branch sockets which currently exist -otherwise have sockets which connect to nothing. setLineDisplayColor(lastConnectedPlug, DataModelStyle.moduleLines); setAllowBranchSocket(lastConnectedPlug, false); lastConnectedPlug=null; } + pamModeltoDataModel(); break; case ConnectorNode.POSSIBLE_CONNECTION: //System.out.println(" DisplayConnectionNode. POSSIBLE_CONNECTION " +shape+" " +foundShape ); break; case ConnectorNode.CONNECTED: - //System.out.println("DisplayConnectionNode. CONNECTED " +shape+" " +foundShape ); + //System.out.println("DisplayConnectionNode. CONNECTED " + this.getPamControlledUnit()); if (shape instanceof StandardConnectionSocket){ if (!((StandardConnectionSocket) shape).isBranch()){ lastConnectedPlug=(StandardConnectionPlug) shape.getConnectedShape(); @@ -63,11 +66,17 @@ public class DisplayConnectionNode extends ModuleConnectionNode { } //printCompatibleDataUnits(); checkLineColours(DataModelStyle.displayLines); + pamModeltoDataModel(); break; } //BUG IN CHECK CONNECTIONS - LINE. 246 (Fixed but keep in mind if 'processor leak' type error occurs) } + private void pamModeltoDataModel() { + super.getDataModelConnectionPane().pamModeltoDataModel(); + + } + /** * Set all lines connecting a plug to node to accept/reject branch sockets * @param connectedPlug - the plug to which the lines belong diff --git a/src/dataModelFX/connectionNodes/ModuleConnectionNode.java b/src/dataModelFX/connectionNodes/ModuleConnectionNode.java index 9e93f339..1e7996b3 100644 --- a/src/dataModelFX/connectionNodes/ModuleConnectionNode.java +++ b/src/dataModelFX/connectionNodes/ModuleConnectionNode.java @@ -169,7 +169,7 @@ public class ModuleConnectionNode extends StandardConnectionNode implements PAMC * Create the module. */ private void initModuleNode(){ - + //create the top hiding pane this.getChildren().add(0,topHidingPane=createTopControls()); @@ -196,7 +196,9 @@ public class ModuleConnectionNode extends StandardConnectionNode implements PAMC * @param type - the type of connection. */ protected void connectionListenerTriggered(ConnectorNode shape, ConnectorNode foundShape, int type){ - //System.out.println(" ModuleConnectionNode. listener triggered " + this.getPamControlledUnit().getUnitName()+ " "+type ); + + //System.out.println(" ModuleConnectionNode. listener triggered " + this.getPamControlledUnit()+ " "+type ); + if (lastConnectionStatus==ConnectorNode.NO_CONNECTION && type==ConnectorNode.NO_CONNECTION) return; switch(type){ case ConnectorNode.NO_CONNECTION: @@ -973,7 +975,9 @@ public class ModuleConnectionNode extends StandardConnectionNode implements PAMC } - + public DataModelConnectPane getDataModelConnectionPane() { + return this.connectionPane; + } } diff --git a/src/dataModelFX/connectionNodes/ModuleIconFactory.java b/src/dataModelFX/connectionNodes/ModuleIconFactory.java index b9992530..86e170e4 100644 --- a/src/dataModelFX/connectionNodes/ModuleIconFactory.java +++ b/src/dataModelFX/connectionNodes/ModuleIconFactory.java @@ -215,7 +215,7 @@ public class ModuleIconFactory { * @return the module icon enum */ public ModuleIcon getModuleIcon(String className) { - System.out.println("Get module icon: " + className); +// System.out.println("Get module icon: " + className); ModuleIcon icon = null; switch (className) { case "Acquisition.AcquisitionControl": diff --git a/src/dataPlotsFX/TDControlFX.java b/src/dataPlotsFX/TDControlFX.java index f02b8d6b..80b0ce55 100644 --- a/src/dataPlotsFX/TDControlFX.java +++ b/src/dataPlotsFX/TDControlFX.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import javafx.application.Platform; import javafx.scene.layout.Region; import pamViewFX.fxNodes.internalNode.PamInternalPane; +import userDisplayFX.UserDisplayControlFX; import userDisplayFX.UserDisplayNodeFX; import userDisplayFX.UserDisplayNodeParams; import dataPlotsFX.data.TDDataInfoFX; @@ -293,8 +294,6 @@ public class TDControlFX extends TDControl implements UserDisplayNodeFX { @Override public void closeNode() { - // TODO Auto-generated method stub - } @Override @@ -375,7 +374,7 @@ public class TDControlFX extends TDControl implements UserDisplayNodeFX { // System.out.println("TDControlFX: Saving the position of the display: " // + internalFrame.getInternalRegion().getLayoutX() + " " + internalFrame.getInternalRegion().getLayoutY()); - //need to use the parent node because insode an internal pane. + //need to use the parent node because inside an internal pane. this.getTdParameters().displayProviderParams.positionX=internalFrame.getInternalRegion().getLayoutX(); this.getTdParameters().displayProviderParams.positionY=internalFrame.getInternalRegion().getLayoutY(); this.getTdParameters().displayProviderParams.sizeX=internalFrame.getInternalRegion().getWidth(); @@ -402,6 +401,19 @@ public class TDControlFX extends TDControl implements UserDisplayNodeFX { tdDisplayController.getDisplayDataBlock().clearAll(); if (detectionGroup==null || detectionGroup.getDataList().size()<=0) return; + + System.out.println("Add pam data: " + detectionGroup + " " + tdDisplayController.getDisplayDataBlock().countObservers()); + for (int i=0; i getDisplays(){ if (displays==null){ - detectionDisplay=new DetectionPlotDisplay(this); + detectionDisplay=new DetectionPlotDisplay(); displays=new ArrayList(); - displays.add(detectionDisplay); + //displays.add(detectionDisplay); } return displays; } diff --git a/src/detectionPlotFX/DetectionDisplayControl2.java b/src/detectionPlotFX/DetectionDisplayControl2.java index 09960f4e..b830f716 100644 --- a/src/detectionPlotFX/DetectionDisplayControl2.java +++ b/src/detectionPlotFX/DetectionDisplayControl2.java @@ -2,156 +2,163 @@ package detectionPlotFX; import java.util.ArrayList; +import PamController.PamController; import PamController.PamControllerInterface; import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataUnit; import PamguardMVC.PamObservable; import PamguardMVC.PamObserverAdapter; +import pamViewFX.fxNodes.internalNode.PamInternalPane; 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 DetectionGroupDisplayFX detectionDisplay; + + /** + * A list of displays-> really redundant as there is only ever one display. + */ + private ArrayList displays; + + /** + * The data observer that + */ + private DetectionDataObserver detectionDataObserver; + + private PamInternalPane internalFrame;; - /** - * The display - */ - private DetectionGroupDisplay detectionDisplay; - - /** - * A list of displays-> really redundant as there is only ever one display. - */ - private ArrayList displays; - - /** - * The data observer that - */ - private DetectionDataObserver detectionDataObserver; - - public DetectionDisplayControl2(String unitName) { - super(unitName); - //set which data blocks can connect as parents. + 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(); - //create the observer for the parent data block. - detectionDataObserver=new DetectionDataObserver(); - setMultiParent(false); - + 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; } - - /** - * 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); + if (this.detectionDisplay!=null) this.detectionDisplay.notifyModelChanged(type); + } - //also add data unit - } - + + /** + * 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); + } - @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; - } + + /** + * 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){ - //now add the observer to the data block - //System.out.println("DetectionDisplayControl: Adding observer to data block: "+ pamDataBlock.getDataName()); - pamDataBlock.addObserver(this.detectionDataObserver); + System.out.println("NEW DATA BLOCK DETECTION DISPLAY: " + pamDataBlock); + //if null then no parent- simply set the DDataInfo to null; + if (pamDataBlock==null) { + this.detectionDisplay.clearDisplay(); return true; } - - @Override - public ArrayList getDisplays(){ - if (displays==null){ - detectionDisplay=new DetectionGroupDisplay(); - displays=new ArrayList(); - 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 { + //now add the observer to the data block + //System.out.println("DetectionDisplayControl: Adding observer to data block: "+ pamDataBlock.getDataName()); + pamDataBlock.addObserver(this.detectionDataObserver); - @Override - public long getRequiredDataHistory(PamObservable o, Object arg) { - return 1000; //no data histroy required for this click. - } + return true; + } - @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"; - } - - } + @Override + public ArrayList getDisplays(){ + if (displays==null){ + detectionDisplay=new DetectionGroupDisplayFX(this); + //set the paramters. + displays=new ArrayList(); + 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); + //send the data unit to the display. + detectionDisplay.setDataUnit(arg); + } + + @Override + public String getObserverName() { + return "Detection Display FX"; + } + } + + } diff --git a/src/detectionPlotFX/DetectionGroupDisplay.java b/src/detectionPlotFX/DetectionGroupDisplay.java index f903d94d..d0414aa1 100644 --- a/src/detectionPlotFX/DetectionGroupDisplay.java +++ b/src/detectionPlotFX/DetectionGroupDisplay.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import PamController.PamSettingManager; import PamguardMVC.PamDataBlock; import PamguardMVC.PamDataUnit; import PamguardMVC.superdet.SuperDetection; @@ -39,7 +40,7 @@ import userDisplayFX.UserDisplayNodeParams; * @author Jamie Macaulay * */ -public class DetectionGroupDisplay extends PamBorderPane implements UserDisplayNodeFX { +public class DetectionGroupDisplay extends PamBorderPane { /** * Index of the current normal unit with the detection summary. @@ -102,17 +103,14 @@ public class DetectionGroupDisplay extends PamBorderPane implements UserDisplayN */ 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(); - detectionPlotParams=new DetectionPlotParams(); createDetectionDisplay(); this.setCenter(detectionDisplayHolder); + } @@ -437,66 +435,15 @@ public class DetectionGroupDisplay extends PamBorderPane implements UserDisplayN 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 - - } + +// @Override +// public boolean requestNodeSettingsPane() { +// if (dDPlotPane.getHidePane(Side.RIGHT)!=null) dDPlotPane.getHidePane(Side.RIGHT).showHidePane(true); +// if (dDPlotPane.getHidePane(Side.LEFT)!=null) dDPlotPane.getHidePane(Side.LEFT).showHidePane(true); +// return true; +// } } \ No newline at end of file diff --git a/src/detectionPlotFX/DetectionGroupDisplayFX.java b/src/detectionPlotFX/DetectionGroupDisplayFX.java new file mode 100644 index 00000000..06148ad2 --- /dev/null +++ b/src/detectionPlotFX/DetectionGroupDisplayFX.java @@ -0,0 +1,200 @@ +package detectionPlotFX; + +import java.io.Serializable; + +import PamController.PamControlledUnitSettings; +import PamController.PamController; +import PamController.PamSettingManager; +import PamController.PamSettings; +import PamguardMVC.PamDataBlock; +import javafx.scene.layout.Region; +import pamViewFX.fxNodes.internalNode.PamInternalPane; +import userDisplayFX.UserDisplayControlFX; +import userDisplayFX.UserDisplayNodeFX; + +/** + * A group detection display with all the bits added to allow the display to be used in the FX GUI as + * a stand alone user display. + * + * @author Jamie Macaulay + * + */ +public class DetectionGroupDisplayFX extends DetectionGroupDisplay implements UserDisplayNodeFX, PamSettings{ + + private DetectionPlotParams detectionPlotParams = new DetectionPlotParams(); + + /** + * Reference to the internal frame that migfth hold this graph. + */ + private PamInternalPane internalFrame; + + private DetectionDisplayControl2 displayControl; + + public DetectionGroupDisplayFX(DetectionDisplayControl2 displayControl){ + this.displayControl = displayControl; + //register the settings. + PamSettingManager.getInstance().registerSettings(this); + } + + @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 void closeNode() {}; + @Override + public DetectionPlotParams getDisplayParams() { + return this.detectionPlotParams; + } + + private void prepareDisplayParams() { + if (displayControl.getUserDisplayProcess().getParentDataBlock()!=null) { + detectionPlotParams.dataSource = displayControl.getUserDisplayProcess().getParentDataBlock().getLongDataName(); + } + else detectionPlotParams.dataSource = null; + + if (this.internalFrame!=null) { + //need to use the parent node because inside an internal pane. + detectionPlotParams.positionX=internalFrame.getInternalRegion().getLayoutX(); + detectionPlotParams.positionY=internalFrame.getInternalRegion().getLayoutY(); + detectionPlotParams.sizeX=internalFrame.getInternalRegion().getWidth(); + detectionPlotParams.sizeY=internalFrame.getInternalRegion().getHeight(); + } + } + + + + @Override + public void setFrameHolder(PamInternalPane internalFrame) { + this.internalFrame=internalFrame; + + } + + @Override + public boolean requestNodeSettingsPane() { + // TODO Auto-generated method stub + return false; + } + + + @Override + public void notifyModelChanged(int changeType) { + + switch (changeType) { + case PamController.INITIALIZATION_COMPLETE: + PamDataBlock dataBlock = PamController.getInstance().getDataBlockByLongName(detectionPlotParams.dataSource); + //set the correct parent data block if on exists + displayControl.getUserDisplayProcess().setParentDataBlock(dataBlock); + displayControl.displayToDataModel(dataBlock); + + break; + } + + } + + /** + * Set the display parameterts. + * @param detectionPlotParams + */ + public void setDisplayParams(DetectionPlotParams detectionPlotParams) { + this.detectionPlotParams = detectionPlotParams; + + } + + @Override + public Serializable getSettingsReference() { + Serializable set = prepareSerialisedSettings(); + return set; + } + + /** + * Prepare settings for saving. + * @return + */ + private Serializable prepareSerialisedSettings() { + if (detectionDisplay==null) return null; + prepareDisplayParams(); + detectionPlotParams = getDisplayParams(); + + System.out.println("SAVE DETECTION DISPLAY DATA SOURCE: " + detectionPlotParams.dataSource); + System.out.println("SAVE DETECTION DISPLAY TAB NAME: " + detectionPlotParams.tabName); + + return detectionPlotParams; + } + + + @Override + public long getSettingsVersion() { + return DetectionPlotParams.serialVersionUID; + } + + + @Override + public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) { + try{ + return restoreSettings((DetectionPlotParams) pamControlledUnitSettings.getSettings()); + } + catch(Exception e){ + e.printStackTrace(); + return false; + } + } + + + private boolean restoreSettings(DetectionPlotParams settings) { + if (settings == null) { + return false; + } + + System.out.println("DETECTION DISPLAY DATA SOURCE: " + settings.dataSource); + System.out.println("DETECTION DISPLAY DATA SOURCE: " + settings.tabName); + + + this.detectionPlotParams = settings.clone(); + return true; + } + + @Override + public String getUnitName() { + return displayControl.getUnitName(); + } + + @Override + public String getUnitType() { + return displayControl.getUnitType(); + } + + @Override + public UserDisplayControlFX getUserDisplayControl() { + return displayControl; + } + +} diff --git a/src/detectionPlotFX/DetectionPlotParams.java b/src/detectionPlotFX/DetectionPlotParams.java index 5085be83..d05ac47a 100644 --- a/src/detectionPlotFX/DetectionPlotParams.java +++ b/src/detectionPlotFX/DetectionPlotParams.java @@ -1,5 +1,9 @@ package detectionPlotFX; +import PamModel.parametermanager.ManagedParameters; +import PamModel.parametermanager.PamParameterSet; +import PamModel.parametermanager.PamParameterSet.ParameterSetType; +import dataPlotsFX.TDParametersFX; import userDisplayFX.UserDisplayNodeParams; /** @@ -8,11 +12,37 @@ import userDisplayFX.UserDisplayNodeParams; * @author Jamie Macaulay * */ -public class DetectionPlotParams extends UserDisplayNodeParams { +public class DetectionPlotParams extends UserDisplayNodeParams implements Cloneable, ManagedParameters { + + /** + * The data source for the detection plot. + */ + public String dataSource = null; + /** * */ - private static final long serialVersionUID = 1L; + static final long serialVersionUID = 1L; + + + /* (non-Javadoc) + * @see java.lang.Object#clone() + */ + @Override + public DetectionPlotParams clone() { + try { + return (DetectionPlotParams) super.clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + return null; + } + } + + @Override + public PamParameterSet getParameterSet() { + PamParameterSet ps = PamParameterSet.autoGenerate(this, ParameterSetType.DISPLAY); + return ps; + } } diff --git a/src/detectionPlotFX/layout/DetectionPlotDisplay.java b/src/detectionPlotFX/layout/DetectionPlotDisplay.java index 4a230cc3..9652ddcb 100644 --- a/src/detectionPlotFX/layout/DetectionPlotDisplay.java +++ b/src/detectionPlotFX/layout/DetectionPlotDisplay.java @@ -37,7 +37,7 @@ import userDisplayFX.UserDisplayNodeParams; * @author Jamie Macaulay * */ -public class DetectionPlotDisplay extends PamBorderPane implements UserDisplayNodeFX { +public class DetectionPlotDisplay extends PamBorderPane { private static final double PREF_SETTINGS_WIDTH = 250; @@ -253,56 +253,23 @@ public class DetectionPlotDisplay extends PamBorderPane implements UserDisplayNo return isViewer; } - - @Override - public String getName() { - return "Detection Display"; - } - - @Override - public Region getNode() { - 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 void closeNode() { - // TODO Auto-generated method stub - - } - - @Override - public void notifyModelChanged(int changeType) { - switch (changeType){ - case PamControllerInterface.INITIALIZATION_COMPLETE: - - break; - case PamControllerInterface.ADD_CONTROLLEDUNIT: - this.dataSettingsPane.notifyDataChange(); - 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. - this.dataSettingsPane.notifyDataChange(); - break; - } - - } +// @Override +// public void notifyModelChanged(int changeType) { +// switch (changeType){ +// case PamControllerInterface.INITIALIZATION_COMPLETE: +// +// break; +// case PamControllerInterface.ADD_CONTROLLEDUNIT: +// this.dataSettingsPane.notifyDataChange(); +// 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. +// this.dataSettingsPane.notifyDataChange(); +// break; +// } +// +// } /** * Set the DataInfo for the display. @@ -499,12 +466,7 @@ public class DetectionPlotDisplay extends PamBorderPane implements UserDisplayNo detectionDisplayControl.dataModelToDisplay(); } - @Override - public boolean requestNodeSettingsPane() { - if (dDPlotPane.getHidePane(Side.RIGHT)!=null) dDPlotPane.getHidePane(Side.RIGHT).showHidePane(true); - if (dDPlotPane.getHidePane(Side.LEFT)!=null) dDPlotPane.getHidePane(Side.LEFT).showHidePane(true); - return true; - } + /** * Get an axis pane @@ -524,11 +486,7 @@ public class DetectionPlotDisplay extends PamBorderPane implements UserDisplayNo return dDPlotPane.getHidePane(side); } - @Override - public boolean isMinorDisplay() { - // these are generally smaller minor displays- only used for automatic resize. - return true; - } + /** * Called whenever a new datablock is added. @@ -609,18 +567,6 @@ public class DetectionPlotDisplay extends PamBorderPane implements UserDisplayNo return detectionPlotProjector; } - - @Override - public UserDisplayNodeParams getDisplayParams() { - return this.detectionPlotParams; - } - - - @Override - public void setFrameHolder(PamInternalPane internalFrame) { - // TODO Auto-generated method stub - } - /** * The pane which holds settings for the the current plot. diff --git a/src/generalDatabase/LogSettings.java b/src/generalDatabase/LogSettings.java index 23b713be..c7072e30 100644 --- a/src/generalDatabase/LogSettings.java +++ b/src/generalDatabase/LogSettings.java @@ -109,9 +109,9 @@ public class LogSettings extends DbSpecial { * data that will fit into the database. */ try { - if (pamSettings.getUnitName().equals("User TDDisplay")) { - System.out.println("Saving user display data"); - } +// if (pamSettings.getUnitName().equals("User TDDisplay")) { +// System.out.println("Saving user display data"); +// } } catch (NullPointerException e) { e.printStackTrace(); diff --git a/src/pamViewFX/PamGuiFX.java b/src/pamViewFX/PamGuiFX.java index 2acb7f03..4fa1a970 100644 --- a/src/pamViewFX/PamGuiFX.java +++ b/src/pamViewFX/PamGuiFX.java @@ -306,6 +306,21 @@ public class PamGuiFX extends StackPane implements PamViewInterface { } } + newTab.setOnClosed((action)->{ + //when a tab is closer. + for (int i=0; i