Getting detection plots properly working in the FX display.

This commit is contained in:
Jamie Mac 2024-03-21 16:56:09 +00:00
parent 755ff7608d
commit f42f092f4a
20 changed files with 492 additions and 298 deletions

View File

@ -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;
}
}

View File

@ -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]);
}

View File

@ -174,7 +174,7 @@ public class DataModelConnectPane extends ConnectionPane {
PamController pamController = PamController.getInstance();
ArrayList<ConnectionNode> 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<ConnectionNode> 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();
}

View File

@ -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)) {

View File

@ -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

View File

@ -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;
}
}

View File

@ -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":

View File

@ -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<tdDisplayController.getDisplayDataBlock().countObservers() ; i++) {
System.out.println("Observer : " + tdDisplayController.getDisplayDataBlock().getPamObserver(i));
}
tdDisplayController.getDisplayDataBlock().addPamData(detectionGroup.getDataList().get(detectionGroup.getFocusedIndex()));
if (isViewer()) tdDisplayController.getDisplayDataBlock().notifyNornalObservers(detectionGroup.getDataList().get(detectionGroup.getFocusedIndex()));
}
@Override
public UserDisplayControlFX getUserDisplayControl() {
return this.tdDisplayController;
}
}

View File

@ -24,6 +24,7 @@ import userDisplayFX.UserDisplayNodeFX;
* @author Jamie Macaulay
*
*/
@Deprecated
public class DetectionDisplayControl extends UserDisplayControlFX {
/**
@ -49,7 +50,8 @@ public class DetectionDisplayControl extends UserDisplayControlFX {
//create the observer for the parent data block.
detectionDataObserver=new DetectionDataObserver();
setMultiParent(false);
}
/**
@ -83,7 +85,7 @@ public class DetectionDisplayControl extends UserDisplayControlFX {
displayToDataModel(this.getUserDisplayProcess().getParentDataBlock());
break;
}
this.detectionDisplay.notifyModelChanged(type);
//this.detectionDisplay.notifyModelChanged(type);
}
/**
@ -159,9 +161,9 @@ public class DetectionDisplayControl extends UserDisplayControlFX {
@Override
public ArrayList<UserDisplayNodeFX> getDisplays(){
if (displays==null){
detectionDisplay=new DetectionPlotDisplay(this);
detectionDisplay=new DetectionPlotDisplay();
displays=new ArrayList<UserDisplayNodeFX>();
displays.add(detectionDisplay);
//displays.add(detectionDisplay);
}
return displays;
}

View File

@ -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<UserDisplayNodeFX> 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<UserDisplayNodeFX> 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<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 {
//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<UserDisplayNodeFX> getDisplays(){
if (displays==null){
detectionDisplay=new DetectionGroupDisplayFX(this);
//set the paramters.
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);
//send the data unit to the display.
detectionDisplay.setDataUnit(arg);
}
@Override
public String getObserverName() {
return "Detection Display FX";
}
}
}

View File

@ -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<PamDataBlock, DDDataInfo>();
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;
// }
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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.

View File

@ -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();

View File

@ -306,6 +306,21 @@ public class PamGuiFX extends StackPane implements PamViewInterface {
}
}
newTab.setOnClosed((action)->{
//when a tab is closer.
for (int i=0; i<newTab.getInternalPanes().size(); i++) {
System.out.println("REMOVE TAB: " + newTab.getInternalPanes().size());
newTab.getInternalPanes().get(i).getUserDisplayNode().closeNode();
if (newTab.getInternalPanes().get(i).getUserDisplayNode().getUserDisplayControl()!=null) {
System.out.println("REMOVE CONTROLLED DISPLAY UNIT: " + newTab.getInternalPanes().get(i).getUserDisplayNode().getUserDisplayControl());
//the display is a standalone display and so remove the tab means the controlled unit should be removed from the data model
PamController.getInstance().removeControlledUnt(newTab.getInternalPanes().get(i).getUserDisplayNode().getUserDisplayControl());
PamGuiManagerFX.getInstance().getDataModelFX().dataModeltoPamModel();
}
}
});
newTab.setDetachable(detachable);
//add tab

View File

@ -296,14 +296,14 @@ public class PamGuiManagerFX implements PAMControllerGUI, PamSettings {
}
/**
* Add a controlled unit from the scene. The controlled unit may have a graphical component or no graphical component at all.
* Remove a controlled unit from the scene. The controlled unit may have a graphical component or no graphical component at all.
* @param controlledUnit - the controlled unit to remove (here we're removing all it's displays)
*/
@Override
public void removeControlledUnit(PamControlledUnit controlledUnit){
//now set the content for the tab.
if (controlledUnit.getGUI(PamGUIManager.FX)!=null){
//System.out.println("PAMGuiMangerFX: Remove module (PamControlledUnit) added" +controlledUnit.getUnitName());
System.out.println("PAMGuiMangerFX: Remove module (PamControlledUnit)" +controlledUnit.getUnitName());
//if FX content then is handles as an FX Node within GUI manager.
PamControlledGUIFX pamControlledUnitFX=(PamControlledGUIFX) controlledUnit.getGUI(PamGUIManager.FX);
//figure out which tab the display should be added to.
@ -416,7 +416,9 @@ public class PamGuiManagerFX implements PAMControllerGUI, PamSettings {
});
}
else {
if (newDisplay.getDisplayParams()!=null) {
newDisplay.getDisplayParams().tabName=tab.getName();
}
}
}

View File

@ -423,7 +423,7 @@ public class PamGuiTabFX extends PamTabFX {
* @author Jamie Macaulay
*
*/
private class PamGuiInternalPane extends PamInternalPane {
class PamGuiInternalPane extends PamInternalPane {
private UserDisplayNodeFX mainPane;

View File

@ -143,4 +143,10 @@ public class SwingDisplayNodeFX implements UserDisplayNodeFX{
}
@Override
public UserDisplayControlFX getUserDisplayControl() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -10,6 +10,13 @@ import pamViewFX.fxNodes.internalNode.PamInternalPane;
*/
public interface UserDisplayNodeFX {
/**
* Get a display controller associated with the display. Note that a display does not need a controller
* so this can return null.
* @return the associated control for the display.
*/
public UserDisplayControlFX getUserDisplayControl();
/**
* The name of display. Used for default tabs etc.
* @return the name of the display