org.apache.hadoopts.app.bucketanalyser.TSOperationControlerPanel.java Source code

Java tutorial

Introduction

Here is the source code for org.apache.hadoopts.app.bucketanalyser.TSOperationControlerPanel.java

Source

/*
 * 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 org.apache.hadoopts.app.bucketanalyser;

import org.apache.commons.math3.stat.correlation.PearsonsCorrelation;
import org.apache.commons.math3.stat.regression.SimpleRegression;
import org.apache.hadoopts.app.thesis.EntropieTest;
import org.apache.hadoopts.chart.simple.MultiChart;
import org.apache.hadoopts.chart.simple.SigmaFilter;
import org.apache.hadoopts.data.export.MeasurementTable;
import org.apache.hadoopts.data.series.TimeSeriesObject;
import org.apache.hadoopts.data.series.TimeSeriesObjectFFT;
import org.apache.hadoopts.hadoopts.core.TSBucket;
import org.apache.hadoopts.statistics.HaeufigkeitsZaehlerDouble;
import org.apache.hadoopts.statphys.detrending.DetrendingMethodFactory;
import org.apache.hadoopts.statphys.detrending.MFDFAAnalyzer;
import org.apache.hadoopts.statphys.detrending.methods.IDetrendingMethod;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.entity.StandardEntityCollection;

import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author kamir
 */
public class TSOperationControlerPanel extends javax.swing.JPanel {

    /**
     * Creates new form FileControlerPanel2
     */
    public TSOperationControlerPanel() {
        initComponents();
    }

    public Vector<TimeSeriesObject> rows;

    JFreeChart chart;
    String label = null;

    String track = MacroRecorder.label_of_TRACK;

    JTextArea statsAndComments = null;

    javax.swing.JDialog holderDialog = null;

    public static String label_of_EXPERIMENT = "default";

    public static String baseFolder = null;

    public TSOperationControlerPanel(Vector<TimeSeriesObject> r, JFreeChart c, String l, JTextArea jtf) {

        this();
        rows = r;
        chart = c;
        label = l;

        statsAndComments = jtf;

        if (baseFolder == null)
            this.jTextField3.setText(this.jTextField3.getText() + label_of_EXPERIMENT + "/");
        else {
            this.jTextField3.setText(baseFolder + "/" + label_of_EXPERIMENT + "/");
        }

        this.jTextField2.setText(label);
        this.jTextField2.setToolTipText(this.getPixNodeFolder().getAbsolutePath());

    }

    public void registerPanelHolder(javax.swing.JDialog holder) {
        holderDialog = holder;
    }

