" "
" , " (1-)
ר 1
: .. (_____________)
: 82
: .. (_____________)
2012
3
1) .
2) , , .
3) .
4) 3- .
5) 3- .
6) , , .
. . (), GPS , . , , , .
. , , .., .
:
1. . . , .
2. ( - ). , . , , , , .
3. . ( , - ). , . . , .
- . .
- , .
|
|
, . , , , .
, . , .
, , , , , , .
: (-) (-). -, - .
:
.
.
.
, .
, .
.
. ( ) .
, , , N s1 (k) s2 (k). :
N. , , . , , , , .. (, ). 1/ N ( ).
. s (k), :
|
|
. (), , , ( ), , , - . , .
́ ́ ( ) , , . .
: [1][2]. , . - - . - .
, , , , . .
, , . , , , ́, .
, ́ . , , , , . , , , .
, , .
( , ) . . , ( - ) . . . ():
- ( .. )
|
|
-
-
-
-
- (, , )
( , ) . , , , . .
, .
, , :
(EKF, Extended Kalman filter). .
Unscented Kalman filter (UKF). , . "" unscented-.
Ensemble Kalman filter (EnKF). .
, .
"" , "" .
:
-
-
- :
-
- ( )
-
Build.java
package core;
import java.util.ArrayList;
/**
*
* @author wae
*/
public class Build {
private ArrayList<Double> xPoints;
private ArrayList<Double> yPoints;
private ArrayList<Double> xFilter;
private ArrayList<Double> yFilter;
private double xDiff;
private double yDiff;
private double div;
private double minX;
private double maxX;
private double minY;
private double maxY;
public Build(ArrayList<Double> xPoints, ArrayList<Double> yPoints) throws NullPointerException {
this.xPoints = xPoints;
this.yPoints = yPoints;
minX = min(xPoints);
maxX = max(xPoints);
minY = min(yPoints);
maxY = max(yPoints);
xDiff = Math.abs(maxX - minX);
yDiff = Math.abs(maxY - minY);
div = Math.abs(maxY / yDiff); //??
}
private double min(ArrayList<Double> array) throws NullPointerException {
double min = array.get(0);
for (int i = 0; i < array.size(); i++) {
if (min > array.get(i)) {
min = array.get(i);
}
}
return min;
}
public double getMaxX() {
return maxX;
}
public double getMaxY() {
return maxY;
}
public double getMinX() {
return minX;
}
public double getMinY() {
return minY;
}
private double max(ArrayList<Double> array) {
double max = array.get(0);
for (int i = 0; i < array.size(); i++) {
if (max < array.get(i)) {
max = array.get(i);
}
}
return max;
|
|
}
public ArrayList<Double> getxPoints() {
return xPoints;
}
public ArrayList<Double> getyPoints() {
return yPoints;
}
public double getxDiff() {
return xDiff;
}
public double getyDiff() {
return yDiff;
}
public double getDiv() {
return div;
}
}
FileAn.java
package core;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Dvein
*/
public class FileAn {
private File file;
private BufferedReader reader;
private int x_G, y_G, z_G, x_A, y_A, z_A, x_M, y_M, z_M;
private ArrayList<Double> sample, x_Gyro, y_Gyro, z_Gyro, x_Acc, y_Acc, z_Acc, x_Magn, y_Magn, z_Magn;
public FileAn(File file) {
this.file = file;
}
public ArrayList<Double> getSample() {
try {
sample=getParam(0);
} catch (FileNotFoundException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
}
return sample;
}
public ArrayList<Double> getX_Magn() {
try {
x_Magn=getParam(position("X Magn"));
} catch (FileNotFoundException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
}
return x_Magn;
}
public ArrayList<Double> getX_Acc() {
try {
x_Acc=getParam(position("X acc"));
} catch (FileNotFoundException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
}
return x_Acc;
}
public ArrayList<Double> getY_Magn() {
try {
y_Magn=getParam(position("Y Magn"));
} catch (FileNotFoundException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
}
return y_Magn;
}
public ArrayList<Double> getY_Acc() {
try {
y_Acc=getParam(position("Y acc"));
} catch (FileNotFoundException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
}
return y_Acc;
}
public ArrayList<Double> getZ_Gyro() {
try {
z_Gyro=getParam(position("Z Gyro"));
} catch (FileNotFoundException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
}
return z_Gyro;
}
public ArrayList<Double> getX_Gyro() {
try {
x_Gyro=getParam(position("X Gryo"));
} catch (FileNotFoundException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
}
return x_Gyro;
}
public ArrayList<Double> getY_Gyro() {
try {
y_Gyro=getParam(position("Y Gyro"));
} catch (FileNotFoundException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
}
return y_Gyro;
}
public ArrayList<Double> getZ_Magn() {
try {
z_Magn=getParam(position("Z Mag"));
} catch (FileNotFoundException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
}
return z_Magn;
}
public ArrayList<Double> getZ_Acc() {
try {
z_Acc=getParam(position("Z acc"));
} catch (FileNotFoundException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(FileAn.class.getName()).log(Level.SEVERE, null, ex);
}
return z_Acc;
}
private ArrayList<Double> getParam(int i) throws FileNotFoundException, IOException {
ArrayList<Double> param = new ArrayList<Double>();
if(i<0){
return null;
}
reader = new BufferedReader(new FileReader(file));
String line = null;
int n = 0;
while ((line = reader.readLine())!= null) {
if (n > 6) {
String mas[] = line.split(",");
|
|
param.add(Double.parseDouble(mas[i]));
}
n++;
}
return param;
}
private int position(String name) throws FileNotFoundException, IOException {
reader = new BufferedReader(new FileReader(file));
String line = null;
int res = -1;
String mas[] = null;
for (int i = 0; i < 6; i++) {
reader.readLine();
}
mas = reader.readLine().split(",");
for (int i = 0; i < mas.length; i++) {
if (mas[i].equals(name)) {
res = i;
}
}
return res;
}
}
Filters.java
package core;
import java.util.ArrayList;
/**
*
* @author Dvein
*/
public class Filters {
private ArrayList<Double> xPoints;
private ArrayList<Double> yPoints;
private ArrayList<Double> xFilter = new ArrayList<Double>();
private ArrayList<Double> yFilter = new ArrayList<Double>();
private double start;
private double end;
private double corel;
public double getCorel(int displacement) {
int n = yPoints.size();
double pr = 0;
double sum = 0; // Y
double sum2 = 0; // Y2
double sum3 = 0; // X
double sum4 = 0; // X2
double sum5 = 0; // YX
for (int i = 0; i < n; i++){
sum = sum + yPoints.get(i)/n;
sum2 = sum2 + yPoints.get(i)*yPoints.get(i)/n;
sum3 = sum3 + xPoints.get(i)/n;
sum4 = sum4 + xPoints.get(i)*xPoints.get(i)/n;
sum5 = sum5 + yPoints.get(i)*xPoints.get(i)/n;
}
//System.out.println(sum/n);
//System.out.println(sum2/n);
//System.out.println(sum3/n);
//System.out.println(sum4/n);
//System.out.println(sum5/n);
//for (int i = 0; i < n; i++) {
// pr = pr + yPoints.get(i) * yPoints.get(i + displacement)/(1000*1000);
//}
corel = (sum5-sum*sum3)/Math.sqrt((sum2-sum*sum)*(sum4-sum3*sum3))*100;
return corel;
}
public ArrayList<Double> getxFilter() {
return xFilter;
}
public ArrayList<Double> getyFilter() {
return yFilter;
}
public Filters(ArrayList<Double> xPoints, ArrayList<Double> yPoints, double start, double end) {
this.xPoints = xPoints;
this.yPoints = yPoints;
this.start = start;
this.end = end;
}
public void SkSrFilter() {
int k = 2;
for (int i = 0; i <= end - start - 2 * k; i++) {
xFilter.add(start + i + k);
}
double g = (2 * k + 1);
for (int i = (int) (start + k); i <= end - k; i++) {
double sum = 0;
for (int j = -k; j <= k; j++) {
sum = sum + yPoints.get(i + j);
}
yFilter.add(sum / g);
}
/*for (int i = (int) start; i <= end; i++) {
xFilter.add((double) i);
}
for (int i = (int) start; i <= end; i++) {
for (int j = i - k; j < i + k; j++) {
double sum = 0;
double q = 0;
try {
sum = sum + yPoints.get(j);
q++;
} catch (Exception e) {
}
yFilter.add(sum / q);
}
}*/
}
public void PorFilter(double porog) {
SkSrFilter();
int k = 40;
int j = 0;
for (int i = (int) (start + k); i <= end - k; i++) {
if (Math.abs(yPoints.get(i) - yFilter.get(j)) < porog) {
yFilter.set(j, yPoints.get(i));
}
j++;
}
/*for (int i = (int) start; i <= end; i++) {
if (Math.abs(yPoints.get(i) - yFilter.get(j)) < porog) {
yFilter.set(j, yPoints.get(i));
}
j++;
}*/
}
MainForm.java
package ui;
import core.Build;
import core.FileAn;
import core.Filters;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.StyledEditorKit.ItalicAction;
public class MainForm extends javax.swing.JFrame {
private File openFile = null, saveFile = null;
private BufferedReader reader;
private ArrayList<Double> sample, xgND, x_Gryo, ygND, y_Gyro, zgND, z_Gyro, xaND, x_Acc, yaND, y_Acc, zaND, z_Acc, xmND, x_Magn, ymND, y_Magn, zmND, z_Magn;
private FileAn fileAn;
private Build build;
private Filters filter;
/** Creates new form MainForm */
public MainForm() {
initComponents();
this.setTitle("");
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
clear_but = new javax.swing.JButton();
paint_but = new javax.swing.JButton();
korel_but = new javax.swing.JButton();
draw_panel = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
z_Gryo_rb = new javax.swing.JRadioButton();
y_Gryo_rb = new javax.swing.JRadioButton();
z_Magn_rb = new javax.swing.JRadioButton();
y_Acc_rb = new javax.swing.JRadioButton();
z_Acc_rb = new javax.swing.JRadioButton();
x_Magn_rb = new javax.swing.JRadioButton();
y_Magn_rb = new javax.swing.JRadioButton();
x_Acc_rb = new javax.swing.JRadioButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
x_Gryo_rb = new javax.swing.JRadioButton();
jPanel3 = new javax.swing.JPanel();
sksrfilter_rb = new javax.swing.JRadioButton();
porfilter_rb = new javax.swing.JRadioButton();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
start_text = new javax.swing.JTextField();
end_text = new javax.swing.JTextField();
porog_text = new javax.swing.JTextField();
sm_text = new javax.swing.JTextField();
korel_text = new javax.swing.JTextField();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
clear_but.setText("");
clear_but.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
clear_butActionPerformed(evt);
}
});
paint_but.setText("");
paint_but.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
paint_butActionPerformed(evt);
}
});
korel_but.setText("");
korel_but.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
korel_butActionPerformed(evt);
}
});
draw_panel.setBackground(new java.awt.Color(255, 255, 255));
draw_panel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
javax.swing.GroupLayout draw_panelLayout = new javax.swing.GroupLayout(draw_panel);
draw_panel.setLayout(draw_panelLayout);
draw_panelLayout.setHorizontalGroup(
draw_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 749, Short.MAX_VALUE)
);
draw_panelLayout.setVerticalGroup(
draw_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 335, Short.MAX_VALUE)
);
buttonGroup1.add(z_Gryo_rb);
z_Gryo_rb.setText("Z");
buttonGroup1.add(y_Gryo_rb);
y_Gryo_rb.setText("Y");
buttonGroup1.add(z_Magn_rb);
z_Magn_rb.setText("Z");
buttonGroup1.add(y_Acc_rb);
y_Acc_rb.setText("Y");
buttonGroup1.add(z_Acc_rb);
z_Acc_rb.setText("Z");
buttonGroup1.add(x_Magn_rb);
x_Magn_rb.setText("X");
buttonGroup1.add(y_Magn_rb);
y_Magn_rb.setText("Y");
buttonGroup1.add(x_Acc_rb);
x_Acc_rb.setText("X");
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 13));
jLabel1.setText("Gryo");
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 13));
jLabel2.setText("Acc");
jLabel3.setFont(new java.awt.Font("Tahoma", 0, 13));
jLabel3.setText("Magn");
buttonGroup1.add(x_Gryo_rb);
x_Gryo_rb.setSelected(true);
x_Gryo_rb.setText("X");
x_Gryo_rb.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
x_Gryo_rbActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(y_Magn_rb)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(x_Gryo_rb, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(y_Gryo_rb, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(16, 16, 16))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(z_Gryo_rb, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(x_Acc_rb)
.addComponent(y_Acc_rb)
.addComponent(z_Acc_rb))
.addGap(11, 11, 11))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(18, 18, 18)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3)
.addComponent(x_Magn_rb)))
.addComponent(z_Magn_rb, javax.swing.GroupLayout.Alignment.TRAILING))))
.addContainerGap(12, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(x_Acc_rb)
.addComponent(x_Gryo_rb)
.addComponent(x_Magn_rb))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(y_Gryo_rb)
.addComponent(y_Acc_rb))
.addComponent(y_Magn_rb))
.addGap(8, 8, 8)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(z_Magn_rb)
.addComponent(z_Acc_rb)
.addComponent(z_Gryo_rb))
.addGap(17, 17, 17))
);
buttonGroup2.add(sksrfilter_rb);
sksrfilter_rb.setSelected(true);
sksrfilter_rb.setText(" ");
buttonGroup2.add(porfilter_rb);
porfilter_rb.setText("");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(porfilter_rb)
.addComponent(sksrfilter_rb))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(sksrfilter_rb)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(porfilter_rb)
.addContainerGap(52, Short.MAX_VALUE))
);
jLabel4.setText(":");
jLabel5.setText(":");
jLabel6.setText(":");
jLabel7.setText("");
jLabel8.setText("");
jLabel9.setText(" ");
start_text.setText("1");
end_text.setText("9999");
porog_text.setText("10");
sm_text.setText("0");
jMenu1.setText("");
jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem1.setText("");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);
jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
jMenuItem2.setText("");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2);
jMenuItem3.setText("");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem3);
jMenuBar1.add(jMenu1);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(clear_but)
.addGap(18, 18, 18)
.addComponent(paint_but)
.addGap(18, 18, 18)
.addComponent(korel_but))
.addGroup(layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(37, 37, 37)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 67, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(jLabel7))
.addComponent(jLabel5)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(start_text, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)
.addComponent(porog_text, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)
.addComponent(sm_text, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(end_text, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(korel_text, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(36, 36, 36))))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(draw_panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(jLabel7)
.addComponent(start_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(end_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(porog_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(sm_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(korel_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGap(29, 29, 29)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(draw_panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(clear_but)
.addComponent(paint_but)
.addComponent(korel_but, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
pack();
}// </editor-fold>
private void x_Gryo_rbActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void paint_butActionPerformed(java.awt.event.ActionEvent evt) {
int p = -1;
try {
if (x_Gryo_rb.isSelected()) {
build = new Build(sample, x_Gryo);
filter = new Filters(sample, x_Gryo, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
if (y_Gryo_rb.isSelected()) {
build = new Build(sample, y_Gyro);
filter = new Filters(sample, y_Gyro, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
if (z_Gryo_rb.isSelected()) {
build = new Build(sample, z_Gyro);
filter = new Filters(sample, z_Gyro, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
if (x_Acc_rb.isSelected()) {
build = new Build(sample, x_Acc);
filter = new Filters(sample, x_Acc, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
if (y_Acc_rb.isSelected()) {
build = new Build(sample, y_Acc);
filter = new Filters(sample, y_Acc, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
if (z_Acc_rb.isSelected()) {
build = new Build(sample, z_Acc);
filter = new Filters(sample, z_Acc, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
if (x_Magn_rb.isSelected()) {
build = new Build(sample, x_Magn);
filter = new Filters(sample, x_Magn, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
if (y_Magn_rb.isSelected()) {
build = new Build(sample, y_Magn);
filter = new Filters(sample, y_Magn, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
if (z_Magn_rb.isSelected()) {
build = new Build(sample, z_Magn);
filter = new Filters(sample, z_Magn, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
if (sksrfilter_rb.isSelected()) {
filter.SkSrFilter();
}
if (porfilter_rb.isSelected()) {
filter.PorFilter(Double.parseDouble(porog_text.getText()));
}
p = 1;
} catch (Exception e) {
}
draw(p);
}
private void clear_butActionPerformed(java.awt.event.ActionEvent evt) {
draw_panel.repaint();
}
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser fileChooser = new JFileChooser();
String homeDir = "C:\\";
fileChooser.setCurrentDirectory(new File(homeDir));
fileChooser.showOpenDialog(this); //
openFile = fileChooser.getSelectedFile(); //
fileAn = new FileAn(openFile);
sample = fileAn.getSample();
x_Gryo = fileAn.getX_Gyro();
y_Gyro = fileAn.getY_Gyro();
z_Gyro = fileAn.getZ_Gyro();
x_Acc = fileAn.getX_Acc();
y_Acc = fileAn.getY_Acc();
z_Acc = fileAn.getZ_Acc();
x_Magn = fileAn.getX_Magn();
y_Magn = fileAn.getY_Magn();
z_Magn = fileAn.getZ_Magn();
//JOptionPane.showMessageDialog(this, x_Gryo);
}
private void korel_butActionPerformed(java.awt.event.ActionEvent evt) {
if (x_Gryo_rb.isSelected()) {
if (x_Gryo == null) {
JOptionPane.showMessageDialog(this, " !");
} else {
build = new Build(sample, x_Gryo);
filter = new Filters(sample, x_Gryo, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
}
if (y_Gryo_rb.isSelected()) {
if (y_Gyro == null) {
JOptionPane.showMessageDialog(this, " !");
} else {
build = new Build(sample, y_Gyro);
filter = new Filters(sample, y_Gyro, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
}
if (z_Gryo_rb.isSelected()) {
if (z_Gyro == null) {
JOptionPane.showMessageDialog(this, " !");
} else {
build = new Build(sample, z_Gyro);
filter = new Filters(sample, z_Gyro, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
}
if (x_Acc_rb.isSelected()) {
if (x_Acc == null) {
JOptionPane.showMessageDialog(this, " !");
} else {
build = new Build(sample, x_Acc);
filter = new Filters(sample, x_Acc, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
}
if (y_Acc_rb.isSelected()) {
if (y_Acc == null) {
JOptionPane.showMessageDialog(this, " !");
} else {
build = new Build(sample, y_Acc);
filter = new Filters(sample, y_Acc, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
}
if (z_Acc_rb.isSelected()) {
if (z_Acc == null) {
JOptionPane.showMessageDialog(this, " !");
} else {
build = new Build(sample, z_Acc);
filter = new Filters(sample, z_Acc, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
}
if (x_Magn_rb.isSelected()) {
if (x_Magn == null) {
JOptionPane.showMessageDialog(this, " !");
} else {
build = new Build(sample, x_Magn);
filter = new Filters(sample, x_Magn, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
}
if (y_Magn_rb.isSelected()) {
if (y_Magn == null) {
JOptionPane.showMessageDialog(this, " !");
} else {
build = new Build(sample, y_Magn);
filter = new Filters(sample, y_Magn, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
}
if (z_Magn_rb.isSelected()) {
if (z_Magn == null) {
JOptionPane.showMessageDialog(this, " !");
} else {
build = new Build(sample, z_Magn);
filter = new Filters(sample, z_Magn, Double.parseDouble(start_text.getText()), Double.parseDouble(end_text.getText()));
}
}
double cor = filter.getCorel(Integer.parseInt(sm_text.getText()));
korel_text.setText(Double.toString(cor));
}
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser fileChooser = new JFileChooser();
String homeDir = "C:\\";
fileChooser.setCurrentDirectory(new File(homeDir));
fileChooser.showSaveDialog(this); //
saveFile = fileChooser.getSelectedFile();
//System.out.println(saveFile.getName());
try {
saveFile.createNewFile();
try {
String text = new String("");
BufferedWriter out = new BufferedWriter(new FileWriter(saveFile));
BufferedReader in = new BufferedReader(new FileReader(openFile));
for (int i = 0; i <= 6; i++) {
text = in.readLine();
out.write(text);
out.newLine();
}
int n = 0;
if (x_Gryo_rb.isSelected()) {
n = 2;
}
if (y_Gryo_rb.isSelected()) {
n = 4;
}
if (z_Gryo_rb.isSelected()) {
n = 6;
}
if (x_Acc_rb.isSelected()) {
n = 8;
}
if (y_Acc_rb.isSelected()) {
n = 10;
}
if (z_Acc_rb.isSelected()) {
n = 12;
}
if (x_Magn_rb.isSelected()) {
n = 14;
}
if (y_Magn_rb.isSelected()) {
n = 16;
}
if (z_Magn_rb.isSelected()) {
n = 18;
}
ArrayList<Double> yFilters;
yFilters = filter.getyFilter();
String text2[];
int i = 0, j = 0;
while ((text = in.readLine())!= null) {
if (i >= Integer.parseInt(start_text.getText()) + 40) {
if (i <= Integer.parseInt(end_text.getText()) - 40) {
text2 = text.split(",");
//System.out.println(yFilters.get(j) + '\n');
//System.out.println(j);
String d = yFilters.get(j).toString();
text2[n] = d;
text = "";
for (int q = 0; q<text2.length; q++) {
text = text + text2[q] + ",";
}
out.write(text);
out.newLine();
//text = text + text2[2];
//text = text + text[2];
j++;
} else {
out.write(text);
out.newLine();
}
} else {
out.write(text);
out.newLine();
}
i++;
//System.out.println(text+'\n');
}
/*for (int i = 0; i < Integer.parseInt(start_text.getText())+2; i++) {
text = in.readLine();
out.write(text);
out.newLine();
}
try{
//System.out.println(yFilters);
for (int i = Integer.parseInt(start_text.getText()); i < Integer.parseInt(end_text.getText()); i++) {
text = in.readLine();
String[] text2 = text.split(",");
int n = -1;
String text3 = new String("");
//System.out.println(yFilters.size());
if (n == -1) {
out.write(text);
out.newLine();
} else {
for (int j = 0; j < 19; j++) {
if (n!= j) {
text3 = text3 + text2[j];
text3 = text3 + ",";
} else {
text3 = text3 + yFilters.get(i);
text3 = text3 + ",";
}
}
out.write(text3);
out.newLine();
}
}
} catch (Exception e){
out.write(text);
out.newLine();
}
out.write("4,1,1.029922,"); out.newLine(); out.write("5,1,0.869934,"); out.newLine(); out.write("6,1,0.659950,"); out.newLine(); out.write("7,1,0.379971,"); out.newLine(); out.write("8,1,-0.179986,"); out.newLine(); out.write("9,1,-1.0699189,"); out.newLine();
for (int i = 0; i <6;i++){
in.readLine();
}
try {
for (int i = Integer.parseInt(end_text.getText())-2; i < 12; i++) {
text = in.readLine();
out.write(text);
out.newLine();
}
} catch (Exception e){
}*/
out.close();
in.close();
} catch (IOException e) {
}
} catch (IOException ex) {
Logger.getLogger(MainForm.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainForm().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.JButton clear_but;
private javax.swing.JPanel draw_panel;
private javax.swing.JTextField end_text;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JButton korel_but;
private javax.swing.JTextField korel_text;
private javax.swing.JButton paint_but;
private javax.swing.JRadioButton porfilter_rb;
private javax.swing.JTextField porog_text;
private javax.swing.JRadioButton sksrfilter_rb;
private javax.swing.JTextField sm_text;
private javax.swing.JTextField start_text;
private javax.swing.JRadioButton x_Acc_rb;
private javax.swing.JRadioButton x_Gryo_rb;
private javax.swing.JRadioButton x_Magn_rb;
private javax.swing.JRadioButton y_Acc_rb;
private javax.swing.JRadioButton y_Gryo_rb;
private javax.swing.JRadioButton y_Magn_rb;
private javax.swing.JRadioButton z_Acc_rb;
private javax.swing.JRadioButton z_Gryo_rb;
private javax.swing.JRadioButton z_Magn_rb;
// End of variables declaration
private void draw(int p) {
//try {
if (p >= 0) {
ArrayList<Double> xPoints = build.getxPoints();
ArrayList<Double> yPoints = build.getyPoints();
ArrayList<Double> xFilter = filter.getxFilter();
ArrayList<Double> yFilter = filter.getyFilter();
double yDiff = build.getyDiff();
double xDiff = build.getxDiff();
double maxY = build.getMaxY();
double minY = build.getMinY();
double maxX = build.getMaxX();
double minX = build.getMinX();
double div = build.getDiv();
//double maxmaxY = build.getMaxMax(x_Gryo, y_Gyro, z_Gyro, x_Acc, y_Acc, z_Acc, x_Magn, y_Magn, z_Magn);
//double minminY = build.getMinMin(x_Gryo, y_Gyro, z_Gyro, x_Acc, y_Acc, z_Acc, x_Magn, y_Magn, z_Magn);
//System.out.println(maxmaxY+" "+minminY+" "+maxX+" "+minX);
Graphics2D gr = (Graphics2D) draw_panel.getGraphics();
Font font = new Font("TimesRoman", Font.BOLD, 14);
gr.setFont(font);
if (yDiff < 10) {
for (int i = 0; i < yPoints.size(); i++) {
yPoints.set(i, yPoints.get(i) * 1000);
}
for (int i = 0; i < yFilter.size(); i++) {
yFilter.set(i, yFilter.get(i) * 1000);
}
yDiff = yDiff * 1000;
}
gr.translate(20, (int) ((draw_panel.getHeight() - 20) * div));
gr.scale((draw_panel.getWidth() - 40) / xDiff, (draw_panel.getHeight() - 40) / yDiff);
/*for (int i = 0; i <= maxY; i = i + 50) {
gr.drawLine((int) minX, -i, (int) maxX, -i);
}*/
/*for (int i = 0; i >= minY; i = i - 50) {
gr.drawLine((int) minX, -i, (int) maxX, -i);
}*/
/*for (int i = (int) minX; i <= maxX; i = i + 100) {
gr.drawLine(i, -(int) minY, i, -(int) maxY);
}*/
gr.setColor(Color.blue);
for (int i = 0; i < xPoints.size() - 1; i++) {
gr.drawLine((int) (double) xPoints.get(i), -(int) (double) yPoints.get(i), (int) (double) xPoints.get(i + 1), -(int) (double) yPoints.get(i + 1));
}
gr.setColor(Color.red);
for (int i = 0; i < xFilter.size() - 1; i++) {
gr.drawLine((int) (double) xFilter.get(i), -(int) (double) yFilter.get(i), (int) (double) xFilter.get(i + 1), -(int) (double) yFilter.get(i + 1));
}
} else {
JOptionPane.showMessageDialog(null, " , !", "", JOptionPane.ERROR_MESSAGE);
}
//} catch (NullPointerException e) {
// JOptionPane.showMessageDialog(null, " , !","",JOptionPane.ERROR_MESSAGE);
//}
}
}
:
, .