Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package ru.spbspu.viewer; import ru.spbspu.presenter.IDataPresenter; import ru.spbspu.presenter.DataPresenter; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Graphics; import java.awt.Image; import java.awt.Label; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; import java.time.LocalTime; import java.util.TimerTask; import javax.sound.midi.Sequence; import javax.sound.sampled.Clip; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.SpinnerNumberModel; import javax.swing.Timer; import javax.swing.border.TitledBorder; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.AxisSpace; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; import org.jfree.data.xy.CategoryTableXYDataset; import ru.spbspu.model.DataLoader; import ru.spbspu.model.MathOperations; import ru.spbspu.model.StdAudio; import ru.spbspu.model.TestData; import ru.spbspu.viewer.IDataView; /** * * @author MuGund-U */ public class DataView extends javax.swing.JFrame implements IDataView { static final int SCALE_OF_SPECT = 70; static final AxisSpace GRAPHIC_SPACE = new AxisSpace(); static final int SPECT_RIGHT_SPACE = 20; private IDataPresenter _presenter; private Clip clip; /** * Creates new form Form */ public DataView() { initComponents(); _presenter = new DataPresenter(this, new DataLoader(), new MathOperations(), new StdAudio()); GRAPHIC_SPACE.setLeft(48); } /** * 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 DataView Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jToolBar1 = new javax.swing.JToolBar(); fileChooser = new javax.swing.JFileChooser(); fftOrEnSpectrum = new javax.swing.ButtonGroup(); scaling = new javax.swing.ButtonGroup(); transformation = new javax.swing.ButtonGroup(); v = new javax.swing.ButtonGroup(); jFileChooser1 = new javax.swing.JFileChooser(); refresh = new javax.swing.JButton(); load = new javax.swing.JButton(); jTabbedPane1 = new javax.swing.JTabbedPane(); controlPanel = new javax.swing.JPanel(); frame = new javax.swing.JLabel(); frameWidthInSecondsTextField = new javax.swing.JTextField(); spinnerFrameWidth = new javax.swing.JSpinner(); jLabel3 = new javax.swing.JLabel(); spinnerDiscretization = new javax.swing.JSpinner(); chosenFileTextField = new javax.swing.JTextField(); autoscale = new javax.swing.JRadioButton(); meanValue = new javax.swing.JRadioButton(); maxValue = new javax.swing.JRadioButton(); spectrogramPanel = new javax.swing.JPanel(); window = new javax.swing.JLabel(); spinnerWindowWidth = new javax.swing.JSpinner(); spinnerLimitFreq = new javax.swing.JSpinner(); jLabel5 = new javax.swing.JLabel(); sliderSpectrogram = new javax.swing.JSlider(); jLabel1 = new javax.swing.JLabel(); fourier = new javax.swing.JRadioButton(); wavelet = new javax.swing.JRadioButton(); windowFunction = new javax.swing.JComboBox<>(); llabelWindowFunction = new javax.swing.JLabel(); testPanel = new javax.swing.JPanel(); FourierTest = new javax.swing.JButton(); WaveletTest = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); LPF = new javax.swing.JCheckBox(); cropBeginningLabel = new javax.swing.JLabel(); cropBeginningTextField = new javax.swing.JTextField(); testDataPanel = new javax.swing.JPanel(); ampl1Input = new javax.swing.JTextField(); ampl2Input = new javax.swing.JTextField(); ampl3Input = new javax.swing.JTextField(); ampl1Label = new javax.swing.JLabel(); ampl2Label = new javax.swing.JLabel(); ampl3Label = new javax.swing.JLabel(); freq1Label = new javax.swing.JLabel(); freq2Label = new javax.swing.JLabel(); freq3Label = new javax.swing.JLabel(); freq1Input = new javax.swing.JTextField(); freq2Input = new javax.swing.JTextField(); freq3Input = new javax.swing.JTextField(); discrLabel = new javax.swing.JLabel(); discrInput = new javax.swing.JTextField(); lengthInput = new javax.swing.JTextField(); lengthLabel = new javax.swing.JLabel(); middleWindow = new javax.swing.JPanel(); showEnergySpectrum = new javax.swing.JRadioButton(); vAcceleration = new javax.swing.JRadioButton(); vDisplacement = new javax.swing.JRadioButton(); jPanel4 = new javax.swing.JPanel(); fileLengthSec = new javax.swing.JLabel(); stop = new javax.swing.JButton(); play = new javax.swing.JButton(); positionInFileSec = new javax.swing.JLabel(); fileLengthSecTextFiled = new javax.swing.JTextField(); positionInFileSecTextField = new javax.swing.JTextField(); seekSlider = new javax.swing.JSlider(); jTabbedPane2 = new javax.swing.JTabbedPane(); jPanel3 = new javax.swing.JPanel(); jSplitPane1 = new javax.swing.JSplitPane(); jPanel1 = new javax.swing.JPanel(); jSplitPane3 = new javax.swing.JSplitPane(); contrastSpectrogram = new javax.swing.JPanel(); energy = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); spectrogram = new javax.swing.JPanel(); labelForFrameScale = new javax.swing.JLabel(); labelForFrameSpectr = new javax.swing.JLabel(); cursor = new javax.swing.JProgressBar(); jPanel6 = new javax.swing.JPanel(); jSplitPane2 = new javax.swing.JSplitPane(); fullEnergy = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); fullSpectrogram = new javax.swing.JPanel(); labelForFullSpectr = new javax.swing.JLabel(); labelForFullScale = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); fileMenu = new javax.swing.JMenu(); openItem = new javax.swing.JMenuItem(); sliderMenu = new javax.swing.JMenu(); forward = new javax.swing.JMenuItem(); backward = new javax.swing.JMenuItem(); refreshItem = new javax.swing.JMenuItem(); playItem = new javax.swing.JMenuItem(); stopItem = new javax.swing.JMenuItem(); jToolBar1.setRollover(true); fileChooser.setDialogTitle(" "); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setLocationByPlatform(true); addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { formKeyPressed(evt); } public void keyReleased(java.awt.event.KeyEvent evt) { formKeyReleased(evt); } }); refresh.setText(""); refresh.setEnabled(false); refresh.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { refreshActionPerformed(evt); } }); load.setText(""); load.setEnabled(false); load.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { loadActionPerformed(evt); } }); jTabbedPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); frame.setText("? ?"); frameWidthInSecondsTextField.setEnabled(false); frameWidthInSecondsTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { frameWidthInSecondsTextFieldActionPerformed(evt); } }); spinnerFrameWidth.setModel(new javax.swing.SpinnerNumberModel(8192, 256, 262144, 512)); spinnerFrameWidth.setEnabled(false); spinnerFrameWidth.setOpaque(false); spinnerFrameWidth.setRequestFocusEnabled(false); spinnerFrameWidth.setValue(32768); spinnerFrameWidth.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { spinnerFrameWidthStateChanged(evt); } }); jLabel3.setLabelFor(spinnerDiscretization); jLabel3.setText("? ?, "); spinnerDiscretization.setModel(new javax.swing.SpinnerNumberModel(5000, 1, 50000, 1000)); spinnerDiscretization.setName(""); // NOI18N chosenFileTextField.setEnabled(false); chosenFileTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { chosenFileTextFieldActionPerformed(evt); } }); scaling.add(autoscale); autoscale.setSelected(true); autoscale.setText("?? "); autoscale.setActionCommand("auto"); autoscale.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { autoscaleActionPerformed(evt); } }); scaling.add(meanValue); meanValue.setText("? ?"); meanValue.setActionCommand("mean"); meanValue.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { meanValueActionPerformed(evt); } }); scaling.add(maxValue); maxValue.setText("? ?"); maxValue.setActionCommand("max"); maxValue.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { maxValueActionPerformed(evt); } }); javax.swing.GroupLayout controlPanelLayout = new javax.swing.GroupLayout(controlPanel); controlPanel.setLayout(controlPanelLayout); controlPanelLayout.setHorizontalGroup(controlPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(controlPanelLayout.createSequentialGroup().addContainerGap().addGroup(controlPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(controlPanelLayout.createSequentialGroup().addGroup(controlPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(frame) .addGroup(controlPanelLayout.createSequentialGroup() .addComponent(spinnerFrameWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(frameWidthInSecondsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(44, 44, 44) .addGroup(controlPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3).addComponent(spinnerDiscretization, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(10, 101, Short.MAX_VALUE)) .addGroup(controlPanelLayout.createSequentialGroup().addComponent(chosenFileTextField) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addGroup(controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(meanValue).addComponent(autoscale).addComponent(maxValue)) .addGap(0, 224, Short.MAX_VALUE))); controlPanelLayout.setVerticalGroup(controlPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(controlPanelLayout.createSequentialGroup().addGap(2, 2, 2) .addGroup(controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3).addComponent(frame).addComponent(autoscale)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(spinnerFrameWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(spinnerDiscretization, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(frameWidthInSecondsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(meanValue)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(maxValue).addComponent(chosenFileTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jTabbedPane1.addTab("?? ", controlPanel); window.setLabelFor(spinnerWindowWidth); window.setText(""); spinnerWindowWidth.setModel(new javax.swing.SpinnerNumberModel(128, 4, 8192, 128)); spinnerWindowWidth.setEnabled(false); spinnerWindowWidth.setValue(256); spinnerLimitFreq.setModel( new SpinnerNumberModel(getSpinnerFreqLimit(), new Integer(5), new Integer(50000), new Integer(50))); spinnerLimitFreq.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { spinnerLimitFreqStateChanged(evt); } }); jLabel5.setLabelFor(spinnerLimitFreq); jLabel5.setText("? ?"); sliderSpectrogram.setValue(100); sliderSpectrogram.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { sliderSpectrogramStateChanged(evt); } }); sliderSpectrogram.addFocusListener(new java.awt.event.FocusAdapter() { public void focusGained(java.awt.event.FocusEvent evt) { sliderSpectrogramFocusGained(evt); } }); jLabel1.setLabelFor(sliderSpectrogram); jLabel1.setText("??"); jLabel1.setToolTipText(""); jLabel1.setName(""); // NOI18N transformation.add(fourier); fourier.setSelected(true); fourier.setText(" "); fourier.setActionCommand("fourier"); transformation.add(wavelet); wavelet.setText(" "); wavelet.setActionCommand("wavelet"); wavelet.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { waveletStateChanged(evt); } }); windowFunction.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Hann", "Hamming" })); llabelWindowFunction.setLabelFor(windowFunction); llabelWindowFunction.setText("? "); javax.swing.GroupLayout spectrogramPanelLayout = new javax.swing.GroupLayout(spectrogramPanel); spectrogramPanel.setLayout(spectrogramPanelLayout); spectrogramPanelLayout.setHorizontalGroup(spectrogramPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(spectrogramPanelLayout.createSequentialGroup().addContainerGap() .addGroup(spectrogramPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(spectrogramPanelLayout.createSequentialGroup() .addGroup(spectrogramPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(spinnerLimitFreq, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(spectrogramPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(spinnerWindowWidth, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(window)) .addGap(26, 26, 26) .addGroup(spectrogramPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(wavelet).addComponent(fourier)) .addGap(43, 43, 43) .addGroup(spectrogramPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(llabelWindowFunction, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(windowFunction, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(spectrogramPanelLayout.createSequentialGroup().addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(sliderSpectrogram, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(430, Short.MAX_VALUE))); spectrogramPanelLayout.setVerticalGroup(spectrogramPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(spectrogramPanelLayout.createSequentialGroup().addContainerGap() .addGroup(spectrogramPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(spectrogramPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(spectrogramPanelLayout.createSequentialGroup() .addGroup(spectrogramPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(spectrogramPanelLayout.createSequentialGroup() .addComponent(window).addGap(5, 5, 5)) .addGroup(spectrogramPanelLayout.createSequentialGroup() .addComponent(llabelWindowFunction).addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED))) .addGroup(spectrogramPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(spinnerWindowWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(spectrogramPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(wavelet).addComponent(windowFunction, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(spectrogramPanelLayout.createSequentialGroup() .addComponent(jLabel5).addGap(5, 5, 5).addComponent( spinnerLimitFreq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(fourier)) .addGap(18, 18, 18) .addGroup(spectrogramPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(spectrogramPanelLayout.createSequentialGroup().addComponent(jLabel1) .addGap(0, 0, Short.MAX_VALUE)) .addComponent(sliderSpectrogram, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addContainerGap())); jTabbedPane1.addTab("?? ?", spectrogramPanel); FourierTest.setText("Fourire Test"); FourierTest.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { FourierTestActionPerformed(evt); } }); WaveletTest.setText("Wavelet Test"); WaveletTest.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { WaveletTestActionPerformed(evt); } }); jButton1.setText("jButton1"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); LPF.setText(" ?"); cropBeginningLabel.setText(" :"); cropBeginningTextField.setText("jTextField1"); javax.swing.GroupLayout testPanelLayout = new javax.swing.GroupLayout(testPanel); testPanel.setLayout(testPanelLayout); testPanelLayout.setHorizontalGroup(testPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(testPanelLayout.createSequentialGroup().addContainerGap() .addGroup(testPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(FourierTest).addComponent(WaveletTest)) .addGap(31, 31, 31) .addGroup(testPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(testPanelLayout.createSequentialGroup().addGap(133, 133, 133) .addComponent(cropBeginningLabel).addGap(3, 3, 3).addComponent( cropBeginningTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(testPanelLayout.createSequentialGroup().addComponent(jButton1) .addGap(65, 65, 65).addComponent(LPF))) .addContainerGap(609, Short.MAX_VALUE))); testPanelLayout.setVerticalGroup(testPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(testPanelLayout.createSequentialGroup().addContainerGap() .addGroup(testPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(FourierTest).addComponent(jButton1).addComponent(LPF)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(testPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(WaveletTest).addComponent(cropBeginningLabel) .addComponent(cropBeginningTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(21, Short.MAX_VALUE))); jTabbedPane1.addTab("?", testPanel); ampl1Input.setText("10"); ampl2Input.setText("20"); ampl3Input.setText("30"); ampl1Label.setText("?.1"); ampl2Label.setText("?.2"); ampl3Label.setText("?.3"); freq1Label.setText("?.1"); freq2Label.setText("?.2"); freq3Label.setText("?.3"); freq1Input.setText("100"); freq2Input.setText("200"); freq3Input.setText("300"); discrLabel.setText("?."); discrInput.setText("5000"); lengthInput.setText("131072"); lengthLabel.setText(""); javax.swing.GroupLayout testDataPanelLayout = new javax.swing.GroupLayout(testDataPanel); testDataPanel.setLayout(testDataPanelLayout); testDataPanelLayout.setHorizontalGroup(testDataPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(testDataPanelLayout.createSequentialGroup().addContainerGap() .addGroup(testDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(ampl1Label).addComponent(ampl2Label).addComponent(ampl3Label)) .addGap(34, 34, 34) .addGroup(testDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(ampl1Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ampl2Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ampl3Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(26, 26, 26) .addGroup(testDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(testDataPanelLayout.createSequentialGroup().addComponent(freq3Label) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(freq3Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(testDataPanelLayout.createSequentialGroup().addGroup(testDataPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(testDataPanelLayout.createSequentialGroup() .addComponent(freq1Label) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(freq1Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(36, 36, 36).addComponent(discrLabel)) .addGroup(testDataPanelLayout.createSequentialGroup() .addComponent(freq2Label) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(freq2Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lengthLabel))) .addGap(18, 18, 18) .addGroup(testDataPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lengthInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(discrInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(704, Short.MAX_VALUE))); testDataPanelLayout.setVerticalGroup(testDataPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(testDataPanelLayout.createSequentialGroup().addGap(6, 6, 6).addGroup(testDataPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(ampl1Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ampl1Label).addComponent(freq1Label) .addComponent(freq1Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(discrLabel).addComponent(discrInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( testDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(ampl2Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ampl2Label).addComponent(freq2Label) .addComponent(freq2Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lengthInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lengthLabel)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( testDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(ampl3Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ampl3Label).addComponent(freq3Label).addComponent(freq3Input, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jTabbedPane1.addTab("?", testDataPanel); v.add(showEnergySpectrum); showEnergySpectrum.setText("?"); showEnergySpectrum.setActionCommand("energy"); showEnergySpectrum.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { showEnergySpectrumStateChanged(evt); } }); v.add(vAcceleration); vAcceleration.setText("?"); vAcceleration.setActionCommand("accel"); v.add(vDisplacement); vDisplacement.setSelected(true); vDisplacement.setText("?"); vDisplacement.setActionCommand("displ"); vDisplacement.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { vDisplacementStateChanged(evt); } }); javax.swing.GroupLayout middleWindowLayout = new javax.swing.GroupLayout(middleWindow); middleWindow.setLayout(middleWindowLayout); middleWindowLayout.setHorizontalGroup( middleWindowLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(middleWindowLayout.createSequentialGroup().addContainerGap() .addComponent(showEnergySpectrum) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(vDisplacement) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(vAcceleration).addContainerGap(697, Short.MAX_VALUE))); middleWindowLayout.setVerticalGroup(middleWindowLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(middleWindowLayout.createSequentialGroup().addContainerGap() .addGroup(middleWindowLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(vDisplacement).addComponent(showEnergySpectrum) .addComponent(vAcceleration)) .addContainerGap(67, Short.MAX_VALUE))); jTabbedPane1.addTab(".", middleWindow); jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jPanel4.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); fileLengthSec.setLabelFor(fileLengthSecTextFiled); fileLengthSec.setText(" , ?"); jPanel4.add(fileLengthSec, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 10, -1, -1)); stop.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ru/spbspu/viewer/stop.png"))); // NOI18N stop.setEnabled(false); stop.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { stopActionPerformed(evt); } }); jPanel4.add(stop, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, 29, 32)); play.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ru/spbspu/viewer/playPause.png"))); // NOI18N play.setEnabled(false); play.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { playActionPerformed(evt); } }); jPanel4.add(play, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 80, 29, 32)); positionInFileSec.setLabelFor(positionInFileSecTextField); positionInFileSec.setText("? , ?"); jPanel4.add(positionInFileSec, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 70, -1, -1)); fileLengthSecTextFiled.setEnabled(false); jPanel4.add(fileLengthSecTextFiled, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 30, 90, -1)); positionInFileSecTextField.setFont(new java.awt.Font("MS Reference Sans Serif", 0, 14)); // NOI18N positionInFileSecTextField.setCaretColor(new java.awt.Color(240, 240, 240)); positionInFileSecTextField.setDisabledTextColor(new java.awt.Color(255, 153, 51)); positionInFileSecTextField.setDoubleBuffered(true); positionInFileSecTextField.setEnabled(false); positionInFileSecTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { positionInFileSecTextFieldActionPerformed(evt); } }); jPanel4.add(positionInFileSecTextField, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 90, 90, -1)); seekSlider.setPaintLabels(true); seekSlider.setValue(0); seekSlider.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); seekSlider.setEnabled(false); seekSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { seekSliderStateChanged(evt); } }); seekSlider.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { seekSliderKeyPressed(evt); } }); jSplitPane1.setDividerLocation(150); jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane1.setPreferredSize(new java.awt.Dimension(809, 150)); jSplitPane3.setDividerLocation(75); jSplitPane3.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); contrastSpectrogram.setBackground(new java.awt.Color(204, 255, 204)); contrastSpectrogram.setLayout(new java.awt.BorderLayout()); jSplitPane3.setLeftComponent(contrastSpectrogram); energy.setBackground(new java.awt.Color(204, 255, 204)); energy.setLayout(new java.awt.BorderLayout()); jSplitPane3.setBottomComponent(energy); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jSplitPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 1503, Short.MAX_VALUE) .addGap(0, 0, 0))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSplitPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)); jSplitPane1.setTopComponent(jPanel1); spectrogram.setBackground(new java.awt.Color(204, 255, 204)); spectrogram.setEnabled(false); spectrogram.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { spectrogramMouseClicked(evt); } }); spectrogram.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { spectrogramPropertyChange(evt); } }); spectrogram.setLayout(new java.awt.GridBagLayout()); labelForFrameScale.setMaximumSize(new java.awt.Dimension(40, 14)); labelForFrameScale.setMinimumSize(new java.awt.Dimension(40, 14)); labelForFrameScale.setPreferredSize(new java.awt.Dimension(65, 14)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; spectrogram.add(labelForFrameScale, gridBagConstraints); labelForFrameSpectr.setEnabled(false); labelForFrameSpectr.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { labelForFrameSpectrMouseClicked(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; spectrogram.add(labelForFrameSpectr, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; spectrogram.add(cursor, gridBagConstraints); jScrollPane1.setViewportView(spectrogram); jSplitPane1.setBottomComponent(jScrollPane1); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout .setHorizontalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1503, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 354, Short.MAX_VALUE)); jTabbedPane2.addTab("", jPanel3); jSplitPane2.setDividerLocation(200); jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); fullEnergy.setLayout(new java.awt.BorderLayout()); jSplitPane2.setLeftComponent(fullEnergy); fullSpectrogram.setLayout(new java.awt.BorderLayout()); labelForFullSpectr.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { labelForFullSpectrMouseClicked(evt); } }); fullSpectrogram.add(labelForFullSpectr, java.awt.BorderLayout.CENTER); labelForFullScale.setMaximumSize(new java.awt.Dimension(35, 14)); labelForFullScale.setMinimumSize(new java.awt.Dimension(35, 14)); labelForFullScale.setPreferredSize(new java.awt.Dimension(65, 14)); fullSpectrogram.add(labelForFullScale, java.awt.BorderLayout.LINE_START); jScrollPane2.setViewportView(fullSpectrogram); jSplitPane2.setRightComponent(jScrollPane2); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 1503, Short.MAX_VALUE) .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSplitPane2))); jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 354, Short.MAX_VALUE).addGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jSplitPane2))); jTabbedPane2.addTab("? ?", jPanel6); fileMenu.setText(""); openItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); openItem.setText(""); openItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { openItemActionPerformed(evt); } }); fileMenu.add(openItem); jMenuBar1.add(fileMenu); sliderMenu.setText(""); sliderMenu.setEnabled(false); forward.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_RIGHT, java.awt.event.InputEvent.SHIFT_MASK)); forward.setText(" "); forward.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { forwardActionPerformed(evt); } }); sliderMenu.add(forward); backward.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_LEFT, java.awt.event.InputEvent.SHIFT_MASK)); backward.setText("? "); backward.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { backwardActionPerformed(evt); } }); sliderMenu.add(backward); refreshItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, 0)); refreshItem.setText(""); refreshItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { refreshItemActionPerformed(evt); } }); sliderMenu.add(refreshItem); playItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SPACE, 0)); playItem.setText(""); playItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { playItemActionPerformed(evt); } }); sliderMenu.add(playItem); stopItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, 0)); stopItem.setText(""); stopItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { stopItemActionPerformed(evt); } }); sliderMenu.add(stopItem); jMenuBar1.add(sliderMenu); 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().addContainerGap().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(load, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(refresh, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addGap(80, 80, 80)) .addComponent(jTabbedPane2).addComponent(seekSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] { load, refresh }); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(31, 31, 31).addComponent(load) .addGap(18, 18, 18).addComponent(refresh)) .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jTabbedPane2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(seekSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] { load, refresh }); pack(); }// </editor-fold>//GEN-END:initComponents private void openItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openItemActionPerformed fileChooser.showOpenDialog(this); String path = null; if (fileChooser.getSelectedFile() != null) { path = fileChooser.getSelectedFile().getAbsolutePath(); } else { return; } _presenter.setEnabledStart(path); if (_presenter.isEnabledStart()) { chosenFileTextField.setText(path); load.setEnabled(_presenter.isEnabledStart()); seekSlider.setEnabled(true); spinnerFrameWidth.setEnabled(true); spinnerWindowWidth.setEnabled(true); spectrogram.setEnabled(true); labelForFrameSpectr.setEnabled(true); sliderMenu.setEnabled(true); } else { JOptionPane.showMessageDialog(rootPane, " .ana", " ", JOptionPane.WARNING_MESSAGE); } }//GEN-LAST:event_openItemActionPerformed private void loadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadActionPerformed Integer discretization = _presenter.setDiscretization(fileChooser.getSelectedFile().getAbsolutePath()); if (discretization > 0) { spinnerDiscretization.setValue(discretization); } seekSlider.setValue(0); _presenter.loadFile(); seekSlider.setEnabled(true); // System.out.println(" view " + seekSlider.getValue()); _presenter.createWav(); load.setEnabled(false); refresh.setEnabled(true); play.setEnabled(true); stop.setEnabled(true); //_presenter.buildFullEnergyGraph(); _presenter.setSizeOfCount(); calculateTimeLength(); clip = _presenter.getWav(); setTimer(); refreshAll(); sliderSpectrogram.setMaximum((int) _presenter.getDataMax()); sliderSpectrogram.setMinimum((int) _presenter.getDataMin()); sliderSpectrogram.setValue((int) _presenter.getDataMax()); }//GEN-LAST:event_loadActionPerformed private void seekSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_seekSliderStateChanged refreshTab1(); cursor.setValue(0); //_presenter.buildOscillogram(); // _presenter.buildGraphEnergy(); // _presenter.changeMiddleWindow(fftOrEnSpectrum.getSelection().getActionCommand()); int value = seekSlider.getValue(); if (clip instanceof Clip) { ((Clip) clip).setFramePosition(value); } }//GEN-LAST:event_seekSliderStateChanged private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed }//GEN-LAST:event_formKeyPressed private void formKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyReleased seekSlider.setValue(seekSlider.getValue() + Integer.valueOf(spinnerFrameWidth.getValue().toString())); _presenter.changeFrame(); }//GEN-LAST:event_formKeyReleased private void seekSliderKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_seekSliderKeyPressed }//GEN-LAST:event_seekSliderKeyPressed private void forwardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_forwardActionPerformed seekSlider.setValue( seekSlider.getValue() + Integer.valueOf(spinnerFrameWidth.getValue().toString()) / Float.BYTES); _presenter.changeFrame(); }//GEN-LAST:event_forwardActionPerformed private void backwardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backwardActionPerformed seekSlider.setValue( seekSlider.getValue() - Integer.valueOf(spinnerFrameWidth.getValue().toString()) / Float.BYTES); _presenter.changeFrame(); }//GEN-LAST:event_backwardActionPerformed private void refreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshActionPerformed System.out.println(jScrollPane1.getHeight() + " scrollpanel1 heght"); System.out.println(spectrogram.getHeight() + " spectrogram heght"); _presenter.changeFrame(); if (_frameTimer.isRunning()) { _frameTimer.stop(); } refreshAll(); setTimer(); _presenter.createWav(); }//GEN-LAST:event_refreshActionPerformed private void refreshItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshItemActionPerformed refreshActionPerformed(evt); }//GEN-LAST:event_refreshItemActionPerformed private void playActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_playActionPerformed if (_frameTimer == null) { System.out.println("There is no sound in test."); return; } if (!_frameTimer.isRunning()) { this._frameTimer.start(); clip.start(); } else { this._frameTimer.stop(); clip.stop(); } }//GEN-LAST:event_playActionPerformed private void stopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopActionPerformed seekSlider.setValue(0); cursor.setValue(0); _frameTimer.stop(); _presenter.stopWav(); clip.stop(); clip.setFramePosition(0); }//GEN-LAST:event_stopActionPerformed private void playItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_playItemActionPerformed if (!_frameTimer.isRunning()) { this._frameTimer.start(); } else { this._frameTimer.stop(); } }//GEN-LAST:event_playItemActionPerformed private void stopItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopItemActionPerformed seekSlider.setValue(0); _frameTimer.stop(); }//GEN-LAST:event_stopItemActionPerformed private void positionInFileSecTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_positionInFileSecTextFieldActionPerformed // TODO add your handling code here: }//GEN-LAST:event_positionInFileSecTextFieldActionPerformed private void sliderSpectrogramFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_sliderSpectrogramFocusGained }//GEN-LAST:event_sliderSpectrogramFocusGained private void sliderSpectrogramStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderSpectrogramStateChanged buildLimitedFullSpectrogram(); }//GEN-LAST:event_sliderSpectrogramStateChanged private void spinnerLimitFreqStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerLimitFreqStateChanged refreshAll(); }//GEN-LAST:event_spinnerLimitFreqStateChanged private void maxValueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_maxValueActionPerformed refreshFullGraph(); refreshTab1(); }//GEN-LAST:event_maxValueActionPerformed private void meanValueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_meanValueActionPerformed refreshFullGraph(); refreshTab1(); }//GEN-LAST:event_meanValueActionPerformed private void autoscaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_autoscaleActionPerformed refreshFullGraph(); refreshTab1(); }//GEN-LAST:event_autoscaleActionPerformed private void chosenFileTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chosenFileTextFieldActionPerformed // TODO add your handling code here: }//GEN-LAST:event_chosenFileTextFieldActionPerformed private void spinnerFrameWidthStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerFrameWidthStateChanged int prevValue = Integer.parseInt(spinnerFrameWidth.getValue().toString()); if (Integer.valueOf(spinnerFrameWidth.getValue().toString()) % 2 != 0) { JOptionPane.showMessageDialog(rootPane, " 2", "?? ", JOptionPane.INFORMATION_MESSAGE); spinnerFrameWidth.setValue(prevValue); return; } if (prevValue < 1024) { spinnerFrameWidth.setValue(1024); } int powerOf2 = (int) Math.round(Math.log(prevValue) / Math.log(2)); spinnerFrameWidth.setValue((int) Math.pow(2, powerOf2)); _presenter.changeFrame(); frameWidthInSecondsTextField.setText(_presenter.getFrameWidthInSeconds() + " ?"); refreshAll(); }//GEN-LAST:event_spinnerFrameWidthStateChanged private void frameWidthInSecondsTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_frameWidthInSecondsTextFieldActionPerformed // TODO add your handling code here: }//GEN-LAST:event_frameWidthInSecondsTextFieldActionPerformed private void spectrogramPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_spectrogramPropertyChange if (_presenter != null) { /*buildSpectrogram(); buildLimitedFullSpectrogram(); drawScale();*/ } }//GEN-LAST:event_spectrogramPropertyChange private void spectrogramMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_spectrogramMouseClicked }//GEN-LAST:event_spectrogramMouseClicked private void labelForFrameSpectrMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labelForFrameSpectrMouseClicked refreshTab1(); }//GEN-LAST:event_labelForFrameSpectrMouseClicked private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed seekSlider.setValue(0); seekSlider.setEnabled(true); load.setEnabled(false); refresh.setEnabled(true); play.setEnabled(true); stop.setEnabled(true); // _presenter.setSizeOfCount(); // calculateTimeLength(); // clip = _presenter.getWav(); // setTimer(); // refreshAll(); sliderSpectrogram.setMaximum((int) _presenter.getDataMax()); sliderSpectrogram.setMinimum((int) _presenter.getDataMin()); sliderSpectrogram.setValue((int) _presenter.getDataMax()); }//GEN-LAST:event_jButton1ActionPerformed private void labelForFullSpectrMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labelForFullSpectrMouseClicked refreshFullGraph(); }//GEN-LAST:event_labelForFullSpectrMouseClicked private void FourierTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FourierTestActionPerformed _presenter.showTestData(); }//GEN-LAST:event_FourierTestActionPerformed private void WaveletTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WaveletTestActionPerformed double freq1 = Double.valueOf(freq1Input.getText()); double freq2 = Double.valueOf(freq2Input.getText()); double freq3 = Double.valueOf(freq3Input.getText()); double ampl1 = Double.valueOf(ampl1Input.getText()); double ampl2 = Double.valueOf(ampl2Input.getText()); double ampl3 = Double.valueOf(ampl3Input.getText()); int discr = Integer.valueOf(discrInput.getText()); int length = Integer.valueOf(lengthInput.getText()); _presenter.showTestData2(freq1, freq2, freq3, ampl1, ampl2, ampl3, discr, length); seekSlider.setValue(0); seekSlider.setEnabled(true); load.setEnabled(false); refresh.setEnabled(true); play.setEnabled(true); stop.setEnabled(true); // _presenter.setSizeOfCount(); // calculateTimeLength(); // clip = _presenter.getWav(); // setTimer(); // refreshAll(); sliderSpectrogram.setMaximum((int) _presenter.getDataMax()); sliderSpectrogram.setMinimum((int) _presenter.getDataMin()); sliderSpectrogram.setValue((int) _presenter.getDataMax()); refreshAll(); }//GEN-LAST:event_WaveletTestActionPerformed private void waveletStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_waveletStateChanged buildSpectrogram(); buildLimitedFullSpectrogram(); }//GEN-LAST:event_waveletStateChanged private void showEnergySpectrumStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_showEnergySpectrumStateChanged if (showEnergySpectrum.isSelected()) { buildEnergyGraph(); } else { buildFourierTransformGraph(); } }//GEN-LAST:event_showEnergySpectrumStateChanged private void vDisplacementStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_vDisplacementStateChanged if (showEnergySpectrum.isSelected()) { buildEnergyGraph(); } else { buildFourierTransformGraph(); } }//GEN-LAST:event_vDisplacementStateChanged private void refreshFullGraph() { buildFullEnergyGraph(); buildLimitedFullSpectrogram(); } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(DataView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(DataView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(DataView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(DataView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new DataView().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton FourierTest; private javax.swing.JCheckBox LPF; private javax.swing.JButton WaveletTest; private javax.swing.JTextField ampl1Input; private javax.swing.JLabel ampl1Label; private javax.swing.JTextField ampl2Input; private javax.swing.JLabel ampl2Label; private javax.swing.JTextField ampl3Input; private javax.swing.JLabel ampl3Label; private javax.swing.JRadioButton autoscale; private javax.swing.JMenuItem backward; private javax.swing.JTextField chosenFileTextField; private javax.swing.JPanel contrastSpectrogram; private javax.swing.JPanel controlPanel; private javax.swing.JLabel cropBeginningLabel; private javax.swing.JTextField cropBeginningTextField; private javax.swing.JProgressBar cursor; private javax.swing.JTextField discrInput; private javax.swing.JLabel discrLabel; private javax.swing.JPanel energy; private javax.swing.ButtonGroup fftOrEnSpectrum; private javax.swing.JFileChooser fileChooser; private javax.swing.JLabel fileLengthSec; private javax.swing.JTextField fileLengthSecTextFiled; private javax.swing.JMenu fileMenu; private javax.swing.JMenuItem forward; private javax.swing.JRadioButton fourier; private javax.swing.JLabel frame; private javax.swing.JTextField frameWidthInSecondsTextField; private javax.swing.JTextField freq1Input; private javax.swing.JLabel freq1Label; private javax.swing.JTextField freq2Input; private javax.swing.JLabel freq2Label; private javax.swing.JTextField freq3Input; private javax.swing.JLabel freq3Label; private javax.swing.JPanel fullEnergy; private javax.swing.JPanel fullSpectrogram; private javax.swing.JButton jButton1; private javax.swing.JFileChooser jFileChooser1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel5; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel6; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JSplitPane jSplitPane1; private javax.swing.JSplitPane jSplitPane2; private javax.swing.JSplitPane jSplitPane3; private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JTabbedPane jTabbedPane2; private javax.swing.JToolBar jToolBar1; private javax.swing.JLabel labelForFrameScale; private javax.swing.JLabel labelForFrameSpectr; private javax.swing.JLabel labelForFullScale; private javax.swing.JLabel labelForFullSpectr; private javax.swing.JTextField lengthInput; private javax.swing.JLabel lengthLabel; private javax.swing.JLabel llabelWindowFunction; private javax.swing.JButton load; private javax.swing.JRadioButton maxValue; private javax.swing.JRadioButton meanValue; private javax.swing.JPanel middleWindow; private javax.swing.JMenuItem openItem; private javax.swing.JButton play; private javax.swing.JMenuItem playItem; private javax.swing.JLabel positionInFileSec; private javax.swing.JTextField positionInFileSecTextField; private javax.swing.JButton refresh; private javax.swing.JMenuItem refreshItem; private javax.swing.ButtonGroup scaling; private javax.swing.JSlider seekSlider; private javax.swing.JRadioButton showEnergySpectrum; private javax.swing.JMenu sliderMenu; private javax.swing.JSlider sliderSpectrogram; private javax.swing.JPanel spectrogram; private javax.swing.JPanel spectrogramPanel; private javax.swing.JSpinner spinnerDiscretization; private javax.swing.JSpinner spinnerFrameWidth; private javax.swing.JSpinner spinnerLimitFreq; private javax.swing.JSpinner spinnerWindowWidth; private javax.swing.JButton stop; private javax.swing.JMenuItem stopItem; private javax.swing.JPanel testDataPanel; private javax.swing.JPanel testPanel; private javax.swing.ButtonGroup transformation; private javax.swing.ButtonGroup v; private javax.swing.JRadioButton vAcceleration; private javax.swing.JRadioButton vDisplacement; private javax.swing.JRadioButton wavelet; private javax.swing.JLabel window; private javax.swing.JComboBox<String> windowFunction; // End of variables declaration//GEN-END:variables @Override public String getFilePath() { return chosenFileTextField.getText(); } @Override public int getFrameWidth() { return Integer.valueOf(spinnerFrameWidth.getValue().toString()); } @Override public int getWindowWidth() { return Integer.valueOf(spinnerWindowWidth.getValue().toString()); } @Override public int getFramePosition() { return this.seekSlider.getValue(); } @Override public int getDiscretization() { return Integer.valueOf(spinnerDiscretization.getValue().toString()); } @Override public void setSampleMaxValue(int maxValue) { seekSlider.setMaximum(maxValue); } @Override public void setFrameWidthInSeconds(float width) { frameWidthInSecondsTextField.setText(Float.toString(width) + " ?"); } @Override public void drawGraphOfSignal(Component comp) { contrastSpectrogram.removeAll(); contrastSpectrogram.add(comp); contrastSpectrogram.validate(); } @Override public void drawFullGraphAndSpectrOfSignal(Component comp) { fullEnergy.removeAll(); fullEnergy.add(comp); fullEnergy.validate(); } @Override public void drawGraphOfEnergySpectrum(Component comp) { energy.removeAll(); energy.add(comp); energy.validate(); } public void drawGraphOfEnergy(Component comp) { energy.removeAll(); energy.add(comp); energy.validate(); } public void drawFullGraphOfEnergy(Component comp) { fullEnergy.removeAll(); fullEnergy.add(comp); fullEnergy.validate(); } @Override public void setSpectrogram(Image spectrogramImage) { /*DefaultXYDataset dataset=new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("Title", "AxisX", "AxisY", dataset); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); plot.setRangeGridlinePaint(Color.BLUE); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); yAxis.setRange(0, 3000); yAxis.isInverted(); ChartPanel chartPanel = new ChartPanel(chart); chart.setBackgroundImage(spectrogramImage); spectrogram.removeAll(); spectrogram.add(chartPanel);*/ //sourceSignal.validate(); //!!!!! // spectrogramImage = spectrogramImage.getScaledInstance(spectrogram.getWidth(), spectrogram.getHeight(), Image.SCALE_SMOOTH); //Graphics newImage=spectrogramImage.getGraphics(); //newImage.drawString("value", 1, 900); //newImage.create(); // ValueAxis yAxis = new NumberAxis(100, 2000, 10); //!!!!!1 // labelForFrameSpectr.setIcon(new ImageIcon(spectrogramImage)); // spectrogramImage.flush(); } private void drawScale() { int specHeigth = spectrogram.getHeight() - cursor.getHeight() / 2; float limit = Integer.valueOf(spinnerLimitFreq.getValue().toString()); int frameWidth = Integer.valueOf(spinnerFrameWidth.getValue().toString()); BufferedImage scaleForFrame = new BufferedImage(SCALE_OF_SPECT, specHeigth, BufferedImage.TYPE_INT_RGB); Graphics g = scaleForFrame.getGraphics(); g.drawLine(5, 0, 5, specHeigth); Integer[] yAxis = new Integer[specHeigth / 8]; try { for (int i = 0; i < yAxis.length; i++) { yAxis[i] = (int) (i * (limit / 1024) * 100); } int j = 0; for (int i = specHeigth; i > 0; i -= specHeigth / 10) { g.drawString(yAxis[j].toString(), 7, i - 2); g.drawLine(0, i, 40, i); j++; } } catch (ArrayIndexOutOfBoundsException e) { System.out.println("To small window."); } labelForFrameScale.setIcon(new ImageIcon(scaleForFrame)); } private void drawScaleFull() { int specHeigth = fullSpectrogram.getHeight() - cursor.getHeight() / 2; float limit = Integer.valueOf(spinnerLimitFreq.getValue().toString()); int frameWidth = Integer.valueOf(spinnerFrameWidth.getValue().toString()); BufferedImage scaleForFrame = new BufferedImage(SCALE_OF_SPECT, specHeigth, BufferedImage.TYPE_INT_RGB); Graphics g = scaleForFrame.getGraphics(); g.drawLine(5, 0, 5, specHeigth); Integer[] yAxis = new Integer[specHeigth / 8]; for (int i = 0; i < yAxis.length; i++) { yAxis[i] = (int) (i * (limit / 1024) * 100); } int j = 0; for (int i = specHeigth; i > 0; i -= specHeigth / 10) { g.drawString(yAxis[j].toString(), 7, i - 2); g.drawLine(0, i, 40, i); j++; } labelForFullScale.setIcon(new ImageIcon(scaleForFrame)); } // public Image drawSpectrogram() { // double limit = Double.valueOf(spinnerLimitFreq.getValue().toString()) * 2 // / Double.valueOf(spinnerDiscretization.getValue().toString()); // return _presenter.drawSpectrogram(limit); // } // public Image drawFullSpectrogram() { // double limit = Double.valueOf(spinnerLimitFreq.getValue().toString()) * 2 // / Double.valueOf(spinnerDiscretization.getValue().toString()); // if (preciseSpectrogram.isSelected()) { // return _presenter.drawPreciseSpectrogram(limit); // } // double maxValue = sliderSpectrogram.getValue(); // return _presenter.drawFullSpectrogram(limit, maxValue); // } private void refreshTab1() { buildOscillogram(); if (showEnergySpectrum.isSelected()) { buildEnergyGraph(); } else { buildFourierTransformGraph(); } buildSpectrogram(); drawScale(); drawScaleFull(); calculateTimePosition(); } private void refreshAll() { buildOscillogram(); if (showEnergySpectrum.isSelected()) { buildEnergyGraph(); } else { buildFourierTransformGraph(); } buildFullEnergyGraph(); buildSpectrogram(); buildLimitedFullSpectrogram(); // int specHeigth = Integer.valueOf(spinnerHeigthOfSpectrogram.getValue().toString()); // // //Image spectrogram = drawSpectrogram().getScaledInstance(drawSpectrogram().getWidth(labelForImage), specHeigth, Image.SCALE_FAST); // Image spectrogram = drawSpectrogram().getScaledInstance(1270, specHeigth, Image.SCALE_FAST); ///!!!!!!!!!!!!!!!!!!!!!!!!!!!! // labelForImage.setIcon(new ImageIcon(spectrogram)); // labelForScale.setIcon(new ImageIcon(drawScale())); // ; // // _presenter.changeFrame(); // _presenter.changeMiddleWindow(fftOrEnSpectrum.getSelection().getActionCommand()); // fileLengthSecTextFiled.setText(_presenter.fileLengthInSeconds() + ""); // positionInFileSecTextField.setText(_presenter.timePositionInFile() + ""); //System.out.println(_presenter.doShortFourierTransform()[0].length + " array"); //System.out.println(_presenter.doShortFourierTransform().length + " array of arrays"); } private Integer getSpinnerFreqLimit() { int limit = Integer.valueOf(spinnerDiscretization.getValue().toString()) / 2; limit = (int) (Math.log(limit) / Math.log(2)); return (int) Math.pow(2, limit); } private Timer _frameTimer; // private void setTimer() { // final int maxFramePosition = slider.getMaximum(); // sliderCursor.setMaximum((int) (_presenter.getFrameWidthInSeconds() * 1000)); // sliderCursor.setMinimum(0); // this._frameTimer = new Timer((int) (_presenter.getFrameWidthInSeconds() * 1000), new ActionListener() { ////(Integer.valueOf(speed.getSelectedItem().toString())*Integer.valueOf(spinnerFrameWidth.getValue().toString())) // @Override // public void actionPerformed(ActionEvent e) { // System.out.println(slider.getMaximum() + " sliderMax"); // _frameCursor.schedule(new MyCursor(), 10); // int currentValue = slider.getValue(); // int shift = Integer.valueOf(spinnerFrameWidth.getValue().toString()); // // int nextValue = Math.min(maxFramePosition, currentValue + shift); // int width = (int) (_presenter.getFrameWidthInSeconds() * 1000); // _presenter.playWav(); // if (currentValue < maxFramePosition) { // DataView.this.slider.setValue(nextValue); // // } else { // DataView.this._frameTimer.stop(); // } // } // }); // } private void setTimer() { final int maxFramePosition = seekSlider.getMaximum(); final int maxFramePositionCursor = (int) (_presenter.getFrameWidthInSeconds() * 1000); int shiftCursor = maxFramePositionCursor / 100; cursor.setMaximum(maxFramePositionCursor); System.out.println(cursor.getMaximum() + " slider Cursor max"); cursor.setMinimum(0); cursor.setValue(0); this._frameTimer = new Timer((int) (_presenter.getFrameWidthInSeconds() * 10), new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int currentValue = seekSlider.getValue(); int shift = Integer.valueOf(spinnerFrameWidth.getValue().toString()); int nextValue = Math.min(maxFramePosition, currentValue + shift); int currentValueCursor = cursor.getValue(); int nextValueCursor = Math.min(maxFramePositionCursor, currentValueCursor + shiftCursor); if (currentValueCursor < maxFramePositionCursor) { DataView.this.cursor.setValue(nextValueCursor); } else if (currentValue < maxFramePosition) { cursor.setValue(0); DataView.this.seekSlider.setValue(nextValue); } else { DataView.this._frameTimer.stop(); } } }); } @Override public void stopTimer() { if (_frameTimer != null) { _frameTimer.stop(); } } public boolean getAutoscale() { return autoscale.isSelected(); } public String getTypeOfScaling() { String choice = scaling.getSelection().getActionCommand(); return choice; } public void setSliderSpectrogram(double maxValue) { sliderSpectrogram.setMaximum((int) (maxValue)); } /** * ? ? */ public void buildOscillogram() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false); double step = 1.0 / getDiscretization(); double startPosition = step * getFramePosition(); double[] data = null; if (LPF.isSelected()) { data = _presenter.lpFilter(_presenter.getFrameData(getFramePosition(), getFrameWidth()), Double.parseDouble(spinnerLimitFreq.getValue().toString())); } else { data = _presenter.getFrameData(getFramePosition(), getFrameWidth()); } for (int i = 0; i < data.length; i++) { serie.add(startPosition, data[i], ""); startPosition += step; } JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "g, /c^2", serie); chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); plot.setFixedRangeAxisSpace(GRAPHIC_SPACE); //plot.setRangeGridlinePaint(Color.BLACK); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); Range range = _presenter.getMinMaxRange(); if (range.getLength() > 0) { yAxis.setRange(range); } org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); double start = getFramePosition() * 1.0 / getDiscretization(); double max = start + getFrameWidth() * 1.0 / getDiscretization(); xAxis.setRange(start, max); ChartPanel chartPanel = new ChartPanel(chart); drawGraphOfSignal(chartPanel); } /** * ? ? */ public void buildEnergyGraph() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false); double step = 1.0 / getDiscretization(); double startPosition = step * getFramePosition(); double[] data = _presenter.getFrameEnergy(getFramePosition(), getFrameWidth(), getWindowWidth()); for (int i = 0; i < data.length; i++) { serie.add(startPosition, data[i], ""); startPosition += step * getFrameWidth() / (data.length - 1); } JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "", serie); chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); String selection = scaling.getSelection().getActionCommand(); switch (selection) { case "max": { yAxis.setRange(_presenter.getMinMaxRangeEnergy()); } break; case "mean": { yAxis.setRange(_presenter.getMeanRangeEnergy()); } break; case "auto": break; } plot.setFixedRangeAxisSpace(GRAPHIC_SPACE); org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); double start = getFramePosition() * 1.0 / getDiscretization(); double max = start + getFrameWidth() * 1.0 / getDiscretization(); xAxis.setRange(start, max); // yAxis.setRange(3.99, 4.01); ChartPanel chartPanel = new ChartPanel(chart); drawGraphOfEnergy(chartPanel); } /** * ? */ public void buildFourierTransformGraph() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false); double[] data = _presenter.getFourierTransform(getFramePosition(), getFrameWidth(), getWindowWidth()); JFreeChart chart = null; String select = v.getSelection().getActionCommand(); if (select.equalsIgnoreCase(vAcceleration.getActionCommand())) { for (int i = 0; i < data.length; i++) { serie.add(1.0 * i / getFrameWidth() * getDiscretization(), 2.0 * data[i], ""); } chart = ChartFactory.createXYLineChart("", "", "g, /?^2", serie); } else if (select.equalsIgnoreCase(vDisplacement.getActionCommand())) { for (int i = 0; i < data.length; i++) { double freq = 1.0 * i / getFrameWidth() * getDiscretization(); if (freq < 1.0) { continue; } double value = 2.0 * data[i] * Math.pow(10, 6) / Math.pow(freq, 2); serie.add(freq, value, ""); } chart = ChartFactory.createXYLineChart("", "", "?, ", serie); } else return; chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); // org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); // // org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); // yAxis.setRange(3.99, 4.01); ChartPanel chartPanel = new ChartPanel(chart); drawGraphOfEnergy(chartPanel); } /** * ? ? ? ? */ public void buildFullEnergyGraph() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false); double step = 1.0 / getDiscretization() * Integer.parseInt(spinnerWindowWidth.getValue().toString()) / 2; double startPosition = 0; double[] data = _presenter.getFullFrameEnergy(getWindowWidth()); for (int i = 0; i < data.length; i++) { serie.add(startPosition, data[i], ""); startPosition += step; } JFreeChart chart = ChartFactory.createXYLineChart("", "", "t,c", serie); chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); AxisSpace space = new AxisSpace(); space.setLeft(GRAPHIC_SPACE.getLeft() - 8); plot.setFixedRangeAxisSpace(space); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); String selection = scaling.getSelection().getActionCommand(); switch (selection) { case "max": { yAxis.setRange(_presenter.getMinMaxRangeEnergy()); } break; case "mean": { yAxis.setRange(_presenter.getMeanRangeEnergy()); } break; case "auto": break; } org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); double start = 0; double max = _presenter.getFullData().length / Double.valueOf(spinnerDiscretization.getValue().toString()); xAxis.setRange(start, max); ChartPanel chartPanel = new ChartPanel(chart); drawFullGraphOfEnergy(chartPanel); } @Deprecated public void buildEnergyGraph2() { double[] data = _presenter.getFrameEnergy(getFramePosition(), getWindowWidth(), getWindowWidth()); CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false); double step = 1.0 / getDiscretization(); double startPosition = step * getFramePosition(); for (int i = 0; i < data.length - 1; i++) { serie.add(startPosition, data[i], ""); startPosition += step; //1.0 / getDiscretization() * getFrameWidth() / (data.length - 1); } JFreeChart chart = ChartFactory.createXYLineChart("", "", "", serie); chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); double start = getFramePosition() * 1.0 / getDiscretization(); double max = start + getFrameWidth() * 1.0 / getDiscretization(); xAxis.setRange(start, max); ChartPanel chartPanel = new ChartPanel(chart); drawGraphOfEnergy(chartPanel); } public void buildFullOscillogram() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false); double step = 1.0 / getDiscretization(); double startPosition = step * getFramePosition(); double[] data = _presenter.getFullData(); for (int i = 0; i < data.length; i++) { serie.add(startPosition, data[i], ""); startPosition += step; } JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "g, /c^2", serie); chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); //plot.setRangeGridlinePaint(Color.BLACK); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); yAxis.setRange(_presenter.getMinMaxRange()); org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); double start = getFramePosition() * 1.0 / getDiscretization(); double max = start + getFrameWidth() * 1.0 / getDiscretization(); xAxis.setRange(start, max); ChartPanel chartPanel = new ChartPanel(chart); drawGraphOfSignal(chartPanel); } /** * ? ? */ void buildSpectrogram() { int cursorHeight = 19; spectrogram.setSize(spectrogram.getWidth(), jScrollPane1.getHeight() - cursorHeight); int spectHeigth = spectrogram.getHeight() - cursorHeight / 2; int spectWidth = spectrogram.getWidth() - SCALE_OF_SPECT - SPECT_RIGHT_SPACE; double limit = Double.valueOf(spinnerLimitFreq.getValue().toString()) * 2 / Double.valueOf(spinnerDiscretization.getValue().toString()); Image spectrogram = _presenter.getSpectrogram(getFramePosition(), getFrameWidth(), getWindowWidth(), limit) .getScaledInstance(spectWidth, spectHeigth, Image.SCALE_FAST); labelForFrameSpectr.setIcon(new ImageIcon(spectrogram)); drawScale(); } /** * ? ? ? */ void buildLimitedFullSpectrogram() { double limit = Double.valueOf(spinnerLimitFreq.getValue().toString()) * 2 / Double.valueOf(spinnerDiscretization.getValue().toString()); int cursorHeight = 19; fullSpectrogram.setSize(fullSpectrogram.getWidth(), jScrollPane2.getHeight() - cursorHeight); int spectHeigth = fullSpectrogram.getHeight() - cursorHeight / 2; int spectWidth = fullSpectrogram.getWidth() - SCALE_OF_SPECT - 8; Image spectrogram = _presenter.drawFullSpectrogram(limit, getWindowWidth(), sliderSpectrogram.getValue()) .getScaledInstance(spectWidth, spectHeigth, Image.SCALE_FAST); labelForFullSpectr.setIcon(new ImageIcon(spectrogram)); drawScaleFull(); } private void calculateTimeLength() { fileLengthSecTextFiled.setText("" + (_presenter.getFullData().length / Double.valueOf(spinnerDiscretization.getValue().toString()))); } private void calculateTimePosition() { positionInFileSecTextField.setText( "" + (seekSlider.getValue() / Double.valueOf(spinnerDiscretization.getValue().toString()))); } public String getTransformationType() { return transformation.getSelection().getActionCommand(); } public String getWindowFunction() { return windowFunction.getSelectedItem().toString(); } }