Commit 7e1071e6 authored by lafabregue's avatar lafabregue

tmp commit

parent b4beb7d2
......@@ -47,7 +47,10 @@ public class ClassificationFrame extends JInternalFrame {
// classifierPanel = new ClassifierPanel(this, false, false);
//
// } else {
classifierPanel = new ClassifierPanel(this, false);
// old version - replace if problem, the problem being that the type has changed
// this class should be extend JPanle instead of JInternalFrame
// classifierPanel = new ClassifierPanel(this, false);
classifierPanel = new ClassifierPanel(null, false);
// }
this.add(classifierPanel);
......
......@@ -7,12 +7,10 @@ import javax.swing.ImageIcon;
import javax.swing.WindowConstants;
import jcl.Classification;
import jcl.data.Data;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.learning.methods.multistrategy.samarah4.comm.ClassificationSAM4;
import mustic.gui.panels.ImageResultPanel;
import mustic.io.ImageData;
import mustic.io.RawImage;
import mustic.models.gui.ClassificationModel;
import mustic.models.gui.panels.ResultPanel;
import net.infonode.tabbedpanel.Tab;
......@@ -21,8 +19,6 @@ import net.infonode.tabbedpanel.TabbedPanel;
public class ClassificationImage extends ClassificationModel {
/** */
private static final long serialVersionUID = 1L;
private DataSession session = null;
/** */
......@@ -35,15 +31,11 @@ public class ClassificationImage extends ClassificationModel {
* @param title
*/
public ClassificationImage(DataSession session, String title) {
super(session.getData(), title, false);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.session = session;
super(session, title, false);
}
public ClassificationImage(DataSession session, String title, boolean justData) {
super(session.getData(), title, justData);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.session = session;
super(session, title, justData);
}
/**
......@@ -64,6 +56,8 @@ public class ClassificationImage extends ClassificationModel {
rpanel = new ResultPanel(result, this);
}
rpanel.setName(title);
resultPanels.add(rpanel);
Tab t1 = ClassificationModel.createTab(title, new ImageIcon(getClass()
.getResource("/icons/actions/document-open-result.png")), //$NON-NLS-1$
rpanel, true);
......
......@@ -18,6 +18,7 @@ import mustic.gui.panels.ImageResultPanel;
import mustic.gui.panels.data.DataPanel;
import mustic.io.ImageData;
import mustic.models.gui.ClassificationModel;
import mustic.models.gui.panels.ResultPanel;
import net.infonode.tabbedpanel.TabDragEvent;
import net.infonode.tabbedpanel.TabEvent;
import net.infonode.tabbedpanel.TabListener;
......@@ -50,7 +51,7 @@ public class DataSession {
protected TabbedPanel mWorskSpace = new TabbedPanel();
/** all ImageResultPanels associated to this session */
private Vector<ImageResultPanel> resultPanels = new Vector<ImageResultPanel>();
private Vector<ResultPanel> resultPanels = new Vector<ResultPanel>();
/** panel that display the content of the data used and allow to modify it */
private DataPanel dataPanel = null;
......@@ -84,7 +85,14 @@ public class DataSession {
@Override
public void tabSelected(TabStateChangedEvent arg0) {
if (arg0.getTab() instanceof ClassificationTitledTab) {
// currentBirdViewPanel = ((ClassificationTitledTab) arg0.getTab())
ResultPanel panel = ((ClassificationTitledTab) arg0.getTab())
.getClassificationModel().getCurrentResultPanel();
if (panel != null && panel instanceof ImageDisplayer) {
setCurrentBirdViewPanel(((ImageDisplayer) panel)
.getImageManager().getBirdViewPanel());
}
} else {
setCurrentBirdViewPanel(null);
}
}
......@@ -154,6 +162,9 @@ public class DataSession {
public void actionPerformed(ActionEvent e) {
tab.getTabbedPanel().removeTab(tab);
classifications.remove(classificationModel);
for (ResultPanel r : classificationModel.getResultPanels()) {
resultPanels.remove(r);
}
}
});
tab.setHighlightedStateTitleComponent(closeButton);
......@@ -163,23 +174,27 @@ public class DataSession {
public void addResultPanel(ImageResultPanel panel) {
if (this.resultPanels == null) {
this.resultPanels = new Vector<ImageResultPanel>();
this.resultPanels = new Vector<ResultPanel>();
}
this.resultPanels.add(panel);
}
public void decreaseBrightness() {
if (this.resultPanels != null) {
for (ImageResultPanel panel : this.resultPanels) {
panel.decreaseBrightness();
for (ResultPanel panel : this.resultPanels) {
if(panel instanceof ImageResultPanel) {
((ImageResultPanel) panel).decreaseBrightness();
}
}
}
}
public void decreaseContrast() {
if (this.resultPanels != null) {
for (ImageResultPanel panel : this.resultPanels) {
panel.decreaseContrast();
for (ResultPanel panel : this.resultPanels) {
if(panel instanceof ImageResultPanel) {
((ImageResultPanel) panel).decreaseContrast();
}
}
}
}
......@@ -187,37 +202,45 @@ public class DataSession {
public void increaseBrightness() {
if (this.resultPanels != null) {
for (ImageResultPanel panel : this.resultPanels) {
panel.increaseBrightness();
for (ResultPanel panel : this.resultPanels) {
if(panel instanceof ImageResultPanel) {
((ImageResultPanel) panel).increaseBrightness();
}
}
}
}
public void increaseContrast() {
if (this.resultPanels != null) {
for (ImageResultPanel panel : this.resultPanels) {
panel.increaseContrast();
for (ResultPanel panel : this.resultPanels) {
if(panel instanceof ImageResultPanel) {
((ImageResultPanel) panel).increaseContrast();
}
}
}
}
public void zoomIn() {
if (this.resultPanels != null) {
for (ImageResultPanel panel : this.resultPanels) {
panel.zoomIn();
for (ResultPanel panel : this.resultPanels) {
if(panel instanceof ImageResultPanel) {
((ImageResultPanel) panel).zoomIn();
}
}
}
}
public void zoomOut() {
if (this.resultPanels != null) {
for (ImageResultPanel panel : this.resultPanels) {
panel.zoomOut();
for (ResultPanel panel : this.resultPanels) {
if(panel instanceof ImageResultPanel) {
((ImageResultPanel) panel).zoomOut();
}
}
}
}
synchronized public Vector<ImageResultPanel> getResultPanels() {
synchronized public Vector<ResultPanel> getResultPanels() {
return this.resultPanels;
}
......@@ -272,7 +295,9 @@ public class DataSession {
* @param panel
*/
public void setCurrentBirdViewPanel(BirdViewPanel panel) {
this.currentBirdViewPanel = panel;
currentBirdViewPanel = panel;
MainFrame.getInstance().setBirdPanelContent(currentBirdViewPanel);
}
public Vector<ClassificationModel> getClassifications() {
......
......@@ -14,6 +14,12 @@ public interface ImageDisplayer {
* @return the corresponding BufferedImage
*/
BufferedImage getBirdViewImage(double resoltionFactor);
/**
* Return the image manager associated to this displayer
* @return the ImageManage
*/
ImageManager getImageManager();
/**
......
......@@ -112,23 +112,26 @@ public class MainFrame extends JFrame {
private File currentDirectory = null;
/** l'image courante selectionne */
private ImageSession currentImageSession;
private ImageSession currentImageSession = null;
/** l'image courante selectionne */
private DataSession currentDataSession;
/** le data courante selectionne */
private DataSession currentDataSession = null;
/** the currenlty selected session */
private Object currentSession = null;
/**
* bureau pour internal frame (une DesktopFrame (extends JInternalFrame) par image)
*/
private MusticDesktop desktop = null;
/** repertoire contenant l'aide */
private String helpPath = "/docs/help"; //$NON-NLS-1$
private String helpPath = "/docs/help"; //$NON-NLS-1$
/** panel pour l'affichage des informations sur l'image selectionnee */
private JPanel infosPanel;
/** boolean pour lier le birdview avec l'image active */
private boolean linkToAllImages = true;
private boolean linkToAllImages = true;
/** the project root for datas */
private DefaultMutableTreeNode mDataProjectNode;
......@@ -254,6 +257,7 @@ public class MainFrame extends JFrame {
MainFrame.getInstance().getDesktop().getSelectedFrame().setSelected(false);
}
MainFrame.this.currentDataSession = (DataSession) nodeInfo;
MainFrame.this.currentSession = MainFrame.this.currentDataSession;
createPanelFromData(MainFrame.this.currentDataSession);
MainFrame.this.currentDataSession.associatedFrame.toFront();
MainFrame.this.currentDataSession.associatedFrame.setSelected(true);
......@@ -291,6 +295,7 @@ public class MainFrame extends JFrame {
return;
if (node.getUserObject() instanceof String) {
MainFrame.this.currentImageSession = null;
MainFrame.this.currentSession = null;
return;
}
if (!(node.isRoot())) {
......@@ -300,6 +305,7 @@ public class MainFrame extends JFrame {
MainFrame.getInstance().getDesktop().getSelectedFrame().setSelected(false);
}
MainFrame.this.currentImageSession = (ImageSession) nodeInfo;
MainFrame.this.currentSession = MainFrame.this.currentImageSession;
createPanelFromImage(MainFrame.this.currentImageSession);
MainFrame.this.currentImageSession.associatedFrame.toFront();
MainFrame.this.currentImageSession.associatedFrame.setSelected(true);
......@@ -703,23 +709,14 @@ public class MainFrame extends JFrame {
//TODO to delete when no more used
// 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);
JMenuItem customToDelete = new JMenuItem("custom"); //$NON-NLS-1$
customToDelete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
customClassify();
}
});
CSVMenu.add(customToDelete);
// menuItemResultToCSV = new JMenuItem(Messages.getString("MainFrame.305")); //$NON-NLS-1$
// menuItemResultToCSV.addActionListener(new ActionListener() {
......@@ -2561,6 +2558,7 @@ public class MainFrame extends JFrame {
MainFrame.getInstance().getDesktop().removeAll();
this.currentImageSession = null;
this.currentSession = null;
createPanelFromData(null);
// createToolBar();
}
......@@ -2575,6 +2573,7 @@ public class MainFrame extends JFrame {
MainFrame.getInstance().getDesktop().removeAll();
this.currentImageSession = null;
this.currentSession = null;
createPanelFromImage(null);
// createToolBar();
}
......@@ -3137,6 +3136,7 @@ public class MainFrame extends JFrame {
this.mImageTreeModel.removeNodeFromParent(currentNode);
this.currentImageSession.associatedFrame.dispose();
this.currentImageSession = null;
this.currentSession = null;
createPanelFromImage(null);
System.gc();
......@@ -3193,6 +3193,7 @@ public class MainFrame extends JFrame {
if (desktopFrames.length > 0) {
this.currentDataSession = desktopFrames[desktopFrames.length - 1].getDataSession();
this.currentSession = this.currentDataSession;
createPanelFromData(this.currentDataSession);
}
}
......@@ -3429,7 +3430,12 @@ public class MainFrame extends JFrame {
}
public void setBirdPanelContent(JPanel panel) {
if (panel == null) {
panel = new JPanel();
}
this.birdPanel.removeAll();
this.birdPanel.add(panel, BorderLayout.CENTER);
this.birdPanel.updateUI();
}
public void setCurrentDirectory(File currentDirectory) {
......@@ -3438,6 +3444,7 @@ public class MainFrame extends JFrame {
public void setCurrentImageSession(ImageSession currentImageSession) {
this.currentImageSession = currentImageSession;
this.currentSession = currentImageSession;
}
public void setInfosPanel(JPanel panel) {
......@@ -3723,20 +3730,25 @@ public class MainFrame extends JFrame {
private void customClassify() {
HybridClassification classification = new HybridClassification();
String datasetName = "ECML";
String datasetName = "Sud";
String datasetPath = "Sud";
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");
Data dataTrain = getDataFromFile(dataPath+datasetPath+"/train/"+datasetName+".data", '\t', "train");
Data dataTest = getDataFromFile(dataPath+datasetPath+"/test/"+datasetName+".data", '\t', "test");
// AttributeMultiDimSequence.setMode(AttributeMultiDimSequence.EUCLIDIEN);
AttributeMultiDimSequence.setMode(AttributeMultiDimSequence.DTW_BARYCENTRE);
DataDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop().getAllDataDesktopFrames();
DataSession testSession = desktopFrames[desktopFrames.length-1].getDataSession();
final DateTime startTime = DateTime.now();
int nInf = 3;
int nSup = 5;
int nInf = 11;
int nSup = 14;
// parametre pour la precision des conflits
double minC = 0.9;
......@@ -3769,33 +3781,37 @@ public class MainFrame extends JFrame {
// 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(10, 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 < 5 ; i++) {
for (int i = 0 ; i < 10 ; i++) {
HybridClassification classif = (HybridClassification) classification.clone();
classif.addAgent(new ParametersKmeans(10, 15, weights), dataTest);
classif.addAgent(new ParametersKmeans(13, 15, weights), dataTest);
classif.addAgent(new ParametersKmeans(16, 15, weights), dataTest);
classif.addAgent(new ParametersKmeans(19, 15, weights), dataTest);
classif.setName(resultPath+datasetName+"/clustering"+i);
classif.setData(dataTest);
if (i % 2 == 1 ) {
classification.setParameters(nInf, nSup, minC, 0.4, 0.6, pcr);
}
if (i <= 5)
classif.addAgent(new ParametersKmeans(8, 10, weights), dataTrain);
if (i <= 7)
classif.addAgent(new ParametersKmeans(10, 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);
if (i >= 4)
classif.addAgent(new ParametersKmeans(22, 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(10, 15, weights), dataTest);
// classif.addAgent(new ParametersKmeans(13, 10, weights), dataTest);
// classif.addAgent(new ParametersKmeans(16, 10, weights), dataTest);
// classif.addAgent(new ParametersKmeans(19, 10, weights), dataTest);
//
// classif.setName(resultPath+datasetPath+"/clustering"+i);
// classif.setData(dataTest);
//// >>>> REPLACE PARAM
Thread t = null;
......@@ -3817,7 +3833,6 @@ public class MainFrame extends JFrame {
} catch (PropertyVetoException e) {
e.printStackTrace();
}
classificationImage.toFront();
classificationImage.setVisible(true);
threadList.add(t);
......@@ -3988,4 +4003,13 @@ public class MainFrame extends JFrame {
DataCsvExchange.dataToCSV("/home/baptiste/dataExtraite.csv", this.currentDataSession.getData(),
"\t", false);
}
/**
* Return the currently selected session
* @return the DataSession/ImageSession
*/
public Object getCurrentSession() {
return currentSession;
}
}
......@@ -1243,4 +1243,9 @@ public class ImagePanel extends JPanel implements Zoomable, Observer, ImageDispl
}
}
@Override
public ImageManager getImageManager() {
return session;
}
}
......@@ -87,7 +87,7 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
protected float mZoomRate = 1.0f;
/** zoom step */
private float mZoomStep = 0.7f;
private float mZoomStep = 0.7f;
/** Coordinates of the current position of the top left corner
* of the screen image in the original image */
......@@ -129,9 +129,9 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
/** the parent session */
private ImageManager imageManager = null;
/** panel that displays the image */
private ZoomBoxPanel displayPanel = null;
protected ZoomBoxPanel displayPanel = null;
/** the viewer that allows to reader the image */
private ImageViewer viewer = null;
......@@ -1620,6 +1620,11 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
return opacityCluster;
}
@Override
public ImageManager getImageManager() {
return imageManager;
}
public ImageData getImgData()
{
return imgData;
......
......@@ -104,7 +104,7 @@ public class ClassifierPanel extends JPanel {
public JCheckBox computCheckBox = new JCheckBox(Messages.getString("ClassifierPanel.6")); //$NON-NLS-1$
/** Reference vers l'eventuel container ou mettre le resultat */
private JInternalFrame container_ = null;
private JPanel container_ = null;
public JDialog dial = new JDialog();
......@@ -177,7 +177,7 @@ public class ClassifierPanel extends JPanel {
* classification.
* @param classifySegmentation classification après segmentation
*/
public ClassifierPanel(JInternalFrame container, boolean monoApproach) {
public ClassifierPanel(JPanel container, boolean monoApproach) {
this.container_ = container;
this.isSimpleAgent = monoApproach;
......@@ -701,7 +701,6 @@ public class ClassifierPanel extends JPanel {
} catch (PropertyVetoException e) {
e.printStackTrace();
}
classificationImage.toFront();
classificationImage.setVisible(true);
}
......
......@@ -1126,7 +1126,11 @@ public class SegmentationPanelResultatImage extends JPanel {
MainFrame.getInstance().getCurrentImageSession().setDataSeg(rdb.getData());
ClassificationImage classificationImage = new ClassificationImage(rdb.getData(), "Clustering...", true) {
MainFrame.getInstance().createDataSession(rdb.getData());
DataDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop().getAllDataDesktopFrames();
DataSession session = desktopFrames[desktopFrames.length-1].getDataSession();
ClassificationImage classificationImage = new ClassificationImage(session, "Clustering...", true) {
/** serialVersionUID */
private static final long serialVersionUID = 1L;
......
......@@ -465,7 +465,7 @@ public class SegmentationResultPanel extends ImageResultPanel {
@Override
protected void setListenerImage() {
this.labelImage.addMouseListener(new MouseAdapter() {
this.displayPanel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent ev) {
......
......@@ -3,7 +3,7 @@ package mustic.models.gui;
import javax.swing.ImageIcon;
import jcl.Classification;
import jcl.data.Data;
import mustic.gui.DataSession;
import mustic.models.gui.panels.ResultPanel;
import mustic.models.gui.widgets.ClassificationManager;
import net.infonode.tabbedpanel.Tab;
......@@ -32,7 +32,7 @@ public class ClassificationFrame extends ClassificationModel {
* @param data
* @param title
*/
public ClassificationFrame(Data data, String title) {
public ClassificationFrame(DataSession data, String title) {
super(data, title);
}
......@@ -43,6 +43,7 @@ public class ClassificationFrame extends ClassificationModel {
/* On cree l'interface graphique d'affichage du resultat */
ResultPanel rp = new ResultPanel(result, this);
rp.setName(name);
resultPanels.add(rp);
Tab tabResult = ClassificationModel.createTab(
result.getName(),
......
......@@ -24,7 +24,9 @@ import jcl.Classification;
import jcl.data.Data;
import jcl.jcld.database.SSHParameters;
import jcl.learning.methods.monostrategy.SingleClassification;
import mustic.gui.DataSession;
import mustic.gui.MainFrame;
import mustic.gui.panels.ImageResultPanel;
import mustic.gui.panels.classifier.ClassifierPanel;
import mustic.gui.panels.data.DataPanel;
import mustic.models.gui.panels.HybridClassificationMonitor;
......@@ -32,7 +34,12 @@ import mustic.models.gui.panels.MaclawClassificationMonitor;
import mustic.models.gui.panels.ResultPanel;
import mustic.models.gui.widgets.ClassificationManager;
import net.infonode.tabbedpanel.Tab;
import net.infonode.tabbedpanel.TabDragEvent;
import net.infonode.tabbedpanel.TabEvent;
import net.infonode.tabbedpanel.TabFactory;
import net.infonode.tabbedpanel.TabListener;
import net.infonode.tabbedpanel.TabRemovedEvent;
import net.infonode.tabbedpanel.TabStateChangedEvent;
import net.infonode.tabbedpanel.TabbedPanel;
import net.infonode.tabbedpanel.titledtab.TitledTab;
......@@ -45,11 +52,8 @@ import net.infonode.tabbedpanel.titledtab.TitledTab;
* </p>
*
* @author Germain Forestier / mehdi uberall
*
* TODO transformer cette classe en jpanel, et creer une methode qui
* renvoie une jinternalframe avec ce panel dedans
*/
public abstract class ClassificationModel extends JInternalFrame {
public abstract class ClassificationModel extends JPanel {
/** */
private static final long serialVersionUID = 1L;
......@@ -75,6 +79,16 @@ public abstract class ClassificationModel extends JInternalFrame {
/** La liste des onglets */
public TabbedPanel tabbedPane = new TabbedPanel();
/** DataSession that contains this classificationModel */
protected DataSession session = null;
/** Record all the results associated to this instance */
protected Vector<ResultPanel> resultPanels = new Vector<ResultPanel>();
protected ResultPanel currentResultPanel =