keel.GraphInterKeel.datacf.visualizeData.VisualizePanelAttribute.java Source code

Java tutorial

Introduction

Here is the source code for keel.GraphInterKeel.datacf.visualizeData.VisualizePanelAttribute.java

Source

/***********************************************************************
    
   This file is part of KEEL-software, the Data Mining tool for regression, 
   classification, clustering, pattern mining and so on.
    
   Copyright (C) 2004-2010
       
   F. Herrera (herrera@decsai.ugr.es)
L. Snchez (luciano@uniovi.es)
J. Alcal-Fdez (jalcala@decsai.ugr.es)
S. Garca (sglopez@ujaen.es)
A. Fernndez (alberto.fernandez@ujaen.es)
J. Luengo (julianlm@decsai.ugr.es)
    
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
    
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
    
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see http://www.gnu.org/licenses/
      
**********************************************************************/

package keel.GraphInterKeel.datacf.visualizeData;

import keel.GraphInterKeel.datacf.util.AttributeTable;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.text.DecimalFormat;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

/**
 * <p>
 * @author Written by Juan Carlos Fernndez and Pedro Antonio Gutirrez(University of Crdoba) 23/10/2008
 * @version 1.0
 * @since JDK1.5
 * </p>
 */
public class VisualizePanelAttribute extends javax.swing.JPanel {

    /**
     * <p>
     * Panel to visualize datasets
     * </p>
     */

    /**
     * <p>
     * Constructor that initializes the panel
     * </p>
     */
    public VisualizePanelAttribute() {
        initComponents();
    }

    /**
     * <p>
     * This method is called from within the constructor to
     * initialize the form.
     * </p>
     * <p>
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     * </p>
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        tablejScrollPane = new javax.swing.JScrollPane();
        this.tablejScrollPane.setEnabled(false);
        this.tablejScrollPane.setVisible(false);
        tableInfojTable = new javax.swing.JTable();
        this.tableInfojTable.getTableHeader().setReorderingAllowed(false);
        this.tableInfojTable.setEnabled(false);
        this.tableInfojTable.setVisible(false);
        infojPanel = new javax.swing.JPanel();
        extendedInfojPanel = new javax.swing.JPanel();
        valueRankjLabel = new javax.swing.JLabel();
        averagejLabel = new javax.swing.JLabel();
        variancejLabel = new javax.swing.JLabel();
        valuesjLabel = new javax.swing.JLabel();
        bracketjLabelIzdo = new javax.swing.JLabel();
        valueRankjLabelIzdo = new javax.swing.JLabel();
        comajLabel = new javax.swing.JLabel();
        valueRankjLabelDcho = new javax.swing.JLabel();
        bracketjLabelDcho = new javax.swing.JLabel();
        valueAveragejLabel = new javax.swing.JLabel();
        valueVariancejLabel = new javax.swing.JLabel();
        valuesjScrollPane = new javax.swing.JScrollPane();
        valuesjTextPane = new javax.swing.JTextPane();
        graphicsjPanel = new javax.swing.JPanel();
        clickToExpandjLabel = new javax.swing.JLabel();
        imagejScrollPane = new javax.swing.JScrollPane();
        imagejLabel = new javax.swing.JLabel();

        setName("Form"); // NOI18N

        tablejScrollPane.setBorder(javax.swing.BorderFactory
                .createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Info"));
        tablejScrollPane.setName("tablejScrollPane"); // NOI18N

        tableInfojTable.setAutoCreateRowSorter(true);
        tableInfojTable.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        tableInfojTable.setModel(this.TMtablaAtributos);
        tableInfojTable.setToolTipText("Select attribute");
        tableInfojTable.setName("tableInfojTable"); // NOI18N
        tableInfojTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableInfojTableMouseClicked(evt);
            }

            public void mousePressed(java.awt.event.MouseEvent evt) {
                tableInfojTableMousePressed(evt);
            }
        });
        tablejScrollPane.setViewportView(tableInfojTable);

        infojPanel.setName("infojPanel"); // NOI18N

        extendedInfojPanel.setBorder(javax.swing.BorderFactory
                .createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Extended Info"));
        extendedInfojPanel.setToolTipText("");
        extendedInfojPanel.setName("extendedInfojPanel"); // NOI18N

        valueRankjLabel.setText("Value Rank");
        valueRankjLabel.setName("valueRankjLabel"); // NOI18N

        averagejLabel.setText("Average");
        averagejLabel.setName("averagejLabel"); // NOI18N

        variancejLabel.setText("Variance");
        variancejLabel.setName("variancejLabel"); // NOI18N

        valuesjLabel.setText("Values");
        valuesjLabel.setName("valuesjLabel"); // NOI18N

        bracketjLabelIzdo.setText("[");
        bracketjLabelIzdo.setName("bracketjLabelIzdo"); // NOI18N

        valueRankjLabelIzdo.setName("valueRankjLabelIzdo"); // NOI18N

        comajLabel.setText(",");
        comajLabel.setName("comajLabel"); // NOI18N

        valueRankjLabelDcho.setName("valueRankjLabelDcho"); // NOI18N

        bracketjLabelDcho.setText("]");
        bracketjLabelDcho.setName("bracketjLabelDcho"); // NOI18N

        valueAveragejLabel.setName("valueAveragejLabel"); // NOI18N

        valueVariancejLabel.setName("valueVariancejLabel"); // NOI18N

        valuesjScrollPane.setName("valuesjScrollPane"); // NOI18N

        valuesjTextPane.setEditable(false);
        valuesjTextPane.setName("valuesjTextPane"); // NOI18N
        this.valuesjScrollPane.setEnabled(false);
        this.valuesjScrollPane.setVisible(false);
        this.valuesjTextPane.setEnabled(false);
        this.valuesjTextPane.setVisible(false);
        valuesjScrollPane.setViewportView(valuesjTextPane);

        javax.swing.GroupLayout extendedInfojPanelLayout = new javax.swing.GroupLayout(extendedInfojPanel);
        extendedInfojPanel.setLayout(extendedInfojPanelLayout);
        extendedInfojPanelLayout.setHorizontalGroup(extendedInfojPanelLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(extendedInfojPanelLayout.createSequentialGroup().addContainerGap()
                        .addGroup(extendedInfojPanelLayout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(extendedInfojPanelLayout.createSequentialGroup()
                                        .addGroup(extendedInfojPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(extendedInfojPanelLayout.createSequentialGroup()
                                                        .addComponent(valueRankjLabel)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(bracketjLabelIzdo))
                                                .addComponent(averagejLabel).addComponent(variancejLabel)
                                                .addComponent(valuesjLabel))
                                        .addGap(6, 6, 6)
                                        .addGroup(extendedInfojPanelLayout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(valueVariancejLabel).addComponent(valueAveragejLabel)
                                                .addGroup(extendedInfojPanelLayout.createSequentialGroup()
                                                        .addComponent(valueRankjLabelIzdo)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(comajLabel)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(valueRankjLabelDcho)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(bracketjLabelDcho))))
                                .addComponent(valuesjScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 117,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(114, Short.MAX_VALUE)));
        extendedInfojPanelLayout.setVerticalGroup(
                extendedInfojPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(extendedInfojPanelLayout.createSequentialGroup()
                                .addGroup(extendedInfojPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(valueRankjLabel).addComponent(bracketjLabelIzdo)
                                        .addComponent(valueRankjLabelIzdo).addComponent(comajLabel)
                                        .addComponent(valueRankjLabelDcho).addComponent(bracketjLabelDcho))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(extendedInfojPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(averagejLabel).addComponent(valueAveragejLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(extendedInfojPanelLayout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(variancejLabel).addComponent(valueVariancejLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(valuesjLabel).addGap(18, 18, 18)
                                .addComponent(valuesjScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 56,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(59, Short.MAX_VALUE)));

        graphicsjPanel.setBorder(javax.swing.BorderFactory
                .createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Graphic Info"));
        graphicsjPanel.setName("graphicsjPanel"); // NOI18N
        graphicsjPanel.setLayout(new java.awt.GridBagLayout());

        clickToExpandjLabel.setText("Click to Expand");
        clickToExpandjLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        clickToExpandjLabel.setName("clickToExpandjLabel"); // NOI18N
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
        graphicsjPanel.add(clickToExpandjLabel, gridBagConstraints);

        imagejScrollPane.setBorder(null);
        imagejScrollPane.setName("imagejScrollPane"); // NOI18N

        imagejLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        imagejLabel.setToolTipText("Click to Expand");
        imagejLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        imagejLabel.setName("imagejLabel"); // NOI18N
        imagejLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                imagejLabelMouseClicked(evt);
            }
        });
        imagejScrollPane.setViewportView(imagejLabel);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        graphicsjPanel.add(imagejScrollPane, gridBagConstraints);

        javax.swing.GroupLayout infojPanelLayout = new javax.swing.GroupLayout(infojPanel);
        infojPanel.setLayout(infojPanelLayout);
        infojPanelLayout.setHorizontalGroup(infojPanelLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(infojPanelLayout.createSequentialGroup()
                        .addComponent(extendedInfojPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(graphicsjPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)));
        infojPanelLayout
                .setVerticalGroup(infojPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(extendedInfojPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(graphicsjPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(tablejScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE)
                .addComponent(infojPanel, javax.swing.GroupLayout.Alignment.TRAILING,
                        javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                        Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                        .addComponent(tablejScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 145,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(infojPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    }// </editor-fold>//GEN-END:initComponents

    private void imagejLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_imagejLabelMouseClicked

        if (this.chart != null) {
            this.chart.setTitle(((VisualizePanel) this.getParent().getParent()).getData()
                    .getAttributeIndex(this.tableInfojTable.getSelectedRow()));

            ChartFrame frame = new ChartFrame("Attribute chart", chart, true);

            frame.pack();
            frame.setBackground(new Color(225, 225, 225));

            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            Dimension frameSize = frame.getSize();
            if (frameSize.height > screenSize.height) {
                frameSize.height = screenSize.height;
            }
            if (frameSize.width > screenSize.width) {
                frameSize.width = screenSize.width;
            }
            frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
            frame.setIconImage(Toolkit.getDefaultToolkit()
                    .getImage(this.getClass().getResource("/keel/GraphInterKeel/resources/ico/logo/logo.gif")));
            frame.setVisible(true);
        }
    }//GEN-LAST:event_imagejLabelMouseClicked

    private void tableInfojTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableInfojTableMouseClicked
        this.infoAttribute();
    }//GEN-LAST:event_tableInfojTableMouseClicked

    private void tableInfojTableMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableInfojTableMousePressed
        //this.infoAttribute();
    }//GEN-LAST:event_tableInfojTableMousePressed
     // Variables declaration - do not modify//GEN-BEGIN:variables

    private javax.swing.JLabel averagejLabel;
    private javax.swing.JLabel bracketjLabelDcho;
    private javax.swing.JLabel bracketjLabelIzdo;
    private javax.swing.JLabel clickToExpandjLabel;
    private javax.swing.JLabel comajLabel;
    private javax.swing.JPanel extendedInfojPanel;
    private javax.swing.JPanel graphicsjPanel;
    private javax.swing.JLabel imagejLabel;
    private javax.swing.JScrollPane imagejScrollPane;
    private javax.swing.JPanel infojPanel;
    private javax.swing.JTable tableInfojTable;
    private javax.swing.JScrollPane tablejScrollPane;
    private javax.swing.JLabel valueAveragejLabel;
    private javax.swing.JLabel valueRankjLabel;
    private javax.swing.JLabel valueRankjLabelDcho;
    private javax.swing.JLabel valueRankjLabelIzdo;
    private javax.swing.JLabel valueVariancejLabel;
    private javax.swing.JLabel valuesjLabel;
    private javax.swing.JScrollPane valuesjScrollPane;
    private javax.swing.JTextPane valuesjTextPane;
    private javax.swing.JLabel variancejLabel;
    // End of variables declaration//GEN-END:variables

    /** Chart */
    protected JFreeChart chart;

    /** Table header */
    protected String[] tableHeader = { "Attribute", "Type", "Function" };

    /** Default values */
    protected Object[] defaultValues = { " ", " ", " " };

    /** Attribute table */
    protected AttributeTable TMtablaAtributos = new AttributeTable(tableHeader, defaultValues, 0);

    /**
     * <p>
     * Clear a table of attributes
     * </p>
     */
    public void clearTable() {
        this.TMtablaAtributos = new AttributeTable(tableHeader, defaultValues, 0);
        this.tableInfojTable.setModel(this.TMtablaAtributos);
    }

    /**
     * <p>
     * Set the Atributtes Table
     * </p>
     * @param tabla Attibutes Table
     */
    public void setTMtablaAtributos(AttributeTable tabla) {
        this.TMtablaAtributos = tabla;
    }

    /**
     * <p>
     * Get the Attributes Table
     * </p>
     * @return Attributes Table
     */
    public AttributeTable getTMtablaAtributos() {
        return this.TMtablaAtributos;
    }

    /**
     * <p>
     * Set a chart for paint attributes values
     * </p>
     * @param chart JFreeChart
     */
    public void setChart(JFreeChart chart) {
        this.chart = chart;
    }

    /**
     * <p>
     * Gets Chart for paint attributes values
     * </p>
     * @return JFreeChar for attributes values
     */
    public JFreeChart getChart() {
        return this.chart;
    }

