Working on datamap for FX mode

This commit is contained in:
Jamie Mac 2024-07-26 16:39:41 +01:00
parent 3d7058e671
commit 7be2e4eeed
6 changed files with 138 additions and 103 deletions

View File

@ -6,7 +6,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Amazon Coretto 21">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Amazon Corretto 21 [21.0.2]">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>

View File

@ -851,7 +851,7 @@ public class PamController implements PamControllerInterface, PamSettings {
String help = null;
int ans = WarnOnce.showWarning(title, msg, WarnOnce.WARNING_MESSAGE, help, e);
System.err.println("Exception while loading " + moduleName);
this.removeControlledUnt(unitBeingLoaded);
//this.removeControlledUnt(unitBeingLoaded);
this.clearLoadedUnit();
;
}

View File

@ -27,6 +27,7 @@ public class DataMapGUIFX extends PamControlledGUIFX implements DataMapControlGU
* The data map displays to add.
*/
public ArrayList<UserDisplayNodeFX> getDisplays(){
try {
if (dataMapDisplays==null){
dataMapPaneFX = new DataMapPaneFX(dataMapControl);
dataMapDisplays=new ArrayList<UserDisplayNodeFX>();
@ -34,6 +35,11 @@ public class DataMapGUIFX extends PamControlledGUIFX implements DataMapControlGU
dataMapDisplays.add(dataMapPaneFX);
}
return dataMapDisplays;
}
catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override

View File

@ -120,7 +120,7 @@ public class ScrollingDataPaneFX extends PamBorderPane {
* @return the scrolling pane.
*/
private Node createScrollingDataPane() {
holder=new PamBorderPane();
//create the main scroll pane
@ -145,8 +145,6 @@ public class ScrollingDataPaneFX extends PamBorderPane {
// holder.setTop(buttonTest);
// //////////
holder.setCenter(mainScrollPane);
holder.setTop(createScrollBar());
// PamButton test = new PamButton("Test");
// test.setOnAction((action)->{
@ -155,7 +153,6 @@ public class ScrollingDataPaneFX extends PamBorderPane {
// holder.setLeft(test);
setupScrollBar();
//finally make sure the scroll bar recalculates stuff when holder changes size
holder.widthProperty().addListener((change)->{
@ -172,8 +169,17 @@ public class ScrollingDataPaneFX extends PamBorderPane {
// dateAxis.prefWidthProperty().bind(scrollingDataPanel.widthProperty());
// dateAxis.setStyle("-fx-background-color: ORANGE;");
dateAxis.setForceZeroInRange(false);
holder.setTop(dateAxis);
PamVBox vBox = new PamVBox();
vBox.getChildren().add(createScrollBar());
vBox.getChildren().add(dateAxis);
holder.setTop(vBox);
holder.setCenter(mainScrollPane);
setupScrollBar();
return holder;
}
@ -211,14 +217,16 @@ public class ScrollingDataPaneFX extends PamBorderPane {
//create the scroll bar and listeners.
timeScrollBar=new ScrollBarPane();
timeScrollBar.addValueListener((obs_val, old_val, new_val)->{
System.out.println("Scroll bar seconds: " + timeScrollBar.getCurrentValue() + " vis amount: " + timeScrollBar.visibleAmountProperty().get());
calcStartEndMillis();
updateScrollBarText();
notifyScrollChange();
});
timeScrollBar.setPrefHeight(20);
timeScrollBar.getTextBox().setPrefColumnCount(15);
timeScrollBar.getTextBox().setPrefWidth(100);
timeScrollBar.setPrefHeight(50);
holder.setCenter(timeScrollBar);
holder.setBottom(timeLabelPane);
@ -231,8 +239,10 @@ public class ScrollingDataPaneFX extends PamBorderPane {
*/
private void calcStartEndMillis(){
screenStartMillis = (long) (dataMapControl.getFirstTime() +
timeScrollBar.getCurrentValue() * 1000L);
screenEndMillis = screenStartMillis + (long) (screenSeconds * 1000);
timeScrollBar.getCurrentValue());
screenEndMillis = (long) (screenStartMillis + timeScrollBar.getVisibleAmount());
getPixelsPerHour();
}
/**
@ -354,29 +364,33 @@ public class ScrollingDataPaneFX extends PamBorderPane {
long dataStart = dataMapControl.getFirstTime();
long dataEnd = dataMapControl.getLastTime();
double dataSeconds = ((dataEnd-dataStart)/1000) + 1;
double pixsPerHour = getPixelsPerHour();
double pixsPerSecond = pixsPerHour / 3600;
double screenWidth = getPlotWidth();
screenSeconds = screenWidth / pixsPerSecond;
if (dataStart == Long.MAX_VALUE || screenSeconds >= dataSeconds) {
//System.out.println("dataSeconds: "+dataSeconds+ " pixsPerHour: " +pixsPerHour+" screenWidth: "+screenWidth+" screenSeconds "+screenSeconds+ " holder width: "+holder.getWidth());
/*
* hide the scroll bar and stretch the display to fit the window
*/
timeScrollBar.setVisible(false);
screenStartMillis = dataStart;
screenEndMillis = dataEnd;
}
else {
//System.out.println("dataSeconds: "+dataSeconds+ " pixsPerHour: " +pixsPerHour+" screenWidth: "+screenWidth+" screenSeconds "+screenSeconds+" holder width: "+holder.getWidth());
screenSeconds = screenWidth / Math.min(600. / 3600, pixsPerSecond);
// if (dataStart == Long.MAX_VALUE || screenSeconds >= dataSeconds) {
// System.out.println("dataSeconds1: "+dataSeconds+ " pixsPerHour: " +pixsPerHour+" screenWidth: "+screenWidth+" screenSeconds "+screenSeconds+ " holder width: "+holder.getWidth());
// /*
// * hide the scroll bar and stretch the display to fit the window
// */
// timeScrollBar.setVisible(true);
// screenStartMillis = dataStart;
// screenEndMillis = dataEnd;
// }
// else {
System.out.println("dataSeconds2: "+dataSeconds+ " pixsPerHour: " +pixsPerHour+" screenWidth: "+screenWidth+" screenSeconds "+screenSeconds+" holder width: "+holder.getWidth());
timeScrollBar.setVisible(true);
timeScrollBar.setMinVal(0);
timeScrollBar.setMaxVal(Math.ceil(dataSeconds));
timeScrollBar.setMaxVal(Math.max(dataSeconds, screenSeconds)*1000L);
timeScrollBar.setBlockIncrement(Math.max(1, screenSeconds * 4/5));
// timeScrollBar.setUnitIncrement(Math.max(1, screenSeconds / 20));
timeScrollBar.setVisibleAmount(screenSeconds);
timeScrollBar.setVisibleAmount(screenSeconds*1000L);
timeScrollBar.setCurrentValue(currentPos);
}
// }
}
@ -416,7 +430,11 @@ public class ScrollingDataPaneFX extends PamBorderPane {
public double getPixelsPerHour() {
return dataMapControl.dataMapParameters.getPixeslPerHour();
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

@ -33,8 +33,9 @@ public class PamDateAxis extends ValueAxis<Long> {
/** We use these for auto ranging to pick a user friendly tick unit. (must be increasingly bigger)*/
private static final double[] TICK_UNIT_DEFAULTS = {
3600000, // 1 hour
86400000, // 1 day
172800000, // 2 das
172800000, // 2 days
259200000, // 3 days
345600000, // 4 days
432000000, // 5 days
@ -63,8 +64,9 @@ public class PamDateAxis extends ValueAxis<Long> {
/** These are matching date formatter strings */
private static final String[] TICK_UNIT_FORMATTER_DEFAULTS = {
"MM/dd/yy", // 1 day
"MM/dd/yy", // 2 das
"HH:mm:SS", // 1 hour
"HH:mm:SS", // 1 day
"MM/dd/yy", // 2 days
"MM/dd/yy", // 3 days
"MM/dd/yy", // 4 days
"MM/dd/yy", // 5 days

View File

@ -258,78 +258,6 @@ public class ScrollBarPane extends PamBorderPane {
return canvas;
}
/**
* Create the text field that allows to manually chage the visible amount amount property.
*/
private void createTextField(){
//create the textbox
textBox= new TextField();
textBox.layoutXProperty().bind(rectangle.layoutXProperty().add(rectangle.widthProperty().divide(2)).subtract(textBox.widthProperty().divide(2)));
textBox.layoutYProperty().bind(rectangle.heightProperty().divide(2).subtract(textBox.heightProperty().divide(2)));
textBox.setOnAction((action)-> {
double millis=this.getTextBoxValue(textBox.getText());
if (millis<=0 || millis>(this.maxValueProperty.get()-this.minValueProperty.get())){
textBoxErrorFlash(textBox);
this.setTextBoxValue(visibleAmountProperty.get());
}
else{
visibleAmountProperty.setValue(millis);
}
});
ft = new FadeTransition(Duration.millis(3000), textBox);
textBox.getStyleClass().add("text_field_trans");
textBox.setPrefWidth(70);
//the rectangle itself.
textBox.setOnMousePressed((event)->{
rectanglePressed(event);
});
textBox.setOnMouseReleased((event)->{
rectangleReleased(event);
});
//text box needs to to drag the rectangle so there isn't a drag 'dead space'
textBox.setOnMouseDragged((event)->{
rectangleDragged(event);
});
textBox.setOnMouseEntered((event)->{
setTextBoxVisible(true);
});
textBox.setOnMouseExited((event)->{
//only set invisible if not in rectangle. This is for fast mouse movements were the exist of the rectangle may not be called
if (!rectangle.contains(rectangle.sceneToLocal(event.getSceneX(), event.getSceneY()))){
setTextBoxVisible(false);
}
});
setTextBoxVisible(false);
//show and hide text box so keeps the scroll bar beautiful
rectangle.setOnMouseEntered((event)->{
setTextBoxVisible(true);
});
rectangle.setOnMouseExited((event)->{
setTextBoxVisible(false);
});
//make sure the text box chnages with visible amount.,
this.visibleAmountProperty.addListener((obsVal, newVal, oldVal)->{
setTextBoxValue(visibleAmountProperty.get());
});
setTextBoxValue(visibleAmountProperty.get());
}
/**
* Create the rectangle which can be dragged to change time but also dragged to change the width of time
* shown.
@ -545,6 +473,87 @@ public class ScrollBarPane extends PamBorderPane {
}
}
/**
* Create the text field that allows to manually chage the visible amount amount property.
*/
private void createTextField(){
//create the textbox
textBox= new TextField();
textBox.layoutXProperty().bind(rectangle.layoutXProperty().add(rectangle.widthProperty().divide(2)).subtract(textBox.widthProperty().divide(2)));
textBox.layoutYProperty().bind(rectangle.heightProperty().divide(2).subtract(textBox.heightProperty().divide(2)));
textBox.setOnAction((action)-> {
double millis=this.getTextBoxValue(textBox.getText());
if (millis<=0 || millis>(this.maxValueProperty.get()-this.minValueProperty.get())){
textBoxErrorFlash(textBox);
this.setTextBoxValue(visibleAmountProperty.get());
}
else{
visibleAmountProperty.setValue(millis);
}
});
ft = new FadeTransition(Duration.millis(3000), textBox);
textBox.getStyleClass().add("text_field_trans");
textBox.setPrefWidth(70);
//the rectangle itself.
textBox.setOnMousePressed((event)->{
rectanglePressed(event);
});
textBox.setOnMouseReleased((event)->{
rectangleReleased(event);
});
//text box needs to to drag the rectangle so there isn't a drag 'dead space'
textBox.setOnMouseDragged((event)->{
rectangleDragged(event);
});
textBox.setOnMouseEntered((event)->{
setTextBoxVisible(true);
});
textBox.setOnMouseExited((event)->{
//only set invisible if not in rectangle. This is for fast mouse movements were the exist of the rectangle may not be called
if (!rectangle.contains(rectangle.sceneToLocal(event.getSceneX(), event.getSceneY()))){
setTextBoxVisible(false);
}
});
setTextBoxVisible(false);
//show and hide text box so keeps the scroll bar beautiful
rectangle.setOnMouseEntered((event)->{
setTextBoxVisible(true);
});
rectangle.setOnMouseExited((event)->{
setTextBoxVisible(false);
});
//make sure the text box chnages with visible amount.,
this.visibleAmountProperty.addListener((obsVal, newVal, oldVal)->{
setTextBoxValue(visibleAmountProperty.get());
});
setTextBoxValue(visibleAmountProperty.get());
}
/**
* Get the text box that shows the visible amount
* @return - the text field
*/
public TextField getTextBox() {
return textBox;
}
/**
*