Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
268 lines (217 loc) · 7.05 KB

File metadata and controls

268 lines (217 loc) · 7.05 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
package dataPlotsFX;
import java.awt.Component;
import PamController.PAMStartupEnabler;
import PamController.PamController;
import PamguardMVC.PamObservable;
import PamguardMVC.PamObserverAdapter;
import PamguardMVC.PamRawDataBlock;
import dataPlotsFX.layout.TDDisplayFX;
import dataPlotsFX.scroller.TDAcousticScroller;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import pamViewFX.fxStyles.PamStylesManagerFX;
import userDisplay.UserDisplayComponent;
import userDisplay.UserDisplayControl;
/**
* TDControlFX acts as a wrapper class for a time base display programmed in JavaFX.
* @author Jamie Macaulay
*/
public class TDControlAWT extends TDControl implements UserDisplayComponent {
private TDControlAWT tdControlfx;
/**
* Checks for incoming data.
*/
private DataObserver dataObserver;
private String uniqueName;
private TDDisplayProviderFX tdDisplayProviderFX;
/**
* This panel acts as the interface between swing and JavaFX;
*/
TDFXPanel fxPanel;
private UserDisplayControl userDisplayControl;
public TDControlAWT(TDDisplayProviderFX tdDisplayProviderFX, UserDisplayControl userDisplayControl, String uniqueDisplayName){
super(uniqueDisplayName);
this.tdDisplayProviderFX = tdDisplayProviderFX;
this.userDisplayControl = userDisplayControl;
setUniqueName(uniqueDisplayName);
tdControlfx=this;
fxPanel = new TDFXPanel();
create();
}
/**
* Create the vital components for the display.
*/
private void create(){
dataObserver = new DataObserver();
}
@Override
public Component getComponent() {
// /**
// * 04/09/2018
// * There is a problem if a TDDisplay is present but then shut down by the user then the FX thread automatically
// * shuts diown if there are no other FX dialogs users. When a user opens up a new display then PG crashes. So have to add this line.
// */
// FXInitialiser.haveRun=false;
// FXInitialiser.initialise();
/**
* This gets called at startup from the AWT thread but launches an FX thread
* to create the actual display within a Swing frame (yep!).
* Need to send a message to PamController to hold off enabling the start
* button and other controls until this thread has completed.
*/
PAMStartupEnabler.addDisableCount();
Platform.runLater(new Runnable() {
@Override
public void run() {
Group root= new Group();
Scene scene = new Scene(root, Color.GRAY);
scene.getStylesheets().clear();
scene.getStylesheets().addAll(PamStylesManagerFX.getPamStylesManagerFX().getCurStyle().getGUICSS());
setTDDisplay(new TDDisplayFX(tdControlfx));
root.getChildren().add(getTDDisplay());
setSceneBinding(scene, getTDDisplay());
fxPanel.setScene(scene);
fxPanel.setMainDisplay(getTDDisplay());
TDAcousticScroller timeScroller = getTDDisplay().getTimeScroller();
if (timeScroller != null && isViewer()) {
timeScroller.coupleScroller(userDisplayControl.getUnitName());
}
PAMStartupEnabler.dropDisableCount();
}
});
return fxPanel;
}
/**
* This panel acts as an interface between the swing awt thread here and the JavaFX components in the tdgraph.
* @author Jamie Macaulay
*
*/
public class TDFXPanel extends JFXPanel {
private static final long serialVersionUID = 1L;
private TDDisplayFX tdMainDisplay;
public TDFXPanel() {
// TODO Auto-generated constructor stub
}
public void setMainDisplay(TDDisplayFX tdMainDisplay){
this.tdMainDisplay=tdMainDisplay;
}
public TDDisplayFX getMainDisplay(){
return tdMainDisplay;
}
public double getScrollableRange(){
double scrollableRange = tdMainDisplay.getTDParams().scrollableTimeRange;
long visibleRange = tdMainDisplay.getTDParams().visibleTimeRange;
return Math.max(scrollableRange, visibleRange);
}
public void scrollDisplayEnd(final long milliSeconds) {
if (tdMainDisplay!=null){
// System.out.println("TDFXPanel: scrollDisplayEnd(milliSeconds)" );
//must run on a different thread here
Platform.runLater(()->{
tdMainDisplay.scrollDisplayEnd(milliSeconds);
});
}
}
}
/**
* Get the main display.
* @return the main display.
*/
public TDDisplayFX getMainDisplay(){
return fxPanel.getMainDisplay();
}
/**
* Create the FX components of the graph.
* @param tdControl
* @param tdMainDisplay
* @return
*/
private static void setSceneBinding(Scene scene, final TDDisplayFX tdMainDisplay) {
//need to make sure that the scene resizes with the JFrame.
scene.widthProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) {
tdMainDisplay.setPrefWidth(observableValue.getValue().doubleValue());
}
});
scene.heightProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observableValue, Number number, Number number2) {
tdMainDisplay.setPrefHeight(observableValue.getValue().doubleValue());
}
});
}
/**
* The data observer monitors incoming data from data blocks.
* @author Doug Gillespie and Jamie Macaulay
*
*/
private class DataObserver extends PamObserverAdapter {
@Override
public long getRequiredDataHistory(PamObservable o, Object arg) {
if (PamRawDataBlock.class == o.getClass()) {
return 0;
}
// return 0;
//// //TODO- this should be the range, not the visible range.
// should really be the maximum of the two.
return (long) (fxPanel.getScrollableRange());
}
@Override
public String getObserverName() {
return "Time Display FX";
}
@Override
public void masterClockUpdate(long milliSeconds, long sampleNumber) {
// System.out.println("MASTER CLOCK UPDATE: " + PamCalendar.formatDateTime(milliSeconds));
fxPanel.scrollDisplayEnd(milliSeconds);
}
}
/**
* Get the data observer- monitors incoming real time data an updates graphs.
* @return data observer
*/
@Override
public DataObserver getDataObserver() {
return dataObserver;
}
@Override
public void openComponent() {
// TODO Auto-generated method stub
}
@Override
public void closeComponent() {
// TODO Auto-generated method stub
}
@Override
public void notifyModelChanged(int changeType) {
// System.out.println("TDControlAWT: Notify model changed: " + changeType );
//need to push onto fx thread.
if (!Platform.isFxApplicationThread()) {
Platform.runLater(()->{
if (tdMainDisplay!=null) tdMainDisplay.notifyModelChanged(changeType);
});
}
else {
if (tdMainDisplay!=null) tdMainDisplay.notifyModelChanged(changeType);
}
}
/**
* In real time mode check if PAMGUARD is paused.
* @return true if paused.
*/
@Override
public boolean isPaused(){
if (PamController.getInstance().getPamStatus()==PamController.PAM_RUNNING) return false;
else return true;
}
@Override
public String getFrameTitle() {
return "TD Display";
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.