Commit 8fa09c81 authored by lafabregue's avatar lafabregue

change visulaisation in ImageResultPanel to ImageViewer interface

parent 704cea5d
......@@ -207,7 +207,7 @@ public class ClassList {
if (!this.PointExists(p)) {
this.addPoint(p);
this.jl_classList.repaint();
this.imageSession.mImagePanel.dessinePoint(x, y,
this.imageSession.getImagePanel().dessinePoint(x, y,
this.getSelectedClassColor());
}
}
......@@ -220,9 +220,9 @@ public class ClassList {
deletePointInTheVectorOfClasses(xreal, yreal);
/** It's removed from the map */
this.imageSession.mImagePanel.supprimePoint(x, y,
this.imageSession.getImagePanel().supprimePoint(x, y,
this.imageSession.getPixelColor(x, y));
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.updateImageView();
}
}
......@@ -245,7 +245,7 @@ public class ClassList {
}
if (this.PointExistZoneVector(pz)) {
BufferedImage img = this.imageSession.mImagePanel
BufferedImage img = this.imageSession.getImagePanel()
.getImage();
int xfin = img.getWidth() + vinfo.get(4);// l'abcisse de fin
......@@ -302,7 +302,7 @@ public class ClassList {
if (!PointExists(p)) {
if (this.vp_zone.size() > 0)
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.dessinerLigne(
(this.vp_zone.get(this.vp_zone
.size() - 1).x)
......@@ -313,7 +313,7 @@ public class ClassList {
.getSelectedClassColor());
else
this.imageSession.mImagePanel.dessinePoint(x, y,
this.imageSession.getImagePanel().dessinePoint(x, y,
this.getSelectedClassColor());
this.vp_zone.add(p);
......@@ -328,17 +328,17 @@ public class ClassList {
try {
clr = listOfDrawnPoints.get(xreal + "-" + yreal); //$NON-NLS-1$
if (clr != null) {
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.WAIT_CURSOR));
deleteOneZone(xreal, yreal, x, y, clr);
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.DEFAULT_CURSOR));
}
} catch (Exception e) {
e.printStackTrace();
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.DEFAULT_CURSOR));
}
......@@ -367,11 +367,11 @@ public class ClassList {
Color clr = listOfDrawnPoints.get(xreal + "-" + yreal); //$NON-NLS-1$
if (clr != null) {
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.WAIT_CURSOR));
deleteAllAreasInSameColor(clr, xreal - x, yreal - y);
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.DEFAULT_CURSOR));
}
......@@ -384,16 +384,16 @@ public class ClassList {
Color clr = null;
try {
clr = listOfDrawnPoints.get(xreal + "-" + yreal); //$NON-NLS-1$
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.WAIT_CURSOR));
deleteHorizontalLine(xreal, yreal, x, y, clr);
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.DEFAULT_CURSOR));
} catch (Exception e) {
e.printStackTrace();
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.DEFAULT_CURSOR));
}
......@@ -406,16 +406,16 @@ public class ClassList {
Color clr = null;
try {
clr = listOfDrawnPoints.get(xreal + "-" + yreal); //$NON-NLS-1$
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.WAIT_CURSOR));
deleteVerticalLine(xreal, yreal, x, y, clr);
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.DEFAULT_CURSOR));
} catch (Exception e) {
e.printStackTrace();
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.DEFAULT_CURSOR));
}
......@@ -425,11 +425,11 @@ public class ClassList {
else if (this.roi.getIndexOfSelectedButton() == 7) {
Color clr = listOfDrawnPoints.get(xreal + "-" + yreal); //$NON-NLS-1$
if (clr != null) {
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.WAIT_CURSOR));
regeneratePolygon(xreal, yreal, x, y);
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.setCursor(new java.awt.Cursor(
java.awt.Cursor.DEFAULT_CURSOR));
}
......@@ -448,7 +448,7 @@ public class ClassList {
this.vectorOfClass.removeAllElements();
/** Points are removed from the the ImagePanel */
this.imageSession.mImagePanel.effacerPoints();
this.imageSession.getImagePanel().effacerPoints();
this.fillListOfDrawnPoints();
}
......@@ -512,8 +512,8 @@ public class ClassList {
*/
public void deleteAllAreasInSameColor(Color clr, int xreal, int yreal) {
int imageWidth = this.imageSession.mImagePanel.getImage().getWidth();
int imageHeight = this.imageSession.mImagePanel.getImage().getHeight();
int imageWidth = this.imageSession.getImagePanel().getImage().getWidth();
int imageHeight = this.imageSession.getImagePanel().getImage().getHeight();
Color clr_tmp;
Polygon plg;
Vector<Point> vp = new Vector<Point>();
......@@ -528,7 +528,7 @@ public class ClassList {
/** If the color is the same, the point is removed */
if (clr.equals(clr_tmp)) {
vp.add(new Point(x + xreal, y + yreal));
this.imageSession.mImagePanel.supprimePoint(x, y,
this.imageSession.getImagePanel().supprimePoint(x, y,
this.imageSession.getPixelColor(x, y));
plg = listOfPolygone.getPolygon(xreal + x, yreal + y);
......@@ -540,7 +540,7 @@ public class ClassList {
}
this.deleteCollectionOfPoints(vp);
fillListOfDrawnPoints();
this.imageSession.mImagePanel
this.imageSession.getImagePanel()
.updateImageView();
}
......@@ -625,7 +625,7 @@ public class ClassList {
int absReal;
int ordReal;
int imgPanelWidth = this.imageSession.mImagePanel.getImage().getWidth();
int imgPanelWidth = this.imageSession.getImagePanel().getImage().getWidth();
pActu = new Point(xx, yy);
pReal = new Point(xreal, yreal);
......@@ -678,11 +678,11 @@ public class ClassList {
/** Each point is removed */
deleteCollectionOfPoints(vectorOfPointActu);
for (Point pt : vectorOfPointActu) {
this.imageSession.mImagePanel.supprimePoint(pt.x, pt.y,
this.imageSession.getImagePanel().supprimePoint(pt.x, pt.y,
this.imageSession.getPixelColor(pt.x, pt.y));
}
fillListOfDrawnPoints();
imageSession.mImagePanel.updateImageView();
imageSession.getImagePanel().updateImageView();
}
/**
......@@ -722,8 +722,8 @@ public class ClassList {
int absReal;
int ordReal;
int imgPanelWidth = this.imageSession.mImagePanel.getImage().getWidth();
int imgPanelHeight = this.imageSession.mImagePanel.getImage()
int imgPanelWidth = this.imageSession.getImagePanel().getImage().getWidth();
int imgPanelHeight = this.imageSession.getImagePanel().getImage()
.getHeight();
pActu = new Point(xx, yy);
......@@ -873,11 +873,11 @@ public class ClassList {
/** Each point is removed */
deleteCollectionOfPoints(vectorOfPointReal);
for (Point pt : vectorOfPointActu) {
this.imageSession.mImagePanel.supprimePoint(pt.x, pt.y,
this.imageSession.getImagePanel().supprimePoint(pt.x, pt.y,
this.imageSession.getPixelColor(pt.x, pt.y));
}
fillListOfDrawnPoints();
imageSession.mImagePanel.updateImageView();
imageSession.getImagePanel().updateImageView();
}
/**
......@@ -989,7 +989,7 @@ public class ClassList {
int absReal;
int ordReal;
int imgPanelHeight = this.imageSession.mImagePanel.getImage()
int imgPanelHeight = this.imageSession.getImagePanel().getImage()
.getHeight();
pActu = new Point(xx, yy);
......@@ -1043,11 +1043,11 @@ public class ClassList {
/** Each point is removed */
deleteCollectionOfPoints(vectorOfPointActu);
for (Point pt : vectorOfPointActu) {
this.imageSession.mImagePanel.supprimePoint(pt.x, pt.y,
this.imageSession.getImagePanel().supprimePoint(pt.x, pt.y,
this.imageSession.getPixelColor(pt.x, pt.y));
}
fillListOfDrawnPoints();
imageSession.mImagePanel.updateImageView();
imageSession.getImagePanel().updateImageView();
}
/**
......@@ -1111,8 +1111,8 @@ public class ClassList {
int absReal;
int ordReal;
int imgPanelWidth = this.imageSession.mImagePanel.getImage().getWidth();
int imgPanelHeight = this.imageSession.mImagePanel.getImage()
int imgPanelWidth = this.imageSession.getImagePanel().getImage().getWidth();
int imgPanelHeight = this.imageSession.getImagePanel().getImage()
.getHeight();
pActu = new Point(xx, yy);
......@@ -1645,26 +1645,16 @@ public class ClassList {
found = true;
int selected_index = this.getSelectedIndex();
this.jl_classList.setSelectedIndex(i);
imageSession.mImagePanel.mImageLabel.setToolTipText(this
imageSession.getImagePanel().getDisplayPanel().setToolTipText(this
.getSelectedClassName());
if (this.roi.getIndexOfSelectedButton() != -1)
this.jl_classList.setSelectedIndex(selected_index);
} else {
imageSession.mImagePanel.mImageLabel.setToolTipText(null);
imageSession.getImagePanel().getDisplayPanel().setToolTipText(null);
}
}
}
/**
* Sets the given ImagePanel <code>ip</code> as the new ImagePanel.
*
* @param ip
* the new ImagePanel
*/
public void setImagePanell(ImagePanel ip) {
this.imageSession.mImagePanel = ip;
}
public void setImageSession(ImageSession imageSession) {
this.imageSession = imageSession;
}
......
......@@ -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 {
}