Commit 74d5ac3e authored by lafabregue's avatar lafabregue

Changed to new JCL version and integrate Data construction with sampling, still need some fixes

parent c8b78603
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -37,18 +37,18 @@ public class ClassificationFrame extends JInternalFrame {
private ClassifierPanel classifierPanel;
private ClassificationFrame() {
if (MainFrame.getInstance().getCurrentSession() != null) {
MainFrame
.getInstance()
.getCurrentSession()
.setData(
MainFrame.getInstance().getCurrentSession()
.getImageData());
classifierPanel = new ClassifierPanel(this, false, false);
} else {
classifierPanel = new ClassifierPanel(this, false, false);
}
// if (MainFrame.getInstance().getCurrentSession() != null) {
// MainFrame
// .getInstance()
// .getCurrentSession()
// .setData(
// MainFrame.getInstance().getCurrentSession()
// .getImageData());
// classifierPanel = new ClassifierPanel(this, false, false);
//
// } else {
classifierPanel = new ClassifierPanel(this, false);
// }
this.add(classifierPanel);
this.setTitle(Messages.getString("ClassificationFrame.0")); //$NON-NLS-1$
......@@ -105,15 +105,20 @@ public class ClassificationFrame extends JInternalFrame {
public void updateClassifierPanel() {
String[] items = this.classifierPanel.getNameData();
// if there is no Data session opened
if (items == null) {
return;
}
this.classifierPanel.getApproachPanel().getSingleDataComboBox()
this.classifierPanel.getApproachPanel().getDataComboBox()
.removeAllItems();
for (int i = 0; i < items.length; i++) {
this.classifierPanel.getApproachPanel().getSingleDataComboBox()
this.classifierPanel.getApproachPanel().getDataComboBox()
.addItem(items[i]);
}
this.classifierPanel.getApproachPanel().getSingleDataComboBox()
this.classifierPanel.getApproachPanel().getDataComboBox()
.setSelectedIndex(0);
}
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ 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;
......@@ -21,8 +22,6 @@ public class ClassificationImage extends ClassificationModel {
/** */
private static final long serialVersionUID = 1L;
/** */
public RawImage mRawImage;
/** */
public ArrayList<Classification> results = new ArrayList<Classification>();
......@@ -36,16 +35,11 @@ public class ClassificationImage extends ClassificationModel {
public ClassificationImage(Data data, String title) {
super(data, title, false);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.mRawImage = MainFrame.getInstance().getCurrentSession()
.getRawImage();
}
public ClassificationImage(Data data, String title, boolean justData) {
super(data, title, justData);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
if (MainFrame.getInstance().getCurrentSession() != null)
this.mRawImage = MainFrame.getInstance().getCurrentSession()
.getRawImage();
}
/**
......@@ -59,19 +53,7 @@ public class ClassificationImage extends ClassificationModel {
@Override
synchronized public void addResult(Classification result, String title,
TabbedPanel pane) {
ImageSession imgSession = MainFrame.getInstance().getCurrentSession();
DesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllDesktopFrames();
for (int i = 0; i < desktopFrames.length; i++) {
if (result
.getData()
.getDataName()
.equals(desktopFrames[i].getImageSession().getRawImage()
.getPath()))
imgSession = desktopFrames[i].getImageSession();
}
ImageResultPanel rpanel = new ImageResultPanel(result, this,
imgSession.getRawImage());
ImageResultPanel rpanel = new ImageResultPanel(result, this, ((ImageData) data));
Tab t1 = ClassificationModel.createTab(title, new ImageIcon(getClass()
.getResource("/icons/actions/document-open-result.png")), //$NON-NLS-1$
rpanel, true);
......@@ -91,9 +73,9 @@ public class ClassificationImage extends ClassificationModel {
ImageResultPanel irp = (ImageResultPanel) this.tabbedPane.getTabAt(
this.tabbedPane.getTabCount() - 1).getContentComponent();
irp.historique.addInfosln(Messages.getString("ClassificationImage.2")); //$NON-NLS-1$
if (result.getData().getDataObject(0).getAttribute(0) instanceof AttributeMultiDimSequence) {
if (result.getData().getOneDataObject().getAttribute(0) instanceof AttributeMultiDimSequence) {
irp.historique.addInfosln(Messages.getString("ClassificationImage.3")); //$NON-NLS-1$
irp.historique.addInfosln(result.getData().getDataFileName());
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$
......
package mustic.gui;
import javax.swing.event.InternalFrameEvent;
public class DataDesktopFrame extends DesktopFrame {
private static final long serialVersionUID = 1L;
/**
* Chaque DesktopFrame corresponde a une ImageSession => On utilise le
* MusticDesktop comme manager pour les DesktopFrames et pour les
* ImageSessions dans le meme temps (les methode utilise sont decrit en java
* API, classe JDesktopPane remove JInternalFrame, add JInternalFrame etc.)
*/
private DataSession dataSession = null;
public DataDesktopFrame(DataSession _session) {
super(_session.getTitle(), true, true, true);
this.dataSession = _session;
dataSession.associatedFrame = this;
this.add(dataSession.getWorkSpace());
}
public DataSession getDataSession() {
return this.dataSession;
}
@Override
public void internalFrameClosed(InternalFrameEvent e) {
MainFrame.getInstance().removeDataNode(this.dataSession);
this.dataSession = null;
}
@Override
public void internalFrameClosing(InternalFrameEvent e) {
this.dispose();
}
@Override
public void internalFrameDeactivated(InternalFrameEvent e) {
}
@Override
public void internalFrameDeiconified(InternalFrameEvent e) {
}
@Override
public void internalFrameIconified(InternalFrameEvent e) {
}
@Override
public void internalFrameOpened(InternalFrameEvent e) {
}
@Override
public void internalFrameActivated(InternalFrameEvent e) {
}
}
package mustic.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import jcl.data.Data;
import mustic.gui.panels.ImageResultPanel;
import mustic.gui.panels.data.DataPanel;
import mustic.io.ImageData;
import net.infonode.tabbedpanel.TabbedPanel;
import net.infonode.tabbedpanel.titledtab.TitledTab;
/**
* Class that manage the creation and the storage of a Data object
*
* @author Baptiste LAFABREGUE
*
*/
public class DataSession {
/**
* parametre permettant de savoir si l'image ouverte provient de la base de donnees
* ?? repris d'ImageSession
*/
public JInternalFrame associatedFrame = null;
/** the data attached to this session */
private Data data;
/** Title of the session */
private String mTitle;
/** Contains image, classifier, results */
protected TabbedPanel mWorskSpace;
/** all ImageResultPanels associated to this session */
private Vector<ImageResultPanel> resultPanels = new Vector<ImageResultPanel>();
private DataPanel dataPanel;
/** save the number of clustering already done a the overall sessions */
public static int nbClustering = 1;
/**
* Constructor
* @param data
* the data attached to this session
*/
public DataSession(Data data) {
this.data = data;
this.mTitle = "Data - "+data.getDataName();
this.dataPanel = new DataPanel(data);
this.mWorskSpace = dataPanel.tabbedPane;
}
/**
* Add a classifier for the data
* @param classificationImage
*/
public void addClassifier(ClassificationImage classificationImage) {
final TitledTab tab = new TitledTab(Messages.getString("ImageSession.7") + nbClustering++, //$NON-NLS-1$
null, classificationImage.tabbedPane, new JPanel());
tab.setFocusableComponent(null);
JButton closeButton = new JButton(new ImageIcon(tab.getClass().getResource("/icons/cluster-invisible.png"))); //$NON-NLS-1$
closeButton.setOpaque(false);
closeButton.setUI(new javax.swing.plaf.metal.MetalButtonUI());
closeButton.setMargin(null);
closeButton.setBorder(new EmptyBorder(1, 1, 1, 1));
closeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tab.getTabbedPanel().removeTab(tab);
}
});
tab.setHighlightedStateTitleComponent(closeButton);
this.mWorskSpace.addTab(tab);
this.mWorskSpace.setSelectedTab(tab);
}
public void addResultPanel(ImageResultPanel panel) {
if (this.resultPanels == null) {
this.resultPanels = new Vector<ImageResultPanel>();
}
this.resultPanels.add(panel);
}
public void decreaseBrightness() {
if (this.resultPanels != null) {
for (ImageResultPanel panel : this.resultPanels) {
panel.decreaseBrightness();
}
}
}
public void decreaseContrast() {
if (this.resultPanels != null) {
for (ImageResultPanel panel : this.resultPanels) {
panel.decreaseContrast();
}
}
}
public void increaseBrightness() {
if (this.resultPanels != null) {
for (ImageResultPanel panel : this.resultPanels) {
panel.increaseBrightness();
}
}
}
public void increaseContrast() {
if (this.resultPanels != null) {
for (ImageResultPanel panel : this.resultPanels) {
panel.increaseContrast();
}
}
}
public void zoomIn() {
if (this.resultPanels != null) {
for (ImageResultPanel panel : this.resultPanels) {
panel.zoomIn();
}
}
}
public void zoomOut() {
if (this.resultPanels != null) {
for (ImageResultPanel panel : this.resultPanels) {
panel.zoomOut();
}
}
}
synchronized public Vector<ImageResultPanel> getResultPanels() {
return this.resultPanels;
}
public Data getData() {
return data;
}
public void setTile(String title) {
this.mTitle = title;
}
public String getTitle() {
return mTitle;
}
public TabbedPanel getWorkSpace() {
return this.mWorskSpace;
}
@Override
public String toString() {
return this.mTitle; //$NON-NLS-1$
}
public Vector<ImageSession> getAssociatedImageSessions() {
if(data instanceof ImageData) {
if (((ImageData) data).getAssociatedImageSessions() != null
&& ((ImageData) data).getAssociatedImageSessions().size() > 0) {
return ((ImageData) data).getAssociatedImageSessions();
}
}
return null;
}
}
\ No newline at end of file
......@@ -8,105 +8,40 @@ import javax.swing.WindowConstants;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;
public class DesktopFrame extends JInternalFrame implements
abstract public class DesktopFrame extends JInternalFrame implements
InternalFrameListener {
private static final long serialVersionUID = 1L;
/**
* Chaque DesktopFrame corresponde a une ImageSession => On utilise le
* MusticDesktop comme manager pour les DesktopFrames et pour les
* ImageSessions dans le meme temps (les methode utilise sont decrit en java
* API, classe JDesktopPane remove JInternalFrame, add JInternalFrame etc.)
*/
private ImageSession imageSession = null;
public DesktopFrame(ImageSession _session) {
super(_session.mTitle, true, true, true);
this.imageSession = _session;
public DesktopFrame(String mTitle, boolean b, boolean c, boolean d) {
super(mTitle,b,c,d);
setSize(300, 200);
setIconifiable(true);
setVisible(true);
imageSession.associatedFrame = this;
addInternalFrameListener(this);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.add(imageSession.getWorkSpace());
try {
setSelected(true);
} catch (java.beans.PropertyVetoException e) {
}
}
public void addROITools() {
// creation du module
ROIToolsFrame module = imageSession.getImagePanel().getROIToolsFrame();
if (module == null) {
module = new ROIToolsFrame(imageSession);
}
this.imageSession.gardeInstance(module);
MainFrame.getInstance().getDesktop().add(module);
try {
module.setSelected(true);
module.setVisible(true);
} catch (PropertyVetoException e) {
}
}
public void closeModuleROI() {
ROIToolsFrame roi = this.imageSession.getImagePanel()
.getROIToolsFrame();
if (roi != null && !roi.isClosed()) {
int answer = JOptionPane.showConfirmDialog(this,
Messages.getString("DesktopFrame.0"), Messages.getString("DesktopFrame.1"), //$NON-NLS-1$ //$NON-NLS-2$
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (answer == JOptionPane.YES_OPTION) {
roi.saveRoiAs();
}
try {
roi.setClosed(true);
} catch (PropertyVetoException ex) {
}
}
}
public ImageSession getImageSession() {
return this.imageSession;
}
/**
* quand on selectionne une autre fenetre, on met a jour le birdpanel et
* l'info panel qui correspond a l'image si on visionne l'image. si on
* visionne un result
*/
@Override
public void internalFrameActivated(InternalFrameEvent e) {
MainFrame.getInstance().setInfosPanel(this.imageSession.getInfoPanel());
MainFrame.getInstance().getInfosPanel().repaint();
MainFrame.getInstance().setBirdPanel(this.imageSession.getBirdPanel());
MainFrame.getInstance().getBirdPanel().repaint();
}
abstract public void internalFrameActivated(InternalFrameEvent e);
@Override
public void internalFrameClosed(InternalFrameEvent e) {
MainFrame.getInstance().removeNode(this.imageSession);
this.imageSession = null;
}
abstract public void internalFrameClosed(InternalFrameEvent e);
@Override
public void internalFrameClosing(InternalFrameEvent e) {
this.closeModuleROI();
this.dispose();
}
......@@ -130,8 +65,4 @@ public class DesktopFrame extends JInternalFrame implements
}
public void setImegeSession(ImageSession imgSession) {
this.imageSession = imgSession;
}
}
package mustic.gui;
import java.beans.PropertyVetoException;
import javax.swing.JOptionPane;
import javax.swing.event.InternalFrameEvent;
public class ImageDesktopFrame extends DesktopFrame {
private static final long serialVersionUID = 1L;
/**
* Chaque DesktopFrame corresponde a une ImageSession => On utilise le
* MusticDesktop comme manager pour les DesktopFrames et pour les
* ImageSessions dans le meme temps (les methode utilise sont decrit en java
* API, classe JDesktopPane remove JInternalFrame, add JInternalFrame etc.)
*/
private ImageSession imageSession = null;
public ImageDesktopFrame(ImageSession _session) {
super(_session.mTitle, true, true, true);
this.imageSession = _session;
imageSession.associatedFrame = this;
this.add(imageSession.getWorkSpace());
}
public void addROITools() {
// creation du module
ROIToolsFrame module = imageSession.getImagePanel().getROIToolsFrame();
if (module == null) {
module = new ROIToolsFrame(imageSession);
}
this.imageSession.gardeInstance(module);
MainFrame.getInstance().getDesktop().add(module);
try {
module.setSelected(true);
module.setVisible(true);
} catch (PropertyVetoException e) {
}
}
public void closeModuleROI() {
ROIToolsFrame roi = this.imageSession.getImagePanel()
.getROIToolsFrame();
if (roi != null && !roi.isClosed()) {
int answer = JOptionPane.showConfirmDialog(this,
Messages.getString("DesktopFrame.0"), Messages.getString("DesktopFrame.1"), //$NON-NLS-1$ //$NON-NLS-2$
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (answer == JOptionPane.YES_OPTION) {
roi.saveRoiAs();
}
try {
roi.setClosed(true);
} catch (PropertyVetoException ex) {
}
}
}
public ImageSession getImageSession() {
return this.imageSession;
}
/**
* quand on selectionne une autre fenetre, on met a jour le birdpanel et
* l'info panel qui correspond a l'image si on visionne l'image. si on
* visionne un result
*/
@Override
public void internalFrameActivated(InternalFrameEvent e) {
MainFrame.getInstance().setInfosPanel(this.imageSession.getInfoPanel());
MainFrame.getInstance().getInfosPanel().repaint();
MainFrame.getInstance().setBirdPanel(this.imageSession.getBirdPanel());
MainFrame.getInstance().getBirdPanel().repaint();
}
@Override
public void internalFrameClosed(InternalFrameEvent e) {
MainFrame.getInstance().removeImageNode(this.imageSession);
this.imageSession = null;
}
@Override
public void internalFrameClosing(InternalFrameEvent e) {
this.closeModuleROI();
this.dispose();
}
@Override
public void internalFrameDeactivated(InternalFrameEvent e) {
}
@Override
public void internalFrameDeiconified(InternalFrameEvent e) {
}
@Override
public void internalFrameIconified(InternalFrameEvent e) {
}
@Override
public void internalFrameOpened(InternalFrameEvent e) {
}
public void setImageSession(ImageSession imgSession) {
this.imageSession = imgSession;
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -12,13 +12,10 @@ import javax.swing.JOptionPane;
import javax.swing.WindowConstants;
/**
* Cette classe est utilise pour l'interface graphyque.
* This class is used for the GUI
*
* On utilise la classe MusticDesktop comme manager pour les DesktopFrames et
* pour les ImageSessions dans le meme temps (Chaque DesktopFrame corresponde a
* une ImageSession) (les methode utilise pour le gestione des JInternalFrame et
* ImageSession sont decrit en java API, dans la classe JDesktopPane exemples:
* remove JInternalFrame, add JInternalFrame etc.)
* We use the MusticDesktop class to manage the DesktopFrames.
* Those DesktopFrames are either, ImageSessions frames or DataSession frames.
*/
public class MusticDesktop extends JDesktopPane {
......@@ -98,12 +95,14 @@ public class MusticDesktop extends JDesktopPane {
}
/**
* Add an ImageSession to the desktop
*