Commit fd23a4b8 authored by lafabregue's avatar lafabregue

integration of cluster constraints

parent 645e82ae
No preview for this file type
...@@ -592,6 +592,7 @@ public class MainFrame extends JFrame { ...@@ -592,6 +592,7 @@ public class MainFrame extends JFrame {
} }
}); });
ArffMenu.add(menuItemArff); ArffMenu.add(menuItemArff);
menuItemRaw = new JMenuItem("RawImage to Arff"); //$NON-NLS-1$ menuItemRaw = new JMenuItem("RawImage to Arff"); //$NON-NLS-1$
menuItemRaw.addActionListener(new ActionListener() { menuItemRaw.addActionListener(new ActionListener() {
@Override @Override
...@@ -600,6 +601,7 @@ public class MainFrame extends JFrame { ...@@ -600,6 +601,7 @@ public class MainFrame extends JFrame {
} }
}); });
ArffMenu.add(menuItemRaw); ArffMenu.add(menuItemRaw);
menuItemLoadArff = new JMenuItem(Messages.getString("MainFrame.34")); //$NON-NLS-1$ menuItemLoadArff = new JMenuItem(Messages.getString("MainFrame.34")); //$NON-NLS-1$
menuItemLoadArff.addActionListener(new ActionListener() { menuItemLoadArff.addActionListener(new ActionListener() {
@Override @Override
...@@ -618,6 +620,24 @@ public class MainFrame extends JFrame { ...@@ -618,6 +620,24 @@ public class MainFrame extends JFrame {
}); });
ArffMenu.add(menuItemArffImage); ArffMenu.add(menuItemArffImage);
menuItemArffData = new JMenuItem(Messages.getString("MainFrame.303")); //$NON-NLS-1$
menuItemArffData.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
toolsMenuDataToArff();
}
});
ArffMenu.add(menuItemArffData);
menuItemLoadArffToData = new JMenuItem(Messages.getString("MainFrame.302")); //$NON-NLS-1$
menuItemLoadArffToData.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
toolsMenuArffToData();
}
});
ArffMenu.add(menuItemLoadArffToData);
menuBar.add(ArffMenu); menuBar.add(ArffMenu);
// Preprocessing // Preprocessing
...@@ -982,6 +1002,10 @@ public class MainFrame extends JFrame { ...@@ -982,6 +1002,10 @@ public class MainFrame extends JFrame {
private Boolean actionRaw; private Boolean actionRaw;
private JMenuItem menuItemLoadArff; private JMenuItem menuItemLoadArff;
private Boolean actionLoadArff; private Boolean actionLoadArff;
private JMenuItem menuItemLoadArffToData;
private Boolean actionLoadArffToData;
private JMenuItem menuItemArffData;
private Boolean actionArffData;
private JMenuItem menuItemArffImage; private JMenuItem menuItemArffImage;
private Boolean actionArffImage; private Boolean actionArffImage;
private JMenuItem menuItemVegetation; private JMenuItem menuItemVegetation;
...@@ -1070,6 +1094,8 @@ public class MainFrame extends JFrame { ...@@ -1070,6 +1094,8 @@ public class MainFrame extends JFrame {
this.actionConfig = true; this.actionConfig = true;
this.actionHelp = true; this.actionHelp = true;
this.actionLoadArff = true; this.actionLoadArff = true;
this.actionLoadArffToData = true;
this.actionArffData = true;
this.actionNew = true; this.actionNew = true;
this.actionOpen = true; this.actionOpen = true;
this.actionOpenRes = true; this.actionOpenRes = true;
...@@ -1160,6 +1186,8 @@ public class MainFrame extends JFrame { ...@@ -1160,6 +1186,8 @@ public class MainFrame extends JFrame {
menuItemRaw.setEnabled(this.actionRaw); menuItemRaw.setEnabled(this.actionRaw);
menuItemLoadArff.setEnabled(this.actionLoadArff); menuItemLoadArff.setEnabled(this.actionLoadArff);
menuItemArffImage.setEnabled(this.actionArffImage); menuItemArffImage.setEnabled(this.actionArffImage);
menuItemArffData.setEnabled(this.actionArffData);
menuItemLoadArffToData.setEnabled(this.actionLoadArffToData);
menuZoomIn.setEnabled(this.actionZoomIn); menuZoomIn.setEnabled(this.actionZoomIn);
menuZoomOut.setEnabled(this.actionZoomOut); menuZoomOut.setEnabled(this.actionZoomOut);
menuBrightP.setEnabled(this.actionBrightP); menuBrightP.setEnabled(this.actionBrightP);
...@@ -2135,8 +2163,7 @@ public class MainFrame extends JFrame { ...@@ -2135,8 +2163,7 @@ public class MainFrame extends JFrame {
*/ */
protected void createConstraints() { protected void createConstraints() {
try { try {
ConstraintsSelectionDialog dialog = new ConstraintsSelectionDialog(); ConstraintsSelectionDialog dialog = new ConstraintsSelectionDialog(this.currentImageSession.getRawImage());
dialog.setImage(this.currentImageSession.getRawImage());
MainFrame.getInstance().getDesktop().addFrame(dialog); MainFrame.getInstance().getDesktop().addFrame(dialog);
} catch (Exception ex) { } 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$
...@@ -3334,6 +3361,19 @@ public class MainFrame extends JFrame { ...@@ -3334,6 +3361,19 @@ public class MainFrame extends JFrame {
arff.toFront(); arff.toFront();
} }
private void toolsMenuArffToData() {
DataToArffDialog dialog = new DataToArffDialog();
this.desktop.add(dialog);
dialog.toFront();
}
private void toolsMenuDataToArff() {
DataToArffDialog dialog = new DataToArffDialog();
this.desktop.add(dialog);
dialog.toFront();
}
private void toolsMenuClustering() throws Exception { private void toolsMenuClustering() throws Exception {
// MainFrame.getInstance().getDesktop().addFrame(ClassificationFrame.getInstance()); // MainFrame.getInstance().getDesktop().addFrame(ClassificationFrame.getInstance());
if (!ClassificationFrame.isCreated()) { if (!ClassificationFrame.isCreated()) {
......
package mustic.gui.dialog;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import jcl.data.Data;
import mustic.gui.DataDesktopFrame;
import mustic.gui.MainFrame;
import mustic.utils.dataExchange.DataArffExchange;
/**
* Fenetre permettant de creer des fichier ARFF à partir d'un image
*
*/
public class DataToArffDialog extends JInternalFrame {
private static final long serialVersionUID = 1L;
/** liste des images ouvertes */
private JComboBox<String> comboData = new JComboBox<String>();
/** nombre de divisions */
private JSpinner spinner = new JSpinner();
/** chemin du fichier que l'on va créer */
private JTextField textSave = new JTextField();
private JTextField txtDate;
public DataToArffDialog() {
super();
JPanel mainPanel = new JPanel(new BorderLayout());
JPanel panelData = new JPanel(new GridLayout(4, 2));
panelData.add(new JLabel(Messages.getString("DataToArffDialog.0"))); //$NON-NLS-1$
DataDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllDataDesktopFrames();
int nbSession = desktopFrames.length;
for (int i = 0; i < nbSession; i++) {
String name = desktopFrames[i].getDataSession().getTitle();
this.comboData.addItem(name);
}
if (nbSession == 0) {
JOptionPane.showMessageDialog(this, Messages.getString("DataToArffDialog.24"), //$NON-NLS-1$
Messages.getString("DataToArffDialog.23"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
return;
}
this.comboData.setPreferredSize(new Dimension(100, 30));
panelData.add(comboData);
panelData.add(new JLabel(Messages.getString("DataToArffDialog.12"))); //$NON-NLS-1$
JPanel panelSave = new JPanel(new BorderLayout());
JButton buttonBrowse = new JButton(Messages.getString("DataToArffDialog.13")); //$NON-NLS-1$
buttonBrowse.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
DataDesktopFrame[] desktopFrames = MainFrame.getInstance()
.getDesktop().getAllDataDesktopFrames();
int nbSessions = desktopFrames.length;
if (nbSessions > 0) {
String name = desktopFrames[comboData.getSelectedIndex()]
.getDataSession().getData().getDataName();
String path = "~/" + name + ".arff"; //$NON-NLS-1$
File f = new File(path);
fileChooser.setSelectedFile(f);
}
int returnVal = fileChooser
.showSaveDialog(DataToArffDialog.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
String path = fileChooser.getSelectedFile().getPath();
textSave.setText(path);
}
}
});
panelSave.add(this.textSave, BorderLayout.CENTER);
panelSave.add(buttonBrowse, BorderLayout.EAST);
panelData.add(panelSave);
txtDate = new JTextField();
DateFormat formatDate=new SimpleDateFormat("ddMMyy");
txtDate.setText(formatDate.format(new Date()));
panelData.add(new JLabel(Messages.getString("DataToArffDialog.15"))); //$NON-NLS-1$
panelData.add(txtDate);
panelData.add(new JLabel(Messages.getString("DataToArffDialog.16"))); //$NON-NLS-1$
JSpinner.NumberEditor spinnerEditor = new JSpinner.NumberEditor(
this.spinner);
this.spinner.setEditor(spinnerEditor);
spinnerEditor.getModel().setMinimum(1);
spinnerEditor.getModel().setMaximum(256);
spinnerEditor.getModel().setStepSize(1);
spinnerEditor.getModel().setValue(10);
panelData.add(this.spinner);
JPanel panelOk = new JPanel();
JButton buttonOk = new JButton(Messages.getString("DataToArffDialog.17")); //$NON-NLS-1$
buttonOk.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
buttonOk_actionPerformed();
}
});
panelOk.add(buttonOk);
mainPanel.add(panelData, BorderLayout.NORTH);
mainPanel.add(panelOk, BorderLayout.SOUTH);
this.setContentPane(mainPanel);
this.setTitle(Messages.getString("DataToArffDialog.18")); //$NON-NLS-1$
this.setSize(350, 175);
this.setResizable(true);
this.setMaximizable(true);
this.setIconifiable(true);
this.setClosable(true);
this.setVisible(true);
}
/**
* lance la création du fichier arff
*/
protected void buttonOk_actionPerformed() {
DataDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllDataDesktopFrames();
int nbSessions = desktopFrames.length;
if (nbSessions == 0) {
JOptionPane.showMessageDialog(this,
Messages.getString("DataToArffDialog.19"), Messages.getString("DataToArffDialog.20"), //$NON-NLS-1$ //$NON-NLS-2$
JOptionPane.WARNING_MESSAGE);
this.dispose();
} else if (this.textSave.getText().equals("")) { //$NON-NLS-1$
JOptionPane.showMessageDialog(this, Messages.getString("DataToArffDialog.22"), //$NON-NLS-1$
Messages.getString("DataToArffDialog.23"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$
} else {
Data data = desktopFrames[this.comboData.getSelectedIndex()]
.getDataSession().getData();
DataArffExchange.dataToArff(this.textSave.getText(), data);
JOptionPane.showMessageDialog(this,
Messages.getString("DataToArffDialog.44"), Messages.getString("DataToArffDialog.45"), //$NON-NLS-1$ //$NON-NLS-2$
JOptionPane.INFORMATION_MESSAGE);
this.dispose();
}
}
}
...@@ -21,6 +21,7 @@ import javax.swing.JPanel; ...@@ -21,6 +21,7 @@ import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
import mustic.gui.DesktopFrame; import mustic.gui.DesktopFrame;
import mustic.gui.ImageDesktopFrame;
import mustic.gui.MainFrame; import mustic.gui.MainFrame;
import mustic.io.RawImage; import mustic.io.RawImage;
...@@ -47,8 +48,8 @@ public class RawImageToArffDialog extends JInternalFrame { ...@@ -47,8 +48,8 @@ public class RawImageToArffDialog extends JInternalFrame {
JPanel panelData = new JPanel(new GridLayout(2, 2)); JPanel panelData = new JPanel(new GridLayout(2, 2));
panelData.add(new JLabel(Messages.getString("ImageToArffDialog.0"))); //$NON-NLS-1$ panelData.add(new JLabel(Messages.getString("ImageToArffDialog.0"))); //$NON-NLS-1$
DesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop() ImageDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllDesktopFrames(); .getAllImageDesktopFrames();
int nbSession = desktopFrames.length; int nbSession = desktopFrames.length;
for (int i = 0; i < nbSession; i++) { for (int i = 0; i < nbSession; i++) {
String path = desktopFrames[i].getImageSession().getRawImage() String path = desktopFrames[i].getImageSession().getRawImage()
...@@ -76,8 +77,8 @@ public class RawImageToArffDialog extends JInternalFrame { ...@@ -76,8 +77,8 @@ public class RawImageToArffDialog extends JInternalFrame {
.getString("ImageToArffDialog.6") //$NON-NLS-1$ .getString("ImageToArffDialog.6") //$NON-NLS-1$
+ nbSession); + nbSession);
MainFrame.getInstance().openNewFile(); MainFrame.getInstance().openNewFile();
DesktopFrame[] desktopFrames = MainFrame.getInstance() ImageDesktopFrame[] desktopFrames = MainFrame.getInstance()
.getDesktop().getAllDesktopFrames(); .getDesktop().getAllImageDesktopFrames();
System.out.println(Messages System.out.println(Messages
.getString("ImageToArffDialog.7") //$NON-NLS-1$ .getString("ImageToArffDialog.7") //$NON-NLS-1$
+ desktopFrames.length); + desktopFrames.length);
...@@ -121,8 +122,8 @@ public class RawImageToArffDialog extends JInternalFrame { ...@@ -121,8 +122,8 @@ public class RawImageToArffDialog extends JInternalFrame {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser(); JFileChooser fileChooser = new JFileChooser();
DesktopFrame[] desktopFrames = MainFrame.getInstance() ImageDesktopFrame[] desktopFrames = MainFrame.getInstance()
.getDesktop().getAllDesktopFrames(); .getDesktop().getAllImageDesktopFrames();
int nbSessions = desktopFrames.length; int nbSessions = desktopFrames.length;
if (nbSessions > 0) { if (nbSessions > 0) {
String path = desktopFrames[comboImage.getSelectedIndex()] String path = desktopFrames[comboImage.getSelectedIndex()]
...@@ -181,8 +182,8 @@ public class RawImageToArffDialog extends JInternalFrame { ...@@ -181,8 +182,8 @@ public class RawImageToArffDialog extends JInternalFrame {
* lance la création du fichier arff * lance la création du fichier arff
*/ */
protected void buttonOk_actionPerformed() {// TODO protected void buttonOk_actionPerformed() {// TODO
DesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop() ImageDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllDesktopFrames(); .getAllImageDesktopFrames();
int nbSessions = desktopFrames.length; int nbSessions = desktopFrames.length;
if (nbSessions == 0) { if (nbSessions == 0) {
JOptionPane JOptionPane
......
...@@ -27,16 +27,26 @@ KMeansSeedSelectionDialog.5=OK ...@@ -27,16 +27,26 @@ KMeansSeedSelectionDialog.5=OK
KMeansSeedSelectionDialog.7=Image KMeansSeedSelectionDialog.7=Image
KMeansSeedSelectionDialog.8=K-means seeds KMeansSeedSelectionDialog.8=K-means seeds
ConstraintsSelectionDialog.0=Information ConstraintsSelectionDialog.0=Information
ConstraintsSelectionDialog.10=Must-Link ConstraintsSelectionDialog.100=Must-Link
ConstraintsSelectionDialog.11=Cannot-Link ConstraintsSelectionDialog.101=Cannot-Link
ConstraintsSelectionDialog.12=Label ConstraintsSelectionDialog.102=Label
ConstraintsSelectionDialog.103=Clusters related
ConstraintsSelectionDialog.104=Number of cluster
ConstraintsSelectionDialog.105=Max. Cluster diameter
ConstraintsSelectionDialog.13=Add ConstraintsSelectionDialog.13=Add
ConstraintsSelectionDialog.15=pixel ConstraintsSelectionDialog.15=pixel
ConstraintsSelectionDialog.16=min
ConstraintsSelectionDialog.17=max
ConstraintsSelectionDialog.21=Apply ConstraintsSelectionDialog.21=Apply
ConstraintsSelectionDialog.22=Refresh ConstraintsSelectionDialog.22=Refresh
ConstraintsSelectionDialog.29=Zoom level at minimum ... ConstraintsSelectionDialog.29=Zoom level at minimum ...
ConstraintsSelectionDialog.30=index(es) ConstraintsSelectionDialog.30=indexes
ConstraintsSelectionDialog.31=Remove ConstraintsSelectionDialog.31=Remove
ConstraintsSelectionDialog.32=index
ConstraintsSelectionDialog.33=Choose which class to assign,\nchoose "New class" if you want to assign to another class.
ConstraintsSelectionDialog.34=Assign class
ConstraintsSelectionDialog.35=New class
ConstraintsSelectionDialog.36=class
ConstraintsSelectionDialog.50=OK ConstraintsSelectionDialog.50=OK
ConstraintsSelectionDialog.51=Import ConstraintsSelectionDialog.51=Import
ConstraintsSelectionDialog.52=Export ConstraintsSelectionDialog.52=Export
......
...@@ -27,16 +27,26 @@ KMeansSeedSelectionDialog.5=OK ...@@ -27,16 +27,26 @@ KMeansSeedSelectionDialog.5=OK
KMeansSeedSelectionDialog.7=Image KMeansSeedSelectionDialog.7=Image
KMeansSeedSelectionDialog.8=K-moyens graines KMeansSeedSelectionDialog.8=K-moyens graines
ConstraintsSelectionDialog.0=Information ConstraintsSelectionDialog.0=Information
ConstraintsSelectionDialog.10=Must-Link ConstraintsSelectionDialog.100=Must-Link
ConstraintsSelectionDialog.11=Cannot-Link ConstraintsSelectionDialog.101=Cannot-Link
ConstraintsSelectionDialog.12=Label ConstraintsSelectionDialog.102=Label
ConstraintsSelectionDialog.103=Relatives aux clusters
ConstraintsSelectionDialog.104=Nombre de cluster
ConstraintsSelectionDialog.105=Diametre de cluster max.
ConstraintsSelectionDialog.13=Ajouter ConstraintsSelectionDialog.13=Ajouter
ConstraintsSelectionDialog.15=pixel ConstraintsSelectionDialog.15=pixel
ConstraintsSelectionDialog.16=min
ConstraintsSelectionDialog.17=max
ConstraintsSelectionDialog.21=Appliquer ConstraintsSelectionDialog.21=Appliquer
ConstraintsSelectionDialog.22=Rafraichir ConstraintsSelectionDialog.22=Rafraichir
ConstraintsSelectionDialog.29=Niveau de zoom est son minimum.... ConstraintsSelectionDialog.29=Niveau de zoom est son minimum....
ConstraintsSelectionDialog.30=index(es) ConstraintsSelectionDialog.30=indexes
ConstraintsSelectionDialog.31=Supr. ConstraintsSelectionDialog.31=Supr.
ConstraintsSelectionDialog.32=index
ConstraintsSelectionDialog.33=Choisissez une nouvelle classe,\nchoisissez "Nouvelle classe" si vous souhaitez affecter une nouvelle classe.
ConstraintsSelectionDialog.34=Affecation de classe
ConstraintsSelectionDialog.35=Nouvelle classe
ConstraintsSelectionDialog.36=classe
ConstraintsSelectionDialog.50=OK ConstraintsSelectionDialog.50=OK
ConstraintsSelectionDialog.51=Importer ConstraintsSelectionDialog.51=Importer
ConstraintsSelectionDialog.52=Exporter ConstraintsSelectionDialog.52=Exporter
......
...@@ -117,6 +117,22 @@ CropDialog.70=_crop ...@@ -117,6 +117,22 @@ CropDialog.70=_crop
CropDialog.71=Zoom level is at it's minimum... CropDialog.71=Zoom level is at it's minimum...
CropDialog.8=Image CropDialog.8=Image
CropDialog.9=Informations CropDialog.9=Informations
DataToArffDialog.0=Input Data \:
DataToArffDialog.12=Output file \:
DataToArffDialog.13=Browse
DataToArffDialog.15=Date (JJMMAA)\:
DataToArffDialog.16=Nb intervalles \:
DataToArffDialog.17=OK
DataToArffDialog.18=ARFF
DataToArffDialog.19=You must open a data before...
DataToArffDialog.20=Warning
DataToArffDialog.22=Select a data to save as.
DataToArffDialog.23=Warning
DataToArffDialog.24=There is no Data currently opened
DataToArffDialog.44=The file was created successfull.
DataToArffDialog.45=Successful
DataToArffDialog.6=DataToArffDialog \=> Nr. sesiune 1 \=
DataToArffDialog.7=DataToArffDialog \=> Nr. sesiune 2 \=
FilterDialog.1=majority FilterDialog.1=majority
FilterDialog.2=Filter FilterDialog.2=Filter
FilterDialog.3=\ Type of filter \: FilterDialog.3=\ Type of filter \:
......
...@@ -117,6 +117,22 @@ CropDialog.70=_crop ...@@ -117,6 +117,22 @@ CropDialog.70=_crop
CropDialog.71=Zoom level is at it's minimum... CropDialog.71=Zoom level is at it's minimum...
CropDialog.8=Image CropDialog.8=Image
CropDialog.9=Informations CropDialog.9=Informations
DataToArffDialog.0=Data en entre \:
DataToArffDialog.12=Fichier en sortie \:
DataToArffDialog.13=Parcourir...
DataToArffDialog.15=Date (JJMMAA)\:
DataToArffDialog.16=Nb intervalles \:
DataToArffDialog.17=OK
DataToArffDialog.18=ARFF
DataToArffDialog.19=Vous devez ouvrir un data auparavant...
DataToArffDialog.20=Avertissement
DataToArffDialog.22=Selectinnez le fichier sauvegarder.
DataToArffDialog.23=Avertissement
DataToArffDialog.24=Il n'y a aucun Data actuellement ouvert
DataToArffDialog.44=Le fichier a t cr avec succs.
DataToArffDialog.45=Avec succs
DataToArffDialog.6=DataToArffDialog \=> Nr. sesiune 1 \=
DataToArffDialog.7=DataToArffDialog \=> Nr. sesiune 2 \=
FilterDialog.1=majorit FilterDialog.1=majorit
FilterDialog.2=Filtre FilterDialog.2=Filtre
FilterDialog.3=\ Type de filtre \: FilterDialog.3=\ Type de filtre \:
......
...@@ -159,8 +159,10 @@ MainFrame.29=Apply mask... ...@@ -159,8 +159,10 @@ MainFrame.29=Apply mask...
MainFrame.3=nb sessions MainFrame.3=nb sessions
MainFrame.30=Create a sub-image... MainFrame.30=Create a sub-image...
MainFrame.301=Constraints MainFrame.301=Constraints
MainFrame.302=Arff to Data
MainFrame.303=Data to Arff
MainFrame.31=TransformationBmpToRoi... MainFrame.31=TransformationBmpToRoi...
MainFrame.32=Image/ARFF MainFrame.32=Image/Data/ARFF
MainFrame.33=Image to ARFF... MainFrame.33=Image to ARFF...
MainFrame.34=Load arff... MainFrame.34=Load arff...
MainFrame.35=ARFF to image... MainFrame.35=ARFF to image...
......
...@@ -159,8 +159,10 @@ MainFrame.29=Appliquer le masque... ...@@ -159,8 +159,10 @@ MainFrame.29=Appliquer le masque...
MainFrame.3=nb sessions MainFrame.3=nb sessions
MainFrame.30=Crer un sous-image... MainFrame.30=Crer un sous-image...
MainFrame.301=Contraintes MainFrame.301=Contraintes
MainFrame.302=Arff en Data
MainFrame.303=Data en Arff
MainFrame.31=TransformationBmpEnRoi... MainFrame.31=TransformationBmpEnRoi...
MainFrame.32=Image/ARFF MainFrame.32=Image/Data/ARFF
MainFrame.33=Image en ARFF... MainFrame.33=Image en ARFF...
MainFrame.34=Charger Arff... MainFrame.34=Charger Arff...
MainFrame.35=ARFF en image... MainFrame.35=ARFF en image...
......
package mustic.utils.dataExchange;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.attribute.AttributeNumerical;
import jcl.data.attribute.AttributeSequence;
import weka.core.Attribute;
import weka.core.DenseInstance;
import weka.core.Instances;
/**
* Class to import/export ARFF files from/to Data objects
*
* @author Baptiste LAFABREGUE
*
*/
public class DataArffExchange {
public static void dataToArff(String path, Data data) {
System.out.println("__________________________________________________________________________________________\n"); //$NON-NLS-1$
System.out.println("Write \""+data.getDataName()+"\" to file : " + path); //$NON-NLS-1$
System.out.println("__________________________________________________________________________________________"); //$NON-NLS-1$
ArrayList<Attribute> attributes = new ArrayList<Attribute>();
attributes.add(new Attribute("index"));
for(int i = 0 ; i < data.getOneDataObject().getAttributes().length ; i++ ) {
attributes.add(getArffAttribute(data.getOneDataObject().getAttributes()[i], i+1));
}
Instances arffData = new Instances(data.getDataName(), attributes, 0);
Iterator<DataObject> iter = data.iterator();
int k = 0;
while(iter.hasNext()) {
double[] values = new double[arffData.numAttributes()];
DataObject current = iter.next();
if (data.getSampler() != null) {
values[0] = data.getSampler().getSampleIndexes()[k];
} else {
values[0] = k;
}
for(int i = 0 ; i < current.getAttributes().length ; i++ ) {
values[i+1] = getArffInstance(current.getAttributes()[i], arffData, i+1);
}
arffData.add(new DenseInstance(1.0, values));
k++;
}
try {
FileOutputStream out = new FileOutputStream(path);
PrintWriter writer = new PrintWriter(out);
writer.println("% Data origin from files : \n% <<<");
for(String files : data.getDataFilesName()) {
writer.println("% \""+files+"\"");
}