Updates to data map and fix to detection plots.

This commit is contained in:
Jamie Mac 2024-07-30 16:46:50 +01:00
parent 7e4ee768d2
commit 9fcc6792f9
9 changed files with 101 additions and 74 deletions

View File

@ -55,7 +55,7 @@ public class DataMapPaneFX extends PamBorderPane implements UserDisplayNodeFX {
/**
* The hiding pane which holds the summary pane.
*/
private HidingPane hidingSummaryPane;
private HidingPane hidingSettingsPane;
/**
* The buttons which shows the top hiding pane.
@ -105,16 +105,16 @@ public class DataMapPaneFX extends PamBorderPane implements UserDisplayNodeFX {
//topHolder.prefHeightProperty().bind(summaryPane.prefHeightProperty());
//hiding summary pane
hidingSummaryPane=new HidingPane(Side.RIGHT, settingsPane, this, true);
hidingSummaryPane.setVisibleImmediatly(false);
hidingSummaryPane.showHidePane(true);
hidingSummaryPane.getStyleClass().add("pane-trans");
hidingSummaryPane.getStylesheets().addAll(PamStylesManagerFX.getPamStylesManagerFX().getCurStyle().getSlidingDialogCSS());
StackPane.setAlignment(hidingSummaryPane, Pos.TOP_RIGHT);
hidingSummaryPane.setPrefWidth(HIDE_PANE_WIDTH);
hidingSettingsPane=new HidingPane(Side.RIGHT, settingsPane, this, true);
hidingSettingsPane.setVisibleImmediatly(false);
hidingSettingsPane.showHidePane(true);
hidingSettingsPane.getStyleClass().add("pane-trans");
hidingSettingsPane.getStylesheets().addAll(PamStylesManagerFX.getPamStylesManagerFX().getCurStyle().getSlidingDialogCSS());
StackPane.setAlignment(hidingSettingsPane, Pos.TOP_RIGHT);
hidingSettingsPane.setPrefWidth(HIDE_PANE_WIDTH);
//style the show button.
showButton=hidingSummaryPane.getShowButton();
showButton=hidingSettingsPane.getShowButton();
showButton.getStyleClass().add("close-button-left");
showButton.getStylesheets().addAll(PamStylesManagerFX.getPamStylesManagerFX().getCurStyle().getSlidingDialogCSS());
@ -127,7 +127,7 @@ public class DataMapPaneFX extends PamBorderPane implements UserDisplayNodeFX {
StackPane.setAlignment(showButton, Pos.CENTER_RIGHT);
StackPane stackPane = new StackPane();
stackPane.getChildren().addAll(scrollingDataPanel, hidingSummaryPane, showButton);
stackPane.getChildren().addAll(scrollingDataPanel, hidingSettingsPane, showButton);
dateAxis = new PamDateAxis();
dateAxis.setMinHeight(50);

View File

@ -13,11 +13,11 @@ import pamViewFX.fxNodes.pamScrollers.acousticScroller.ScrollBarPane;
/**
* A scroll bar whihc shows a summary fo the data.
*/
public class DataMapScrollPane extends ScrollBarPane {
public class DataMapScrollBar extends ScrollBarPane {
private DataMapControl dataMapControl;
public DataMapScrollPane(DataMapControl dataMapControl) {
public DataMapScrollBar(DataMapControl dataMapControl) {
super();
this.dataMapControl=dataMapControl;
}

View File

@ -1,5 +1,6 @@
package dataMap.layoutFX;
import java.awt.Insets;
import java.util.Arrays;
import java.util.Iterator;
@ -13,7 +14,6 @@ import dataMap.DataMapControl;
import dataMap.DataMapDrawing;
import dataMap.OfflineDataMap;
import dataMap.OfflineDataMapPoint;
import dataPlotsFX.layout.AxisPane;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.geometry.Orientation;
@ -29,9 +29,10 @@ import javafx.scene.paint.Color;
import javafx.util.Duration;
import PamController.OfflineDataStore;
import PamController.PamController;
import PamUtils.PamCalendar;
import PamguardMVC.PamDataBlock;
import pamViewFX.fxGlyphs.PamGlyphDude;
import pamViewFX.fxNodes.PamBorderPane;
import pamViewFX.fxNodes.PamButton;
import pamViewFX.fxNodes.PamHBox;
import pamViewFX.fxNodes.pamAxis.PamAxisFX;
import pamViewFX.fxNodes.pamAxis.PamAxisPane;
@ -42,7 +43,9 @@ public class DataStreamPaneFX extends PamBorderPane {
/**
* The preferred width of the axis.
*/
public static double axisPrefWidth=80;
public static double PREF_AXIS_WIDTH=80;
public static double PREF_HEADER_HEIGHT=20;
/**
* Reference to the data map control
@ -119,6 +122,8 @@ public class DataStreamPaneFX extends PamBorderPane {
*/
private Timeline timeline;
private PamButton showButton;
/**
* Constructor for the data stream pane.
* @param dataMapControl - the DataMapControl control the DataStreamPaneFX belongs to
@ -147,7 +152,23 @@ public class DataStreamPaneFX extends PamBorderPane {
topPane.getStyleClass().add("pane-opaque");
topPane.getChildren().add(new Label(this.dataBlock.getDataName()));
topPane.setAlignment(Pos.CENTER);
return topPane;
PamBorderPane pane = new PamBorderPane();
pane.setCenter(topPane);
showButton = new PamButton();
showButton.setStyle("-fx-padding: 0 10 0 10; -fx-border-radius: 0 0 0 0; -fx-background-radius: 0 0 0 0;");
showButton.setGraphic(PamGlyphDude.createPamIcon("mdi2c-chevron-down", 18));
showButton.setOnAction((action)->{
this.setCollapsed(!this.isCollapsed());
});
pane.setLeft(showButton);
pane.setPrefHeight(PREF_HEADER_HEIGHT);
return pane;
}
@ -356,7 +377,7 @@ public class DataStreamPaneFX extends PamBorderPane {
axisPane=new PamAxisPane(datastreamAxis, Orientation.VERTICAL);
axisPane.getStyleClass().add("pane");
axisPane.setOrientation(Orientation.VERTICAL);
axisPane.setPrefWidth(DataStreamPaneFX.axisPrefWidth);
axisPane.setPrefWidth(DataStreamPaneFX.PREF_AXIS_WIDTH);
axisPane.setStrokeColor(Color.BLACK);
this.setLeft(axisPane);
@ -393,7 +414,7 @@ public class DataStreamPaneFX extends PamBorderPane {
long time2 = System.currentTimeMillis();
//System.out.println("Paint Canvas: " + this + " " + System.currentTimeMillis() + " " + (time2-time1));
// System.out.println("Paint Canvas: " + this + " " + System.currentTimeMillis() + " " + (time2-time1));
}
@ -543,7 +564,8 @@ public class DataStreamPaneFX extends PamBorderPane {
}
private void datagramPaint3D(GraphicsContext g) {
private synchronized void datagramPaint3D(GraphicsContext g) {
// System.out.println("Paint 3D Canvas: " + this + " " + System.currentTimeMillis());
/*
* hopefully, there will be datagram data for this block, so do a pretty
@ -1063,6 +1085,16 @@ public class DataStreamPaneFX extends PamBorderPane {
*/
public void setCollapsed(boolean collapsed) {
this.collapsed=collapsed;
if (collapsed) {
this.setCenter(null);
this.setMaxHeight(PREF_HEADER_HEIGHT);
}
else {
this.setCenter(dataGraph);
this.setMaxHeight(-1);
}
}
/**

View File

@ -12,6 +12,7 @@ import javafx.geometry.Side;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollBar;
import javafx.scene.control.ScrollPane.ScrollBarPolicy;
import javafx.scene.paint.Color;
import javafx.util.Duration;
import PamguardMVC.PamDataBlock;
@ -34,7 +35,7 @@ public class ScrollingDataPaneFX extends PamBorderPane {
/**
* The default expanded hieght for each pane.
*/
private static final int DATASTREAMPANE_HEIGHT = 200;
private static final int DATASTREAMPANE_HEIGHT = 220;
/**
* Reference to the DataMapControl.
@ -78,12 +79,7 @@ public class ScrollingDataPaneFX extends PamBorderPane {
/**
* Scroll bar for time (horizontal)
*/
private DataMapScrollPane timeScrollBar;
/**
* Settings strip at top of the display. Shows all sorts of detailed info such cursor position and start and end times.
*/
private SettingsStripFX settingsStrip;
private DataMapScrollBar timeScrollBar;
/**
* Shows the start time of the scroll position
@ -111,7 +107,6 @@ public class ScrollingDataPaneFX extends PamBorderPane {
DataMapPaneFX dataMapPaneFX) {
this.dataMapControl = dataMapControl;
this.dataMapPaneFX = dataMapPaneFX;
settingsStrip=new SettingsStripFX(this);
this.setCenter(createScrollingDataPane());
}
@ -125,6 +120,7 @@ public class ScrollingDataPaneFX extends PamBorderPane {
//create the main scroll pane
mainScrollPane = new PamScrollPane();
mainScrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
//create the split pane to hold the graphs.
@ -215,9 +211,9 @@ public class ScrollingDataPaneFX extends PamBorderPane {
//create the scroll bar and listeners.
timeScrollBar=new DataMapScrollPane(this.dataMapControl);
timeScrollBar=new DataMapScrollBar(this.dataMapControl);
timeScrollBar.addValueListener((obs_val, old_val, new_val)->{
System.out.println("Scroll bar seconds: " + timeScrollBar.getCurrentValue() + " vis amount: " + timeScrollBar.visibleAmountProperty().get());
// System.out.println("Scroll bar seconds: " + timeScrollBar.getCurrentValue() + " vis amount: " + timeScrollBar.visibleAmountProperty().get());
calcStartEndMillis();
updateScrollBarText();
notifyScrollChange();
@ -241,8 +237,12 @@ public class ScrollingDataPaneFX extends PamBorderPane {
screenStartMillis = (long) (dataMapControl.getFirstTime() +
timeScrollBar.getCurrentValue());
screenEndMillis = (long) (screenStartMillis + timeScrollBar.getVisibleAmount());
double pixsPerHour = getPixelsPerHour();
double pixsPerSecond = pixsPerHour / 3600;
double screenWidth = getPlotWidth();
screenSeconds = screenWidth / Math.min(600. / 3600, pixsPerSecond);
getPixelsPerHour();
}
/**
@ -261,7 +261,7 @@ public class ScrollingDataPaneFX extends PamBorderPane {
for (int i = 0; i < dataStreamPanels.size(); i++) {
dataStreamPanels.get(i).scrollChanged();
}
settingsStrip.scrollChanged();
// settingsStrip.scrollChanged();
updateDateAxis();
}
@ -321,7 +321,7 @@ public class ScrollingDataPaneFX extends PamBorderPane {
for (int i = 0; i < dataBlocks.size(); i++) {
aStreamPanel = new DataStreamPaneFX(dataMapControl, this, dataBlocks.get(i));
dataStreamPanels.add(aStreamPanel);
dataStreamPanels.get(i).setMinHeight(DATASTREAMPANE_HEIGHT);
dataStreamPanels.get(i).setPrefHeight(DATASTREAMPANE_HEIGHT);
//now add to a split pane.
//SplitPane.setResizableWithParent(aStreamPanel, true);
dataPanePanes.getChildren().add(aStreamPanel);
@ -356,6 +356,7 @@ public class ScrollingDataPaneFX extends PamBorderPane {
}
private void setupScrollBar() {
/**
* Do scrolling in seconds - will give up to 68 years with a
* 32 bit integer control of scroll bar. milliseconds would give < 1 year !
@ -365,10 +366,7 @@ public class ScrollingDataPaneFX extends PamBorderPane {
long dataEnd = dataMapControl.getLastTime();
double dataSeconds = ((dataEnd-dataStart)/1000) + 1;
double pixsPerHour = getPixelsPerHour();
double pixsPerSecond = pixsPerHour / 3600;
double screenWidth = getPlotWidth();
screenSeconds = screenWidth / Math.min(600. / 3600, pixsPerSecond);
calcStartEndMillis();
@ -383,7 +381,8 @@ public class ScrollingDataPaneFX extends PamBorderPane {
// screenEndMillis = dataEnd;
// }
// else {
System.out.println("dataSeconds2: "+dataSeconds+ " pixsPerHour: " +pixsPerHour+" screenWidth: "+screenWidth+" screenSeconds "+screenSeconds+" holder width: "+holder.getWidth());
// System.out.println("dataSeconds2: "+dataSeconds+ " pixsPerHour: " +pixsPerHour+" screenWidth: "+screenWidth+" screenSeconds "+screenSeconds+" holder width: "+holder.getWidth());
timeScrollBar.setVisible(true);
timeScrollBar.setMinVal(0);
timeScrollBar.setMaxVal(Math.max(dataSeconds, screenSeconds)*1000L);
@ -393,12 +392,7 @@ public class ScrollingDataPaneFX extends PamBorderPane {
timeScrollBar.setCurrentValue(currentPos);
//now paint the canvas to show the data.
try {
timeScrollBar.paintDataSummary();
}
catch (Exception e) {
e.printStackTrace();
}
}
@ -408,7 +402,7 @@ public class ScrollingDataPaneFX extends PamBorderPane {
*/
private double getPlotWidth() {
//HACK- seems like there is a lyout delay in datstream panes.
return this.holder.getWidth()-DataStreamPaneFX.axisPrefWidth;
return this.holder.getWidth()-DataStreamPaneFX.PREF_AXIS_WIDTH;
// if (dataStreamPanels.size()>0){
// dataStreamPanels.get(0).layout();
// return dataStreamPanels.get(0).getDataGraph().getPlotWidth();
@ -438,7 +432,7 @@ public class ScrollingDataPaneFX extends PamBorderPane {
public double getPixelsPerHour() {
System.out.println("Pixels per hour: " + dataMapControl.dataMapParameters.getPixeslPerHour() + " " + this.getPlotWidth()/(this.timeScrollBar.getVisibleAmount()/1000./3600.));
// System.out.println("Pixels per hour: " + dataMapControl.dataMapParameters.getPixeslPerHour() + " " + this.getPlotWidth()/(this.timeScrollBar.getVisibleAmount()/1000./3600.));
//return dataMapControl.dataMapParameters.getPixeslPerHour();
return this.getPlotWidth()/(this.timeScrollBar.getVisibleAmount()/1000./3600.);

View File

@ -1,16 +0,0 @@
package dataMap.layoutFX;
import pamViewFX.fxNodes.PamBorderPane;
public class SettingsStripFX extends PamBorderPane {
public SettingsStripFX(ScrollingDataPaneFX scrollingDataPaneFX) {
// TODO Auto-generated constructor stub
}
public void scrollChanged() {
// TODO Auto-generated method stub
}
}

View File

@ -276,7 +276,7 @@ public abstract class DDDataInfo<T extends PamDataUnit> {
getCurrentDetectionPlot().setupAxis((PamDataUnit) pamDataUnit, this.getHardSampleRate(), projector);
getCurrentDetectionPlot().paintPlot((PamDataUnit) pamDataUnit, g, windowRect, projector, flag);
}

View File

@ -226,7 +226,7 @@ public class DetectionPlotDisplay extends PamBorderPane {
* Called whenever the scroll values change
*/
void scrollBarChanged() {
if (detectionPlotProjector.enableScrollBar) {
if (detectionPlotProjector.isEnableScrollBar()) {
detectionPlotProjector.setAxisMinMax(scrollBarPane.getCurrentValue(),
scrollBarPane.getCurrentValue()+scrollBarPane.getVisibleAmount(), detectionPlotProjector.getScrollAxis());
drawCurrentUnit();
@ -237,7 +237,7 @@ public class DetectionPlotDisplay extends PamBorderPane {
* Repaint the scroll bar.
*/
private void repainScrollBar() {
if (currentDataInfo!=null && detectionPlotProjector.enableScrollBar && lastDetection!=null) {
if (currentDataInfo!=null && detectionPlotProjector.isEnableScrollBar() && lastDetection!=null) {
currentDataInfo.drawData(scrollBarPane.getDrawCanvas().getGraphicsContext2D(),
new Rectangle(0,0,scrollBarPane.getDrawCanvas().getWidth(),scrollBarPane.getDrawCanvas().getHeight()),
this.detectionPlotProjector, this.lastDetection, DetectionPlot.SCROLLPANE_DRAW);
@ -355,6 +355,7 @@ public class DetectionPlotDisplay extends PamBorderPane {
* the current data unit.
*/
public void setupScrollBar(PamDataUnit newDataUnit){
System.out.println("SETUP SCROLL BAR:");
if (currentDataInfo!=null) {
//important we put this here as it allows the plot to set up the scroll bar pane.
@ -382,12 +383,18 @@ public class DetectionPlotDisplay extends PamBorderPane {
this.detectionPlotProjector, newDataUnit, DetectionPlot.SCROLLPANE_DRAW);
}
}
else {
System.out.println("Min scroll limit: " + detectionPlotProjector.getMinScrollLimit() + "max: " + detectionPlotProjector.getMaxScrollLimit());
//need this to ensure the axis change when scroll bar is not longer displayed.
detectionPlotProjector.setAxisMinMax(detectionPlotProjector.getMinScrollLimit(),
detectionPlotProjector.getMaxScrollLimit(), detectionPlotProjector.getScrollAxis());
//need to setup the axis as it takes it data fom the ploit projector.
if (currentDataInfo!=null) {
this.currentDataInfo.setupAxis(detectionPlotProjector, newDataUnit);
}
this.setTop(null);
}
}
@ -411,22 +418,27 @@ public class DetectionPlotDisplay extends PamBorderPane {
*Draw the data unit.
*/
private void drawDataUnit(PamDataUnit newDataUnit) {
//Debug.out.println("DetectionPlotDisplay DrawDataUnit: " +newDataUnit);
if (reDrawScroll) {
setupScrollBar(newDataUnit);
reDrawScroll=false;
}
if (currentDataInfo!=null){
//sometimes the axis just need a little push to make sure the pane and axis object bindings have been updated
for (int i=0; i<Side.values().length; i++) {
dDPlotPane.getAxisPane(Side.values()[i]).layout();
}
// System.out.println("Axis Width: " + dDPlotPane.getAxisPane(Side.BOTTOM).getWidth() + " canvas width " + dDPlotPane.getPlotCanvas().getWidth());
currentDataInfo.drawData(dDPlotPane.getPlotCanvas().getGraphicsContext2D(),
new Rectangle(0,0,dDPlotPane.getPlotCanvas().getWidth(),dDPlotPane.getPlotCanvas().getHeight()),
this.detectionPlotProjector, newDataUnit);
}
//Debug.out.println("DetectionPlotDisplay DrawDataUnit: " +newDataUnit);
if (reDrawScroll) {
setupScrollBar(newDataUnit);
reDrawScroll=false;

View File

@ -93,7 +93,7 @@ public abstract class WaveformPlot<D extends PamDataUnit> implements DetectionPl
*/
@Override
public void setupAxis(D pamDetection, double sR, DetectionPlotProjector plotProjector){
//System.out.println("WaveformPlot: plotting the waveform" + waveform.length);
System.out.println("WaveformPlot.setupAxis plotting the waveform: " + getWaveform(pamDetection)[0].length);
//all axis are used in the waveform plot except the right axis.
double[][] waveform=getWaveform(pamDetection);
@ -107,20 +107,23 @@ public abstract class WaveformPlot<D extends PamDataUnit> implements DetectionPl
else binLength=waveform[0].length;
//System.out.println("Waveform Length: " + binLength);
// plotProjector.setEnableScrollBar(true);
//set the scroller minimum and maximum
plotProjector.setMinScrollLimit(0);
plotProjector.setMaxScrollLimit((binLength*1000.)/sR);
plotProjector.setEnableScrollBar(true);
plotProjector.setScrollAxis(Side.BOTTOM);
// System.out.println("Waveform Time Axis: min " + (plotProjector.getAxis(Side.BOTTOM).getMinVal()/1000.)*sR +
// " max: " + (plotProjector.getAxis(Side.BOTTOM).getMaxVal()/1000)*sR);
//set the min and max value.
//set the min and max value from the bottom axis on the top axis. This essentially means that the scroller can
//set the top axis.
plotProjector.setAxisMinMax((plotProjector.getAxis(Side.BOTTOM).getMinVal()/1000.)*sR,
(plotProjector.getAxis(Side.BOTTOM).getMaxVal()/1000)*sR, Side.TOP);
System.out.println("WaveformPlot.setupAxis: min " + (plotProjector.getAxis(Side.BOTTOM).getMinVal()/1000.)*sR +
" max: " + (plotProjector.getAxis(Side.BOTTOM).getMaxVal()/1000)*sR);
// plotProjector.setAxisMinMax(0, (binLength*1000.)/sR, Side.BOTTOM);
plotProjector.setAxisMinMax(-1, 1, Side.LEFT); //TODO
@ -182,6 +185,7 @@ public abstract class WaveformPlot<D extends PamDataUnit> implements DetectionPl
* @param projector - the projector
*/
private void forcePaintPlot(D pamDetection, GraphicsContext gc, Rectangle rectangle, DetectionPlotProjector projector){
System.out.println("WaveformPlot.forcePaintPlot:");
currentWaveform=getWaveform(pamDetection);
if (currentWaveform==null) return;
@ -255,6 +259,7 @@ public abstract class WaveformPlot<D extends PamDataUnit> implements DetectionPl
synchronized (storedWaveformLock) {
if (currentDetection == null || waveform==null || waveform.length==0 || waveform[0]==null)
return;
paintWaveform(waveform, currentDetection.getSequenceBitmap(), g, clipRect, (int) projector.getAxis(Side.TOP).getMinVal(), (int) projector.getAxis(Side.TOP).getMaxVal(),
log2Amplitude, color, !waveformPlotParams.showSperateWaveform || waveform.length==1, waveformPlotParams.invert);
}
@ -274,7 +279,7 @@ public abstract class WaveformPlot<D extends PamDataUnit> implements DetectionPl
*/
public static void paintWaveform(double[][] waveform, int channelBitMap, GraphicsContext g, Rectangle clipRect,
int minbin, int maxbin, double yScaleInfo, Color color, boolean singlePlot, boolean invert) {
//System.out.println("Paint the waveform: " + clipRect.getWidth());
System.out.println("Paint the waveform: " + waveform[0].length);
g.setLineWidth(1);
// boolean singlePlot=!waveformPlotParams.showSperateWaveform;

View File

@ -7,7 +7,7 @@ import detectionPlotFX.layout.DetectionPlotDisplay;
import detectionPlotFX.plots.WaveformPlot;
/**
* Plot a click waveform.
* Plot for any RawDataHolder to show a waveform.
* @author Jamie Macaulay
*
*/