Commit a1c233f6 authored by lafabregue's avatar lafabregue

update currentview to ArrayList

parent fd23a4b8
This diff is collapsed.
......@@ -2163,10 +2163,12 @@ public class MainFrame extends JFrame {
*/
protected void createConstraints() {
try {
ConstraintsSelectionDialog dialog = new ConstraintsSelectionDialog(this.currentImageSession.getRawImage());
ConstraintsSelectionDialog dialog = new ConstraintsSelectionDialog(
this.currentImageSession.getRawImage(), null);
MainFrame.getInstance().getDesktop().addFrame(dialog);
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, Messages.getString("MainFrame.128"), Messages.getString("MainFrame.129"), //$NON-NLS-1$ //$NON-NLS-2$
JOptionPane.showMessageDialog(this, Messages.getString("MainFrame.128"),
Messages.getString("MainFrame.129"), //$NON-NLS-1$ //$NON-NLS-2$
JOptionPane.WARNING_MESSAGE);
}
}
......
......@@ -49,8 +49,18 @@ ConstraintsSelectionDialog.35=New class
ConstraintsSelectionDialog.36=class
ConstraintsSelectionDialog.50=OK
ConstraintsSelectionDialog.51=Import
ConstraintsSelectionDialog.510=The file was successfully imported.
ConstraintsSelectionDialog.511=Import
ConstraintsSelectionDialog.52=Export
ConstraintsSelectionDialog.520=From which source do you want to link the exported index ?
ConstraintsSelectionDialog.521=Image
ConstraintsSelectionDialog.522=Data
ConstraintsSelectionDialog.523=Select source
ConstraintsSelectionDialog.524=From which source are these constraints linked ?
ConstraintsSelectionDialog.525=Constraints were successfully exported.
ConstraintsSelectionDialog.526=Export
ConstraintsSelectionDialog.53=Unknown file format for import
ConstraintsSelectionDialog.54=Error
ConstraintsSelectionDialog.55=Cancel
ConstraintsSelectionDialog.7=Image
ConstraintsSelectionDialog.8=Constraint selection
......@@ -49,8 +49,18 @@ ConstraintsSelectionDialog.35=Nouvelle classe
ConstraintsSelectionDialog.36=classe
ConstraintsSelectionDialog.50=OK
ConstraintsSelectionDialog.51=Importer
ConstraintsSelectionDialog.510=Le fichier a t import avec succs
ConstraintsSelectionDialog.511=Import
ConstraintsSelectionDialog.52=Exporter
ConstraintsSelectionDialog.520=A quelle source voulez vous associer les indexes des contraintes ?
ConstraintsSelectionDialog.521=Image
ConstraintsSelectionDialog.522=Data
ConstraintsSelectionDialog.523=Slectionner source
ConstraintsSelectionDialog.524=A quelle source voulez vous associer les indexes des contraintes ?
ConstraintsSelectionDialog.525=Les contraintes ont t exportes avec succs.
ConstraintsSelectionDialog.526=Export
ConstraintsSelectionDialog.53=Format de fichier inconnu lors de l'import
ConstraintsSelectionDialog.54=Erreur
ConstraintsSelectionDialog.55=Annuler
ConstraintsSelectionDialog.7=Image
ConstraintsSelectionDialog.8=Slection des contraintes
......@@ -14,11 +14,14 @@ import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
......@@ -26,6 +29,9 @@ import jcl.data.Data;
import jcl.utils.Histogram;
import mustic.gui.ClassificationFrame;
import mustic.gui.MainFrame;
import mustic.gui.dialog.classifier.ConstraintsSelectionDialog;
import mustic.io.ImageData;
import mustic.io.RawImage;
import mustic.models.gui.dialogs.FilterDataDialog;
import mustic.models.gui.panels.DataViewPanel;
import mustic.models.gui.panels.ScatterPlotPanel;
......@@ -56,60 +62,63 @@ import org.jfree.ui.RefineryUtilities;
* @author Germain Forestier
* @see Data
*/
public class DataPanel extends JPanel {
public class DataPanel extends JPanel implements ChangeListener {
/** Necessaire */
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
JFreeChart attrChart = null;
JFreeChart attrChart = null;
/** Pour mettre a jour le chart */
ChartPanel attrChartPanel = null;
ChartPanel attrChartPanel = null;
/** Affichage dynamique selon la selection dans la table */
JLabel attrNameLabel = null;
JLabel attrNameLabel = null;
/** Table des attributs */
JTable attrTable = null;
JTable attrTable = null;
JLabel attrTypeLabel = null;
JLabel attrTypeLabel = null;
/** Affichage des classes du resultat connu s'il existe */
JPanel classesPanel = null;
JPanel classesPanel = null;
/** Table des classes */
JTable classesTable = null;
JTable classesTable = null;
/** Reference vers les donnees */
Data data = null;
Data data = null;
JButton deleteAttributeButton = new JButton("Delete Attribute");
JButton deleteAttributeButton = new JButton("Delete Attribute");
JButton doOp = new JButton("doOp");
JButton doOp = new JButton("doOp");
JButton filterButton = new JButton("Filter Attributes");
JButton filterButton = new JButton("Filter Attributes");
JLabel nbattrLabel = null;
JLabel nbattrLabel = null;
JLabel nbobjLabel = null;
JLabel nbobjLabel = null;
/** Affichage dynamique en cas de suppression d'un attr/objet */
JLabel relationLabel = null;
JLabel relationLabel = null;
/** Table des statistiques */
JTable statsTable = null;
JTable statsTable = null;
JButton viewCommentsButton = new JButton("View Comments");
JButton viewCommentsButton = new JButton("View Comments");
JButton viewDataButton = new JButton("View Data (text)");
JButton viewDataButton = new JButton("View Data (text)");
/** Boutons de choix */
JButton visualizeDataButton = new JButton("Visualize Data (chart)");
JButton visualizeDataButton = new JButton("Visualize Data (chart)");
/** Button to classify the Data */
JButton classifyButton = new JButton("Classify");
JButton classifyButton = new JButton("Classify");
/** Button to classify the Data */
JButton constraintButton = new JButton(Messages.getString("DataPanel.01"));
/** La liste des onglets */
public TabbedPanel tabbedPane = new TabbedPanel();
public TabbedPanel tabbedPane = new TabbedPanel();
/**
* <p>
......@@ -296,6 +305,7 @@ public class DataPanel extends JPanel {
buttonPanel.add(this.viewCommentsButton);
buttonPanel.add(this.filterButton);
buttonPanel.add(this.classifyButton);
buttonPanel.add(this.constraintButton);
// buttonPanel.add(doOp);
container.add(buttonPanel, BorderLayout.SOUTH);
......@@ -417,6 +427,25 @@ public class DataPanel extends JPanel {
}
}
});
this.constraintButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
RawImage img = null;
if(data instanceof ImageData) {
img = ((ImageData)data).getRawImages().get(0);
}
ConstraintsSelectionDialog dialog = new ConstraintsSelectionDialog(img, data);
MainFrame.getInstance().getDesktop().addFrame(dialog);
} catch (Exception ex) {
JOptionPane.showMessageDialog(tabbedPane, Messages.getString("ConstraintsSelectionDialog.53"),
Messages.getString("ConstraintsSelectionDialog.54"), JOptionPane.ERROR_MESSAGE);
ex.printStackTrace();
}
}
});
}
/**
......@@ -569,4 +598,13 @@ public class DataPanel extends JPanel {
this.statsTable.setModel(new ClarffxTableModel(init, initName));
}
@Override
public void stateChanged(ChangeEvent e) {
if(e.getSource() instanceof ConstraintsSelectionDialog) {
this.data.updateAndSetConstraintsToSample(
((ConstraintsSelectionDialog) e.getSource()).getConstraints());
}
}
}
......@@ -15,6 +15,7 @@ import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.text.PlainDocument;
import jcl.data.sampling.Sampler;
import mustic.gui.panels.data.DataConstructPanel;
import mustic.gui.panels.data.Messages;
import mustic.utils.documentFilter.DoubleDocumentFilter;
......@@ -42,9 +43,12 @@ public class SamplingSelectionPanel extends JPanel implements ToUpdateObject {
/** all components related to the sampling mode used */
private ButtonGroup sampleModeSelection = new ButtonGroup();
private JRadioButton intervalRadioButton = new JRadioButton(
Messages.getString("sampling.01"), true);
private JRadioButton randomRadioButton = new JRadioButton(
Messages.getString("sampling.02"), true);
/* */
/** all components related to the parmaters used */
......@@ -81,14 +85,34 @@ public class SamplingSelectionPanel extends JPanel implements ToUpdateObject {
typePanel.setLayout(new BoxLayout(typePanel, BoxLayout.Y_AXIS));
JPanel currentPanel = new JPanel();
currentPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
currentPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
intervalRadioButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(SamplingSelectionPanel.this.fatherContainer.getSample() != null) {
SamplingSelectionPanel.this.fatherContainer.getSample()
.setSamplingMethod(Sampler.INTERVAL_METHOD_TYPE);
}
}
});
currentPanel.add(intervalRadioButton);
randomRadioButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if(SamplingSelectionPanel.this.fatherContainer.getSample() != null) {
SamplingSelectionPanel.this.fatherContainer.getSample()
.setSamplingMethod(Sampler.RANDOM_METHOD_TYPE);
}
}
});
currentPanel.add(randomRadioButton);
typePanel.add(currentPanel);
this.add(typePanel);
sampleModeSelection.add(intervalRadioButton);
sampleModeSelection.add(randomRadioButton);
intervalRadioButton.setSelected(true);
this.add(buildParameters());
......
......@@ -4,10 +4,12 @@ DataConstruct.02=Sampling
DataConstruct.03=Generate
DataConstruct.04=Cancel
DataConstruct.10=other ...
DataPanel.01=Add/view constraints
source.00=MultiDate
source.01=MonoDate
source.02=Files
sampling.01=Per intervals
sampling.02=Random
sampling.20=Parameters
sampling.21=By count
sampling.22=By percentage
\ No newline at end of file
......@@ -4,10 +4,12 @@ DataConstruct.02=Echantillonnage
DataConstruct.03=Générer
DataConstruct.04=Annuler
DataConstruct.10=autre ...
DataPanel.01=Ajouter/voir les contraintes
source.00=Multi-dates
source.01=Mono-date
source.02=Fichiers
sampling.01=par intervalles
sampling.02=aléatoire
sampling.20=Paramètres
sampling.21=Par taille
sampling.22=Par pourcentage
\ No newline at end of file
package mustic.io;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import jcl.data.DataObject;
......@@ -99,7 +101,7 @@ public class ImageData extends SimpleData implements Serializable {
* To do ... this.dataObjects = ...
*/
this.currentView = new DataObject[nbPixels];
this.currentView = new ArrayList<DataObject>(nbPixels);
// Pierre
if (MainFrame.DEBUG_MODE == true)
......@@ -114,12 +116,12 @@ public class ImageData extends SimpleData implements Serializable {
// creates the object
if (!image.isMasked(x, y)) {
this.currentView[current] = new DataObject(image.getNbSelectedBands());
this.currentView.add(new DataObject(image.getNbSelectedBands()));
// fill the attributes
for (int i = 0; i < image.getNbBands()/* buffer.length */; i++) {
this.currentView[current].setAttribute(i, new AttributeNumerical(image.getPixel(x, y, i)));/*
this.currentView.get(current).setAttribute(i, new AttributeNumerical(image.getPixel(x, y, i)));/*
* buffer
* [
* i
......@@ -185,7 +187,7 @@ public class ImageData extends SimpleData implements Serializable {
int size = ww * hh;
this.setLocked(new boolean[size]);
this.currentView = new DataObject[size];
this.currentView = new ArrayList<DataObject>(size);
for (int current = 0; current < size;) {
int x = (int) (Math.random() * image.getWidth());
......@@ -199,11 +201,11 @@ public class ImageData extends SimpleData implements Serializable {
for (int y2 = 0; y2 < buffer[0][x2].length; y2++) {
// creates the object
this.currentView[current] = new DataObject(image.getNbSelectedBands());
this.currentView.add(new DataObject(image.getNbSelectedBands()));
// fill the attributes
for (int i = 0; i < buffer.length; i++) {
this.currentView[current].setAttribute(i, new AttributeNumerical(buffer[i][x2][y2]));
this.currentView.get(current).setAttribute(i, new AttributeNumerical(buffer[i][x2][y2]));
}
// unlock the pixel
......@@ -409,7 +411,7 @@ public class ImageData extends SimpleData implements Serializable {
*/
public DataObject getPixel(int index) {
// testing params
if (index >= this.currentView.length) {
if (index >= this.currentView.size()) {
PiLLiTools.error("Invalid pixel index to return", "data/ImageData.java", "getPixel(int)");
return null;
}
......@@ -449,12 +451,12 @@ public class ImageData extends SimpleData implements Serializable {
*/
public void setPixel(int index, DataObject val) {
// testing params
if (index >= this.currentView.length) {
if (index >= this.currentView.size()) {
PiLLiTools.error("Invalid pixel index to modify", "data/ImageData.java", "setPixel");
return;
}
this.currentView[index] = val;
this.currentView.set(index, val);
}
public void setResolution(double resolution) {
......@@ -476,13 +478,14 @@ public class ImageData extends SimpleData implements Serializable {
@Override
public String toString() {
String str = "";
str += " width = " + this.dimensions[0] + " height = " + this.dimensions[1] + " nbBands = " + this.currentView[0].getNbAttributes()
+ "\n";
str += " width = " + this.dimensions[0] + " height = " + this.dimensions[1] +
" nbBands = " + this.currentView.get(0).getNbAttributes() +
"\n";
str += " nombre de valeur : " + this.getNbObjects() + "\n";
for (int i = 0; i < this.currentView[0].getNbAttributes(); i++) {
str += this.currentView[i] + "\n";
for (int i = 0; i < this.currentView.get(0).getNbAttributes(); i++) {
str += this.currentView.get(i) + "\n";
}
return str;
}
......
......@@ -101,7 +101,7 @@ public class ImageMultiDimSequenceData extends SimpleData implements Serializabl
*/
this.setLocked(new boolean[nbPixels]);
this.currentView = new DataObject[nbPixels];
this.currentView = new ArrayList<DataObject>(nbPixels);
this.indexInImage = new long[nbPixels];
int xdim = seqImages[0].getWidth(), ydim = seqImages[0].getHeight();
......@@ -160,7 +160,7 @@ public class ImageMultiDimSequenceData extends SimpleData implements Serializabl
for (Integer key : values.keySet()) {
ArrayList<Double[]> seq = values.remove(key);
// every data object has one attribute : a sequence
this.currentView[globalIter] = new DataObject(1);
this.currentView.add(new DataObject(1));
this.indexInImage[globalIter] = key;
lengthHisto[seq.size()]++;
// we create a tuple array for storing a tuple sequence
......@@ -170,7 +170,7 @@ public class ImageMultiDimSequenceData extends SimpleData implements Serializabl
tArray[l][k] = seq.get(l)[k];
}
}
this.currentView[globalIter].setAttribute(0,
this.currentView.get(globalIter).setAttribute(0,
new AttributeMultiDimSequence(tArray));
this.setLocked(globalIter, false);
globalIter++;
......@@ -210,7 +210,7 @@ public class ImageMultiDimSequenceData extends SimpleData implements Serializabl
*/
this.setLocked(new boolean[nbPixels]);
this.currentView = new DataObject[nbPixels];
this.currentView = new ArrayList<DataObject>(nbPixels);
this.indexInImage = new long[nbPixels];
int xdim = seqImages[0].getWidth(), ydim = seqImages[0].getHeight();
......@@ -265,7 +265,7 @@ public class ImageMultiDimSequenceData extends SimpleData implements Serializabl
for (Integer key : values.keySet()) {
Double[] seq = values.remove(key);
// every data object has one attribute : a sequence
this.currentView[globalIter] = new DataObject(1);
this.currentView.add(new DataObject(1));
this.indexInImage[globalIter] = key;
// we create a tuple array for storing a tuple sequence
......@@ -275,7 +275,7 @@ public class ImageMultiDimSequenceData extends SimpleData implements Serializabl
tArray[l][k] = seq[l * nbBands + k];
}
}
this.currentView[globalIter].setAttribute(0,
this.currentView.get(globalIter).setAttribute(0,
new AttributeMultiDimSequence(tArray));
this.setLocked(globalIter, false);
globalIter++;
......@@ -317,7 +317,7 @@ public class ImageMultiDimSequenceData extends SimpleData implements Serializabl
*/
this.setLocked(new boolean[nbPixels]);
this.currentView = new DataObject[nbPixels];
this.currentView = new ArrayList<DataObject>(nbPixels);
/*
* les indices représentent, de gauche à droite : - le numero de l'image
......@@ -343,7 +343,7 @@ public class ImageMultiDimSequenceData extends SimpleData implements Serializabl
/* creates the objects */
if (!seqImages[0].isMasked(x, y)) {
// every data object has one attribute : a sequence
this.currentView[y * xdim + x] = new DataObject(1);
this.currentView.add(new DataObject(1));
// we create a tuple array for storing a tuple sequence
double[][] tArray = new double[seqImages.length][nbBands];
......@@ -359,7 +359,7 @@ public class ImageMultiDimSequenceData extends SimpleData implements Serializabl
}
}
tArray = Arrays.copyOf(tArray, iter);
this.currentView[y * xdim + x].setAttribute(0,
this.currentView.get(y * xdim + x).setAttribute(0,
new AttributeMultiDimSequence(tArray));
}
......@@ -412,7 +412,7 @@ public class ImageMultiDimSequenceData extends SimpleData implements Serializabl
*/
this.setLocked(new boolean[nbPixels]);
this.currentView = new DataObject[nbPixels];
this.currentView = new ArrayList<DataObject>(nbPixels);
/*
* les indices représentent, de gauche à droite : - le numero de l'image
......@@ -450,8 +450,8 @@ public class ImageMultiDimSequenceData extends SimpleData implements Serializabl
/* creates the objects */
if (!seqImages[0].isMasked(x, y)) {
// every data object has one attribute : a sequence
currentView[indexCourant] = new DataObject(1);
currentView[indexCourant].setAttribute(
currentView.add(new DataObject(1));
currentView.get(indexCourant).setAttribute(
0,
new AttributeMultiDimSequence(Arrays.copyOf(
buffer[y][x], buffer[y][x].length)));
......
package mustic.io;
import java.util.ArrayList;
import image.*;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.SimpleData;
import jcl.data.attribute.AttributeNumerical;
......@@ -50,15 +51,15 @@ public class PelicanImageData extends SimpleData {
this.setAttributesNames(names);
// instanciation de data avec les données de l'image
this.currentView = new DataObject[pelicanImage.getXDim()
* pelicanImage.getYDim()];
this.currentView = new ArrayList<DataObject>(pelicanImage.getXDim()
* pelicanImage.getYDim());
int current = 0;
for (int y = 0; y < pelicanImage.getYDim(); y++) {
for (int x = 0; x < pelicanImage.getXDim(); x++) {
this.currentView[current] = new DataObject(
pelicanImage.getBDim());
this.currentView.add(new DataObject(
pelicanImage.getBDim()));
for (int b = 0; b < pelicanImage.getBDim(); b++) {
double d = 0.0;
if (pelicanImage instanceof IntegerImage)
......@@ -66,7 +67,7 @@ public class PelicanImageData extends SimpleData {
else
// (pelicanImage instanceof DoubleImage)
d = pelicanImage.getPixelXYBDouble(x, y, b);
this.currentView[current].setAttribute(b,
this.currentView.get(current).setAttribute(b,
new AttributeNumerical(d));
}
current++;
......
......@@ -3,6 +3,7 @@ package mustic.models.gui.charts;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.util.List;
import javax.swing.JPanel;
......@@ -44,7 +45,7 @@ public class CentroidsChart extends JPanel {
private JFreeChart chart = null;
private DataObject[] data = null;
private List<DataObject> data = null;
private int indexBande1, indexBande2, type;
......@@ -200,11 +201,11 @@ public class CentroidsChart extends JPanel {
*/
private CategoryDataset createDataset() {
DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
for (int i = 0; i < this.data.length; i++)
if ((this.result.getCluster(i).isVisible()) && this.data[i] != null)
for (int j = 0; j < this.data[i].getNbAttributes(); j++) {
for (int i = 0; i < this.data.size(); i++)
if ((this.result.getCluster(i).isVisible()) && this.data.get(i) != null)
for (int j = 0; j < this.data.get(i).getNbAttributes(); j++) {
if ((this.result.getWeights(0).getWeight(j)) != 0) {
dataSet.addValue(this.data[i].getValue(j), i + "",
dataSet.addValue(this.data.get(i).getValue(j), i + "",
(j + 1) + "");
}
......@@ -220,9 +221,9 @@ public class CentroidsChart extends JPanel {
private CategoryDataset createDatasetSequence(int type, int indexBande1) {
DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
AttributeMultiDimSequence tmpAttr = null;
for (int i = 0; i < this.data.length; i++)
if ((this.result.getCluster(i).isVisible()) && this.data[i] != null) {
tmpAttr = (AttributeMultiDimSequence) this.data[i]
for (int i = 0; i < this.data.size(); i++)
if ((this.result.getCluster(i).isVisible()) && this.data.get(i) != null) {
tmpAttr = (AttributeMultiDimSequence) this.data.get(i)
.getAttribute(0);
for (int j = 0; j < tmpAttr.getNbTuples(); j++) {
switch (type) {
......@@ -311,12 +312,12 @@ public class CentroidsChart extends JPanel {
+ indexBande1 + "," + indexBande2 + ")");
AttributeMultiDimSequence tmpAttr = null;
for (int i = 0; i < this.data.length; i++) {
if ((this.result.getCluster(i).isVisible()) && this.data[i] != null) {
for (int i = 0; i < this.data.size(); i++) {
if ((this.result.getCluster(i).isVisible()) && this.data.get(i) != null) {
tmpSerie = new XYSeries("cluster" + i, false);
tmpAttr = (AttributeMultiDimSequence) this.data[i]
tmpAttr = (AttributeMultiDimSequence) this.data.get(i)
.getAttribute(0);
System.out.println("tmpAttr.getNbTuples()"
......
......@@ -10,6 +10,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
......@@ -200,7 +201,7 @@ public class ConvertValuesPanel extends JPanel {
* le fichier de destination
*/
private void convertDensity(int step, String filename) {
DataObject[] dobj = this.data.getViewDataObjects();
List<DataObject> dobj = this.data.getViewDataObjects();
Attribute[] max = this.data.getMax();
Attribute[] min = this.data.getMin();
......@@ -228,9 +229,9 @@ public class ConvertValuesPanel extends JPanel {
.getValue() + 1; i++) {
ranks.add(new Rank(i));
}
for (int i = 0; i < dobj.length; i++) {
for (int i = 0; i < dobj.size(); i++) {
for (Rank r : ranks) {