    /**
     * 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">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTextField1 = new javax.swing.JTextField();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jTextField2 = new javax.swing.JTextField();
        jButton15 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jRadioButton1 = new javax.swing.JRadioButton();
        jPanel2 = new javax.swing.JPanel();
        jTextField3 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jButton18 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jButton22 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jtMIN = new javax.swing.JTextField();
        jtMAX = new javax.swing.JTextField();
        jtBINS = new javax.swing.JTextField();
        jButton10 = new javax.swing.JButton();
        jButton20 = new javax.swing.JButton();
        jButton21 = new javax.swing.JButton();
        jButton19 = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        jButton14 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jPanel7 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jButton16 = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jButton17 = new javax.swing.JButton();
        jButton23 = new javax.swing.JButton();
        jButton24 = new javax.swing.JButton();
        jButton25 = new javax.swing.JButton();
        jButton26 = new javax.swing.JButton();
        jButton27 = new javax.swing.JButton();

        jTextField1.setText("jTextField1");

        setBackground(new java.awt.Color(204, 204, 255));
        setBounds(new java.awt.Rectangle(0, 0, 800, 150));
        setMinimumSize(new java.awt.Dimension(308, 150));
        setPreferredSize(new java.awt.Dimension(800, 150));
        setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0));

        jPanel1.setBackground(new java.awt.Color(204, 204, 255));
        jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 1, 1));

        jTextField2.setBackground(new java.awt.Color(204, 255, 204));
        jTextField2.setColumns(45);
        jTextField2.setText("ChartLabel");
        jPanel1.add(jTextField2);

        jButton15.setText("persist TSB");
        jButton15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton15ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton15);

        jButton11.setText("hide");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton11);

        jRadioButton1.setText("show labels");
        jPanel1.add(jRadioButton1);

        jTabbedPane1.addTab("TSB", jPanel1);

        jPanel2.setBackground(new java.awt.Color(204, 204, 255));
        jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 1, 1));

        jTextField3.setColumns(45);
        jTextField3.setText("/GITHUB/dissertation/main/FINAL/LATEX/semanpix/");
        jTextField3.setMinimumSize(new java.awt.Dimension(40, 28));
        jTextField3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField3ActionPerformed(evt);
            }
        });
        jPanel2.add(jTextField3);

        jButton1.setBackground(new java.awt.Color(204, 204, 255));
        jButton1.setText("save PN");
        jButton1.setToolTipText("Save series in an Origin-Project.");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton1);

        jButton2.setText("show PN");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton2);

        jTabbedPane1.addTab("Pix-Node", jPanel2);

        jPanel3.setBackground(new java.awt.Color(255, 255, 204));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Single Time Series Transformations"));
        jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 1));

        jButton18.setText("Shuffle");
        jButton18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton18ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton18);

        jButton12.setText("NORM max=1");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton12);

        jButton13.setText("NORM std=1, avg=0");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton13);

        jButton22.setText("Log");
        jButton22.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton22ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton22);

        jButton9.setText("Returns (Rel-Diff)");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton9);

        jButton8.setText("Diffs");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton8);

        jButton7.setText("Profile");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton7);

        jButton3.setText("FFT");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton3);

        jTabbedPane1.addTab("Transformations", jPanel3);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Univariate Analysis"));
        jPanel4.setPreferredSize(new java.awt.Dimension(1225, 113));

        jtMIN.setText("-10");
        jPanel4.add(jtMIN);

        jtMAX.setText("10");
        jPanel4.add(jtMAX);

        jtBINS.setText("50");
        jPanel4.add(jtBINS);

        jButton10.setText("Histogram per series");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });
        jPanel4.add(jButton10);

        jButton20.setText("Histogram cross-cut");
        jButton20.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton20ActionPerformed(evt);
            }
        });
        jPanel4.add(jButton20);

        jButton21.setText("TEST Normal Distribution");
        jButton21.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton21ActionPerformed(evt);
            }
        });
        jPanel4.add(jButton21);

        jButton19.setText("CDF");
        jButton19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton19ActionPerformed(evt);
            }
        });
        jPanel4.add(jButton19);

        jButton14.setText("ENTROPY");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });
        jPanel6.add(jButton14);

        jButton4.setText("Auto-Correlation");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPanel6.add(jButton4);

        jButton5.setText("DFA");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jPanel6.add(jButton5);

        jButton6.setText("MF-DFA");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        jPanel6.add(jButton6);

        jPanel4.add(jPanel6);

        jTabbedPane1.addTab("Uni-variate. Analysis", jPanel4);

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Multi-variate analysis"));
        jTabbedPane1.addTab("Multi-variate Analysis", jPanel7);

        jPanel5.setBackground(new java.awt.Color(255, 204, 204));
        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Group Operations"));

        jButton16.setText("Sigma Band");
        jButton16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton16ActionPerformed(evt);
            }
        });
        jPanel5.add(jButton16);

        jTabbedPane1.addTab("Group Operations", jPanel5);

        jPanel8.setBackground(new java.awt.Color(204, 255, 204));
        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Models"));

        jButton17.setText("AR");
        jPanel8.add(jButton17);

        jButton23.setText("MA");
        jPanel8.add(jButton23);

        jButton24.setText("ARMA");
        jPanel8.add(jButton24);

        jButton25.setText("ARIMA");
        jPanel8.add(jButton25);

        jButton26.setText("SARIMA");
        jPanel8.add(jButton26);

        jButton27.setText("CARIMA");
        jPanel8.add(jButton27);

        jTabbedPane1.addTab("TS-Model", jPanel8);

        add(jTabbedPane1);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        try {
            save();
        } catch (IOException ex) {
            Logger.getLogger(TSOperationControlerPanel.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jButton1ActionPerformed

    private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        if (Desktop.isDesktopSupported()) {
            try {
                Desktop.getDesktop().open(getPixNodeFolder().getParentFile());
            } catch (IOException ex) {
                Logger.getLogger(TSOperationControlerPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed

        String operationLabel = "FFT of ";
        String operationPrefix = "FFT_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();

        for (TimeSeriesObject r : this.rows) {

            TimeSeriesObjectFFT rFFT = TimeSeriesObjectFFT.convertToMessreiheFFT(r);

            v.add(rFFT.getFFT(EntropieTest.samplingRate));

        }

        MultiChart.open(v, this.jRadioButton1.isSelected(), "FFT of " + this.label);

    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed

        String label = "DFA of " + this.label;

        double alpha = 0.0; // will be calculated later
        int order = 0; // will be defined later
        int nrOfSValues = 250;

        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();

        StringBuffer alphas = new StringBuffer();

        for (TimeSeriesObject d4 : this.rows) {

            try {

                int N = d4.yValues.size() / 2;

                double[] zr = new double[N];

                Vector<TimeSeriesObject> vr = new Vector<TimeSeriesObject>();

                vr.add(d4);

                zr = d4.getData()[1];

                IDetrendingMethod dfa = DetrendingMethodFactory.getDetrendingMethod(DetrendingMethodFactory.DFA2);
                order = dfa.getPara().getGradeOfPolynom();
                dfa.getPara().setzSValues(nrOfSValues);

                // Anzahl der Werte in der Zeitreihe
                dfa.setNrOfValues(N);

                // die Werte fr die Fensterbreiten sind zu whlen ...
                dfa.initIntervalS();
                //                dfa.initIntervalSlog();

                dfa.showS();

                // http://stackoverflow.com/questions/12049407/build-sample-data-for-apache-commons-fast-fourier-transform-algorithm
                dfa.setZR(d4.getData()[1]);

                dfa.calc();

                TimeSeriesObject mr4 = dfa.getResultsMRLogLog();

                alphas.append(mr4.getLabel() + "\t" + alpha + "\n");

                mr4.setLabel(d4.getLabel());

                String status = dfa.getStatus();

                SimpleRegression alphaSR = mr4.linFit(EntropieTest.fitMIN, EntropieTest.fitMAX);

                alpha = alphaSR.getSlope();

                System.out.println(status);

                mr4.setLabel(mr4.getLabel() + "_alpha=" + alpha);
                v.add(mr4);

            } catch (Exception ex) {
                Logger.getLogger(TSOperationControlerPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        if (true) {
            DecimalFormat df = new DecimalFormat("0.000");
            MultiChart.open(v, label + " fluctuation function F(s) [order:" + order + "] ", "log(s)", "log(F(s))",
                    this.jRadioButton1.isSelected(), alphas.toString(), null);

            System.out.println(" alpha = " + df.format(alpha));
            System.out.println("       = " + ((2 * alpha) - 1.0));
        }

        String operationLabel = "DFA of ";
        String operationPrefix = "DFA_" + order;

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed

        String operationLabel = "AC of ";
        String operationPrefix = "AC_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();

        for (TimeSeriesObject r : this.rows) {
            TimeSeriesObject ac = new TimeSeriesObject();
            ac.setLabel("AC_" + r.label);

            PearsonsCorrelation pc = new PearsonsCorrelation();

            for (int i = 0; i < r.getYData().length / 2; i = i + 1) {

                try {

                    TimeSeriesObject mr1 = r.shift(i);

                    double ac_i = pc.correlation(mr1.getYData(), r.getYData());

                    ac.addValuePair(i, ac_i);

                } catch (Exception ex) {
                    Logger.getLogger(TSOperationControlerPanel.class.getName()).log(Level.SEVERE, null, ex);
                }

            }
            v.add(ac);

        }

        MultiChart.open(v, this.jRadioButton1.isSelected(), "AUTO-CORRELATION of " + this.label);
    }//GEN-LAST:event_jButton4ActionPerformed

    /**
     * Calculate Profiles ...
     *
     * @param evt
     */
    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed

