Commit 5386ad76 authored by harrison's avatar harrison
Browse files

Vue éclaté avec JTabbedPanel custom ( drag and drop ) et JTree pour controler...

Vue éclaté avec JTabbedPanel custom ( drag and drop ) et JTree pour controler les resultat que l'on visualise
parent 46bc574a
File mode changed from 100644 to 100755
package mustic.gui;
import java.awt.Container;
import java.lang.management.ManagementFactory;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
......@@ -7,6 +8,7 @@ import java.util.Date;
import java.util.Iterator;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import jcl.Classification;
......@@ -64,6 +66,10 @@ public class ClassificationImage extends ClassificationModel {
pane.addTab(t1);
t1.setSelected(true);
}
public JPanel test() {
//System.out.println(tabbedPane.getParent().getClass());
return classifierPanel;
}
@Override
public void doOperationAfterClassification(Classification result) {
......
package mustic.gui;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.Spring;
import javax.swing.WindowConstants;
import mustic.models.gui.ClassificationModel;
import net.infonode.tabbedpanel.Tab;
import net.infonode.tabbedpanel.TabbedPanel;
import mustic.models.gui.panels.ResultPanel;
public class ClassificationResultFrame extends JFrame{
private TabbedPanel _pere;
private Container _jComponent;
private JFrame jFrame;
private Container _contain;
private int tmpmp;
private int _index;
private String _name;
private Container _tab;
private ClassificationModel _classifModel;
private TabbedPanel _tabbed;
public ClassificationResultFrame(JPanel jComponent , String mTitle, Container contain) {
super(mTitle);
setSize(300, 200);
this.add(jComponent);
_jComponent = jComponent;
_contain = contain;
setVisible(true);
//addInternalFrameListener(this);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
JButton returnButton = new JButton(new ImageIcon(getClass().getResource("/icons/icons_toInternalFrame.png"))); //$NON-NLS-1$
returnButton.setToolTipText(Messages.getString("MainFrame.125")); //$NON-NLS-1$
returnButton.setFocusable(false);
returnButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(_contain.getComponentCount());
//((TabContentPanel)(_contain));
_contain.getParent().add(_jComponent);
System.out.println(_contain.getComponentCount());
//jFrame.dispose();
}
});
toolBar.add(returnButton);
this.add(toolBar, BorderLayout.PAGE_START);
jFrame = this;
}
public ClassificationResultFrame(JPanel jComponent , String mTitle, int index,TabbedPanel tabbed, ClassificationModel classifModel) {
super(mTitle);
setSize(300, 200);
this.add(jComponent);
_jComponent = jComponent;
_classifModel = classifModel;
_name = mTitle;
_index = index;
_tabbed = tabbed;
((ResultPanel)jComponent).isInFrame = true;
setVisible(true);
//addInternalFrameListener(this);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
JButton returnButton = new JButton(new ImageIcon(getClass().getResource("/icons/icons_toInternalFrame.png"))); //$NON-NLS-1$
returnButton.setToolTipText(Messages.getString("MainFrame.125")); //$NON-NLS-1$
returnButton.setFocusable(false);
returnButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Tab t1 = ClassificationModel.createTab(_name, new ImageIcon(getClass()
.getResource("/icons/actions/document-open-result.png")), //$NON-NLS-1$
jComponent, true);
_tabbed.insertTab(t1,index-_classifModel.getCountResultToFrame((ResultPanel)jComponent));
((ResultPanel)jComponent).test.changeValueOutToList((ResultPanel)jComponent);;
/*_tabbed.insertTab(_name, new ImageIcon(getClass()
.getResource("/icons/actions/document-open-result.png")), //$NON-NLS-1$
jComponent, null,index);*/
((ResultPanel)jComponent).isInFrame = false;
t1.setSelected(true);
jFrame.dispose();
}
});
toolBar.add(returnButton);
this.add(toolBar, BorderLayout.PAGE_START);
jFrame = this;
}
public ClassificationResultFrame(Container jComponent , String mTitle, Container contain, Container tab) {
super(mTitle);
setSize(300, 200);
/*JPanel panel = new JPanel();
panel.add(jComponent);*/
this.add(jComponent);
_jComponent = jComponent;
_contain = contain;
_tab = tab;
setVisible(true);
//addInternalFrameListener(this);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
JButton returnButton = new JButton(new ImageIcon(getClass().getResource("/icons/icons_toInternalFrame.png"))); //$NON-NLS-1$
returnButton.setToolTipText(Messages.getString("MainFrame.125")); //$NON-NLS-1$
returnButton.setFocusable(false);
returnButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
/*System.out.println(_contain.getParent().getComponentCount());
System.out.println(_jComponent.getParent().getComponentCount());
System.out.println(_jComponent.getParent().getParent().getComponentCount());
System.out.println(_jComponent.getParent().getParent().getParent().getComponentCount());*/
//((TabContentPanel)(_contain));
_contain.add(jComponent);
//System.out.println(_contain.getParent().getComponentCount());
_tab.setVisible(true);
jFrame.dispose();
}
});
toolBar.add(returnButton);
this.add(toolBar, BorderLayout.PAGE_START);
jFrame = this;
}
public ClassificationResultFrame(JComponent jComponent , String mTitle, TabbedPanel pere) {
super(mTitle);
setSize(300, 200);
this.add(jComponent);
_jComponent = jComponent;
_pere = pere;
setVisible(true);
//addInternalFrameListener(this);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
JButton returnButton = new JButton(new ImageIcon(getClass().getResource("/icons/icons_toInternalFrame.png"))); //$NON-NLS-1$
returnButton.setToolTipText(Messages.getString("MainFrame.125")); //$NON-NLS-1$
returnButton.setFocusable(false);
returnButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//TabbedPanel tmp = new TabbedPanel();
//new Tab().add(_jComponent);
//tmp.setName(mTitle);
//tmp.add(_jComponent);
//Tab tmp = new Tab();
/*tmp.add("Tab 2", null, _jComponent,
"Does twice as much nothing");*/
System.out.println(_pere.getTabCount());
_pere.addTab((Tab) _jComponent);
//addTab("Tab 2", null, _jComponent,
// "Does twice as much nothing");
jFrame.dispose();
}
});
toolBar.add(returnButton);
this.add(toolBar, BorderLayout.PAGE_START);
jFrame = this;
}
public ClassificationResultFrame(JComponent jComponent , String mTitle, TabbedPanel pere,int index) {
super(mTitle);
setSize(300, 200);
this.add(jComponent);
_jComponent = jComponent;
_pere = pere;
tmpmp = index;
setVisible(true);
//addInternalFrameListener(this);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
JButton returnButton = new JButton(new ImageIcon(getClass().getResource("/icons/icons_toInternalFrame.png"))); //$NON-NLS-1$
returnButton.setToolTipText(Messages.getString("MainFrame.125")); //$NON-NLS-1$
returnButton.setFocusable(false);
returnButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//TabbedPanel tmp = new TabbedPanel();
//new Tab().add(_jComponent);
//tmp.setName(mTitle);
//tmp.add(_jComponent);
//Tab tmp = new Tab();
/*tmp.add("Tab 2", null, _jComponent,
"Does twice as much nothing");*/
System.out.println(_pere.getTabCount());
//_pere.addTab((Tab) _jComponent);
//((TabbedPanel)_pere.getTabAt(index).getContentComponent()).getTabAt(0).add(_jComponent);
_pere.getTabAt(index).setVisible(true);
//addTab("Tab 2", null, _jComponent,
// "Does twice as much nothing");
jFrame.dispose();
}
});
toolBar.add(returnButton);
this.add(toolBar, BorderLayout.PAGE_START);
jFrame = this;
}
}
......@@ -19,9 +19,11 @@ public class DataDesktopFrame extends DesktopFrame {
super(_session.getTitle(), true, true, true);
this.dataSession = _session;
dataSession.associatedFrame = this;
dataSession.associatedFrame = this.getFrame();
this.add(dataSession.getWorkSpace());
MainFrame.getInstance().getDesktop().addList(this);
}
......@@ -30,7 +32,7 @@ public class DataDesktopFrame extends DesktopFrame {
return this.dataSession;
}
@Override
/*@Override
public void internalFrameClosed(InternalFrameEvent e) {
MainFrame.getInstance().removeDataNode(this.dataSession);
this.dataSession = null;
......@@ -65,6 +67,6 @@ public class DataDesktopFrame extends DesktopFrame {
@Override
public void internalFrameActivated(InternalFrameEvent e) {
}
}*/
}
......@@ -2,6 +2,7 @@ package mustic.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;
import java.util.Vector;
import javax.swing.Icon;
......@@ -21,6 +22,7 @@ import mustic.io.ImageData;
import mustic.models.gui.ClassificationModel;
import mustic.models.gui.panels.ResultPanel;
import mustic.utils.image.ImageDisplayer;
import net.infonode.tabbedpanel.Tab;
import net.infonode.tabbedpanel.TabDragEvent;
import net.infonode.tabbedpanel.TabEvent;
import net.infonode.tabbedpanel.TabFactory;
......@@ -65,6 +67,8 @@ public class DataSession {
private Vector<ClassificationModel> classifications = new Vector<ClassificationModel>();
public Vector<JPanel> panelsTabbed = new Vector<JPanel>();
public Vector<Tab> panelsTabbed2 = new Vector<Tab>();
/** save the number of clustering already done a the overall sessions */
public static int nbClustering = 1;
......@@ -151,10 +155,13 @@ public class DataSession {
public void addClassifier(final ClassificationModel classificationModel) {
classifications.add(classificationModel);
classificationModel.setTitle(Messages.getString("ImageSession.7") + nbClustering);
JPanel panelTab = new JPanel();
final TitledTab tab = new ClassificationTitledTab(Messages.getString("ImageSession.7") + nbClustering++, //$NON-NLS-1$
null, classificationModel.tabbedPane, new JPanel(), classificationModel);
null, classificationModel.tabbedPane, panelTab, classificationModel);
tab.setFocusableComponent(null);
panelsTabbed.add(panelTab);
panelsTabbed2.add(tab);
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());
......@@ -164,6 +171,7 @@ public class DataSession {
@Override
public void actionPerformed(ActionEvent e) {
tab.getTabbedPanel().removeTab(tab);
MainFrame.getInstance().UpdateDataProjectTree();
classifications.remove(classificationModel);
for (ResultPanel r : classificationModel.getResultPanels()) {
resultPanels.remove(r);
......@@ -187,6 +195,21 @@ public class DataSession {
classificationImage.tabbedPane.addTab(tabClassifier);
//classificationImage.tabbedPane.getTabAt(1).setSelected(true);
}
public void selecTab(ClassificationModel model) {
for(int i=0 ; i<this.classifications.size(); i++) {
if(model == this.classifications.get(i)) {
this.mWorskSpace.setSelectedTab(this.mWorskSpace.getTabAt(i+1));
try {
associatedFrame.setSelected(true);
MainFrame.getInstance().setCurrentDataSession(this);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
public void addResultPanel(ResultPanel panel) {
if (this.resultPanels == null) {
......
package mustic.gui;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Panel;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.RoundRectangle2D;
import java.beans.PropertyVetoException;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.JToolBar;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.border.AbstractBorder;
......@@ -24,63 +35,217 @@ import javax.swing.plaf.basic.BasicInternalFrameUI;
import mustic.gui.panels.designe.Designer;
import mustic.gui.panels.designe.MyBorder;
import mustic.gui.panels.designe.TextBubbleBorder;
import net.infonode.tabbedpanel.TabbedPanel;
abstract public class DesktopFrame extends JInternalFrame implements
InternalFrameListener {
abstract public class DesktopFrame {
private static final long serialVersionUID = 1L;
private boolean flagInternalFrame = true;
private MusticInternalFrame tmp;
private MusticFrame tmp2;
private Panel panel;
private TabbedPanel tabbedPanel;
private int type;
private String title;
private MusticDesktop musticDesktop;
private boolean _b, _c, _d;
public DesktopFrame(String mTitle, boolean b, boolean c, boolean d) {
super(mTitle,b,c,d);
setSize(300, 200);
setIconifiable(true);
setVisible(true);
addInternalFrameListener(this);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setOpaque(false);
try {
setSelected(true);
} catch (java.beans.PropertyVetoException e) {
}
title = mTitle;
tmp = new MusticInternalFrame( mTitle, b, c, d);
_b = b;
_c = c;
_d = d;
}
/**
* 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
abstract public void internalFrameActivated(InternalFrameEvent e);
public void add(Panel panel) {
this.panel = panel;
type = 1;
if(flagInternalFrame) {
tmp.add(panel);
}
}
public void add(MusticDesktop desktop) {
musticDesktop = desktop;
}
@Override
abstract public void internalFrameClosed(InternalFrameEvent e);
@Override
public void internalFrameClosing(InternalFrameEvent e) {
this.dispose();
public void add(TabbedPanel panel) {
this.tabbedPanel = panel;
type = 2;
if(flagInternalFrame) {
tmp.add(panel);
}
}
public boolean isSelected() {
if(flagInternalFrame) {
return tmp.isSelected();
}
return false;
}
public JInternalFrame getFrame() {
if(flagInternalFrame) {
return tmp;
}
return null;
}
public void setMaximum(boolean bool) {
if(flagInternalFrame) {
try {
tmp.setMaximum(bool);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
};
}
}
public void setSelected(boolean bool) {
if(flagInternalFrame) {
try {
tmp.setSelected(bool);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
};
}
}
public void setLocation(int x,int y ) {
if(flagInternalFrame) {
tmp.setLocation(x,y);
}
}
public void setSize(Dimension dim) {
if(flagInternalFrame) {
tmp.setSize(dim);
}
}
public void changeView(){
if(flagInternalFrame) {
tmp2 = new MusticFrame(title,this);
tmp2.setVisible(true);
switch(type) {
case 1:tmp2.add(panel);
break;
case 2:tmp2.add(tabbedPanel);
}
tmp.dispose();
flagInternalFrame = false;
}else {
tmp = new MusticInternalFrame( title, _b, _c, _d);
switch(type) {
case 1:tmp.add(panel);
break;
case 2:tmp.add(tabbedPanel);
}
tmp2.dispose();
musticDesktop.add(tmp);
flagInternalFrame = true;
}
}
class MusticInternalFrame extends JInternalFrame implements InternalFrameListener{
@Override
public void internalFrameDeactivated(InternalFrameEvent e) {
public MusticInternalFrame(String mTitle, boolean b, boolean c, boolean d) {
super(mTitle,b,c,d);
setSize(300, 200);
setIconifiable(true);
setVisible(true);
addInternalFrameListener(this);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setOpaque(false);
try {
setSelected(true);
} catch (java.beans.PropertyVetoException e) {
}
}
/**
* 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 internalFrameClosing(InternalFrameEvent e) {
this.dispose();
}
}
@Override
public void internalFrameDeactivated(InternalFrameEvent e) {
@Override
public void internalFrameDeiconified(InternalFrameEvent e) {
}
}
@Override
public void internalFrameDeiconified(InternalFrameEvent e) {
@Override
public void internalFrameIconified(InternalFrameEvent e) {
}
}
@Override
public void internalFrameIconified(InternalFrameEvent e) {
@Override
public void internalFrameOpened(InternalFrameEvent e) {
}
}
@Override
public void internalFrameOpened(InternalFrameEvent e) {
}
@Override
public void internalFrameActivated(InternalFrameEvent e) {
// TODO Auto-generated method stub
}
@Override
public void internalFrameClosed(InternalFrameEvent e) {
// TODO Auto-generated method stub
}
}
class MusticFrame extends JFrame{
public DesktopFrame _pere;
public MusticFrame(String mTitle,DesktopFrame pere) {