Updates to FX datamap

Updating the FX datamap to make it more user friendly
This commit is contained in:
Jamie Mac 2024-03-14 17:04:29 +00:00
parent 112960924b
commit 6882935e9a
6 changed files with 110 additions and 72 deletions

View File

@ -6,8 +6,9 @@
<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/JavaSE-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"/>
</attributes>
</classpathentry>

View File

@ -1,8 +1,5 @@
package dataMap.layoutFX;
import java.awt.Dimension;
import PamController.PamController;
import PamController.PamControllerInterface;
import dataMap.DataMapControl;
import javafx.application.Platform;
@ -34,7 +31,7 @@ import userDisplayFX.UserDisplayNodeParams;
*/
public class DataMapPaneFX extends PamBorderPane implements UserDisplayNodeFX {
private static final double HIDE_PANE_WIDTH = 400;
private static final double HIDE_PANE_WIDTH = 500;
/**
* Reference to the data map control.
@ -46,9 +43,6 @@ public class DataMapPaneFX extends PamBorderPane implements UserDisplayNodeFX {
*/
public ScrollingDataPaneFX scrollingDataPanel;
private Dimension graphDimension;
private SummaryPaneFX summaryPane;
/**
@ -66,12 +60,10 @@ public class DataMapPaneFX extends PamBorderPane implements UserDisplayNodeFX {
*/
private ScalePaneFX scalePane;
private PamVBox settingsPane;
/**
* Axis which shows the current dates
* The settings pane.
*/
private PamDateAxis dateAxis;
private PamVBox settingsPane;
public DataMapPaneFX(DataMapControl dataMapControl){
this.dataMapControl=dataMapControl;
@ -127,12 +119,7 @@ public class DataMapPaneFX extends PamBorderPane implements UserDisplayNodeFX {
StackPane stackPane = new StackPane();
stackPane.getChildren().addAll(scrollingDataPanel, hidingSummaryPane, showButton);
dateAxis = new PamDateAxis();
dateAxis.setMinHeight(50);
dateAxis.prefWidthProperty().bind(scrollingDataPanel.widthProperty());
this.setTop(dateAxis);
this.setCenter(stackPane);
}
@ -159,7 +146,7 @@ public class DataMapPaneFX extends PamBorderPane implements UserDisplayNodeFX {
*/
private void setGraphDimensions() {
long totalLength = dataMapControl.getLastTime() - dataMapControl.getFirstTime();
graphDimension = new Dimension(2000, 100);
//graphDimension = new Dimension(2000, 100);
}
public void repaintAll() {
@ -276,8 +263,6 @@ public class DataMapPaneFX extends PamBorderPane implements UserDisplayNodeFX {
public void selectedDataTime(Long timeStart, Long timeEnd) {
System.out.println("SELECTED DATA TIME: " + timeStart + " " + timeEnd);
summaryPane.setSelectedDataTime(timeStart, timeEnd);
dateAxis.setUpperBound(timeEnd);
dateAxis.setLowerBound(timeStart);
}

View File

@ -386,7 +386,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));
}

View File

@ -9,12 +9,15 @@ import PamUtils.PamCalendar;
import binaryFileStorage.BinaryStore;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.util.StringConverter;
import pamViewFX.PamGuiManagerFX;
import pamViewFX.fxNodes.PamBorderPane;
import pamViewFX.fxNodes.PamGridPane;
@ -22,6 +25,7 @@ import pamViewFX.fxNodes.PamHBox;
import pamViewFX.fxNodes.PamVBox;
import pamViewFX.fxNodes.pamDialogFX.PamDialogFX;
import pamViewFX.fxNodes.sliders.PamSlider;
import pamViewFX.fxNodes.utilityPanes.PamToggleSwitch;
/**
* Allows uses to change the horizontal and vertical scales on the data map.
@ -59,14 +63,17 @@ public class ScalePaneFX extends PamBorderPane {
/**
* Check box for log vertical scale.
*/
private CheckBox logScaleBox;
private PamToggleSwitch logScaleBox;
/**
* The chosen time values.
*/
private double[] timeScaleChoices = DataMapParameters.hScaleChoices;
private Pane datagramPane;
/**
* Combo box holding options to channge the datargam bin size
*/
private ComboBox<String> datagramBox;
/**
* Holds a list of times for the datagram bin size.
@ -76,7 +83,14 @@ public class ScalePaneFX extends PamBorderPane {
/**
* Holds everything.
*/
private PamVBox holder;
private PamVBox holder;
/**
* Grid pane with settings for the data scales
*/
private PamGridPane scaleSettingsPane;
private Label dataGramLabel;
@ -84,9 +98,16 @@ public class ScalePaneFX extends PamBorderPane {
this.dataMapControl = dataMapControl;
this.dataMapPane = dataMapPane;
// //create the holder pane.
// PamVBox vBoxHolder=new PamVBox();
// vBoxHolder.setSpacing(5);
// Label title=new Label("Scales");
// PamGuiManagerFX.titleFont2style(title);
// vBoxHolder.getChildren().addAll(title, controlPane);
holder=new PamVBox();
holder.setSpacing(20);
holder.getChildren().add(createScalePane());
holder.getChildren().add(scaleSettingsPane = createScalePane());
this.setCenter(holder);
@ -103,31 +124,28 @@ public class ScalePaneFX extends PamBorderPane {
public void checkDataGramPane(){
if (BinaryStore.findBinaryStoreControl()!=null){
DatagramManager dataGramManager=BinaryStore.findBinaryStoreControl().getDatagramManager();
if (dataGramManager!=null && datagramPane==null) {
datagramPane=createDatagramPane(dataGramManager);
holder.getChildren().add(datagramPane);
if (dataGramManager!=null && datagramBox==null) {
datagramBox=createDatagramPane(dataGramManager);
scaleSettingsPane.add(dataGramLabel= new Label("Datagram bin size"), 0, 2);
scaleSettingsPane.add(dataGramComboBox, 1, 2);
}
}
else {
holder.getChildren().remove(datagramPane);
datagramPane=null;
scaleSettingsPane.getChildren().remove(dataGramLabel);
scaleSettingsPane.getChildren().remove(dataGramComboBox);
datagramBox=null;
}
}
/**
* Create the pane to reset the datagram pane bin size.
* Create the a datagram combo box to change the size of the datagram
* @param dataGramManager - the datagram manager for the current biinary store.
* @return
* @return a combo box with datagram bin sizes.
*/
private Pane createDatagramPane(DatagramManager dataGramManager){
private ComboBox<String> createDatagramPane(DatagramManager dataGramManager){
PamGridPane dataGramOptions=new PamGridPane();
dataGramOptions.setHgap(5);
dataGramOptions.setVgap(5);
dataGramOptions.add(new Label("Datagram Bin Size"),0,0);
dataGramComboBox=new ComboBox<String>(createDurationList(dataGramManager));
dataGramComboBox.getSelectionModel().select(durationToString(dataGramManager.getDatagramSettings().datagramSeconds*1000L));
@ -147,19 +165,7 @@ public class ScalePaneFX extends PamBorderPane {
}
});
dataGramOptions.add(dataGramComboBox,1,0);
//create the holder pane.
PamVBox vBoxHolder=new PamVBox();
vBoxHolder.setSpacing(5);
Label title=new Label("Datagram");
// title.setFont(PamGuiManagerFX.titleFontSize2);
PamGuiManagerFX.titleFont2style(title);
vBoxHolder.getChildren().addAll(title, dataGramOptions);
return vBoxHolder;
return dataGramComboBox;
}
@ -184,19 +190,24 @@ public class ScalePaneFX extends PamBorderPane {
}
private Node createScalePane() {
private PamGridPane createScalePane() {
PamGridPane controlPane=new PamGridPane();
controlPane.setHgap(5);
controlPane.setVgap(5);
//create time scale controls
controlPane.add(new Label("Time"),0,1);
controlPane.add(new Label("Time window"),0,1);
//create time slider
timeSlider=new Slider(0, timeScaleChoices.length-1, 1);
timeSlider.setShowTickLabels(true);
timeSlider.setShowTickMarks(true);
timeSlider.setMajorTickUnit(1);
timeSlider.setLabelFormatter(new ScaleStringConverter());
// PamGridPane.setHalignment(timeSlider, Pos.BOTTOM_CENTER);
controlPane.add(timeSlider,1,1);
//add listener to time slider to change datamap.
@ -205,10 +216,11 @@ public class ScalePaneFX extends PamBorderPane {
dataMapPane.scaleChanged();
});
controlPane.add(timeScaleLabel=new Label(""),2,1);
controlPane.add(timeScaleLabel=new Label(""),3,1);
//create vertical scale controls
controlPane.add(new Label("Data Counts"),0,0);
controlPane.add(new Label("Data counts"),0,0);
scaleBox=new ComboBox<String> ();
scaleBox.getItems().add("No Scaling");
@ -217,28 +229,37 @@ public class ScalePaneFX extends PamBorderPane {
scaleBox.getItems().add("per Hour");
scaleBox.getItems().add("per Day");
controlPane.add(scaleBox,1,0);
scaleBox.setPrefWidth(200);
scaleBox.valueProperty().addListener((ov, oldVal, newVal)->{
dataMapPane.scaleChanged();
});
logScaleBox=new CheckBox("Log Scale");
logScaleBox.setOnAction((action)->{
logScaleBox=new PamToggleSwitch("Log Scale");
logScaleBox.selectedProperty().addListener((obsVal, oldVal, newVal)->{
dataMapPane.scaleChanged();
});;
controlPane.add(logScaleBox,2,0);
});
//create the holder pane.
PamVBox vBoxHolder=new PamVBox();
vBoxHolder.setSpacing(5);
Label title=new Label("Scales");
PamGuiManagerFX.titleFont2style(title);
vBoxHolder.getChildren().addAll(title, controlPane);
controlPane.add(logScaleBox,3,0);
return controlPane;
}
class ScaleStringConverter extends StringConverter<Double> {
@Override
public String toString(Double object) {
return String.valueOf(timeScaleChoices[object.intValue()]);
}
@Override
public Double fromString(String string) {
return Double.valueOf(string);
}
return vBoxHolder;
}
/**

View File

@ -8,6 +8,7 @@ import PamUtils.PamCalendar;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.geometry.Insets;
import javafx.geometry.Side;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollBar;
@ -23,6 +24,7 @@ import pamViewFX.fxNodes.PamButton;
import pamViewFX.fxNodes.PamColorsFX;
import pamViewFX.fxNodes.PamScrollPane;
import pamViewFX.fxNodes.PamVBox;
import pamViewFX.fxNodes.pamAxis.PamDateAxis;
import pamViewFX.fxNodes.sashPane.SashPane;
public class ScrollingDataPaneFX extends PamBorderPane {
@ -99,8 +101,10 @@ public class ScrollingDataPaneFX extends PamBorderPane {
private PamBorderPane holder;
/**
* Axis which shows the current dates
*/
private PamDateAxis dateAxis;
/**
* Constructor for the ScrollingDataPaneFX
@ -162,6 +166,18 @@ public class ScrollingDataPaneFX extends PamBorderPane {
notifyScrollChange(300);
});
dateAxis = new PamDateAxis();
dateAxis.setAutoRanging(false);
dateAxis.setLabel("Time");
dateAxis.setSide(Side.TOP);
dateAxis.setAnimated(false);
dateAxis.setMinHeight(50);
// dateAxis.prefWidthProperty().bind(scrollingDataPanel.widthProperty());
// dateAxis.setStyle("-fx-background-color: ORANGE;");
dateAxis.setForceZeroInRange(false);
holder.setTop(dateAxis);
return holder;
}
@ -204,6 +220,8 @@ public class ScrollingDataPaneFX extends PamBorderPane {
notifyScrollChange();
});
timeScrollBar.setPrefHeight(20);
holder.setCenter(timeScrollBar);
holder.setBottom(timeLabelPane);
@ -236,10 +254,13 @@ public class ScrollingDataPaneFX extends PamBorderPane {
dataStreamPanels.get(i).scrollChanged();
}
settingsStrip.scrollChanged();
updateDateAxis();
}
Timeline timeline;
long lastTime = 0;
/**
* Notify all panels and the settings strip that the scroll bar moved - but have a timer to wait to not call too often.
*/
@ -259,9 +280,19 @@ public class ScrollingDataPaneFX extends PamBorderPane {
}
lastTime=currentTime;
updateDateAxis();
}
private void updateDateAxis() {
calcStartEndMillis();
dateAxis.setUpperBound(screenEndMillis);
dateAxis.setLowerBound(screenStartMillis);
double[] ticks = dateAxis.recalculateTicks();
System.out.println("Ticks: " + (ticks[3]/1000/3600) + "hours");
dateAxis.setTickUnit(ticks[3]);
}
/**
* Create the data graphs to go into the pane.
@ -282,7 +313,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).setPrefHeight(DATASTREAMPANE_HEIGHT);
dataStreamPanels.get(i).setMinHeight(DATASTREAMPANE_HEIGHT);
//now add to a split pane.
//SplitPane.setResizableWithParent(aStreamPanel, true);
dataPanePanes.getChildren().add(aStreamPanel);

View File

@ -217,7 +217,7 @@ public class PamDateAxis extends ValueAxis<Long> {
};
}
private double[] recalculateTicks()
public double[] recalculateTicks()
{
final Side side = getSide();
final boolean vertical = Side.LEFT.equals(side) || Side.RIGHT.equals(side);