    /**
     * <p>
     * Sets left value Rank
     * </p>
     * @param value Left value rank
     */
    public void setLeftValueRank(String value) {
        this.valueRankjLabelIzdo.setText(value);
    }

    /**
     * <p>
     * Sets right value Rank
     * </p>
     * @param value right value rank
     */
    public void setRightValueRank(String value) {
        this.valueRankjLabelDcho.setText(value);
    }

    /**
     * <p>
     * Sets value average
     * </p>
     * @param value value average
     */
    public void setValueAverage(String value) {
        this.valueAveragejLabel.setText(value);
    }

    /**
     * <p>
     * Sets value variance
     * </p>
     * @param value value variance
     */
    public void setValueVariance(String value) {
        this.valueVariancejLabel.setText(value);
    }

    /**
     * <p>
     * Sets nominal values
     * </p>
     * @param value Nominal values
     */
    public void setNominalValues(String values) {
        this.valuesjTextPane.setText(values);
    }

    /**
     * <p>
     * Cotrol for Expand chart
     * </p>
     * @param value Value for Expand chart
     */
    public void setClickToExpand(String value) {
        this.clickToExpandjLabel.setText(value);
    }

    /**
     * <p>
     * Sets image of attributes
     * </p>
     * @param image Image of Attributes
     */
    public void setImage(BufferedImage image) {
        if (image == null) {
            this.imagejLabel.setIcon(null);
        } else {
            this.imagejLabel.setIcon(new ImageIcon(image));
        }
    }

    /**
     * <p>
     * Enables tha Attribute Table
     * </p>
     * @param state State of attribute Table, true or false
     */
    public void enabledTable(boolean state) {
        this.tablejScrollPane.setEnabled(state);
        this.tablejScrollPane.setVisible(state);
        this.tableInfojTable.setEnabled(state);
        this.tableInfojTable.setVisible(state);
    }

