📄 ecgapplet.java
字号:
aiTable.getModel().setValueAt(new Double(a[1]), 0, 0);
aiTable.getModel().setValueAt(new Double(a[2]), 1, 0);
aiTable.getModel().setValueAt(new Double(a[3]), 2, 0);
aiTable.getModel().setValueAt(new Double(a[4]), 3, 0);
aiTable.getModel().setValueAt(new Double(a[5]), 4, 0);
biTable.getModel().setValueAt(new Double(b[1]), 0, 0);
biTable.getModel().setValueAt(new Double(b[2]), 1, 0);
biTable.getModel().setValueAt(new Double(b[3]), 2, 0);
biTable.getModel().setValueAt(new Double(b[4]), 3, 0);
biTable.getModel().setValueAt(new Double(b[5]), 4, 0);
/*
* ECG Animate parameters
*/
// convert into miliseconds interval
ecgAnimateInterval = (long)(1000/(sfecg));
}
private void resetECG(){
ecgGenerated = false;
clearParameters();
resetPlotArea();
resetButtons();
resetStatusBar();
}
/*
* Set the appropiate state of the controls for start the ECG Animation
*/
private void startECGAnimationSetControls(){
stopAnimateButton.setEnabled(true);
//exportButton.setEnabled(true);
clearButton.setEnabled(false);
generateButton.setEnabled(false);
paramButton.setEnabled(false);
zoomInButton.setEnabled(false);
zoomOutButton.setEnabled(false);
startAnimateButton.setEnabled(false);
}
/*
* Set the appropiate state of the controls for stop the ECG Animation
*/
private void stopECGAnimationSetControls(){
startAnimateButton.setEnabled(true);
clearButton.setEnabled(true);
generateButton.setEnabled(true);
paramButton.setEnabled(true);
zoomInButton.setEnabled(true);
zoomOutButton.setEnabled(true);
stopAnimateButton.setEnabled(false);
}
/*
* Enable the buttons after generating the ecg Data.
*/
private void enableButtons(){
startAnimateButton.setEnabled(true);
exportButton.setEnabled(true);
clearButton.setEnabled(true);
zoomInButton.setEnabled(true);
zoomOutButton.setEnabled(true);
}
private void resetButtons(){
stopAnimateButton.setEnabled(false);
startAnimateButton.setEnabled(false);
exportButton.setEnabled(false);
clearButton.setEnabled(false);
zoomInButton.setEnabled(false);
zoomOutButton.setEnabled(false);
}
private void resetPlotArea(){
lblMaxAmplitude.setText("1.4");
lblMinAmplitude.setText("-1.4");
readyToPlot = false;
plotScrollBarValue = 0;
}
private void resetStatusBar(){
txtStatus.setText(null);
txtStatus.append("**********************************************************\n");
txtStatus.append("Change desired ECG Parameters\n");
txtStatus.append("and then click 'Generate' button to generate and plot data\n");
txtStatus.append("**********************************************************");
}
private void clearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearButtonActionPerformed
desktopPane.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
paramDialog.hide();
// Delete the DataTable
clearDataTable();
resetECG();
ecgFrame.repaint();
desktopPane.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
}//GEN-LAST:event_clearButtonActionPerformed
private void stopAnimateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopAnimateButtonActionPerformed
paramDialog.hide();
/* Stop the Animate Plotting Task */
ecgAnimateTimer.cancel();
ecgAnimateFlg =false;
/* Enable automatic plot */
readyToPlot = true;
/* Repaint Plot Area */
ecgFrame.repaint();
/* Set the Animate Buttons */
stopECGAnimationSetControls();
}//GEN-LAST:event_stopAnimateButtonActionPerformed
private boolean checkParameters(){
txtStatus.append("Starting to check ECG parameters entered...\n");
boolean RetValue = true;
//ECG Sampling frequency flag
boolean sfecg_flg = true;
//Internal Sampling frequency flag
boolean sf_flg = true;
/* General Intergace parameters */
try {
N = Integer.valueOf(txtN.getText()).intValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'Approximate number of heart beats' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
sfecg = Integer.valueOf(txtSfecg.getText()).intValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'ECG Sampling Frequency' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
sfecg_flg = false;
RetValue = false;
}
if(sfecg_flg){
try {
sf = Integer.valueOf(txtSf.getText()).intValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'Internal Sampling Frequency' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
sf_flg = false;
RetValue = false;
}
}
// Check the Internal frequency respect to ECG frequency
if(sfecg_flg && sf_flg){
if(((int)Math.IEEEremainder(sf, sfecg)) != 0){
txtStatus.append("Internal sampling frequency must be an integer multiple of the\n");
txtStatus.append("ECG sampling frequency!, that currently is = " + sfecg + " Hertz\n");
RetValue = false;
}
}
try {
Anoise = Double.valueOf(txtAnoise.getText()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'Amplitude of additive uniform noise' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
hrmean = Double.valueOf(txtHrmean.getText()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'Heart rate mean' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
hrstd = Double.valueOf(txtHrstd.getText()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'Heart rate standard deviation' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
seed = Integer.valueOf(txtSeed.getText()).intValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'seed' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
amplitude = Double.valueOf(txtAmplitude.getText()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'Plot Area Amplitude' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
/* Spectral Characteristics parameters */
try {
flo = Double.valueOf(txtFlo.getText()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'Low frequency' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
fhi = Double.valueOf(txtFhi.getText()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'High frequency' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
flostd = Double.valueOf(txtFlostd.getText()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'Low frequency standard deviation' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
fhistd = Double.valueOf(txtFhistd.getText()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'High frequency standard deviation' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
lfhfratio = Double.valueOf(txtLfhfratio.getText()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'LF/HF ratio' entered, please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
/*
* ECG morphology: Order of extrema: [P Q R S T]
*/
// theta
try {
theta[1] = Double.valueOf(tiTable.getValueAt(0,0).toString()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'theta' value entered (position 1), please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
theta[2] = Double.valueOf(tiTable.getValueAt(1,0).toString()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'theta' value entered (position 2), please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
theta[3] = Double.valueOf(tiTable.getValueAt(2,0).toString()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'theta' value entered (position 3), please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
theta[4] = Double.valueOf(tiTable.getValueAt(3,0).toString()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'theta' value entered (position 4), please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
try {
theta[5] = Double.valueOf(tiTable.getValueAt(4,0).toString()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'theta' value entered (position 5), please correct it!\n");
txtStatus.append("Exception Error : " + e + "\n");
RetValue = false;
}
// a
try {
a[1] = Double.valueOf(aiTable.getValueAt(0,0).toString()).doubleValue();
} catch(java.lang.NumberFormatException e){
txtStatus.append("Incorrect 'a' value entered (position 1), please correct it!\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -