Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

Commit 694e5934 authored by hvernier's avatar hvernier
Browse files

maj ligne panel and distance object trie

parent f52dfc30
......@@ -45,6 +45,8 @@ public class CardinalityChart extends JPanel {
/** Le resultat a afficher */
private ClusteringResult result = null;
private ClusterViewPanel clustView = null;
TreeMap<String, ClarffxDialog> clustersDialogMap;
/**
* <p>
......@@ -60,7 +62,9 @@ public class CardinalityChart extends JPanel {
this.viewButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ClusterViewPanel clustView = new ClusterViewPanel(classification,new JLabel("tmp"));
if(clustView == null)
clustView = new ClusterViewPanel(classification,new JLabel("Cluster View"));
ClarffxDialog viewDataDialog = new ClarffxDialog( clustView, ClarffxDialog.CLOSE_BUTTONS);
viewDataDialog.setPreferredSize(new Dimension(700,500));
RefineryUtilities.centerFrameOnScreen(viewDataDialog);
......
package mustic.models.gui.charts;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.util.ArrayList;
......@@ -11,10 +12,8 @@ import javax.swing.JPanel;
import jcl.Classification;
import jcl.clustering.ClusteringResult;
import jcl.data.DataObject;
import jcl.data.SimpleData;
import jcl.data.attribute.Attribute;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.attribute.AttributeNumerical;
import jcl.data.attribute.AttributeSequence;
import jcl.data.pretraitement.Normalisation;
......@@ -62,6 +61,10 @@ public class CentroidsChart extends JPanel {
private boolean usingXY = false;
private int flagNormalisation = 0;
private double tabLigne[][] = new double[0][0];
private Color tabColorLigne[][] = new Color[0][0];
/**
* @param _classification
......@@ -73,7 +76,8 @@ public class CentroidsChart extends JPanel {
super();
this.mSeq = mSeq;
tabLigne = new double[_classification.getData().getOneDataObject().getNbAttributes()][0];
tabColorLigne = new Color[_classification.getData().getOneDataObject().getNbAttributes()][0];
this.result = _classification.getClusteringResult();
this.data[0] = this.result.getClusterCenters();
......@@ -249,6 +253,14 @@ public class CentroidsChart extends JPanel {
renderer.setSeriesShape(c, new Rectangle(-2, -2, 4, 4));
renderer.setSeriesShapesVisible(c, true);
}
if(tabColorLigne.length>0) {
for(int i =0 ; i<tabColorLigne[this.indexBande1].length ; i++) {
renderer.setSeriesPaint(i+this.result.getNbClusters(), tabColorLigne[this.indexBande1][i]);
// /*adaugat*/renderer.setSeriesShapesVisible(c, true);
renderer.setSeriesShape(i+this.result.getNbClusters(), new Rectangle(-2, -2, 4, 4));
renderer.setSeriesShapesVisible(i+this.result.getNbClusters(), true);
}
}
return mychart;
}
......@@ -278,8 +290,10 @@ public class CentroidsChart extends JPanel {
*/
private CategoryDataset createDatasetSequence(int type,int numAttr, int indexBande1) {
DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
int seqMax = 0;
double test = 0.45;
AttributeMultiDimSequence tmpAttr = null;
for (int i = 0; i < this.data[flagNormalisation].size(); i++)
for (int i = 0; i < this.data[flagNormalisation].size(); i++) {
if ((this.result.getCluster(i).isVisible()) && this.data[flagNormalisation].get(i) != null) {
if(this.data[flagNormalisation].get(i).getAttribute(numAttr) instanceof AttributeMultiDimSequence) {
tmpAttr = (AttributeMultiDimSequence) this.data[flagNormalisation].get(i)
......@@ -311,12 +325,23 @@ public class CentroidsChart extends JPanel {
}
}else if(this.data[flagNormalisation].get(i).getAttribute(numAttr) instanceof AttributeSequence) {
AttributeSequence tmpAttrSeq = (AttributeSequence) this.data[flagNormalisation].get(i).getAttribute(indexBande1);
if(tmpAttrSeq.getNbTuples()> seqMax) {
seqMax = tmpAttrSeq.getNbTuples();
}
for (int j = 0; j < tmpAttrSeq.getNbTuples(); j++) {
dataSet.addValue(tmpAttrSeq.getSequence()[j],
i + "", (j + 1) + "");
}
}
}
}
if(tabLigne.length>0) {
for(int i =0 ; i<tabLigne[indexBande1].length ; i++) {
for (int j = 0; j < seqMax; j++) {
dataSet.addValue(tabLigne[indexBande1][i],this.data[flagNormalisation].size()+i + "", (j + 1) + "");
}
}
}
return dataSet;
}
......@@ -537,6 +562,16 @@ public class CentroidsChart extends JPanel {
default:
CategoryDataset d1 = createDatasetSequence(type,0, indexBande1);
this.chart.getCategoryPlot().setDataset(d1);
int tmp1 = 0;
for (int i = 0; i < this.result.getNbClusters(); i++)
if (this.result.getCluster(i).isVisible())
tmp1++;
if(tabColorLigne.length>0) {
for(int i =0 ; i<tabColorLigne[this.indexBande1].length ; i++) {
this.chart.getCategoryPlot().getRenderer().setSeriesPaint(i+tmp1, tabColorLigne[this.indexBande1][i]);
}
}
break;
}
......@@ -740,5 +775,10 @@ public class CentroidsChart extends JPanel {
}
updateChart();
}
public void refrechLigne(int index,Color color[], double value[]) {
tabLigne[index] = value;
tabColorLigne[index] = color;
}
}
}
\ No newline at end of file
package mustic.models.gui.panels;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
......@@ -44,6 +45,9 @@ public class CentroidsPanel extends JPanel {
/** Button see graph in Python **/
JButton pythonButton = new JButton();
/** Button see graph in Python **/
JButton ligneButton = new JButton();
/** Button edit cluster centers **/
JCheckBox changeClustersCenters = new JCheckBox();
......@@ -61,6 +65,8 @@ public class CentroidsPanel extends JPanel {
private String[] complementGraph;
private Classification classif;
private LigneColorPanel lignePanel;
private JLabel lblY;
......@@ -91,6 +97,14 @@ public class CentroidsPanel extends JPanel {
*/
private void refreshChartSingle() {
this.dataChart.refresh(1,
this.coord1Combo.getSelectedIndex(),
0);
lignePanel.changeAttrSelect(this.coord1Combo.getSelectedIndex());
}
public void refreshLigne(Color tabColor[], double value[]) {
dataChart.refrechLigne(this.coord1Combo.getSelectedIndex(), tabColor, value);
this.dataChart.refresh(1,
this.coord1Combo.getSelectedIndex(),
0);
......@@ -179,7 +193,7 @@ public class CentroidsPanel extends JPanel {
// JLabel coord2Label = new JLabel("Object for y");
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new GridBagLayout());
setLayout(new BorderLayout());
......@@ -543,7 +557,7 @@ public class CentroidsPanel extends JPanel {
// this.dataChart = new CentroidsChart(classif, false, 0);
lignePanel = new LigneColorPanel(classif.getData().getOneDataObject().getNbAttributes(),0,this);
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new GridBagLayout());
setLayout(new BorderLayout());
......@@ -571,6 +585,7 @@ public class CentroidsPanel extends JPanel {
coord1Combo.setBounds(12, 168, 106, 24);
centerPanel.add(coord1Combo);
for (int i = 0; i < classif.getData().getOneDataObject().getNbAttributes(); i++) {
if(classif.getData().getAttributeName(i) == null) {
......@@ -587,6 +602,23 @@ public class CentroidsPanel extends JPanel {
}
});
}
ligneButton = new JButton("Ligne panel");
ligneButton.setBounds(12, 231, 106, 24);
centerPanel.add(ligneButton);
this.ligneButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ClarffxDialog viewDataDialog = new ClarffxDialog(lignePanel
,
ClarffxDialog.CLOSE_BUTTONS);
// viewDataDialog.setSize(700, 500);
viewDataDialog.setPreferredSize(new Dimension(200,400));
RefineryUtilities.centerFrameOnScreen(viewDataDialog);
// @todo
viewDataDialog.setTitle("Ligne Panel");
viewDataDialog.setVisible(true);
}
});
this.dataChart = new CentroidsChart(classif, true, 1);
add(this.dataChart, BorderLayout.CENTER);
......@@ -601,4 +633,4 @@ public class CentroidsPanel extends JPanel {
this.dataChart.updateChart();
// this.repaint();
}
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package mustic.models.gui.panels;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
......@@ -20,6 +21,7 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
......@@ -67,7 +69,13 @@ public class ClusterViewPanel extends JPanel{
/** Boutons d'action */
private JButton AddConstrain = new JButton("Add Constrain");
private JButton objectDistanceView = new JButton("% obj");
private JTextArea percentageObj = new JTextArea("5.0");
protected Vector<Constraint> constraintsToUse = null;
private double tabClusterDistance[][][];
/** Label du nomnom de la Classification */
JLabel nameFile = null;
......@@ -91,12 +99,14 @@ public class ClusterViewPanel extends JPanel{
this.classif = classif;
this.nameFile = nameFile;
ClusteringResult clusteringResult = classif.getClusteringResult();
tabClusterDistance = new double[classif.getNbClusters()][][];
int maxObjCluster = 0;
int clusterMap[] = clusteringResult.getClusterMap();
int countPosTab[] = new int[classif.getNbClusters()];
String[] colNames = new String[classif.getNbClusters()];
for(int i=0 ; i<classif.getNbClusters() ; i++) {
tabClusterDistance[i] = new double[clusteringResult.getCard(i)][2];
if(clusteringResult.getCard(i) > maxObjCluster)
maxObjCluster = clusteringResult.getCard(i);
}
......@@ -125,59 +135,6 @@ public class ClusterViewPanel extends JPanel{
ListSelectionModel rowSelectionModel = clusterTable.getSelectionModel();
rowSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//this.clusterTable.setColumnSelectionAllowed(true);
//this.clusterTable.setRowSelectionAllowed(true);
/*this.clusterTable.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if(e.getKeyCode()==KeyEvent.VK_CONTROL){//check if user is pressing CTRL key
pressingCTRL=true;
System.out.println("crtlOK\n");
}
}
public void keyReleased(KeyEvent e) {
if(e.getKeyCode()==KeyEvent.VK_CONTROL){//check if user released CTRL key
pressingCTRL=false;
}
}
});
this.clusterTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(pressingCTRL){//check if user is pressing CTRL key
int row = clusterTable.rowAtPoint(e.getPoint());//get mouse-selected row
int col = clusterTable.columnAtPoint(e.getPoint());//get mouse-selected col
int[] newEntry = new int[]{row,col};//{row,col}=selected cell
if(selectedCells.contains(newEntry)){
//cell was already selected, deselect it
selectedCells.remove(newEntry);
}else{
//cell was not selected
selectedCells.add(newEntry);
}
}
}
});*/
//this.clusterTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
/* Selectionne l'objet
ListSelectionModel rowSM = this.clusterTable.getSelectionModel();
rowSM.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting())
return;
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
if (!lsm.isSelectionEmpty()) {
int selectedRow = lsm.getMinSelectionIndex();
System.out.println(selectedRow);
}
}
});*/
tableScrollPane = new JScrollPane(this.clusterTable);
tableScrollPane.setPreferredSize(new Dimension(100, 100));
......@@ -201,7 +158,7 @@ public class ClusterViewPanel extends JPanel{
viewDataDialog.setVisible(true);
}
});
initTabClusterDistance();
/* South : boutons de config */
JPanel buttonPanel = new JPanel();
......@@ -216,11 +173,33 @@ public class ClusterViewPanel extends JPanel{
});
buttonPanel.add(this.AddConstrain);
}
JPanel controlPanel = new JPanel(new GridLayout(1,2));
controlPanel.add(percentageObj);
controlPanel.add(objectDistanceView);
buttonPanel.add(controlPanel);
buttonPanel.add(this.ExportToCSV);
buttonPanel.add(this.ExportToKML);
this.add(buttonPanel, BorderLayout.SOUTH);
objectDistanceView.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ObjectViewPanel objView = new ObjectViewPanel(tabClusterDistance , Double.parseDouble(percentageObj.getText()), new JLabel("jesaispas"));
ClarffxDialog viewDataDialog = new ClarffxDialog(
objView,
ClarffxDialog.CLOSE_BUTTONS);
// viewDataDialog.setSize(700, 500);
viewDataDialog.setPreferredSize(new Dimension(200,400));
RefineryUtilities.centerFrameOnScreen(viewDataDialog);
// @todo
viewDataDialog.setTitle("obj view");
viewDataDialog.setVisible(true);
}
});
}
public ClusterViewPanel() {
super(new BorderLayout());
......@@ -247,58 +226,6 @@ public class ClusterViewPanel extends JPanel{
ListSelectionModel rowSelectionModel = clusterTable.getSelectionModel();
rowSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//this.clusterTable.setColumnSelectionAllowed(true);
//this.clusterTable.setRowSelectionAllowed(true);
/*this.clusterTable.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if(e.getKeyCode()==KeyEvent.VK_CONTROL){//check if user is pressing CTRL key
pressingCTRL=true;
System.out.println("crtlOK\n");
}
}
public void keyReleased(KeyEvent e) {
if(e.getKeyCode()==KeyEvent.VK_CONTROL){//check if user released CTRL key
pressingCTRL=false;
}
}
});
this.clusterTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(pressingCTRL){//check if user is pressing CTRL key
int row = clusterTable.rowAtPoint(e.getPoint());//get mouse-selected row
int col = clusterTable.columnAtPoint(e.getPoint());//get mouse-selected col
int[] newEntry = new int[]{row,col};//{row,col}=selected cell
if(selectedCells.contains(newEntry)){
//cell was already selected, deselect it
selectedCells.remove(newEntry);
}else{
//cell was not selected
selectedCells.add(newEntry);
}
}
}
});*/
//this.clusterTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
/* Selectionne l'objet
ListSelectionModel rowSM = this.clusterTable.getSelectionModel();
rowSM.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting())
return;
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
if (!lsm.isSelectionEmpty()) {
int selectedRow = lsm.getMinSelectionIndex();
System.out.println(selectedRow);
}
}
});*/
tableScrollPane = new JScrollPane(this.clusterTable);
tableScrollPane.setPreferredSize(new Dimension(100, 100));
......@@ -333,6 +260,10 @@ public class ClusterViewPanel extends JPanel{
/* South : boutons de config */
JPanel buttonPanel = new JPanel();
JPanel controlPanel = new JPanel(new GridLayout(1,2));
controlPanel.add(percentageObj);
controlPanel.add(objectDistanceView);
buttonPanel.add(controlPanel);
buttonPanel.add(this.AddConstrain);
buttonPanel.add(this.ExportToCSV);
buttonPanel.add(this.ExportToKML);
......@@ -371,6 +302,50 @@ public class ClusterViewPanel extends JPanel{
}
}
private void initTabClusterDistance() {
for(int i=0 ; i<classif.getNbClusters() ; i++) {
List<DataObject> tmpList = classif.getClusteringResult().getCluster(i).getData(true).getViewDataObjects();
DataObject center = classif.getClusteringResult().getCluster(i).getCenter();
for(int j=0 ; j< tmpList.size() ; j++) {
tabClusterDistance[i][j][0] = tmpList.get(j).getId();
tabClusterDistance[i][j][1] = center.distance(tmpList.get(j), classif.getData().getDistanceModel(), classif.getData().getDistanceParameters()[0]);
}
quicksort(tabClusterDistance[i],0,tabClusterDistance[i].length-1);
}
}
public static void quicksort(double [][] tableau, int début, int fin) {
if (début < fin) {
int indicePivot = partition(tableau, début, fin);
quicksort(tableau, début, indicePivot-1);
quicksort(tableau, indicePivot+1, fin);
}
}
public static int partition (double [][] t, int début, int fin) {
double valeurPivot = t[début][1];
double idPivot = t[début][0];
int d = début+1;
int f = fin;
while (d < f) {
while(d < f && t[f][1] >= valeurPivot) f--;
while(d < f && t[d][1] <= valeurPivot) d++;
double temp = t[d][1];
double tempId = t[d][0];
t[d][1]= t[f][1];
t[d][0]= t[f][0];
t[f][1] = temp;
t[f][0] = tempId;
}
if (t[d][1] > valeurPivot) d--;
t[début][1] = t[d][1];
t[d][1] = valeurPivot;
t[début][0] = t[d][0];
t[d][0] = idPivot;
return d;
}
public static void main(String[]args){
ClusterViewPanel tmp = new ClusterViewPanel();
......
package mustic.models.gui.panels;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import com.alee.laf.button.WebButton;
import mustic.gui.dialog.Messages;
public class LigneColorPanel extends JPanel {
private class Line {
public double valeur;
public Color color;
public String nom;
public LigneColorPanel() {
super();
public Line(String nom, double valeur, Color color) {
this.nom = nom;
this.valeur = valeur;
this.color = color;
}
@Override
public String toString() {
return this.nom;
}
}
private List<DefaultListModel<Line>> tabLine = new ArrayList<DefaultListModel<Line>>();
private JList<Line> jListline ;
private JPanel panelline = new JPanel(new FlowLayout());
private int indices[];
private int attrSelect;
private CentroidsPanel centroidsPanel;
//Color color;
Color color;
public LigneColorPanel(int nbAttr, int attrSelect, CentroidsPanel centroidPanel ) {
super(new FlowLayout());
for(int i =0 ; i<nbAttr ; i++) {
tabLine.add(new DefaultListModel<Line>());
}
this.attrSelect = attrSelect;
this.centroidsPanel = centroidPanel;
jListline = new JList<Line>(tabLine.get(attrSelect));
JPanel controlPanel = new JPanel(new GridLayout(2,1));
JPanel buttonPanel = new JPanel(new GridLayout(1,2));
JButton addLine = new JButton("add Ligne");
JButton suppLine = new JButton("supp Ligne");
JButton addLine = new JButton("add line");
JButton suppLine = new JButton("supp line");
buttonPanel.add(addLine);
buttonPanel.add(suppLine);
JPanel linePanel = new JPanel(new GridLayout(1,2));
JPanel paramlinePanel = new JPanel(new GridLayout(1,2));
WebButton colorButton = new WebButton("color");
colorButton.setBackground(Color.CYAN);
JColorChooser colorChooser = new JColorChooser();
JTextArea value = new JTextArea("00.0");
paramlinePanel.add(colorButton);
paramlinePanel.add(value);
linePanel.add(paramlinePanel);
JTextArea name = new JTextArea("name");
linePanel.add(name);
controlPanel.add(linePanel);
controlPanel.add(buttonPanel);
this.jListline.setFixedCellHeight(25);
JScrollPane jsp_listData = new JScrollPane(this.jListline);
jsp_listData.setBorder(null);
jsp_listData.setPreferredSize(new Dimension(200, 150));
this.panelline.add(jsp_listData);
this.panelline.setBorder(BorderFactory
.createTitledBorder(Messages.getString("SequenceDialog.19"))); //$NON-NLS-1$
this.panelline.setSize(210, 300);
this.add(controlPanel, BorderLayout.NORTH);
this.add(this.panelline, BorderLayout.CENTER);
colorButton.addActionListener(new ActionListener() {
@Override