Commit b4beb7d2 authored by lafabregue's avatar lafabregue

tmp commit

parent 8fa09c81
......@@ -21,6 +21,8 @@ import net.infonode.tabbedpanel.TabbedPanel;
public class ClassificationImage extends ClassificationModel {
/** */
private static final long serialVersionUID = 1L;
private DataSession session = null;
/** */
......@@ -32,14 +34,16 @@ public class ClassificationImage extends ClassificationModel {
* @param data
* @param title
*/
public ClassificationImage(Data data, String title) {
super(data, title, false);
public ClassificationImage(DataSession session, String title) {
super(session.getData(), title, false);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.session = session;
}
public ClassificationImage(Data data, String title, boolean justData) {
super(data, title, justData);
public ClassificationImage(DataSession session, String title, boolean justData) {
super(session.getData(), title, justData);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.session = session;
}
/**
......@@ -55,10 +59,11 @@ public class ClassificationImage extends ClassificationModel {
TabbedPanel pane) {
ResultPanel rpanel = null;
if (data instanceof ImageData) {
rpanel = new ImageResultPanel(result, this, ((ImageData) data));
rpanel = new ImageResultPanel(session, result, this, ((ImageData) data));
} else {
rpanel = new ResultPanel(result, this);
}
rpanel.setName(title);
Tab t1 = ClassificationModel.createTab(title, new ImageIcon(getClass()
.getResource("/icons/actions/document-open-result.png")), //$NON-NLS-1$
rpanel, true);
......
......@@ -4,16 +4,25 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import jcl.data.Data;
import mustic.gui.panels.BirdViewPanel;
import mustic.gui.panels.ImageResultPanel;
import mustic.gui.panels.data.DataPanel;
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.titledtab.TitledTab;
......@@ -29,24 +38,32 @@ public class DataSession {
* parametre permettant de savoir si l'image ouverte provient de la base de donnees
* ?? repris d'ImageSession
*/
public JInternalFrame associatedFrame = null;
public JInternalFrame associatedFrame = null;
/** the data attached to this session */
private Data data;
private Data data = null;
/** Title of the session */
private String mTitle;
private String mTitle;
/** Contains image, classifier, results */
protected TabbedPanel mWorskSpace;
protected TabbedPanel mWorskSpace = new TabbedPanel();
/** 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 */
public static int nbClustering = 1;
public static int nbClustering = 1;
/**
......@@ -60,17 +77,71 @@ public class DataSession {
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
* @param classificationImage
* @param classificationModel
*/
public void addClassifier(ClassificationImage classificationImage) {
final TitledTab tab = new TitledTab(Messages.getString("ImageSession.7") + nbClustering++, //$NON-NLS-1$
null, classificationImage.tabbedPane, new JPanel());
public void addClassifier(final ClassificationModel classificationModel) {
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);
JButton closeButton = new JButton(new ImageIcon(tab.getClass().getResource("/icons/cluster-invisible.png"))); //$NON-NLS-1$
......@@ -82,6 +153,7 @@ public class DataSession {
@Override
public void actionPerformed(ActionEvent e) {
tab.getTabbedPanel().removeTab(tab);
classifications.remove(classificationModel);
}
});
tab.setHighlightedStateTitleComponent(closeButton);
......@@ -170,6 +242,11 @@ public class DataSession {
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() {
if(data instanceof ImageData) {
if (((ImageData) data).getAssociatedImageSessions() != null
......@@ -180,4 +257,50 @@ public class DataSession {
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 {
private JPanel infosPanel;
/** boolean pour lier le birdview avec l'image active */
private boolean linkToAllImages = false;
private boolean linkToAllImages = true;
/** the project root for datas */
private DefaultMutableTreeNode mDataProjectNode;
......@@ -702,23 +702,24 @@ public class MainFrame extends JFrame {
CSVMenu.add(menuItemLoadCSVToData);
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);
//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);
// menuItemResultToCSV = new JMenuItem(Messages.getString("MainFrame.305")); //$NON-NLS-1$
// menuItemResultToCSV.addActionListener(new ActionListener() {
......@@ -840,21 +841,25 @@ public class MainFrame extends JFrame {
menuView.add(menuContrast);
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() {
@Override
public void actionPerformed(ActionEvent e) {
MainFrame.getInstance().setLierBirdView(true);
MainFrame.getInstance().setLierBirdView(false);
menuConnectActiv.setState(true);
menuConnectAll.setState(false);
}
});
menuConnect.add(menuConnectActiv);
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() {
@Override
public void actionPerformed(ActionEvent e) {
MainFrame.getInstance().setLierBirdView(false);
MainFrame.getInstance().setLierBirdView(true);
menuConnectActiv.setState(false);
menuConnectAll.setState(true);
}
});
group.add(menuConnectActiv);
......@@ -1137,8 +1142,8 @@ public class MainFrame extends JFrame {
private Boolean actionContratsP;
private JMenuItem menuContrastM;
private Boolean actionContrastM;
private JMenuItem menuConnectActiv;
private JMenuItem menuConnectAll;
private JCheckBoxMenuItem menuConnectActiv;
private JCheckBoxMenuItem menuConnectAll;
private JMenuItem menuResetAll;
private Boolean actionResetAll;
private JMenuItem menuChooseRgb;
......@@ -1316,8 +1321,10 @@ public class MainFrame extends JFrame {
menuBrightM.setEnabled(this.actionBrightM);
menuContrastP.setEnabled(this.actionContratsP);
menuContrastM.setEnabled(this.actionContrastM);
menuConnectActiv.setEnabled(!this.isLinkToAllBirdView());
menuConnectAll.setEnabled(this.isLinkToAllBirdView());
menuConnectActiv.setEnabled(this.isLinkToAllBirdView());
menuConnectAll.setEnabled(!this.isLinkToAllBirdView());
menuConnectActiv.setState(!this.isLinkToAllBirdView());
menuConnectAll.setState(this.isLinkToAllBirdView());
menuResetAll.setEnabled(this.actionResetAll);
menuChooseRgb.setEnabled(this.actionChooseRgb);
menuRefresh.setEnabled(this.actionRefresh);
......@@ -1612,14 +1619,11 @@ public class MainFrame extends JFrame {
this.desktop.addDataFrame(dataSession);
else
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 ================
JPanel panel_desktop = new JPanel(new BorderLayout());
......@@ -2093,6 +2097,9 @@ public class MainFrame extends JFrame {
refreshButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (currentImageSession != null) {
currentImageSession.getImagePanel().resetAll();
}
MainFrame.this.repaint();
}
});
......@@ -3712,10 +3719,6 @@ public class MainFrame extends JFrame {
public void setLaunchOrthoRect(boolean launchOrthoRect) {
this.launchOrthoRect = launchOrthoRect;
}
private void exportData() {
}
private void customClassify() {
HybridClassification classification = new HybridClassification();
......@@ -3796,7 +3799,7 @@ public class MainFrame extends JFrame {
//// >>>> REPLACE PARAM
Thread t = null;
ClassificationImage classificationImage = new ClassificationImage(dataTest,
ClassificationImage classificationImage = new ClassificationImage(testSession,
Messages.getString("ClassifierPanel.73") + DataSession.nbClustering, //$NON-NLS-1$
true);
......
......@@ -6,6 +6,7 @@ import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.swing.*;
......@@ -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
public double[][][] load(int x, int y, int w, int h) {
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;
......@@ -614,7 +591,7 @@ public class CropDialog extends JInternalFrame {
} catch (Exception e) {}
}
public void save_actionPerformed() {
public void save_actionPerformed() {
JFileChooser fileChooser = new JFileChooser();
String path = CropDialog.this.session.getRawImage().getPath();
path = path.substring(0, path.length() - 4) + Messages.getString("CropDialog.30"); //$NON-NLS-1$
......@@ -756,8 +733,7 @@ public class CropDialog extends JInternalFrame {
MainFrame.getInstance().openSession(new File(path));
}
}
else {
} else {
File f = new File(path + ".bsq"); //$NON-NLS-1$
if (f.exists()) {
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;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector;
import javax.swing.JPanel;
import mustic.gui.ImageDesktopFrame;
import mustic.gui.ImageManager;
import mustic.gui.ImageSession;
import mustic.gui.MainFrame;
import mustic.io.PiLLiTools;
public class BirdViewPanel extends JPanel implements MouseListener,
MouseMotionListener {
MouseMotionListener, Observer {
/** Represents the moving action. */
static private final int ACT_MOVE = 1;
......@@ -594,34 +597,23 @@ public class BirdViewPanel extends JPanel implements MouseListener,
this.repaint();
this.action = BirdViewPanel.ACT_NONE;
if (!MainFrame.getInstance().isLinkToAllBirdView()) {
ImageDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllImageDesktopFrames();
int nbSessions = desktopFrames.length;
for (int i = 0; i < nbSessions; i++) {
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);
if(session instanceof ImageSession) {
if (MainFrame.getInstance().isLinkToAllBirdView()) {
ImageDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllImageDesktopFrames();
int nbSessions = desktopFrames.length;
for (int i = 0; i < nbSessions; i++) {
syncImage(desktopFrames[i].getImageSession());
}
} else {
if (session != null) {
syncImage();
}
}
} else {
if (session != null) {
syncImage(session);
session.getImageDisplayer().reloadPoint(
session.getBirdViewPanel().xxsave,
session.getBirdViewPanel().yysave,
session.getBirdViewPanel().rxsave,
session.getBirdViewPanel().rysave);
syncImage();
}
}
......@@ -821,7 +813,41 @@ public class BirdViewPanel extends JPanel implements MouseListener,
if (ry < 0)
ry = 0;
this.session.getImageDisplayer().updateImageViewTo(rx, ry, width, height);
session.getImageDisplayer().updateImageViewTo(rx, ry, width, height);
}
@Override
public void update(Observable o, Object arg) {
// try {
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// double x_zoomFactor = 1;
// double y_zoomFactor = 1;
// double dest_w = 180;
// double dest_h = 200;
//
// // we considerate only the smallest zoom factor
// if (this.session.getRawImage().getWidth() > 0)
// x_zoomFactor = (double) dest_w / (double) this.session.getRawImage().getWidth();
// if (this.session.getRawImage().getHeight() > 0)
// y_zoomFactor = (double) dest_h / (double) this.session.getRawImage().getHeight();
//
// if (MainFrame.DEBUG_MODE)
// System.out.println("public void createBirdview(int dest_w, int dest_h)" + dest_w + " " + dest_h + " "
// + x_zoomFactor + " " + y_zoomFactor);
//
// if (x_zoomFactor < y_zoomFactor)
// {
// this.mBirdImage = this.session.getImageDisplayer().getBirdViewImage(x_zoomFactor);
// }
// else
// {
// this.mBirdImage = this.session.getImageDisplayer().getBirdViewImage(y_zoomFactor);
// }
}
}
\ No newline at end of file
......@@ -499,11 +499,11 @@ public class ImageInformationPanel extends JPanel {
// TODO voir ce qui ne va pas
int r, g, b;
r = MainFrame.getInstance().getCurrentImageSession().getBirdViewPanel()
r = MainFrame.getInstance().getCurrentImageSession().getRawImage()
.getR();
g = MainFrame.getInstance().getCurrentImageSession().getBirdViewPanel()
g = MainFrame.getInstance().getCurrentImageSession().getRawImage()
.getG();
b = MainFrame.getInstance().getCurrentImageSession().getBirdViewPanel()
b = MainFrame.getInstance().getCurrentImageSession().getRawImage()
.getB();
if (r == g && g == b) {
renderer2.setSeriesPaint(0, Color.black);
......
This diff is collapsed.
......@@ -38,6 +38,7 @@ import mustic.utils.Packager;
import mustic.utils.filters.*;
import mustic.utils.image.BufferedImageHelper;
import mustic.utils.image.ClusteringImageViewer;
import mustic.utils.image.ImageHelper;
import mustic.utils.image.ImageViewer;
import mustic.utils.image.MultiResolutionClusterMap;
import mustic.utils.image.PyramidImageViewer;
......@@ -57,11 +58,11 @@ import org.apache.batik.svggen.SVGGraphics2DIOException;
public class ImageResultPanel extends ResultPanel implements TreeSelectionListener, ImageDisplayer, Zoomable {
/** serialVersionUID */
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
private float brightnessValue = 30;
private float brightnessValue = 30;
protected File currentDirectory = null;
protected File currentDirectory = null;
/** l'image contenant les donnees d'origine */
private BufferedImage data;
......@@ -71,11 +72,11 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
private ImageData imgData;
protected JInternalFrame jif_saveResult = new JInternalFrame();
protected JInternalFrame jif_saveResult = new JInternalFrame();
JLayeredPane lpane = new JLayeredPane();
protected JLayeredPane lpane = new JLayeredPane();
protected int[] map = null;
protected int[] map = null;
/** classification */
// protected Classification classification;
......@@ -83,65 +84,65 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
// protected RawImage mRawImage;
/** zoom level */
protected float mZoomRate = 1.0f;
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 */
private Point currentTopLeft = new Point(0,0);
private Point currentTopLeft = new Point(0,0);
/** width of the screen image */
private int lastWidth = 0;
private int lastWidth = 0;
/** height of the screen image */
private int lastHeight = 0;
private int lastHeight = 0;
/** offset between the panel and the actual displayed image */
private Point screenOffset = new Point(0,0);
private Point screenOffset = new Point(0,0);
/** */
protected JPanel panelImage = new JPanel(new BorderLayout());
protected JPanel panelImage = new JPanel(new BorderLayout());
protected JPanel panelResSave = new JPanel();
protected JPanel panelResSave = new JPanel();
protected ClusteringResult result;
protected boolean[] resultSave = null;
protected boolean[] resultSave = null;
private ROIImage roi = null;
private ROIImage roi = null;
protected int rx = 0;
protected int rx = 0;
protected int ry = 0;
protected int ry = 0;
private float scaleFactor = 1.0f;
private float scaleFactor = 1.0f;
/** */
protected JToolBar tools = new JToolBar();
protected JToolBar tools = new JToolBar();
protected JButton vectorise = new JButton("Segmentation");
protected JButton vectorise = new JButton("Segmentation");
/** */
protected BufferedImage zoomed;
/** the parent session */
private ImageManager imageManager = null;
private ImageManager imageManager = null;
/** panel that displays the image */
private ZoomBoxPanel displayPanel = null;
private ZoomBoxPanel displayPanel = null;
/** the viewer that allows to reader the image */
private ImageViewer viewer = null;
private ImageViewer viewer = null;
private MultiResolutionClusterMap clusterMap = null;
private MultiResolutionClusterMap clusterMap = null;
// clusters' opacity
// up to 0 - 1
public static float opacity = 1;
private float opacity = 1;
public static float opacityCluster = 1;
private float opacityCluster = 1;
/**