📄 ecgapplet.java
字号:
zoomOutButton.setEnabled(false);
zoomOutButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
zoomOutButtonActionPerformed(evt);
}
});
zoomOutButton.setBounds(7, 17, 90, 20);
zommDesktopPane.add(zoomOutButton, javax.swing.JLayeredPane.DEFAULT_LAYER);
zommDesktopPane.setBounds(7, 447, 220, 45);
desktopPane.add(zommDesktopPane, javax.swing.JLayeredPane.DEFAULT_LAYER);
ecgWindow.getContentPane().add(desktopPane, java.awt.BorderLayout.CENTER);
getContentPane().add(ecgWindow, java.awt.BorderLayout.CENTER);
}//GEN-END:initComponents
private void paramHelpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_paramHelpButtonActionPerformed
helpEditorPane.setContentType("text/html");
helpEditorPane.setText( "<html> <body>" +
"<font size='3'>"+
"<table width='400' border='0' align='center' cellpadding='0' cellspacing='5'>" +
" <tr> " +
" <td height='50' align='left' valign='middle'><strong><font color='#FF0000' size='4' face='Arial, Helvetica, sans-serif'>ECGSYN " +
" PARAMETER DOCUMENTATION</font></strong></td>" +
" </tr>" +
" <tr> " +
" <td height='30' align='left' valign='top'><strong><font color='#0000FF'>GENERAL " +
" INTERFACE</font></strong></td> "+
" </tr>" +
" <tr> " +
" <td align='left' valign='top'> <table width='100%' border='0' cellspacing='5' cellpadding='5'>" +
" <tr> " +
" <td width='60'> </td>" +
" <td><strong>Approximate number of heart beats:</strong><br>" +
" fjaklsdfjasldjasdjfgfagsdgfasdgfywerwaegsdgfwefasjkgiawegasfkgiawefaklsdgfaiwegfklasegfaiwegaklgawiegfafwgegfauiwegfkasdgfiawegfawiegfasdklgfialweugfasefiuawgefilugfawileugfawilegfaweilgfawilegfasiduflskdgfailwuegfawileusdjklgfawilesdfk</td>" +
" </tr>" +
" <tr>" +
" <td width='60'> </td>" +
" <td><strong><dt>ECG Sampling Frequency</dt></strong>" +
" <dd>definition</dd></td>" +
" </tr>" +
" <tr>" +
" <td width='60'> </td>" +
" <td><strong><dt>Internal Sampling Frequency</dt></strong>" +
" <dd>definition</dd></td>" +
" </tr>" +
" <tr>" +
" <td width='60'> </td>" +
" <td><strong><dt>Amplitude of additive uniform noise</dt></strong>" +
" <dd>definition</dd></td>" +
" </tr>" +
" <tr>" +
" <td width='60'> </td>" +
" <td><strong><dt>Heart rate mean</dt></strong>" +
" <dd>definition</dd></td>" +
" </tr>" +
" <tr>" +
" <td width='60'> </td>" +
" <td><strong><dt>Heart rate standard deviation</dt></strong>" +
" <dd>definition</dd></td>" +
" </tr>" +
" <tr>" +
" <td width='60'> </td>" +
" <td><strong><dt>Seed</dt></strong>" +
" <dd>definition</dd></td>" +
" </tr>" +
" </table></td>" +
" </tr>" +
"</table>" +
"</font>" +
"</body> </html>");
helpDialog.show();
}//GEN-LAST:event_paramHelpButtonActionPerformed
private void alertButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_alertButtonActionPerformed
alert.hide();
}//GEN-LAST:event_alertButtonActionPerformed
private void zoomInButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoomInButtonActionPerformed
desktopPane.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
paramDialog.hide();
plotZoom = plotZoom / plotZoomInc;
ecgFrame.repaint();
desktopPane.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
}//GEN-LAST:event_zoomInButtonActionPerformed
private void zoomOutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoomOutButtonActionPerformed
desktopPane.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
paramDialog.hide();
plotZoom = plotZoom * plotZoomInc;
ecgFrame.repaint();
desktopPane.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
}//GEN-LAST:event_zoomOutButtonActionPerformed
private void startAnimateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startAnimateButtonActionPerformed
paramDialog.hide();
// Disabling automatic plot
readyToPlot = false;
ecgFrame.repaint();
/*
* Initialize ECG Animate variables
*/
ecgAnimateFlg = true;
ecgAnimateNumRows = tableValuesModel.getRowCount();
ecgAnimateCurRow = 0;
ecgAnimatePanelWidth = ecgFrame.getBounds().width;
ecgAnimateInitialZero = 0;
ecgAnimateLastPoint.setLocation(0, posOriginY - (int)(Double.valueOf(tableValues.getValueAt(0, 1).toString()).doubleValue() * frameAmplitude / amplitude));
/* Create Timer */
ecgAnimateTimer = new Timer();
/* Schedule the Animate Plotting Task */
ecgAnimateTimer.scheduleAtFixedRate(new ECGAnimate(), 0, ecgAnimateInterval);
/* Set the Animate Buttons */
startECGAnimationSetControls();
}//GEN-LAST:event_startAnimateButtonActionPerformed
private void saveParamDialogButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveParamDialogButtonActionPerformed
saveParametersValues();
paramDialog.hide();
}//GEN-LAST:event_saveParamDialogButtonActionPerformed
private void resetParamDialogButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetParamDialogButtonActionPerformed
clearParameters();
}//GEN-LAST:event_resetParamDialogButtonActionPerformed
private void closeParamDialogButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeParamDialogButtonActionPerformed
paramDialog.hide();
}//GEN-LAST:event_closeParamDialogButtonActionPerformed
private void paramButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_paramButtonActionPerformed
paramDialog.show();
}//GEN-LAST:event_paramButtonActionPerformed
private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed
paramDialog.hide();
exportDialog.setBounds(80, 80,500,500);
exportDialog.show();
}//GEN-LAST:event_exportButtonActionPerformed
private void saveParametersValues(){
txtStatus.setText(null);
checkParameters();
}
private void clearDataTable(){
// Delete the DataTable
tableValuesModel.setRowCount(0);
}
/**
* Draw a string in the center of a given box.
* Reduce the font size if necessary to fit. Can
* fix the type size to a value passed as an argument.
* The position of the string within the box passed
* as LEFT, CENTER or RIGHT constant value.
* Don't draw the strings if they do not fit.
*/
private int drawText( Graphics g, String msg, int xBox, int yBox, int boxWidth, int boxHeight,
int fixedTypeSizeValue, int position){
boolean fixedTypeSize = false;
int typeSize = 24;
// Fixed to a particular type size.
if(fixedTypeSizeValue > 0) {
fixedTypeSize = true;
typeSize = fixedTypeSizeValue;
}
int typeSizeMin = 8;
int x=xBox,y=yBox;
do {
// Create the font and pass it to the Graphics context
g.setFont(new Font("Monospaced",Font.PLAIN,typeSize));
// Get measures needed to center the message
FontMetrics fm = g.getFontMetrics();
// How many pixels wide is the string
int msgWidth = fm.stringWidth(msg);
// How tall is the text?
int msgHeight = fm.getHeight();
// See if the text will fit in the allotted
// vertical limits
if( msgHeight < boxHeight && msgWidth < boxWidth) {
y = yBox + boxHeight/2 +(msgHeight/2);
if( position == CENTER)
x = xBox + boxWidth/2 - (msgWidth/2);
else if(position == RIGHT)
x = xBox + boxWidth - msgWidth;
else
x = xBox;
break;
}
// If fixedTypeSize and wouldn't fit, don't draw.
if( fixedTypeSize) return -1;
// Try smaller type
typeSize -= 2;
} while (typeSize >= typeSizeMin);
// Don't display the numbers if they did not fit
if( typeSize < typeSizeMin) return -1;
// Otherwise, draw and return positive signal.
g.drawString(msg,x,y);
// ecgFrame.revalidate();
// ecgFrame.repaint();
return typeSize;
}
/*
* ReInit the Button Parameters' values
*/
private void clearParameters(){
/* General Intergace parameters */
txtN.setText("256");
N = 256;
txtSfecg.setText("256");
sfecg = 256;
txtSf.setText("512");
sf = 512;
txtAnoise.setText("0.1");
Anoise = 0.1;
txtHrmean.setText("60.0");
hrmean = 60.0;
txtHrstd.setText("1.0");
hrstd = 1.0;
txtSeed.setText("1");
seed = 1;
txtAmplitude.setText("1.4");
amplitude = 1.4;
/* Spectral Characteristics parameters */
txtFlo.setText("0.1");
flo = 0.1;
txtFhi.setText("0.25");
fhi = 0.25;
txtFlostd.setText("0.01");
flostd = 0.01;
txtFhistd.setText("0.01");
fhistd = 0.01;
txtLfhfratio.setText("0.5");
lfhfratio = 0.5;
/*
* ECG morphology: Order of extrema: [P Q R S T]
*/
theta[1]= -60.0;
theta[2]= -15.0;
theta[3]= 0.0;
theta[4]= 15.0;
theta[5]= 90.0;
a[1]= 1.2;
a[2]= -5.0;
a[3]= 30.0;
a[4]= -7.5;
a[5]= 0.75;
b[1]= 0.25;
b[2]= 0.1;
b[3]= 0.1;
b[4]= 0.1;
b[5]= 0.4;
//data tables
tiTable.getModel().setValueAt(new Double(theta[1]), 0, 0);
tiTable.getModel().setValueAt(new Double(theta[2]), 1, 0);
tiTable.getModel().setValueAt(new Double(theta[3]), 2, 0);
tiTable.getModel().setValueAt(new Double(theta[4]), 3, 0);
tiTable.getModel().setValueAt(new Double(theta[5]), 4, 0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -