Commit 548ff38d authored by lafabregue's avatar lafabregue

first released version v6.0

parents

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

temporary/*
*.class
# eclipse specific git ignore
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
*.hprof
File added
12
\ No newline at end of file
12
\ No newline at end of file
package mustic.models.gui.panels;
//t
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import jcl.Classification;
import jcl.data.Data;
import mustic.models.gui.charts.ScatterPlotChart;
/**
* <p>
* Permet d'affiche un nuage de point qui represente les donnees.
* </p>
*
* @author Germain FORESTIER
*/
public class ScatterPlotPanel extends JPanel {
/** serialVersionUID */
private static final long serialVersionUID = 1L;
/** Attribut des X */
JComboBox bandxCombo = new JComboBox();
/** Attribut des Y */
JComboBox bandyCombo = new JComboBox();
/** Les donnees * */
private Data data;
/** Le nuage de point */
ScatterPlotChart dataChart;
/** Variation du nombre d'objets a afficher */
JSlider nbpixelSlider = new JSlider();
/** Nombre d'objets a afficher */
JTextField nbpixelTextField = new JTextField();
/** Choix des pixels aleatoire ? */
JCheckBox randomCombo = new JCheckBox(" Random choice");
int test;
/**
* <p>
* Construteur de base.
* </p>
*
* @param data
* les donnees
* @param classification
* la classification
*/
public ScatterPlotPanel(Data data, Classification classification) {
this.data = data;
JLabel nbpixelLabel = new JLabel("Number of object");
JLabel bandxLabel = new JLabel("Object for x");
JLabel bandyLabel = new JLabel("Object for y");
JButton applyButton = new JButton("Apply");
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new GridBagLayout());
setLayout(new BorderLayout());
this.randomCombo.setSelected(true);
this.randomCombo
.setToolTipText("select random objets or select only the first objects");
centerPanel.setMaximumSize(new Dimension(250, 250));
centerPanel.setMinimumSize(new Dimension(250, 250));
centerPanel.setPreferredSize(new Dimension(130, 250));
centerPanel.add(bandxLabel, new GridBagConstraints(0, 0, 1, 1, 0.0,
0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(42, 23, 0, 7), 11, 0));
centerPanel.add(this.bandxCombo, new GridBagConstraints(0, 1, 1, 1,
1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(8, 20, 0, 16), 47, 0));
centerPanel.add(this.bandyCombo, new GridBagConstraints(0, 3, 1, 1,
1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(8, 20, 0, 16), 47, 0));
centerPanel.add(bandyLabel, new GridBagConstraints(0, 2, 1, 1, 0.0,
0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(19, 23, 0, 9), 8, 0));
centerPanel.add(this.randomCombo, new GridBagConstraints(0, 7, 1, 1,
0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(7, 7, 0, 0), 0, 0));
centerPanel
.add(this.nbpixelTextField, new GridBagConstraints(0, 6, 1, 1,
1.0, 0.0, GridBagConstraints.WEST,
GridBagConstraints.HORIZONTAL,
new Insets(9, 23, 0, 17), 61, 0));
centerPanel.add(this.nbpixelSlider, new GridBagConstraints(0, 5, 1, 1,
0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(6, 7, 0, 0), -100, 0));
centerPanel.add(nbpixelLabel, new GridBagConstraints(0, 4, 1, 1, 0.0,
0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
new Insets(22, 17, 0, 7), 0, 0));
centerPanel.add(applyButton, new GridBagConstraints(0, 8, 1, 1, 0.0,
0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets(11, 22, 9, 16), 0, 0));
for (int i = 0; i < data.getDataObject(0).getNbAttributes(); i++) {
if (classification == null
|| (classification.getClusteringResult().getWeights(0)
.getWeight(i)) != 0) {
this.bandxCombo.addItem(data.getAttributeName(i));
this.bandyCombo.addItem(data.getAttributeName(i));
}
}
this.dataChart = new ScatterPlotChart(data, classification);
add(centerPanel, BorderLayout.WEST);
add(this.dataChart, BorderLayout.CENTER);
int max = data.getNbObjects();
this.nbpixelSlider.setMaximum(max);
max = max >= 1000 ? 1000 : max;
this.nbpixelSlider.setValue(max);
this.nbpixelTextField.setText(max + "");
/* Applique les modifications */
applyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
refreshChart();
}
});
/* Change l'attribut a afficher pour les X */
this.bandxCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
refreshChart();
}
});
/* Change l'attribut a afficher pour les Y */
this.bandyCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
refreshChart();
}
});
/* Change le nombre de pixels a afficher */
this.nbpixelSlider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
ScatterPlotPanel.this.nbpixelTextField.setText(Integer
.toString(ScatterPlotPanel.this.nbpixelSlider