Commit a949300f authored by adrmeyer's avatar adrmeyer

Merge branch 'master' of icube-forge.unistra.fr:lafabregue/Mustic

parents 33fe6b92 7da3f6fa
......@@ -53,7 +53,12 @@ public class ClassificationImage extends ClassificationModel {
@Override
synchronized public void addResult(Classification result, String title,
TabbedPanel pane) {
ImageResultPanel rpanel = new ImageResultPanel(result, this, ((ImageData) data));
ResultPanel rpanel = null;
if (data instanceof ImageData) {
rpanel = new ImageResultPanel(result, this, ((ImageData) data));
} else {
rpanel = new ResultPanel(result, this);
}
Tab t1 = ClassificationModel.createTab(title, new ImageIcon(getClass()
.getResource("/icons/actions/document-open-result.png")), //$NON-NLS-1$
rpanel, true);
......@@ -70,12 +75,14 @@ public class ClassificationImage extends ClassificationModel {
.getCurrentThreadCpuTime());
this.results.add(result);
this.addResult(result, Messages.getString("ClassificationImage.1") + ResultPanel.nbResult++); //$NON-NLS-1$
ImageResultPanel irp = (ImageResultPanel) this.tabbedPane.getTabAt(
ResultPanel irp = (ResultPanel) this.tabbedPane.getTabAt(
this.tabbedPane.getTabCount() - 1).getContentComponent();
irp.historique.addInfosln(Messages.getString("ClassificationImage.2")); //$NON-NLS-1$
if (result.getData().getOneDataObject().getAttribute(0) instanceof AttributeMultiDimSequence) {
irp.historique.addInfosln(Messages.getString("ClassificationImage.3")); //$NON-NLS-1$
irp.historique.addInfosln(result.getData().getDataFilesName().get(0));
if (result.getData().getDataFilesName().size() > 0) {
irp.historique.addInfosln(result.getData().getDataFilesName().get(0));
}
} else
irp.historique.addInfosln(Messages.getString("ClassificationImage.4") //$NON-NLS-1$
+ result.getData().getDataName() + "\n"); //$NON-NLS-1$
......
......@@ -10,6 +10,12 @@ import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.beans.PropertyVetoException;
import java.io.*;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.zip.ZipEntry;
......@@ -24,13 +30,22 @@ import javax.swing.tree.*;
import jcl.Classification;
import jcl.clustering.Cluster;
import jcl.clustering.ClusteringResult;
import jcl.clustering.constraints.CannotLinkConstraint;
import jcl.clustering.constraints.Constraint;
import jcl.clustering.constraints.LabelConstraint;
import jcl.clustering.constraints.MustLinkConstraint;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.SimpleData;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.io.results.CSVResultWriter;
import jcl.learning.LearningMethod;
import jcl.learning.methods.monostrategy.SingleClassification;
import jcl.learning.methods.monostrategy.kmeans.ParametersKmeans;
import jcl.learning.methods.multistrategy.samarah.HybridClassification;
import jcl.learning.methods.multistrategy.samarah.SamarahConfig;
import jcl.weights.ClassificationWeights;
import jcl.weights.GlobalWeights;
import jsl.Segmentation;
import mustic.gui.dialog.*;
import mustic.gui.dialog.arff.ArffLoadDialog;
......@@ -41,6 +56,7 @@ import mustic.gui.dialog.arff.ImageToArffDialog;
import mustic.gui.dialog.arff.RawImageToArffDialog;
import mustic.gui.dialog.classifier.ConstraintsSelectionDialog;
import mustic.gui.dialog.consoleHandler.ConsoleFrame;
import mustic.gui.dialog.csv.CSVToDataDialog;
import mustic.gui.panels.*;
import mustic.gui.panels.data.DataConstructFrame;
import mustic.gui.progressbar.OpenRawImage;
......@@ -48,9 +64,13 @@ import mustic.gui.segmentation.*;
import mustic.io.*;
import mustic.models.gui.ClassificationModel;
import mustic.models.gui.panels.*;
import mustic.models.thread.ClassificationThread;
import mustic.utils.ImageHelper;
import mustic.utils.UnZipSub;
import mustic.utils.filters.ImageFileFilter;
import mustic.utils.filters.ZipFileFilter;
import mustic.utils.io.CSVUtils;
import mustic.utils.io.dataExchange.DataCsvExchange;
import net.infonode.tabbedpanel.*;
import net.infonode.tabbedpanel.titledtab.TitledTab;
import net.infonode.util.Direction;
......@@ -606,7 +626,9 @@ public class MainFrame extends JFrame {
menuBar.add(toolsMenu);
ArffMenu = new JMenu(Messages.getString("MainFrame.32")); //$NON-NLS-1$
ImportExportMenu = new JMenu(Messages.getString("MainFrame.32")); //$NON-NLS-1$
ArffMenu = new JMenu(Messages.getString("MainFrame.321")); //$NON-NLS-1$
menuItemArff = new JMenuItem(Messages.getString("MainFrame.33")); //$NON-NLS-1$
menuItemArff.addActionListener(new ActionListener() {
......@@ -661,8 +683,49 @@ public class MainFrame extends JFrame {
}
});
ArffMenu.add(menuItemLoadArffToData);
CSVMenu = new JMenu(Messages.getString("MainFrame.322")); //$NON-NLS-1$
menuItemLoadCSVToData = new JMenuItem(Messages.getString("MainFrame.305")); //$NON-NLS-1$
menuItemLoadCSVToData.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
toolsMenuCSVtoData();
}
});
CSVMenu.add(menuItemLoadCSVToData);
JMenuItem customToDelete = new JMenuItem("custom"); //$NON-NLS-1$
customToDelete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
customClassify();
}
});
CSVMenu.add(customToDelete);
JMenuItem custom2ToDelete = new JMenuItem("extract custom"); //$NON-NLS-1$
custom2ToDelete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
extractcustomESV();
}
});
CSVMenu.add(custom2ToDelete);
// menuItemResultToCSV = new JMenuItem(Messages.getString("MainFrame.305")); //$NON-NLS-1$
// menuItemResultToCSV.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// toolsMenuResultToCSV();
// }
// });
// CSVMenu.add(menuItemResultToCSV);
menuBar.add(ArffMenu);
ImportExportMenu.add(ArffMenu);
ImportExportMenu.add(CSVMenu);
menuBar.add(ImportExportMenu);
// Preprocessing
menuPreprocessing = new JMenu(Messages.getString("MainFrame.351"));
......@@ -769,7 +832,6 @@ public class MainFrame extends JFrame {
menuContrast.add(menuContrastM);
menuView.add(menuContrast);
// TODO
menuConnect = new JMenu(Messages.getString("MainFrame.260")); //$NON-NLS-1$
menuConnectActiv = new JMenuItem(Messages.getString("MainFrame.261")); //$NON-NLS-1$
menuConnectActiv.addActionListener(new ActionListener() {
......@@ -792,7 +854,6 @@ public class MainFrame extends JFrame {
group.add(menuConnectAll);
menuConnect.add(menuConnectAll);
menuView.add(menuConnect);
// TODO
menuResetAll = new JMenuItem(Messages.getString("MainFrame.46")); //$NON-NLS-1$
menuResetAll.addActionListener(new ActionListener() {
......@@ -989,6 +1050,8 @@ public class MainFrame extends JFrame {
private JMenu fileMenu;
private JMenu toolsMenu;
private JMenu menuROI;
private JMenu ImportExportMenu;
private JMenu CSVMenu;
private JMenu ArffMenu;
private JMenu menuPreprocessing;
private JMenu menuView;
......@@ -1041,6 +1104,10 @@ public class MainFrame extends JFrame {
private Boolean actionLoadArff;
private JMenuItem menuItemLoadArffToData;
private Boolean actionLoadArffToData;
private JMenuItem menuItemLoadCSVToData;
private Boolean actionLoadCSVToData;
private JMenuItem menuItemResultToCSV;
private Boolean actionResultToCSV;
private JMenuItem menuItemArffData;
private Boolean actionArffData;
private JMenuItem menuItemArffImage;
......@@ -1134,6 +1201,8 @@ public class MainFrame extends JFrame {
this.actionHelp = true;
this.actionLoadArff = true;
this.actionLoadArffToData = true;
this.actionLoadCSVToData = true;
this.actionResultToCSV = true;
this.actionArffData = true;
this.actionNew = true;
this.actionOpen = true;
......@@ -1232,6 +1301,8 @@ public class MainFrame extends JFrame {
menuItemArffImage.setEnabled(this.actionArffImage);
menuItemArffData.setEnabled(this.actionArffData);
menuItemLoadArffToData.setEnabled(this.actionLoadArffToData);
menuItemLoadCSVToData.setEnabled(this.actionLoadCSVToData);
// menuItemResultToCSV.setEnabled(this.actionResultToCSV);
menuZoomIn.setEnabled(this.actionZoomIn);
menuZoomOut.setEnabled(this.actionZoomOut);
menuBrightP.setEnabled(this.actionBrightP);
......@@ -1260,7 +1331,9 @@ public class MainFrame extends JFrame {
fileMenu.setText(Messages.getString("MainFrame.6"));
toolsMenu.setText(Messages.getString("MainFrame.13"));
menuROI.setText(Messages.getString("MainFrame.20"));
ArffMenu.setText(Messages.getString("MainFrame.32"));
ImportExportMenu.setText(Messages.getString("MainFrame.32"));
ArffMenu.setText(Messages.getString("MainFrame.321"));
CSVMenu.setText(Messages.getString("MainFrame.322"));
menuView.setText(Messages.getString("MainFrame.36"));
menuPreprocessing.setText(Messages.getString("MainFrame.351"));
......@@ -3258,7 +3331,7 @@ public class MainFrame extends JFrame {
this.panelResSave.add(bouton);
HybridClassificationMonitor hcm = (HybridClassificationMonitor) ((TabbedPanel) session.getWorkSpace().getTabAt(j)
.getContentComponent()).getTabAt(0).getContentComponent();
ImageResultPanel irp = (ImageResultPanel) hcm.tabbedPane.getTabAt(hcm.tabbedPane.getTabCount()-1).getContentComponent();
ResultPanel irp = (ResultPanel) hcm.tabbedPane.getTabAt(hcm.tabbedPane.getTabCount()-1).getContentComponent();
vecRes.add(irp);
nbClustering++;
}
......@@ -3298,15 +3371,26 @@ public class MainFrame extends JFrame {
for (int i = 0; i < panelResSave.getComponentCount(); i++) {
if (((JRadioButton) panelResSave.getComponent(i)).isSelected()) {
if (vecRes.get(i) instanceof ImageResultPanel) {
// case of an image
ImageResultPanel irp = (ImageResultPanel) vecRes.get(i);
irp.saveAs_actionPerformed();
resultSaveTextField.setVisible(false);
}
else {
SegmentationPanel sg = (SegmentationPanel) ((TitledTab) ((TabbedPanel) vecRes.get(i)).getTabAt(0)).getContentComponent();
else if (vecRes.get(i) instanceof TabbedPanel &&
((TabbedPanel) vecRes.get(i)).getTabAt(0) instanceof TitledTab &&
((TitledTab) ((TabbedPanel) vecRes.get(i)).getTabAt(0))
.getContentComponent() instanceof SegmentationPanel){
// case of a segmentation
SegmentationPanel sg = (SegmentationPanel) ((TitledTab) ((TabbedPanel) vecRes.get(i))
.getTabAt(0)).getContentComponent();
sg.save_actionPerformed();
resultSaveTextField.setVisible(false);
break;
} else {
// other cases
ResultPanel rp = (ResultPanel) vecRes.get(i);
rp.saveResult();
resultSaveTextField.setVisible(false);
}
}
}
......@@ -3444,6 +3528,12 @@ public class MainFrame extends JFrame {
this.desktop.add(dialog);
dialog.toFront();
}
private void toolsMenuCSVtoData() {
CSVToDataDialog dialog = new CSVToDataDialog();
this.desktop.add(dialog);
dialog.toFront();
}
private void toolsMenuDataToArff() {
......@@ -3621,4 +3711,273 @@ public class MainFrame extends JFrame {
public void setLaunchOrthoRect(boolean launchOrthoRect) {
this.launchOrthoRect = launchOrthoRect;
}
private void exportData() {
}
private void customClassify() {
HybridClassification classification = new HybridClassification();
String datasetName = "InsectWingbeatSound";
String dataPath = "/home/baptiste/A2CNES/";
String resultPath = "/home/baptiste/A2CNES/results/";
String testResultPath = "/home/baptiste/A2CNES/Train_results/";
Data dataTrain = getDataFromFile(dataPath+datasetName+"/train/"+datasetName+".data", '\t', "train");
Data dataTest = getDataFromFile(dataPath+datasetName+"/test/"+datasetName+".data", '\t', "test");
DataDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop().getAllDataDesktopFrames();
DataSession testSession = desktopFrames[desktopFrames.length-1].getDataSession();
int nInf = 10;
int nSup = 13;
// parametre pour la precision des conflits
double minC = 0.9;
// parametre pour les classes representatives
double pcr = 0.2;
// parametre qualite/similitude
double ps = 0.2;
double pq = 1.0 - ps;
double constraintsWgt = 0;
double valueKExtern = 60;
double kExtern = valueKExtern * ((100-constraintsWgt)/100);
double kIntern = (100 - valueKExtern) * ((100-constraintsWgt)/100);
int solutionType = 3;
double classRatio = 0.01;
int criterion = 0;
double degradation = 0.9;
int unificationType = SamarahConfig.WITHOUT_UNCLASSIFIED_UNIFICATION;
classification.setParameters(nInf, nSup, minC, ps, pq, pcr);
classification.setAdvancedParameters(degradation, classRatio, solutionType, kIntern,
kExtern, unificationType, criterion, constraintsWgt);
ClassificationWeights weights = new GlobalWeights(dataTest);
final Vector<Thread> threadList = new Vector<Thread>();
final Vector<Classification> classifList = new Vector<Classification>();
// we search for all constraints files
//// <<<< START FOR PARAM config
// for (int i = 0 ; i < 6 ; i++) {
// HybridClassification classif = (HybridClassification) classification.clone();
// if (i % 2 == 1 ) {
// classification.setParameters(nInf, nSup, minC, 0.4, 0.6, pcr);
// }
// if (i <= 4)
// classif.addAgent(new ParametersKmeans(11, 10, weights), dataTrain);
// classif.addAgent(new ParametersKmeans(13, 10, weights), dataTrain);
// classif.addAgent(new ParametersKmeans(16, 10, weights), dataTrain);
// if (i >= 2)
// classif.addAgent(new ParametersKmeans(19, 10, weights), dataTrain);
//// classif.addAgent(new ParametersKmeans(3, 10, weights), dataTest);
//// classif.addAgent(new ParametersKmeans(4, 10, weights), dataTest);
//// classif.addAgent(new ParametersKmeans(6, 10, weights), dataTest);
//
// classif.setName(testResultPath+datasetName+"/clusteing"+i);
// classif.setData(dataTrain);
//// >>>> END FOR PARAM config1
for (int i = 0 ; i < 10 ; i++) {
HybridClassification classif = (HybridClassification) classification.clone();
classif.addAgent(new ParametersKmeans(11, 15, weights), dataTrain);
classif.addAgent(new ParametersKmeans(13, 15, weights), dataTrain);
classif.addAgent(new ParametersKmeans(16, 15, weights), dataTrain);
classif.addAgent(new ParametersKmeans(19, 15, weights), dataTrain);
classif.setName(resultPath+datasetName+"/clustering"+i);
classif.setData(dataTest);
//// >>>> REPLACE PARAM
Thread t = null;
ClassificationImage classificationImage = new ClassificationImage(dataTest,
Messages.getString("ClassifierPanel.73") + DataSession.nbClustering, //$NON-NLS-1$
true);
t = new ClassificationThread(classif, classificationImage.getProgressBar(),
classificationImage, null);
t.start();
try {
testSession.associatedFrame.setMaximum(true);
} catch (PropertyVetoException e1) {}
testSession.addClassifier(classificationImage);
try {
testSession.associatedFrame.setSelected(true);
testSession.associatedFrame.toFront();
} catch (PropertyVetoException e) {
e.printStackTrace();
}
classificationImage.toFront();
classificationImage.setVisible(true);
threadList.add(t);
classifList.add(classif);
}
// <<<< CONSTRAINTS
// try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(
// Paths.get(dataPath+datasetName+"/test/"), "*constraints")) {
// Iterator<Path> iter = dirStream.iterator();
// while(iter.hasNext()) {
// Vector<Constraint> constraints = new Vector<Constraint>();
// String filename = iter.next().getFileName().toString();
// System.out.println(filename);
// CSVUtils reader = null;
// try {
// reader = new CSVUtils(new File(dataPath+datasetName+"/test/"+filename), '\t');
// List<String> line;
// while((line = reader.readNext()) != null) {
// switch (Integer.parseInt(line.get(line.size()-1))) {
// case Constraint.MUST_LINK_TYPE :
// try {
// int index1 = Integer.parseInt(line.get(0))-1;
// int index2 = Integer.parseInt(line.get(1))-1;
// constraints.add(new MustLinkConstraint(index1, index2));
// } catch(Exception e) {
// e.printStackTrace();
// }
// break;
// case Constraint.CANNOT_LINK_TYPE :
// try {
// int index1 = Integer.parseInt(line.get(0))-1;
// int index2 = Integer.parseInt(line.get(1))-1;
// constraints.add(new CannotLinkConstraint(index1, index2));
// } catch(Exception e) {
// e.printStackTrace();
// }
// break;
// }
// }
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
// HybridClassification classif = (HybridClassification) classification.clone();
// Data currentData = (Data) dataTest.clone();
// currentData.updateAndSetConstraintsToSample(constraints);
//
// classif.addAgent(new ParametersKmeans(14, 15, weights), currentData);
// classif.addAgent(new ParametersKmeans(17, 15, weights), currentData);
// classif.addAgent(new ParametersKmeans(20, 15, weights), currentData);
//
// classif.setName(resultPath+datasetName+"/"+
// ImageHelper.stripExtension(filename)+
// ".clustering");
// classif.setData(dataTest);
//
// Thread t = null;
//
// ClassificationImage classificationImage = new ClassificationImage(currentData,
// Messages.getString("ClassifierPanel.73") + DataSession.nbClustering, //$NON-NLS-1$
// true);
//
//
// t = new ClassificationThread(classif, classificationImage.getProgressBar(),
// classificationImage, null);
// t.start();
// try {
// testSession.associatedFrame.setMaximum(true);
// } catch (PropertyVetoException e1) {}
// testSession.addClassifier(classificationImage);
// try {
// testSession.associatedFrame.setSelected(true);
// testSession.associatedFrame.toFront();
// } catch (PropertyVetoException e) {
// e.printStackTrace();
// }
// classificationImage.toFront();
// classificationImage.setVisible(true);
//
// threadList.add(t);
// classifList.add(classif);
// }
// } catch (IOException e2) {
// e2.printStackTrace();
// }
// >>>> CONSTRAINTS
new Thread() {
@Override
public void run() {
try {
for (Thread thread : threadList) {
thread.join();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
for(Classification cl : classifList) {
try {
new CSVResultWriter(cl, cl.getName()).write();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}.start();
ClassificationFrame.getInstance().updateClassifierPanel();
ClassificationFrame.getInstance().dispose();
}
private Data getDataFromFile(String path, char separator, String name) {
Data data = null;
// we create the two data session
// the first session is used for training, the second for classification
try {
List<DataObject> result = new ArrayList<DataObject>();
CSVUtils reader = null;
try {
File file = new File(path);
reader = new CSVUtils(file, separator);
List<String> line;
while((line = reader.readNext()) != null) {
extractObjectFromLine(result, line, 1);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
result = null;
}
data = new SimpleData(result);
data.setDataName(name);
MainFrame.getInstance().createDataSession(data);
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
/**
* Construct a DataObject from a set of Strings and add it to a List
* @param list
* the list to add the DataObject to
* @param line
* the line to interpret
*/
private void extractObjectFromLine(List<DataObject> list, List<String> line, int featureNb) {
DataObject obj = new DataObject(1);
double[][] seq = new double[line.size()/featureNb][];
for (int i = 0 ; i < line.size()/featureNb ; i++) {
seq[i] = new double[featureNb];
for (int j = 0 ; j < featureNb ; j++) {
seq[i][j] = Double.parseDouble(line.get(i*featureNb + j));
}
}
obj.setAttribute(0, new AttributeMultiDimSequence(seq));
list.add(obj);
}
private void extractcustomESV() {
DataCsvExchange.dataToCSV("/home/baptiste/dataExtraite.csv", this.currentDataSession.getData(),
"\t", false);
}
}
......@@ -222,7 +222,7 @@ public class ArffToDataDialog extends JInternalFrame implements ToUpdateObject {
JOptionPane.showMessageDialog(this,
Messages.getString("ArffToDataDialog.151") + this.textData.getText() //$NON-NLS-1$
+ Messages.getString("ArffToDataDialog.152"), //$NON-NLS-1$
+ " " + Messages.getString("ArffToDataDialog.152"), //$NON-NLS-1$
Messages.getString("ArffToDataDialog.16"), //$NON-NLS-1$
JOptionPane.INFORMATION_MESSAGE);
} else {
......
......@@ -8,6 +8,7 @@ import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import jcl.data.Data;
import jcl.learning.LearningParameters;
import mustic.gui.DataDesktopFrame;
import mustic.gui.DataSession;
......@@ -35,7 +36,7 @@ public class AgentDialog extends JDialog {
public ClassifierPanel classifierPanel = null;
/** */
ImageData imgdata;
Data imgdata;
/** bouton d'annulation */
JButton jButtonCancel = new JButton(Messages.getString("AgentDialog.0")); //$NON-NLS-1$
......@@ -148,7 +149,7 @@ public class AgentDialog extends JDialog {
[this.classifierPanel.getApproachPanel().getDataComboBox().getSelectedIndex()].getDataSession();
// récupère les données de l'image
this.imgdata = (ImageData) img.getData();
this.imgdata = img.getData();
this.imgdata.setDataFilesName(imgdata.getDataFilesName());
}
......@@ -173,8 +174,8 @@ public class AgentDialog extends JDialog {
}
} else {
System.out.println(this.imgdata.getWidth());
System.out.println(this.imgdata.getHeight());
// System.out.println(this.imgdata.getWidth());
// System.out.println(this.imgdata.getHeight());
System.out.println(this.imgdata.getNbObjects());
// cas particulier - utilisation samarah4
......
......@@ -173,21 +173,23 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
this.labelImage.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int x = (int) ((e.getX() - (int) ((labelImage.getWidth() - (labelImage.getIcon().getIconWidth())) / 2.0)) / mZoomRate);
int y = (int) ((e.getY() - (int) ((labelImage.getHeight() - (labelImage.getIcon().getIconHeight())) / 2.0)) / mZoomRate);
if (x>=0 && y>=0 && x<imageSource.getWidth() * mZoomRate && y<imageSource.getHeight() * mZoomRate) {
switch(currentStep) {
case MustLink_step1 : case CannotLink_step1 : case Label_step1 :
addFirstPixel(x, y);
break;
case MustLink_step2 : case CannotLink_step2 :
addSecondPixel(x, y);
break;
default :
// we don't refresh if not a valid step
return;
if (image != null) {
int x = (int) ((e.getX() - (int) ((labelImage.getWidth() - (labelImage.getIcon().getIconWidth())) / 2.0)) / mZoomRate);
int y = (int) ((e.getY() - (int) ((labelImage.getHeight() - (labelImage.getIcon().getIconHeight())) / 2.0)) / mZoomRate);
if (x>=0 && y>=0 && x<imageSource.getWidth() * mZoomRate && y<imageSource.getHeight() * mZoomRate) {
switch(currentStep) {
case MustLink_step1 : case CannotLink_step1 : case Label_step1 :
addFirstPixel(x, y);
break;
case MustLink_step2 : case CannotLink_step2 :
addSecondPixel(x, y);
break;
default :
// we don't refresh if not a valid step
return;
}
displayPixels();
}
displayPixels();
}
}
});
......@@ -263,14 +265,14 @@ public class ConstraintsSelectionDialog extends JInternalFrame {
ExportConstraintsTask exportConstraintsTask = new ExportConstraintsTask(this);
exportConstraintsTask.addPropertyChangeListener(new ProgressPropertyChangeListener());
exportConstraintsTask.execute();
}
}
protected void importConstraints()
{
ImportConstraintsTask importConstraintsTask = new ImportConstraintsTask(this);
importConstraintsTask.addPropertyChangeListener(new ProgressPropertyChangeListener());
importConstraintsTask.execute();
}