    private void infoAttribute() {
        this.enabledTable(true);
        // Extended info about selected attribute
        if (((VisualizePanel) this.getParent().getParent()).getData()
                .getAttributeTypeIndex(this.tableInfojTable.getSelectedRow()).equals("nominal")) {
            this.valuesjScrollPane.setEnabled(true);
            this.valuesjScrollPane.setVisible(true);
            this.valuesjTextPane.setEnabled(true);
            this.valuesjTextPane.setVisible(true);

            Vector r = ((VisualizePanel) this.getParent().getParent()).getData()
                    .getRangesVar(((VisualizePanel) this.getParent().getParent()).getData()
                            .getAttributeIndex(this.tableInfojTable.getSelectedRow()));

            this.valuesjTextPane.setText("");
            this.valueAveragejLabel.setText("");
            this.valueVariancejLabel.setText("");
            this.valueRankjLabelIzdo.setText("  ");
            this.valueRankjLabelDcho.setText("  ");

            String cadena = new String();
            for (int i = 0; i < r.size(); i++) {
                if (i == 0) {
                    cadena = r.elementAt(i).toString() + "";
                    this.valuesjTextPane.setText(cadena);
                } else {
                    cadena = this.valuesjTextPane.getText() + "\n" + r.elementAt(i).toString();
                }
                this.valuesjTextPane.setText(cadena);
            }
            boolean legend = false;
            // Draw bar chart
            DefaultCategoryDataset dataset = new DefaultCategoryDataset();
            try {
                for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
                    String column = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                            this.tableInfojTable.getSelectedRow());
                    String row = "";
                    if (((VisualizePanel) this.getParent().getParent()).getOutAttribute() != -1
                            && this.tableInfojTable
                                    .getSelectedRow() != ((VisualizePanel) this.getParent().getParent())
                                            .getOutAttribute()) {
                        row = "Class " + ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                                ((VisualizePanel) this.getParent().getParent()).getOutAttribute());
                        legend = true;
                    }

                    if (column != null) {
                        if (dataset.getRowIndex(row) == -1 || ((dataset.getColumnIndex(column) == -1))) {
                            dataset.addValue(1.0, row, column);
                        } else {
                            dataset.incrementValue(1.0, row, column);
                        }
                    }
                }
            } catch (ArrayIndexOutOfBoundsException exp) {
                JOptionPane.showMessageDialog(this,
                        "The data set contains some errors. This attribute can not be visualized", "Error", 2);
            }

            this.chart = ChartFactory.createBarChart3D("", "", "", dataset, PlotOrientation.VERTICAL, legend, false,
                    false);

            this.chart.setBackgroundPaint(new Color(0xFFFFFF));
            //BufferedImage image = this.chart.createBufferedImage(210, 140);
            BufferedImage image = this.chart.createBufferedImage(400, 240);
            this.imagejLabel.setIcon(new ImageIcon(image));
            this.clickToExpandjLabel.setVisible(true);
        } else {
            this.valuesjScrollPane.setEnabled(false);
            this.valuesjScrollPane.setVisible(false);
            this.valuesjTextPane.setEnabled(false);
            this.valuesjTextPane.setVisible(false);
            Vector r = ((VisualizePanel) this.getParent().getParent()).getData()
                    .getRangesVar(((VisualizePanel) this.getParent().getParent()).getData()
                            .getAttributeIndex(this.tableInfojTable.getSelectedRow()));
            this.valueRankjLabelIzdo.setText(r.elementAt(0).toString());
            this.valueRankjLabelDcho.setText(r.elementAt(1).toString());

            // Average
            double m = 0.0;
            for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
                String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                        this.tableInfojTable.getSelectedRow());
                if (valor != null) {
                    m += Double.valueOf(valor).doubleValue();
                }
            }
            m = m / ((VisualizePanel) this.getParent().getParent()).getData().getNData();
            DecimalFormat df = new DecimalFormat();
            df.setMaximumFractionDigits(3);
            this.valueAveragejLabel.setText(df.format(m));
            // Variance
            double v = 0.0;
            for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
                String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                        this.tableInfojTable.getSelectedRow());
                if (valor != null) {
                    v += Math.pow(Double.valueOf(valor).doubleValue() - m, 2);
                }
            }
            v = v / (((VisualizePanel) this.getParent().getParent()).getData().getNData() - 1);
            this.valueVariancejLabel.setText(df.format(v));

            // Draw scatter plot
            XYSeriesCollection juegoDatos = new XYSeriesCollection();
            boolean legend = false;
            if (((VisualizePanel) this.getParent().getParent()).getOutAttribute() != -1) {
                Vector outputRang = ((VisualizePanel) this.getParent().getParent()).getData()
                        .getRange(((VisualizePanel) this.getParent().getParent()).getOutAttribute());
                XYSeries series[] = new XYSeries[outputRang.size()];
                for (int i = 0; i < outputRang.size(); i++) {
                    series[i] = new XYSeries("Class " + outputRang.elementAt(i));
                    juegoDatos.addSeries(series[i]);
                }
                for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
                    int clase = outputRang.indexOf(((VisualizePanel) this.getParent().getParent()).getData()
                            .getDataIndex(i, ((VisualizePanel) this.getParent().getParent()).getOutAttribute()));
                    String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                            this.tableInfojTable.getSelectedRow());
                    if (valor != null) {
                        series[clase].add(Double.parseDouble(Integer.toString(i)),
                                Double.valueOf(valor).doubleValue());
                    }
                }
                legend = true;
            } else {
                XYSeries series = new XYSeries("Regresin");
                juegoDatos.addSeries(series);
                for (int i = 0; i < ((VisualizePanel) this.getParent().getParent()).getData().getNData(); i++) {
                    String valor = ((VisualizePanel) this.getParent().getParent()).getData().getDataIndex(i,
                            this.tableInfojTable.getSelectedRow());
                    if (valor != null) {
                        series.add(Double.parseDouble(Integer.toString(i)), Double.valueOf(valor).doubleValue());
                    }
                }

            }

            chart = ChartFactory.createScatterPlot("", "", "", juegoDatos, PlotOrientation.VERTICAL, legend, false,
                    false);
            chart.setBackgroundPaint(new Color(0xFFFFFF));
            //BufferedImage image = chart.createBufferedImage(210, 140);
            BufferedImage image = chart.createBufferedImage(400, 240);
            this.imagejLabel.setIcon(new ImageIcon(image));
            this.clickToExpandjLabel.setVisible(true);
        }
    }
}