        String operationLabel = "Profile of ";
        String operationPrefix = "Profile_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();

        for (TimeSeriesObject r : this.rows) {

            TimeSeriesObject profile = r.getProfile();
            v.add(profile);

        }

        MultiChart.open(v, this.jRadioButton1.isSelected(), target);

    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        String operationLabel = "Diff of ";
        String operationPrefix = "Diff_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();

        for (TimeSeriesObject r : this.rows) {

            TimeSeriesObject diffs = r.getNextDiffs();
            v.add(diffs);

        }

        MultiChart.open(v, this.jRadioButton1.isSelected(), "Diff of " + this.label);
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed

        String operationLabel = "LogRETURN of ";
        String operationPrefix = "LogRETURN_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();

        for (TimeSeriesObject r : this.rows) {

            TimeSeriesObject diffs = r.getLogReturn();
            v.add(diffs);

        }

        MultiChart.open(v, this.jRadioButton1.isSelected(), "LogRETURN of " + this.label);
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed

        String operationLabel = "PDF of ";
        String operationPrefix = "PDF_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();

        double minY = Integer.parseInt(this.jtMIN.getText());
        double maxY = Integer.parseInt(this.jtMAX.getText());
        int bins = Integer.parseInt(this.jtBINS.getText());

        for (TimeSeriesObject r : this.rows) {

            TimeSeriesObject distr = r.distributionOfYValues((int) minY, (int) maxY, bins);
            v.add(distr);

        }

