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();
/**
......
This diff is collapsed.
......@@ -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 = null;
private String title = "";
/**
* <p>
......@@ -87,18 +101,72 @@ public abstract class ClassificationModel extends JInternalFrame {
* le titre de la fenetre
*/
public ClassificationModel(Data data, String title) {
public ClassificationModel(DataSession data, String title) {
this(data, title, false);
}
public ClassificationModel(Data data, String title, boolean justData) {
this.data = data;
public ClassificationModel(DataSession dataSession, String title, boolean justData) {
this.data = dataSession.getData();
this.session = dataSession;
this.title = title;
/* On garde une trace des parametres */
// this.data_ = data;
if (data != null)
this.dataPanel = new DataPanel(data);
this.classifierPanel = new ClassifierPanel(this, false);
tabbedPane.addTabListener(new TabListener() {
@Override
public void tabSelected(TabStateChangedEvent arg0) {
if (arg0.getTab().getContentComponent() instanceof ResultPanel) {
currentResultPanel = (ResultPanel) arg0.getTab().getContentComponent();
if (currentResultPanel instanceof ImageResultPanel) {
session.setCurrentBirdViewPanel(((ImageResultPanel) currentResultPanel)
.getImageManager().getBirdViewPanel());
} else {
session.setCurrentBirdViewPanel(null);
}
}
}
@Override
public void tabRemoved(TabRemovedEvent arg0) {
}
@Override
public void tabMoved(TabEvent arg0) {
}
@Override
public void tabHighlighted(TabStateChangedEvent arg0) {
}
@Override
public void tabDropped(TabDragEvent arg0) {
}
@Override
public void tabDragged(TabDragEvent arg0) {
}
@Override
public void tabDragAborted(TabEvent arg0) {
}
@Override
public void tabDeselected(TabStateChangedEvent arg0) {
}
@Override
public void tabDehighlighted(TabStateChangedEvent arg0) {
}
@Override
public void tabAdded(TabEvent arg0) {
}
});
final TitledTab tabClassifier = TabFactory.createTitledTab(
......@@ -135,14 +203,9 @@ public abstract class ClassificationModel extends JInternalFrame {
// if (this.plugins.size() > 0)
// tabbedPane.addTab ("Plugins", null, new PluginPanel (this.plugins,
// this.data_, this), "Plugins");
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(this.tabbedPane, BorderLayout.CENTER);
this.setTitle(title);
this.setLayout(new BorderLayout());
this.add(this.tabbedPane, BorderLayout.CENTER);
this.setSize(700, 500);
this.setResizable(true);
this.setMaximizable(true);
this.setIconifiable(true);
this.setClosable(true);
this.setVisible(true);
}
......@@ -164,7 +227,6 @@ public abstract class ClassificationModel extends JInternalFrame {
public abstract void addResult(Classification result, String title,
TabbedPanel pane);
@Override
public void doDefaultCloseAction() {
/* On enleve les resultats de la frame que l'on ferme */
Component[] comp = this.tabbedPane.getComponents();
......@@ -176,7 +238,6 @@ public abstract class ClassificationModel extends JInternalFrame {
}
}
/* Comportement reel */
super.doDefaultCloseAction();
}
/** */
......@@ -297,15 +358,47 @@ public abstract class ClassificationModel extends JInternalFrame {
@Override
public void actionPerformed(ActionEvent e) {
tab.getTabbedPanel().removeTab(tab);
if (tab.getContentComponent() instanceof ResultPanel)
if (tab.getContentComponent() instanceof ResultPanel) {
ResultPanel resPanel = (ResultPanel) tab.getContentComponent();
ClassificationManager
.removeClassification(((ResultPanel) tab
.getContentComponent())
.getClassification());
.removeClassification(resPanel.getClassification());
resPanel.getSession().getResultPanels().remove(resPanel);
}
}
});
tab.setHighlightedStateTitleComponent(closeButton);
}
return tab;
}
/**
* Called when the classification is closed
*/
public void closed() {
// we remove all results associated to this panel
for(ResultPanel r : resultPanels) {
session.getResultPanels().remove(r);
}
}
public String getTitle() {
return title;
}
/**
* Return the ResultPanels contained in this ClassificationModel
* @return the vector of ResultPanel
*/
public Vector<ResultPanel> getResultPanels() {
return resultPanels;
}
/**
* Return the ResultPanel currently selected in this ClassificationModel
* @return the ResultPanel
*/
public ResultPanel getCurrentResultPanel() {
return currentResultPanel;
}
}
......@@ -106,8 +106,6 @@ public class ScatterPlotChart extends JPanel {
int i;
int rdInt;
int max = this.data_.getNbObjects();
if (MainFrame.DEBUG_MODE)
System.out.println("max " + max);
Random rd;
......
......@@ -14,12 +14,8 @@ import jcl.Classification;
import jcl.clustering.Cluster;
import jcl.clustering.ClusteringResult;
import jcl.learning.methods.ClassifierUtils;
import jcl.utils.Matrix;
import jcl.utils.exceptions.MethodNotImplementedException;
import mustic.gui.MainFrame;
import mustic.gui.panels.ImageResultPanel;
//<<<< TRANSPARENCE
//import mustic.gui.panels.ImageResultPanel;
//>>>> TRANSPARENCE
import mustic.models.gui.charts.MultiresolutionChart;
import mustic.models.gui.dialogs.MergeDialog;
import mustic.models.gui.dialogs.SplitDialog;
......@@ -649,56 +645,31 @@ public class ClassConfigPanel extends JPanel implements TreeSelectionListener, A
return boutonsPanel;
}
/**
* Ask the user to select a clustering to copy the color from
* It only compares it with clustering from the same DataSession
*/
private void matchToClusteringColor() {
if (resultPanel_.getSession() != null) {
JPanel panelResSave = new JPanel();
final JPanel panelResSave = new JPanel();
JPanel panel = new JPanel(new BorderLayout());
panel.add(new JLabel("Which results would you save ?"), BorderLayout.NORTH);
JScrollPane pane = new JScrollPane();
panelResSave.setLayout(new BoxLayout(panelResSave, BoxLayout.Y_AXIS));
Vector<ImageResultPanel> imageResultPanels = new Vector<ImageResultPanel>();
if (!this.classFrame.tabbedPane.getTabAt(0).toString().startsWith("Hybrid")) {
int nbRes = this.classFrame.tabbedPane.getTabCount();
if (nbRes == 1) {
this.resultSave = new boolean[1];
this.resultSave[0] = true;
imageResultPanels.add(this);
save_actionPerformed(this.resultSave);
return;
}
else {
for (int i = 0; i < this.classFrame.tabbedPane.getTabCount(); i++) {
if (this.classFrame.tabbedPane.getTabAt(i).toString().startsWith("MACLAW")) {
MaclawClassificationMonitor mcm = (MaclawClassificationMonitor) this.classFrame.tabbedPane.getTabAt(i)
.getContentComponent();
for (int j = 0; j < mcm.tabbedPane.getTabCount(); j++) {
this.panelResSave.add(new JCheckBox("MACLAW " + mcm.tabbedPane.getTabAt(j).toString()));
}
nbRes += mcm.tabbedPane.getTabCount() - 1;
}
else {
this.panelResSave.add(new JCheckBox(this.classFrame.tabbedPane.getTabAt(i).toString()));
}
}
this.resultSave = new boolean[nbRes];
}
}
else {
int nbRes = 0;
HybridClassificationMonitor hcm = (HybridClassificationMonitor) this.classFrame.tabbedPane.getTabAt(0).getContentComponent();
for (int i = 0; i < hcm.tabbedPane.getTabCount(); i++) {
this.panelResSave.add(new JCheckBox(hcm.tabbedPane.getTabAt(i).toString()));
nbRes = hcm.tabbedPane.getTabCount();
}
if (this.classFrame.tabbedPane.getTabCount() > 1) {
for (int i = 1; i < this.classFrame.tabbedPane.getTabCount(); i++) {
this.panelResSave.add(new JCheckBox(this.classFrame.tabbedPane.getTabAt(i).toString()));
nbRes++;
}
final int[] resultSave = new int[this.resultPanel_.getSession().getResultPanels().size() -1];
final JDialog jif_saveResult = new JDialog();
int k = 0;
for (int i = 0 ; i < resultSave.length +1 ; i++) {
if (this.resultPanel_.getSession().getResultPanels().get(i) != this.resultPanel_) {
panelResSave.add(new JCheckBox(this.resultPanel_.getSession()
.getResultPanels().get(i).getName()));
resultSave[k] = i;
k++;
}
this.resultSave = new boolean[nbRes];
}
pane.getViewport().add(this.panelResSave);
pane.getViewport().add(panelResSave);
panel.add(pane, BorderLayout.CENTER);
JPanel panelButton = new JPanel();
JButton buttonOk = new JButton("OK");
......@@ -707,38 +678,56 @@ public class ClassConfigPanel extends JPanel implements TreeSelectionListener, A
buttonOk.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean enregistre = false;
for (int i = 0; i < resultSave.length; i++) {
int index = -1;
for (int i = 0 ; i < resultSave.length ; i++) {
if (((JCheckBox) panelResSave.getComponent(i)).isSelected()) {
jif_saveResult.setVisible(false);
resultSave[i] = true;
enregistre = true;
index = resultSave[i];
break;
}
}
if (!enregistre) {
JOptionPane.showMessageDialog(ImageResultPanel.this, "Selectionnez au moins un résultat", "Warning", JOptionPane.WARNING_MESSAGE);
if (index < 0) {
JOptionPane.showMessageDialog(ClassConfigPanel.this.resultPanel_,
"Selectionnez au moins un résultat", "Warning", JOptionPane.WARNING_MESSAGE);
}
else {
save_actionPerformed(resultSave);
matchToClusteringColor(index);
jif_saveResult.dispose();
}
}
});
this.jif_saveResult.setContentPane(panel);
jif_saveResult.setContentPane(panel);
jif_saveResult.setSize(300, 200);
jif_saveResult.setLocation(15, 15);
jif_saveResult.setResizable(true);
jif_saveResult.setMaximizable(true);
jif_saveResult.setIconifiable(true);
jif_saveResult.setClosable(true);
jif_saveResult.setTitle("Save " + this.classFrame.getTitle());
jif_saveResult.setTitle("Copy color from");
jif_saveResult.setVisible(true);
MainFrame.getInstance().getDesktop().remove(jif_saveResult);
MainFrame.getInstance().getDesktop().add(jif_saveResult);
MainFrame.getInstance().getDesktop().setSelectedFrame(jif_saveResult);
this.jif_saveResult.toFront();
jif_saveResult.toFront();
}
}
/**
* Copy the color from a given clustering
* @param index
* index of the clustering in the same DataSession
*/
private void matchToClusteringColor(int index) {
ClusteringResult thisRes = this.resultPanel_.getClassification().getClusteringResult();
ClusteringResult compRes = this.resultPanel_.getSession().getResultPanels().get(index)
.getClassification().getClusteringResult();
Matrix confusion = thisRes.confusion(compRes);
for(int i = 0 ; i < thisRes.getNbClusters() ; i++) {
int matchingCluster = confusion.maxColumn(i);
thisRes.getCluster(i).setColor(compRes.getCluster(matchingCluster).getColor());
}
/* On rafraichit les graphiques */
if (this.resultPanel_ != null) {
this.resultPanel_.updateChart();
}
this.clusterTree.updateUI();