Commit b4beb7d2 authored by lafabregue's avatar lafabregue

tmp commit

parent 8fa09c81
...@@ -22,6 +22,8 @@ public class ClassificationImage extends ClassificationModel { ...@@ -22,6 +22,8 @@ public class ClassificationImage extends ClassificationModel {
/** */ /** */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private DataSession session = null;
/** */ /** */
public ArrayList<Classification> results = new ArrayList<Classification>(); public ArrayList<Classification> results = new ArrayList<Classification>();
...@@ -32,14 +34,16 @@ public class ClassificationImage extends ClassificationModel { ...@@ -32,14 +34,16 @@ public class ClassificationImage extends ClassificationModel {
* @param data * @param data
* @param title * @param title
*/ */
public ClassificationImage(Data data, String title) { public ClassificationImage(DataSession session, String title) {
super(data, title, false); super(session.getData(), title, false);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.session = session;
} }
public ClassificationImage(Data data, String title, boolean justData) { public ClassificationImage(DataSession session, String title, boolean justData) {
super(data, title, justData); super(session.getData(), title, justData);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.session = session;
} }
/** /**
...@@ -55,10 +59,11 @@ public class ClassificationImage extends ClassificationModel { ...@@ -55,10 +59,11 @@ public class ClassificationImage extends ClassificationModel {
TabbedPanel pane) { TabbedPanel pane) {
ResultPanel rpanel = null; ResultPanel rpanel = null;
if (data instanceof ImageData) { if (data instanceof ImageData) {
rpanel = new ImageResultPanel(result, this, ((ImageData) data)); rpanel = new ImageResultPanel(session, result, this, ((ImageData) data));
} else { } else {
rpanel = new ResultPanel(result, this); rpanel = new ResultPanel(result, this);
} }
rpanel.setName(title);
Tab t1 = ClassificationModel.createTab(title, new ImageIcon(getClass() Tab t1 = ClassificationModel.createTab(title, new ImageIcon(getClass()
.getResource("/icons/actions/document-open-result.png")), //$NON-NLS-1$ .getResource("/icons/actions/document-open-result.png")), //$NON-NLS-1$
rpanel, true); rpanel, true);
......
...@@ -4,16 +4,25 @@ import java.awt.event.ActionEvent; ...@@ -4,16 +4,25 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Vector; import java.util.Vector;
import javax.swing.Icon;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JInternalFrame; import javax.swing.JInternalFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import jcl.data.Data; import jcl.data.Data;
import mustic.gui.panels.BirdViewPanel;
import mustic.gui.panels.ImageResultPanel; import mustic.gui.panels.ImageResultPanel;
import mustic.gui.panels.data.DataPanel; import mustic.gui.panels.data.DataPanel;
import mustic.io.ImageData; import mustic.io.ImageData;
import mustic.models.gui.ClassificationModel;
import net.infonode.tabbedpanel.TabDragEvent;
import net.infonode.tabbedpanel.TabEvent;
import net.infonode.tabbedpanel.TabListener;
import net.infonode.tabbedpanel.TabRemovedEvent;
import net.infonode.tabbedpanel.TabStateChangedEvent;
import net.infonode.tabbedpanel.TabbedPanel; import net.infonode.tabbedpanel.TabbedPanel;
import net.infonode.tabbedpanel.titledtab.TitledTab; import net.infonode.tabbedpanel.titledtab.TitledTab;
...@@ -32,23 +41,31 @@ public class DataSession { ...@@ -32,23 +41,31 @@ public class DataSession {
public JInternalFrame associatedFrame = null; public JInternalFrame associatedFrame = null;
/** the data attached to this session */ /** the data attached to this session */
private Data data; private Data data = null;
/** Title of the session */ /** Title of the session */
private String mTitle; private String mTitle;
/** Contains image, classifier, results */ /** Contains image, classifier, results */
protected TabbedPanel mWorskSpace; protected TabbedPanel mWorskSpace = new TabbedPanel();
/** all ImageResultPanels associated to this session */ /** all ImageResultPanels associated to this session */
private Vector<ImageResultPanel> resultPanels = new Vector<ImageResultPanel>(); private Vector<ImageResultPanel> resultPanels = new Vector<ImageResultPanel>();
private DataPanel dataPanel; /** panel that display the content of the data used and allow to modify it */
private DataPanel dataPanel = null;
/** store the birdViewPanle currently used */
private BirdViewPanel currentBirdViewPanel = null;
private Vector<ClassificationModel> classifications = new Vector<ClassificationModel>();
/** save the number of clustering already done a the overall sessions */ /** save the number of clustering already done a the overall sessions */
public static int nbClustering = 1; public static int nbClustering = 1;
/** /**
* Constructor * Constructor
* @param data * @param data
...@@ -60,17 +77,71 @@ public class DataSession { ...@@ -60,17 +77,71 @@ public class DataSession {
this.dataPanel = new DataPanel(data); this.dataPanel = new DataPanel(data);
this.mWorskSpace = dataPanel.tabbedPane; this.mWorskSpace.addTab(dataPanel.getDataTabPanel());
this.mWorskSpace.addTabListener(new TabListener() {
@Override
public void tabSelected(TabStateChangedEvent arg0) {
if (arg0.getTab() instanceof ClassificationTitledTab) {
// currentBirdViewPanel = ((ClassificationTitledTab) arg0.getTab())
}
}
@Override
public void tabRemoved(TabRemovedEvent arg0) {
if (arg0.getTab() instanceof ClassificationTitledTab) {
classifications.remove(((ClassificationTitledTab) arg0.getTab())
.getClassificationModel());
}
}
@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) {
}
});
} }
/** /**
* Add a classifier for the data * Add a classifier for the data
* @param classificationImage * @param classificationModel
*/ */
public void addClassifier(ClassificationImage classificationImage) { public void addClassifier(final ClassificationModel classificationModel) {
final TitledTab tab = new TitledTab(Messages.getString("ImageSession.7") + nbClustering++, //$NON-NLS-1$
null, classificationImage.tabbedPane, new JPanel()); classifications.add(classificationModel);
final TitledTab tab = new ClassificationTitledTab(Messages.getString("ImageSession.7") + nbClustering++, //$NON-NLS-1$
null, classificationModel.tabbedPane, new JPanel(), classificationModel);
tab.setFocusableComponent(null); tab.setFocusableComponent(null);
JButton closeButton = new JButton(new ImageIcon(tab.getClass().getResource("/icons/cluster-invisible.png"))); //$NON-NLS-1$ JButton closeButton = new JButton(new ImageIcon(tab.getClass().getResource("/icons/cluster-invisible.png"))); //$NON-NLS-1$
...@@ -82,6 +153,7 @@ public class DataSession { ...@@ -82,6 +153,7 @@ public class DataSession {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
tab.getTabbedPanel().removeTab(tab); tab.getTabbedPanel().removeTab(tab);
classifications.remove(classificationModel);
} }
}); });
tab.setHighlightedStateTitleComponent(closeButton); tab.setHighlightedStateTitleComponent(closeButton);
...@@ -170,6 +242,11 @@ public class DataSession { ...@@ -170,6 +242,11 @@ public class DataSession {
return this.mTitle; //$NON-NLS-1$ return this.mTitle; //$NON-NLS-1$
} }
/**
* Retrieve the list of ImageSession used to create the data
*
* @return the list of ImageSession
*/
public Vector<ImageSession> getAssociatedImageSessions() { public Vector<ImageSession> getAssociatedImageSessions() {
if(data instanceof ImageData) { if(data instanceof ImageData) {
if (((ImageData) data).getAssociatedImageSessions() != null if (((ImageData) data).getAssociatedImageSessions() != null
...@@ -180,4 +257,50 @@ public class DataSession { ...@@ -180,4 +257,50 @@ public class DataSession {
return null; return null;
} }
/**
* The BirdViewPanel of the last classification selected
* @return the last BirdViewPanel
*/
public BirdViewPanel getCurrentBirdViewPanel() {
return currentBirdViewPanel;
}
/**
* The BirdViewPanel of the last classification selected
*
* @param panel
*/
public void setCurrentBirdViewPanel(BirdViewPanel panel) {
this.currentBirdViewPanel = panel;
}
public Vector<ClassificationModel> getClassifications() {
return classifications;
}
/**
* Small class to allow a TitledTab to store a classification model
*
* @author Baptiste LAFABREGUE
*
*/
public class ClassificationTitledTab extends TitledTab {
/** */
private static final long serialVersionUID = 1L;
private ClassificationModel model = null;
public ClassificationTitledTab(String arg0, Icon arg1, JComponent arg2,
JComponent arg3, ClassificationModel model) {
super(arg0, arg1, arg2, arg3);
this.model = model;
}
public ClassificationModel getClassificationModel() {
return this.model;
}
}
} }
\ No newline at end of file
...@@ -128,7 +128,7 @@ public class MainFrame extends JFrame { ...@@ -128,7 +128,7 @@ public class MainFrame extends JFrame {
private JPanel infosPanel; private JPanel infosPanel;
/** boolean pour lier le birdview avec l'image active */ /** boolean pour lier le birdview avec l'image active */
private boolean linkToAllImages = false; private boolean linkToAllImages = true;
/** the project root for datas */ /** the project root for datas */
private DefaultMutableTreeNode mDataProjectNode; private DefaultMutableTreeNode mDataProjectNode;
...@@ -702,23 +702,24 @@ public class MainFrame extends JFrame { ...@@ -702,23 +702,24 @@ public class MainFrame extends JFrame {
CSVMenu.add(menuItemLoadCSVToData); CSVMenu.add(menuItemLoadCSVToData);
JMenuItem customToDelete = new JMenuItem("custom"); //$NON-NLS-1$ //TODO to delete when no more used
customToDelete.addActionListener(new ActionListener() { // JMenuItem customToDelete = new JMenuItem("custom"); //$NON-NLS-1$
@Override // customToDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { // @Override
customClassify(); // public void actionPerformed(ActionEvent e) {
} // customClassify();
}); // }
CSVMenu.add(customToDelete); // });
// CSVMenu.add(customToDelete);
JMenuItem custom2ToDelete = new JMenuItem("extract custom"); //$NON-NLS-1$ //
custom2ToDelete.addActionListener(new ActionListener() { // JMenuItem custom2ToDelete = new JMenuItem("extract custom"); //$NON-NLS-1$
@Override // custom2ToDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { // @Override
extractcustomESV(); // public void actionPerformed(ActionEvent e) {
} // extractcustomESV();
}); // }
CSVMenu.add(custom2ToDelete); // });
// CSVMenu.add(custom2ToDelete);
// menuItemResultToCSV = new JMenuItem(Messages.getString("MainFrame.305")); //$NON-NLS-1$ // menuItemResultToCSV = new JMenuItem(Messages.getString("MainFrame.305")); //$NON-NLS-1$
// menuItemResultToCSV.addActionListener(new ActionListener() { // menuItemResultToCSV.addActionListener(new ActionListener() {
...@@ -840,21 +841,25 @@ public class MainFrame extends JFrame { ...@@ -840,21 +841,25 @@ public class MainFrame extends JFrame {
menuView.add(menuContrast); menuView.add(menuContrast);
menuConnect = new JMenu(Messages.getString("MainFrame.260")); //$NON-NLS-1$ menuConnect = new JMenu(Messages.getString("MainFrame.260")); //$NON-NLS-1$
menuConnectActiv = new JMenuItem(Messages.getString("MainFrame.261")); //$NON-NLS-1$ menuConnectActiv = new JCheckBoxMenuItem(Messages.getString("MainFrame.261")); //$NON-NLS-1$
menuConnectActiv.addActionListener(new ActionListener() { menuConnectActiv.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
MainFrame.getInstance().setLierBirdView(true); MainFrame.getInstance().setLierBirdView(false);
menuConnectActiv.setState(true);
menuConnectAll.setState(false);
} }
}); });
menuConnect.add(menuConnectActiv); menuConnect.add(menuConnectActiv);
ButtonGroup group = new ButtonGroup(); ButtonGroup group = new ButtonGroup();
menuConnectAll = new JMenuItem(Messages.getString("MainFrame.262")); //$NON-NLS-1$ menuConnectAll = new JCheckBoxMenuItem(Messages.getString("MainFrame.262")); //$NON-NLS-1$
menuConnectAll.addActionListener(new ActionListener() { menuConnectAll.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
MainFrame.getInstance().setLierBirdView(false); MainFrame.getInstance().setLierBirdView(true);
menuConnectActiv.setState(false);
menuConnectAll.setState(true);
} }
}); });
group.add(menuConnectActiv); group.add(menuConnectActiv);
...@@ -1137,8 +1142,8 @@ public class MainFrame extends JFrame { ...@@ -1137,8 +1142,8 @@ public class MainFrame extends JFrame {
private Boolean actionContratsP; private Boolean actionContratsP;
private JMenuItem menuContrastM; private JMenuItem menuContrastM;
private Boolean actionContrastM; private Boolean actionContrastM;
private JMenuItem menuConnectActiv; private JCheckBoxMenuItem menuConnectActiv;
private JMenuItem menuConnectAll; private JCheckBoxMenuItem menuConnectAll;
private JMenuItem menuResetAll; private JMenuItem menuResetAll;
private Boolean actionResetAll; private Boolean actionResetAll;
private JMenuItem menuChooseRgb; private JMenuItem menuChooseRgb;
...@@ -1316,8 +1321,10 @@ public class MainFrame extends JFrame { ...@@ -1316,8 +1321,10 @@ public class MainFrame extends JFrame {
menuBrightM.setEnabled(this.actionBrightM); menuBrightM.setEnabled(this.actionBrightM);
menuContrastP.setEnabled(this.actionContratsP); menuContrastP.setEnabled(this.actionContratsP);
menuContrastM.setEnabled(this.actionContrastM); menuContrastM.setEnabled(this.actionContrastM);
menuConnectActiv.setEnabled(!this.isLinkToAllBirdView()); menuConnectActiv.setEnabled(this.isLinkToAllBirdView());
menuConnectAll.setEnabled(this.isLinkToAllBirdView()); menuConnectAll.setEnabled(!this.isLinkToAllBirdView());
menuConnectActiv.setState(!this.isLinkToAllBirdView());
menuConnectAll.setState(this.isLinkToAllBirdView());
menuResetAll.setEnabled(this.actionResetAll); menuResetAll.setEnabled(this.actionResetAll);
menuChooseRgb.setEnabled(this.actionChooseRgb); menuChooseRgb.setEnabled(this.actionChooseRgb);
menuRefresh.setEnabled(this.actionRefresh); menuRefresh.setEnabled(this.actionRefresh);
...@@ -1612,15 +1619,12 @@ public class MainFrame extends JFrame { ...@@ -1612,15 +1619,12 @@ public class MainFrame extends JFrame {
this.desktop.addDataFrame(dataSession); this.desktop.addDataFrame(dataSession);
else else
this.desktop.setSelectedFrame(dataSession.associatedFrame); this.desktop.setSelectedFrame(dataSession.associatedFrame);
// this.birdPanel.add(dataSession.getBirdViewPanel()); if(dataSession.getCurrentBirdViewPanel() != null) {
this.birdPanel.add(dataSession.getCurrentBirdViewPanel());
} }
if (aSession != null) {
// fill the west panel with right information if a session is open
this.infosPanel.add(aSession.getInfoPanel());
this.birdPanel.add(aSession.getBirdPanel());
} }
// =============== Creation of the Desktop ================ // =============== Creation of the Desktop ================
JPanel panel_desktop = new JPanel(new BorderLayout()); JPanel panel_desktop = new JPanel(new BorderLayout());
panel_desktop.setOpaque(false); panel_desktop.setOpaque(false);
...@@ -2093,6 +2097,9 @@ public class MainFrame extends JFrame { ...@@ -2093,6 +2097,9 @@ public class MainFrame extends JFrame {
refreshButton.addActionListener(new ActionListener() { refreshButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (currentImageSession != null) {
currentImageSession.getImagePanel().resetAll();
}
MainFrame.this.repaint(); MainFrame.this.repaint();
} }
}); });
...@@ -3713,10 +3720,6 @@ public class MainFrame extends JFrame { ...@@ -3713,10 +3720,6 @@ public class MainFrame extends JFrame {
this.launchOrthoRect = launchOrthoRect; this.launchOrthoRect = launchOrthoRect;
} }
private void exportData() {
}
private void customClassify() { private void customClassify() {
HybridClassification classification = new HybridClassification(); HybridClassification classification = new HybridClassification();
...@@ -3796,7 +3799,7 @@ public class MainFrame extends JFrame { ...@@ -3796,7 +3799,7 @@ public class MainFrame extends JFrame {
//// >>>> REPLACE PARAM //// >>>> REPLACE PARAM
Thread t = null; Thread t = null;
ClassificationImage classificationImage = new ClassificationImage(dataTest, ClassificationImage classificationImage = new ClassificationImage(testSession,
Messages.getString("ClassifierPanel.73") + DataSession.nbClustering, //$NON-NLS-1$ Messages.getString("ClassifierPanel.73") + DataSession.nbClustering, //$NON-NLS-1$
true); true);
......
...@@ -6,6 +6,7 @@ import java.awt.geom.AffineTransform; ...@@ -6,6 +6,7 @@ import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp; import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException;
import javax.swing.*; import javax.swing.*;
...@@ -79,35 +80,11 @@ public class CropDialog extends JInternalFrame { ...@@ -79,35 +80,11 @@ public class CropDialog extends JInternalFrame {
} }
@Override
protected Picture load(double zoomfactor) {
// TODO Auto-generated method stub
return null;
}
@Override
protected Picture load(double zoomfactor, int band) {
// TODO Auto-generated method stub
return null;
}
@Override @Override
public double[][][] load(int x, int y, int w, int h) { public double[][][] load(int x, int y, int w, int h) {
return data; return data;
} }
@Override
protected Picture load(int x, int y, int w, int h, int dest_w, int dest_h) {
// TODO Auto-generated method stub
return null;
}
@Override
public double[][][] loadData(int x, int y, int w, int h, int stepx, int stepy) {
// TODO Auto-generated method stub
return null;
}
} }
static private final int ACT_MOVE = 1; static private final int ACT_MOVE = 1;
...@@ -756,8 +733,7 @@ public class CropDialog extends JInternalFrame { ...@@ -756,8 +733,7 @@ public class CropDialog extends JInternalFrame {
MainFrame.getInstance().openSession(new File(path)); MainFrame.getInstance().openSession(new File(path));
} }
} } else {
else {
File f = new File(path + ".bsq"); //$NON-NLS-1$ File f = new File(path + ".bsq"); //$NON-NLS-1$
if (f.exists()) { if (f.exists()) {
int rep = JOptionPane.showConfirmDialog(this, Messages.getString("CropDialog.65") + Messages.getString("CropDialog.66"), //$NON-NLS-1$ //$NON-NLS-2$ int rep = JOptionPane.showConfirmDialog(this, Messages.getString("CropDialog.65") + Messages.getString("CropDialog.66"), //$NON-NLS-1$ //$NON-NLS-2$
......
...@@ -10,17 +10,20 @@ import java.awt.event.MouseEvent; ...@@ -10,17 +10,20 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener; import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector; import java.util.Vector;
import javax.swing.JPanel; import javax.swing.JPanel;
import mustic.gui.ImageDesktopFrame; import mustic.gui.ImageDesktopFrame;
import mustic.gui.ImageManager; import mustic.gui.ImageManager;
import mustic.gui.ImageSession;
import mustic.gui.MainFrame; import mustic.gui.MainFrame;
import mustic.io.PiLLiTools; import mustic.io.PiLLiTools;
public class BirdViewPanel extends JPanel implements MouseListener, public class BirdViewPanel extends JPanel implements MouseListener,
MouseMotionListener { MouseMotionListener, Observer {
/** Represents the moving action. */ /** Represents the moving action. */
static private final int ACT_MOVE = 1; static private final int ACT_MOVE = 1;
...@@ -594,34 +597,23 @@ public class BirdViewPanel extends JPanel implements MouseListener, ...@@ -594,34 +597,23 @@ public class BirdViewPanel extends JPanel implements MouseListener,
this.repaint(); this.repaint();
this.action = BirdViewPanel.ACT_NONE; this.action = BirdViewPanel.ACT_NONE;
if (!MainFrame.getInstance().isLinkToAllBirdView()) { if(session instanceof ImageSession) {
if (MainFrame.getInstance().isLinkToAllBirdView()) {
ImageDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop() ImageDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllImageDesktopFrames(); .getAllImageDesktopFrames();
int nbSessions = desktopFrames.length; int nbSessions = desktopFrames.length;
for (int i = 0; i < nbSessions; i++) { for (int i = 0; i < nbSessions; i++) {
syncImage(desktopFrames[i].getImageSession()); syncImage(desktopFrames[i].getImageSession());
desktopFrames[i]
.getImageSession()
.getImagePanel()
.reloadPoint(
desktopFrames[i].getImageSession()
.getBirdViewPanel().xxsave,
desktopFrames[i].getImageSession()
.getBirdViewPanel().yysave,
desktopFrames[i].getImageSession()
.getBirdViewPanel().rxsave,
desktopFrames[i].getImageSession()
.getBirdViewPanel().rysave);
} }
} else { } else {
if (session != null) { if (session != null) {
syncImage(session); syncImage();
session.getImageDisplayer().reloadPoint( }
session.getBirdViewPanel().xxsave, }
session.getBirdViewPanel().yysave, } else {
session.getBirdViewPanel().rxsave, if (session != null) {
session.getBirdViewPanel().rysave); syncImage();
} }