        MultiChart.open(v, this.jRadioButton1.isSelected(), "y-value distributions of " + this.label);

    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed

        String operationLabel = "Norm MAX of ";
        String operationPrefix = "NormMAX_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();

        for (TimeSeriesObject r : this.rows) {

            TimeSeriesObject a = r.copy();
            a.normalize();

            v.add(a);

        }

        MultiChart.open(v, this.jRadioButton1.isSelected(), "NORM_MAX=1 of " + this.label);

    }//GEN-LAST:event_jButton12ActionPerformed

    public static String correlatorClass = "experiments.Correlator";

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
        String operationLabel = "Standardized of ";
        String operationPrefix = "Standardized_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();

        for (TimeSeriesObject r : this.rows) {

            TimeSeriesObject a = r.copy();

            a = a.normalizeToStdevIsOne();

            v.add(a);

        }

        try {

            ICorrelator c = (ICorrelator) Class.forName(correlatorClass).newInstance();

            MultiChart.openWithCorrelator(v, this.jRadioButton1.isSelected(), "NORM_STD=1,AVG=0 of " + this.label,
                    c);

        } catch (ClassNotFoundException ex) {
            Logger.getLogger(TSOperationControlerPanel.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(TSOperationControlerPanel.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(TSOperationControlerPanel.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jButton13ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed

        String operationLabel = "H of ";
        String operationPrefix = "H_";

        String source = this.label;
        String target = operationPrefix + this.label;

        int l = Integer.parseInt(javax.swing.JOptionPane.showInputDialog("Length: "));

        Vector<TimeSeriesObject> slidingWindowResults = new Vector<TimeSeriesObject>();

        for (TimeSeriesObject comp : this.rows) {

            slidingWindowResults.add(comp.calcEntropyForWindow(l));
        }

        MultiChart.open(slidingWindowResults, this.jRadioButton1.isSelected(), target);
        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

    }//GEN-LAST:event_jButton14ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        String operationLabel = "MFDFA of ";
        String operationPrefix = "MFDFA_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        try {

            MFDFAAnalyzer.process(this.rows, "MFDFA of " + this.label);

        } catch (Exception ex) {
            Logger.getLogger(TSOperationControlerPanel.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jButton6ActionPerformed

    public void persistTSB() {

        TSBucket tsb = new TSBucket();

        try {

            tsb.createBucketFromVectorOfSeries(this.track, this.label, this.rows);

        } catch (IOException ex) {
            Logger.getLogger(TSOperationControlerPanel.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed

    }//GEN-LAST:event_jButton15ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed

        holderDialog.setVisible(false);

    }//GEN-LAST:event_jButton11ActionPerformed

    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed

        String operationLabel = "AVG of ";
        String operationPrefix = "AVG_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));
        SigmaFilter.open(this.rows, "AVG for " + this.label, true);

    }//GEN-LAST:event_jButton16ActionPerformed

    private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed
        String operationLabel = "Shuffle of ";
        String operationPrefix = "Shuffle_";

        String source = this.label;
        String target = operationPrefix + this.label;

        try {

            int l = Integer.parseInt(javax.swing.JOptionPane.showInputDialog("Nr fo shuffelings: "));

            Vector<TimeSeriesObject> shuffled = new Vector<TimeSeriesObject>();

            for (TimeSeriesObject comp : this.rows) {
                TimeSeriesObject m = comp.copy();
                m.shuffleYValues(l);
                shuffled.add(m);
            }

            MultiChart.open(shuffled, this.jRadioButton1.isSelected(), target);
            MacroTrackerFrame.addTransformation(
                    TSBucketTransformation.getTransformation(source, target, operationLabel + source));

        } catch (Exception ex) {
            Logger.getLogger(TSOperationControlerPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton18ActionPerformed

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton19ActionPerformed

        String operationLabel = "CDF of ";
        String operationPrefix = "CDF_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();

        for (TimeSeriesObject r : this.rows) {

            TimeSeriesObject distr = r.cumulatedDistributionOfYValues(30);
            v.add(distr);

        }

        MultiChart.open(v, this.jRadioButton1.isSelected(), "y-value distributions of " + this.label);

    }//GEN-LAST:event_jButton19ActionPerformed

    private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton20ActionPerformed

        String operationLabel = "PDF (cross)";
        String operationPrefix = "PDF_cross_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        String i = javax.swing.JOptionPane.showInputDialog("Window length l=");

        int l = Integer.parseInt(i);
        int pos = 0;

        double minY = Integer.parseInt(this.jtMIN.getText());
        double maxY = Integer.parseInt(this.jtMAX.getText());
        int bins = Integer.parseInt(this.jtBINS.getText());

        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();

        // create series of cuts ...
        while (pos < this.rows.elementAt(0).getXValues().size()) {

            System.out.println(pos + " => " + (pos + l));

            HaeufigkeitsZaehlerDouble hz = new HaeufigkeitsZaehlerDouble();

            hz.setLabel(pos + "_" + (pos + l));

            hz.min = minY;
            hz.max = maxY;

            hz.intervalle = bins;

            for (TimeSeriesObject r : this.rows) {

                hz.addData(r.cutOut(pos, pos + l).getYValues());

            }

            hz.calcWS();

            v.add(hz.getHistogram());
            pos = pos + l;

        }

        MultiChart.open(v, this.jRadioButton1.isSelected(),
                "y-value distributions (tims slice l=" + l + " of " + this.label);

    }//GEN-LAST:event_jButton20ActionPerformed

    private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton21ActionPerformed

        String operationLabel = "PDF (SW_pvalues)";
        String operationPrefix = "PDF_SW_pvalues_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        int[] L = { 20, 40, 60, 80, 100 };

        double minY = 0.0;
        double maxY = 1.0;
        int bins = 100;

        // PDFS
        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();
        Vector<TimeSeriesObject> v2 = new Vector<TimeSeriesObject>();

        // create series of cuts ...
        for (int l : L) {

            int pos = 0;

            HaeufigkeitsZaehlerDouble hz = new HaeufigkeitsZaehlerDouble();

            hz.setLabel("SW_PDF_pvalues l=" + l);

            hz.min = minY;
            hz.max = maxY;

            hz.intervalle = bins;

            while (pos < this.rows.elementAt(0).getXValues().size()) {

                System.out.println(pos + " => " + (pos + l));

                for (TimeSeriesObject r : this.rows) {

                    try {
                        TimeSeriesObject cut = r.cutOut(pos, pos + l);

                        if (cut.yValues.size() == l) {

                            double t = cut.getSWTestResult()[0];

                            double pVal = cut.getSWTestResult()[1];

                            hz.addData(t);
                        }
                    } catch (IOException ex) {
                        Logger.getLogger(TSOperationControlerPanel.class.getName()).log(Level.SEVERE, null, ex);
                    }

                }

                pos = pos + l;

            }

            hz.calcWS();

            v.add(hz.getHistogramNORM());

            hz.mrCUMUL.normalize();
            hz.mrCUMUL.setLabel("l=" + l);

            v2.add(hz.mrCUMUL);

        }

        MultiChart.open(v, this.jRadioButton1.isSelected(), "SW t-value distributions of " + this.label);
        MultiChart.open(v2, this.jRadioButton1.isSelected(), "SW CDF of " + this.label);

    }//GEN-LAST:event_jButton21ActionPerformed

    private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton22ActionPerformed

        String operationLabel = "Log of ";
        String operationPrefix = "LOG_";

        String source = this.label;
        String target = operationPrefix + this.label;

        MacroTrackerFrame
                .addTransformation(TSBucketTransformation.getTransformation(source, target, operationLabel));

        Vector<TimeSeriesObject> v = new Vector<TimeSeriesObject>();

        for (TimeSeriesObject r : this.rows) {

            TimeSeriesObject diffs = r.calcMR_Log_for_Y();

            v.add(diffs);

        }

        MultiChart.open(v, this.jRadioButton1.isSelected(), "Log of " + this.label);
    }//GEN-LAST:event_jButton22ActionPerformed

    public void storeChartImageAsPNG(JFreeChart chart, File folder, String filename) {

        String fn = filename;
        try {

            final File file1 = new File(folder.getAbsolutePath() + File.separator + fn + ".png");
            System.out.println("\n>>> Save as PNG Image - Filename: " + file1.getAbsolutePath() + "; CP: " + chart);
            try {
                final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());

                Thread.currentThread().sleep(1000);

                ChartUtilities.saveChartAsPNG(file1, chart, 800, 600, info);

                Thread.currentThread().sleep(1000);

            } catch (Exception e) {
                e.printStackTrace();
            }

            //                File file = new File(folder.getAbsolutePath() + File.separator + fn + ".svg");
            //                System.out.println(">>> Save as SVG Image - Filename: " + file.getAbsolutePath()
            //                        + "; CP: "+ cp);
            //
            //
            //                // Get a DOMImplementation and create an XML document
            //                DOMImplementation domImpl =
            //                        GenericDOMImplementation.getDOMImplementation();
            //                Document document = domImpl.createDocument(null, "svg", null);
            //
            //                // Create an instance of the SVG Generator
            //                SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
            //
            //                // draw the chart in the SVG generator
            //                cp.draw(svgGenerator, new Rectangle(800, 600));
            //
            //                // Write svg file
            //                OutputStream outputStream = new FileOutputStream(file);
            //                Writer out = new OutputStreamWriter(outputStream, "UTF-8");
            //                svgGenerator.stream(out, true /* use css */);
            //                outputStream.flush();
            //                outputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton20;
    private javax.swing.JButton jButton21;
    private javax.swing.JButton jButton22;
    private javax.swing.JButton jButton23;
    private javax.swing.JButton jButton24;
    private javax.swing.JButton jButton25;
    private javax.swing.JButton jButton26;
    private javax.swing.JButton jButton27;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jtBINS;
    private javax.swing.JTextField jtMAX;
    private javax.swing.JTextField jtMIN;
    // End of variables declaration//GEN-END:variables

    private File getPixNodeFolder() {

        String fn = jTextField3.getText() + this.jTextField2.getText();
        fn = fn.replaceAll("[^a-zA-Z0-9.-/]", "_");
        return new File(fn);
    }

    public void save() throws IOException {

        File folder = getPixNodeFolder();

        String fn = this.jTextField2.getText().replaceAll("[^a-zA-Z0-9.-/]", "_");

        MeasurementTable tab = new MeasurementTable();

        String mwtData = folder.getAbsolutePath() + "/" + fn + ".mwt.tsv";

        tab.setMessReihen(this.rows);
        tab.writeToFile(new File(mwtData));

        storeChartImageAsPNG(chart, folder.getParentFile(), fn);

        if (statsAndComments != null) {

            File fCAP = new File(folder.getParentFile().getAbsolutePath() + "/caption_" + fn + ".tex");
            FileWriter fw2 = new FileWriter(fCAP);

            fw2.write(statsAndComments.getText());

            fw2.flush();
            fw2.close();

        }

    }

    public void addCorrelationButton(JButton b) {
        this.jPanel5.add(b);
    };
}