Commit 8fa09c81 authored by lafabregue's avatar lafabregue

change visulaisation in ImageResultPanel to ImageViewer interface

parent 704cea5d
This diff is collapsed.
......@@ -7,9 +7,9 @@ public class DataDesktopFrame extends DesktopFrame {
private static final long serialVersionUID = 1L;
/**
* Chaque DesktopFrame corresponde a une ImageSession => On utilise le
* Chaque DesktopFrame corresponde a une DataSession => On utilise le
* MusticDesktop comme manager pour les DesktopFrames et pour les
* ImageSessions dans le meme temps (les methode utilise sont decrit en java
* DataSessions dans le meme temps (les methode utilise sont decrit en java
* API, classe JDesktopPane remove JInternalFrame, add JInternalFrame etc.)
*/
private DataSession dataSession = null;
......
......@@ -80,7 +80,7 @@ public class ImageDesktopFrame extends DesktopFrame {
public void internalFrameActivated(InternalFrameEvent e) {
MainFrame.getInstance().setInfosPanel(this.imageSession.getInfoPanel());
MainFrame.getInstance().getInfosPanel().repaint();
MainFrame.getInstance().setBirdPanel(this.imageSession.getBirdPanel());
MainFrame.getInstance().setBirdPanelContent(this.imageSession.getBirdPanel());
MainFrame.getInstance().getBirdPanel().repaint();
}
......
package mustic.gui;
import java.awt.image.BufferedImage;
public interface ImageDisplayer {
/**
* Return the full image with a given resolution relative to
* the original image
*
* @param resoltionFactor
* the resolution factor to use
* @return the corresponding BufferedImage
*/
BufferedImage getBirdViewImage(double resoltionFactor);
/**
* Reload all the point in a given area on the displayed image
*
* @param rx
x coordinate of the original image
* @param ry
y coordinate of the original image
* @param xx
width on the original image
* @param yy
height on the original image
*/
void reloadPoint(int xxsave, int yysave, int rxsave, int rysave);
/**
* Update the screen image to contains an area from the source image
* It always takes the higher zoom rate, between width and height
*
* @param rx
* the x coordinate in the original image
* @param ry
* the y coordinate in the original image
* @param rwidth
* the width of the selection
* @param rheight
* the height of the selection
*/
void updateImageViewTo(int rx, int ry, int rwidth, int rheight);
}
package mustic.gui;
import mustic.gui.panels.BirdViewPanel;
import mustic.io.RawImage;
/**
* Interface to manage communication from different elements linked
* to an image visualization.
* Its only purpose is to centralize communication between objects.
*
* @author Baptiste LAFABREGUE
*
*/
public class ImageManager {
/** Object that handles the birdView image display */
protected BirdViewPanel birdViewPanel;
/** Object that handle the main display */
protected ImageDisplayer displayer;
/** The Data que decrit une imqge */
protected RawImage rawImage;
/** enable the image to display the image or not, for a memory usage matter */
protected boolean displayEnable = true;
/**
* A basic constructor to be used by class implementing it
* Be aware that birdViewPanel, displayer and rawImage must be filled in
*/
public ImageManager() {
}
/**
* Create an ImageManager that links the three different elements
*
* @param displayer
* the component that handles the main display
* @param birdViewPanel
* the component that displays a birdView of the image
* @param rawImage
* the component that contains information about the image itself
*/
public ImageManager(ImageDisplayer displayer, BirdViewPanel birdViewPanel, RawImage rawImage) {
this.displayer = displayer;
this.birdViewPanel = birdViewPanel;
this.rawImage = rawImage;
}
/**
* Return the BirdViewPanel associate with the image
* @return the BirdViewPanel
*/
public BirdViewPanel getBirdViewPanel() {
return this.birdViewPanel;
}
/**
* Set the BirdViewPanel associate with the image
* @param aBirdPanel a BirdViewPanel
*/
public void setBirdViewdPanel(BirdViewPanel aBirdPanel) {
this.birdViewPanel = aBirdPanel;
}
/**
* Return the ImageDisplayer associated to the image
* @return the ImageDisplayer
*/
public ImageDisplayer getImageDisplayer() {
return this.displayer;
}
/**
* Tells if the image is displayed or not
* @return true if displayed, false otherwise
*/
public boolean isDisplayEnable() {
return displayEnable;
}
/**
* Return the RawImage associated to the image
* @return the RawImage
*/
public RawImage getRawImage() {
return this.rawImage;
}
}
......@@ -24,12 +24,12 @@ import net.infonode.tabbedpanel.titledtab.TitledTab;
* affichage
*/
public class ImageSession {
public class ImageSession extends ImageManager {
public JInternalFrame associatedFrame = null;
/** panel used to pick up information on the birdview selection */
private BirdViewPanel birdViewPanel;
/** Bird */
protected JPanel mBirdPanel;
/**
* Les donnees analyse qui peuvent etre this.imageData ou this.dataSeg en fonction d'acction qui
......@@ -46,29 +46,18 @@ public class ImageSession {
/** The image origine file path */
private String imagePath;
/** Bird */
protected JPanel mBirdPanel;
/** The Image Panel */
protected ImagePanel mImagePanel;
/** Title of the session */
public String mTitle;
/** Contains image, classifier, results */
protected TabbedPanel mWorskSpace;
/** The Data que decrit une imqge */
private RawImage rawImage;
/** Les SegmentationPanels associes a cette session */
private Vector<SegmentationPanel> segPanels = new Vector<SegmentationPanel>();
/** paramtre de la connection ssh si besoin */
public SSHParameters sshparameters = null;
/** enable the image to display the image or not, for a memory usage matter */
private boolean displayEnable = true;
/**
* @param aImage
......@@ -92,26 +81,17 @@ public class ImageSession {
*/
this.rawImage = aImage;
/**
* creation ImageData
*/
// Test de passage sur le sampler
//this.imageData = new ImageData(this.rawImage);
// Sampler sampler = new ImageSampler(aImage.getPath());
// sampler.setSizeByCount(10000);
// this.imageData = new ImageData(sampler, this.rawImage);
if (MainFrame.DEBUG_MODE)
System.out.println(Messages.getString("ImageSession.3")); //$NON-NLS-1$
/**
* creation ImagePane
*/
this.mImagePanel = new ImagePanel(aImage, this);
this.displayer = new ImagePanel(aImage, this);
if (MainFrame.DEBUG_MODE)
System.out.println(Messages.getString("ImageSession.4")); //$NON-NLS-1$
this.birdViewPanel = new BirdViewPanel(aImage, mImagePanel, mImagePanel.getInfosPanel(), this);
this.birdViewPanel = new BirdViewPanel(this);
if (MainFrame.DEBUG_MODE)
System.out.println(Messages.getString("ImageSession.5")); //$NON-NLS-1$
......@@ -127,8 +107,7 @@ public class ImageSession {
"Image",
new ImageIcon(getClass().getResource(
"/icons/mimetypes/image-x-generic.png")),
this.mImagePanel);
// mWorskSpace = new JPanel(new BorderLayout());
((ImagePanel) this.displayer));
mWorskSpace.addTab(tabImage);
......@@ -142,7 +121,7 @@ public class ImageSession {
}
public void decreaseBrightness() {
this.mImagePanel.decreaseBrightness();
((ImagePanel) this.displayer).decreaseBrightness();
if (this.segPanels != null) {
for (SegmentationPanel panel : this.segPanels) {
......@@ -152,7 +131,7 @@ public class ImageSession {
}
public void decreaseContrast() {
this.mImagePanel.decreaseContrast();
((ImagePanel) this.displayer).decreaseContrast();
if (this.segPanels != null) {
for (SegmentationPanel panel : this.segPanels) {
......@@ -162,16 +141,13 @@ public class ImageSession {
}
public void gardeInstance(ROIToolsFrame m) {
this.mImagePanel.gardeInstance(m, this);
((ImagePanel) this.displayer).gardeInstance(m, this);
}
public JPanel getBirdPanel() {
return this.mBirdPanel;
}
public BirdViewPanel getBirdViewPanel() {
return this.birdViewPanel;
}
public Data getData() {
return this.data;
......@@ -198,11 +174,11 @@ public class ImageSession {
}
public ImagePanel getImagePanel() {
return this.mImagePanel;
return ((ImagePanel) this.displayer);
}
public ImageInformationPanel getInfoPanel() {
return this.mImagePanel.getInfosPanel();
return ((ImagePanel) this.displayer).getInfosPanel();
}
/**
......@@ -216,10 +192,7 @@ public class ImageSession {
return new Color(im.getRGB(xreel, yreel));
}
public RawImage getRawImage() {
return this.rawImage;
}
public Vector<SegmentationPanel> getSegPanels() {
return this.segPanels;
}
......@@ -229,7 +202,7 @@ public class ImageSession {
}
public void increaseBrightness() {
this.mImagePanel.increaseBrightness();
((ImagePanel) this.displayer).increaseBrightness();
if (this.segPanels != null) {
for (SegmentationPanel panel : this.segPanels) {
......@@ -239,7 +212,7 @@ public class ImageSession {
}
public void increaseContrast() {
this.mImagePanel.increaseContrast();
((ImagePanel) this.displayer).increaseContrast();
if (this.segPanels != null) {
for (SegmentationPanel panel : this.segPanels) {
......@@ -258,12 +231,12 @@ public class ImageSession {
// on recupere les informations de la ou on se situe
Vector<Integer> vi = this.birdViewPanel.getvalInformation();
// on recharge les points sur la carte
this.mImagePanel.reloadPoint(vi.get(4), vi.get(5), vi.get(2), vi.get(3));
this.displayer.reloadPoint(vi.get(4), vi.get(5), vi.get(2), vi.get(3));
}
public void mask() {
JFileChooser fileChooser = new JFileChooser(Messages.getString("ImageSession.9")); //$NON-NLS-1$
int returnVal = fileChooser.showOpenDialog(this.mImagePanel);
int returnVal = fileChooser.showOpenDialog(((ImagePanel) this.displayer));
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
......@@ -271,8 +244,8 @@ public class ImageSession {
}
if (displayEnable) {
this.mImagePanel.applyMask(this.rawImage.getMask());
this.mImagePanel.refresh();
((ImagePanel) this.displayer).applyMask(this.rawImage.getMask());
((ImagePanel) this.displayer).refresh();
}
}
......@@ -286,7 +259,7 @@ public class ImageSession {
}
public void resetAll() {
this.mImagePanel.resetAll();
((ImagePanel) this.displayer).resetAll();
if (this.segPanels != null) {
for (SegmentationPanel panel : this.segPanels) {
......@@ -295,14 +268,6 @@ public class ImageSession {
}
}
/**
* Set the birdpanel associate with the image
* @param aBirdPanel a birdpanel
*/
public void setBirdPanel(BirdViewPanel aBirdPanel) {
this.mBirdPanel = aBirdPanel;
}
public void setData(Data data) {
this.data = data;
}
......@@ -323,7 +288,7 @@ public class ImageSession {
}
public void zoomIn() {
this.mImagePanel.zoomIn();
((ImagePanel) this.displayer).zoomIn();
if (this.segPanels != null) {
for (SegmentationPanel panel : this.segPanels) {
......@@ -333,7 +298,7 @@ public class ImageSession {
}
public void zoomOut() {
this.mImagePanel.zoomOut();
((ImagePanel) this.displayer).zoomOut();
if (this.segPanels != null) {
for (SegmentationPanel panel : this.segPanels) {
......@@ -342,13 +307,6 @@ public class ImageSession {
}
}
/**
* Tells if the image is displayed or not
* @return true if displayed, false otherwise
*/
public boolean isDisplayEnable() {
return displayEnable;
}
/**
* Enable or disable the image display
......
......@@ -75,6 +75,7 @@ import mustic.utils.filters.ZipFileFilter;
import mustic.utils.image.ImageHelper;
import mustic.utils.io.CSVUtils;
import mustic.utils.io.dataExchange.DataCsvExchange;
import mustic.utils.tools.ProgressStatus;
import net.infonode.tabbedpanel.*;
import net.infonode.tabbedpanel.titledtab.TitledTab;
import net.infonode.util.Direction;
......@@ -1540,7 +1541,7 @@ public class MainFrame extends JFrame {
/**
* Cree le paneau principal du MainFrame (ContentPane). Les information afiches dans le panel
* west sont les information sur la sesion aSession
* @param aSession Une session qui correpond a une image.
* @param aSession Une session qui correpond a un Data.
*/
private void createPanelFromData(DataSession dataSession) {
......@@ -1611,6 +1612,7 @@ public class MainFrame extends JFrame {
this.desktop.addDataFrame(dataSession);
else
this.desktop.setSelectedFrame(dataSession.associatedFrame);
// this.birdPanel.add(dataSession.getBirdViewPanel());
}
if (aSession != null) {
......@@ -3419,8 +3421,8 @@ public class MainFrame extends JFrame {
}
}
public void setBirdPanel(JPanel panel) {
this.birdPanel = panel;
public void setBirdPanelContent(JPanel panel) {
this.birdPanel.add(panel, BorderLayout.CENTER);
}
public void setCurrentDirectory(File currentDirectory) {
......
......@@ -68,11 +68,11 @@ import jcl.clustering.constraints.MustLinkConstraint;
import jcl.clustering.constraints.NbClusterConstraint;
import jcl.data.Data;
import jcl.utils.Images.StreamedImageReaderWrapper;
import mustic.gui.ProgressPropertyChangeListener;
import mustic.io.RawImage;
import mustic.utils.filters.CSVFileFilter;
import mustic.utils.image.ZoomBoxPanel;
import mustic.utils.io.CSVUtils;
import mustic.utils.tools.ProgressPropertyChangeListener;
/**
* Dialog window that allows the user to generate a set of constraints
......
......@@ -15,11 +15,9 @@ import java.util.Vector;
import javax.swing.JPanel;
import mustic.gui.ImageDesktopFrame;
import mustic.gui.ImageSession;
import mustic.gui.ImageManager;
import mustic.gui.MainFrame;
import mustic.gui.segmentation.SegmentationPanel;
import mustic.io.PiLLiTools;
import mustic.io.RawImage;
public class BirdViewPanel extends JPanel implements MouseListener,
MouseMotionListener {
......@@ -69,15 +67,6 @@ public class BirdViewPanel extends JPanel implements MouseListener,
/** The Image */
private BufferedImage mBirdImage;
/** The Data */
private RawImage mImage;
/** Represents the panel which display the selection area */
private ImagePanel mImagePanel;
/** Info */
private ImageInformationPanel mInfoPanel;
/** Represents an offscreen image for double buffer purpose */
private Image offscreenImage;
......@@ -95,25 +84,21 @@ public class BirdViewPanel extends JPanel implements MouseListener,
public int yysave;
/** the father session */
private ImageSession session;
private ImageManager session;
public BirdViewPanel(RawImage aImage, ImagePanel aImagePanel,
ImageInformationPanel aInfoPanel, ImageSession session) {
public BirdViewPanel(ImageManager session) {
int selAreaWidth, selAreaHeight;
this.mImage = aImage;
this.mImagePanel = aImagePanel;
this.mInfoPanel = aInfoPanel;
this.session = session;
if (aImage.height < 100)
selAreaHeight = aImage.height;
if (session.getRawImage().height < 100)
selAreaHeight = session.getRawImage().height;
else
selAreaHeight = 100;
if (aImage.width < 100)
selAreaWidth = aImage.width;
if (session.getRawImage().width < 100)
selAreaWidth = session.getRawImage().width;
else
selAreaWidth = 100;
......@@ -151,10 +136,10 @@ public class BirdViewPanel extends JPanel implements MouseListener,
}
// we considerate only the smallest zoom factor
if (this.mImage.getWidth() > 0)
x_zoomFactor = (double) dest_w / (double) this.mImage.getWidth();
if (this.mImage.getHeight() > 0)
y_zoomFactor = (double) dest_h / (double) this.mImage.getHeight();
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 + " "
......@@ -162,11 +147,11 @@ public class BirdViewPanel extends JPanel implements MouseListener,
if (x_zoomFactor < y_zoomFactor)
{
this.mBirdImage = this.mImagePanel.getBirdViewImage(x_zoomFactor);
this.mBirdImage = this.session.getImageDisplayer().getBirdViewImage(x_zoomFactor);
}
else
{
this.mBirdImage = this.mImagePanel.getBirdViewImage(y_zoomFactor);
this.mBirdImage = this.session.getImageDisplayer().getBirdViewImage(y_zoomFactor);
}
}
......@@ -191,7 +176,7 @@ public class BirdViewPanel extends JPanel implements MouseListener,
}
public int getNbBands() {
return this.mImage.getNbBands();
return this.session.getRawImage().getNbBands();
}
public BufferedImage getSaveImage() {
......@@ -620,7 +605,6 @@ public class BirdViewPanel extends JPanel implements MouseListener,
.getImageSession()
.getImagePanel()
.reloadPoint(
// .getBirdView().mImagePanel.reloadPoint(
desktopFrames[i].getImageSession()
.getBirdViewPanel().xxsave,
desktopFrames[i].getImageSession()
......@@ -633,7 +617,7 @@ public class BirdViewPanel extends JPanel implements MouseListener,
} else {
if (session != null) {
syncImage(session);
session.getImagePanel().reloadPoint(
session.getImageDisplayer().reloadPoint(
session.getBirdViewPanel().xxsave,
session.getBirdViewPanel().yysave,
session.getBirdViewPanel().rxsave,
......@@ -648,7 +632,7 @@ public class BirdViewPanel extends JPanel implements MouseListener,
if(!session.isDisplayEnable())
return;
// Testing environment
if (this.mImage == null) {
if (this.session.getRawImage() == null) {
super.paint(g);
return;
}
......@@ -712,9 +696,9 @@ public class BirdViewPanel extends JPanel implements MouseListener,
* height in the original image
*/
public void updateSelectedArea(int x, int y, int width, int height) {
double xfact = (double) this.mImage.getWidth()
double xfact = (double) this.session.getRawImage().getWidth()
/ (double) mBirdImage.getWidth();
double yfact = (double) this.mImage.getHeight()
double yfact = (double) this.session.getRawImage().getHeight()
/ (double) mBirdImage.getHeight();
int sx = (int) (x / xfact);
......@@ -733,17 +717,17 @@ public class BirdViewPanel extends JPanel implements MouseListener,
}
public void setR(int r) {
this.r = r;
this.mImage.setR(this.r);
this.session.getRawImage().setR(this.r);
}
public void setG(int g) {
this.g = g;
this.mImage.setG(this.g);
this.session.getRawImage().setG(this.g);
}
public void setB(int b) {
this.b = b;
this.mImage.setB(this.b);
this.session.getRawImage().setB(this.b);
}
......@@ -758,9 +742,9 @@ public class BirdViewPanel extends JPanel implements MouseListener,
if(!session.isDisplayEnable())
return;
// Compute the real selection area
double xfact = (double) this.mImage.getWidth()
double xfact = (double) this.session.getRawImage().getWidth()
/ (double) mBirdImage.getWidth();
double yfact = (double) this.mImage.getHeight()
double yfact = (double) this.session.getRawImage().getHeight()
/ (double) mBirdImage.getHeight();
int rx = (int) (this.selArea.x * xfact);
......@@ -768,7 +752,7 @@ public class BirdViewPanel extends JPanel implements MouseListener,
int width = (int) Math.ceil(this.selArea.width * xfact);
int height = (int) Math.ceil(this.selArea.height * yfact);
this.mImagePanel.updateImageViewTo(rx, ry, width, height);
this.session.getImageDisplayer().updateImageViewTo(rx, ry, width, height);
this.rxsave = rx;
this.rysave = ry;
......@@ -781,24 +765,24 @@ public class BirdViewPanel extends JPanel implements MouseListener,
*
* @param session the ImageSession to be synchronized
*/
synchronized public void syncImage(ImageSession session) {
synchronized public void syncImage(ImageManager session) {
if (!session.isDisplayEnable())
return;
// Compute the real selection area
double xfact = (double) this.mImage.getWidth()
double xfact = (double) this.session.getRawImage().getWidth()
/ (double) this.mBirdImage.getWidth();
double yfact = (double) this.mImage.getHeight()
double yfact = (double) this.session.getRawImage().getHeight()
/ (double) this.mBirdImage.getHeight();
double xgeo;
double ygeo;
if (this.mImage.getInitPosGeo() != null) {
xgeo = this.mImage.getInitPosGeoX() + this.selArea.x * xfact
* this.mImage.getResolution()[0];
ygeo = this.mImage.getInitPosGeoY() - this.selArea.y * yfact
* this.mImage.getResolution()[1];
if (this.session.getRawImage().getInitPosGeo() != null) {
xgeo = this.session.getRawImage().getInitPosGeoX() + this.selArea.x * xfact
* this.session.getRawImage().getResolution()[0];
ygeo = this.session.getRawImage().getInitPosGeoY() - this.selArea.y * yfact
* this.session.getRawImage().getResolution()[1];
} else {
xgeo = this.selArea.x * xfact;
ygeo = this.selArea.y * yfact;
......@@ -837,17 +821,7 @@ public class BirdViewPanel extends JPanel implements MouseListener,
if (ry < 0)
ry = 0;
this.session.getImagePanel().updateImageViewTo(rx, ry, width, height);
//TODO do the same for the DataSession
// for (ImageResultPanel resultPanel : session.getResultPanels()) {
// resultPanel.setImage(image, rx, ry);
// }
for (SegmentationPanel segPanel : session.getSegPanels()) {
segPanel.setImage(this.session.getImagePanel().getImage(), rx, ry);
}
//
this.session.getImageDisplayer().updateImageViewTo(rx, ry, width, height);
}
}
\ No newline at end of file
......@@ -25,7 +25,7 @@ import mustic.utils.image.Zoomable;
/**
* Display an image and allows the user to do some operations on it (zoom, contrast..)
*/
public class ImagePanel extends JPanel implements Zoomable, Observer {
public class ImagePanel extends JPanel implements Zoomable, Observer, ImageDisplayer {
/** */
private static final long serialVersionUID = 1L;
......@@ -40,6 +40,7 @@ public class ImagePanel extends JPanel implements Zoomable, Observer {
/** label which contains the image */
// public JLabel mImageLabel = null;
/** panel that displays the image */
private ZoomBoxPanel displayPanel = null;
......@@ -152,8 +153,8 @@ public class ImagePanel extends JPanel implements Zoomable, Observer {
displayPanel.requestFocusInWindow();
// TODO adjustment might be necessary to get the exact coordinates
double x2 = e.getX() - ((displayPanel.getHeight() - lastHeight) / 2.0);;
double y2 = e.getY() - ((displayPanel.getHeight() - lastHeight) / 2.0);;
double x2 = e.getX() - ((displayPanel.getHeight() - lastHeight) / 2.0);
double y2 = e.getY() - ((displayPanel.getHeight() - lastHeight) / 2.0);
double x3 = x2 / mZoomRate;
double y3 = y2 / mZoomRate;
......@@ -671,17 +672,7 @@ public class ImagePanel extends JPanel implements Zoomable, Observer {
return pl.getModuleIHM();
}
/**
* Fonction qui reaffiche a chaque fois les points en fonction de l'endroit de l'image ou on se
* situe
* @param rx l'abscisse reel de depart sur l'image du panel
* @param ry l'ordonnee reel de depart sur l'image du panel
* @param xx le nb de point entre l'abscisse de depart et le debut x du rectangle sur le
* birdview
* @param yy le nb de point entre l'ordonnee de depart et le debut y du rectangle sur le
* birdview
*/
@Override
public void reloadPoint(int rx, int ry, int xx, int yy) {