Commit 2ead1919 authored by lafabregue's avatar lafabregue

fix about mask application

parent a3c6831f
......@@ -269,8 +269,10 @@ public class ImageSession {
this.rawImage.setMask(file);
}
this.mImagePanel.applyMask(this.rawImage.getMask());
this.mImagePanel.doZoomOp();
if (displayEnable) {
this.mImagePanel.applyMask(this.rawImage.getMask());
this.mImagePanel.doZoomOp();
}
}
/**
......
......@@ -31,6 +31,7 @@ import javax.swing.event.ListSelectionListener;
import loci.formats.FormatException;
import mustic.gui.ImageDesktopFrame;
import mustic.gui.ImageSession;
import mustic.gui.MainFrame;
import mustic.io.PictureTool;
import mustic.io.RawImage;
......@@ -305,9 +306,9 @@ public class SequenceDialog extends JDialog {
}
/**
* Renvoie la donnée correspondant à la sequence d'images
* Return the list of image path constituting the selected sequence
*
* @return data
* @return the list of ordered file path
*
* @throws FormatException
* if the images don't have the same dimensions
......@@ -331,6 +332,33 @@ public class SequenceDialog extends JDialog {
return paths;
}
/**
* Return the list of image sessions constituting the selected sequence
*
* @return the list of ordered session
*
* @throws FormatException
* if the images don't have the same dimensions
*/
public Vector<ImageSession> getSequenceSessions() throws FormatException {
int nb = this.dlmSeq.getSize();
Donnee donnee;
Vector<ImageSession> paths = new Vector<ImageSession>();
if (nb > 0) {
ImageDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllImageDesktopFrames();
// int nbSessions = desktopFrames.length;
for (int i = 0; i < nb; i++) {
donnee = (Donnee) this.dlmSeq.getElementAt(i);
paths.add(desktopFrames[donnee.index].getImageSession());
}
}
return paths;
}
/**
* Renvoie les indices de chaque image de la sequence
......
......@@ -969,6 +969,19 @@ public class BirdViewPanel extends JPanel implements MouseListener,
}
}
session.getBirdViewPanel().selArea.x = (int) Math.round(rx / xfact);
session.getBirdViewPanel().selArea.y = (int) Math.round(ry / yfact);
session.getBirdViewPanel().selArea.width = this.selArea.width;
session.getBirdViewPanel().selArea.height = this.selArea.height;
session.getBirdViewPanel().xsave = (int) Math.round(rx / xfact);
session.getBirdViewPanel().ysave = (int) Math.round(ry / yfact);
session.getBirdViewPanel().xxsave = realarea.x;
session.getBirdViewPanel().yysave = realarea.y;
session.getBirdViewPanel().rxsave = rx;
session.getBirdViewPanel().rysave = ry;
session.getRawImage().afficheRoi(image, rx, ry);
session.getImagePanel().setImage(image);
......@@ -980,18 +993,6 @@ public class BirdViewPanel extends JPanel implements MouseListener,
for (SegmentationPanel segPanel : session.getSegPanels()) {
segPanel.setImage(image, rx, ry);
}
session.getBirdViewPanel().selArea.x = (int) Math.round(rx / xfact);
session.getBirdViewPanel().selArea.y = (int) Math.round(ry / yfact);
session.getBirdViewPanel().selArea.width = this.selArea.width;
session.getBirdViewPanel().selArea.height = this.selArea.height;
session.getBirdViewPanel().xsave = (int) Math.round(rx / xfact);
session.getBirdViewPanel().ysave = (int) Math.round(ry / yfact);
session.getBirdViewPanel().xxsave = realarea.x;
session.getBirdViewPanel().yysave = realarea.y;
session.getBirdViewPanel().rxsave = rx;
session.getBirdViewPanel().rysave = ry;
//
}
......
......@@ -10,7 +10,6 @@ import javax.swing.*;
import jcl.data.mask.Mask;
import mustic.gui.*;
import mustic.io.MusticImageMask;
import mustic.io.RawImage;
import mustic.io.roi.RegionOfInterest;
import mustic.utils.filters.ZipFileFilter;
......@@ -105,6 +104,9 @@ public class ImagePanel extends JPanel {
this.mImageLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(mImageLabel.getIcon() == null)
return;
double w1 = mImageLabel.getWidth();
double w2 = mImageLabel.getIcon().getIconWidth();
......@@ -742,6 +744,10 @@ public class ImagePanel extends JPanel {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
// if the display is disabled we don't take it in consideration
if (!MainFrame.getInstance().getCurrentImageSession().isDisplayEnable()) {
return;
}
// Toute les JInternalFrames afiche sur le MusticDesktop
ImageDesktopFrame[] jInternalFrames = MainFrame.getInstance().getDesktop().getAllImageDesktopFrames();
......@@ -823,6 +829,9 @@ public class ImagePanel extends JPanel {
@Override
public void mousePressed(MouseEvent e) {
if (ImagePanel.this.mScreenImage == null) {
return;
}
// ici on receptionne les evenements de clic de la souris sur
// l'image satelitte
int x = (int) ((e.getX() - (int) ((ImagePanel.this.mImageLabel.getWidth() - (ImagePanel.this.mScreenImage.getWidth() * ImagePanel.this.mZoomRate)) / 2)) / ImagePanel.this.mZoomRate);
......
......@@ -4,6 +4,8 @@ import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import javax.swing.JButton;
......@@ -14,8 +16,10 @@ import com.l2fprod.common.swing.JTaskPane;
import com.l2fprod.common.swing.JTaskPaneGroup;
import jcl.data.mask.Mask;
import jcl.data.sampling.ImageSampler;
import jcl.data.sampling.Sampler;
import mustic.gui.ImageDesktopFrame;
import mustic.gui.ImageSession;
import mustic.gui.MainFrame;
import mustic.gui.dialog.SequenceDialog;
import mustic.gui.panels.data.components.SamplingSelectionPanel;
......@@ -39,6 +43,8 @@ public class DataConstructPanel extends JPanel implements ToUpdateObject {
public static int SEGMENTATION_SOURCE_TYPE = 1;
private Vector<String> filesPaths = null;
private Vector<ImageSession> imageSessions = null;
/** Les menus deroulants */
private JTaskPane taskPane = new JTaskPane();
......@@ -119,6 +125,21 @@ public class DataConstructPanel extends JPanel implements ToUpdateObject {
private void generateData() {
ImageData data = null;
if (sourcePanel.isSequenceMaskSelected() && sample instanceof ImageSampler
&& imageSessions != null) {
List<Mask> maskSequence = new ArrayList<Mask>();
boolean containsAtLeastOne = false;
for (ImageSession session : imageSessions) {
Mask m = session.getRawImage().getMask();
maskSequence.add(m);
if (m != null) {
containsAtLeastOne = true;
}
}
if (containsAtLeastOne) {
((ImageSampler) sample).setMaskSequence(maskSequence);
}
}
if (filesPaths.size() > 1) {
data = new ImageData(sample, filesPaths);
} else {
......@@ -134,18 +155,58 @@ public class DataConstructPanel extends JPanel implements ToUpdateObject {
samplingPanel.updatedSample();
}
/**
* Set the list of file path constituting of the current data generated
*
* @param filesPaths
* the list of image's file paths
*/
public void setFileSources(Vector<String> filesPaths) {
this.filesPaths = filesPaths;
}
/**
* Return the list of file path constituting of the current data generated
*
* @return the list of image's file paths
*/
public Vector<String> getFilesSources() {
return filesPaths;
}
/**
* Set the list of ImageSessions constituting of the current data generated
*
* @param imageSessions
* the list of ImageSessions
*/
public void setImageSessions(Vector<ImageSession> imageSessions) {
this.imageSessions = imageSessions;
}
/**
* Return the list of ImageSessions constituting of the current data generated
*
* @return the list of ImageSessions
*/
public Vector<ImageSession> getImageSessions() {
return imageSessions;
}
/**
* Return the subpanel used to select the data source
*
* @return the panel
*/
public SourceSelectionPanel getSourceSelectionPanel() {
return sourcePanel;
}
/**
* Return the subpanel used to select the sampling parameters
*
* @return the panel
*/
public SamplingSelectionPanel getSamplingSelectionPanel() {
return samplingPanel;
}
......
package mustic.gui.panels.data.components;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
......@@ -22,6 +22,7 @@ import javax.swing.JRadioButton;
import jcl.data.sampling.ImageSampler;
import loci.formats.FormatException;
import mustic.gui.ImageDesktopFrame;
import mustic.gui.ImageSession;
import mustic.gui.MainFrame;
import mustic.gui.dialog.MaskImportDialog;
import mustic.gui.panels.data.DataConstructPanel;
......@@ -64,7 +65,7 @@ public class SourceSelectionPanel extends JPanel {
private JLabel maskLabel = new JLabel("_"); //$NON-NLS-1$
private JPanel parameterContainer = null;
private JPanel parameterContainer = new JPanel();
/** store the sessions used to build the combobox, the order might change
* in the MusticDesktop, so we use it to search by index */
......@@ -110,7 +111,9 @@ public class SourceSelectionPanel extends JPanel {
}
private void updateParametersPanel() {
parameterContainer = new JPanel();
for (Component c : parameterContainer.getComponents()) {
parameterContainer.remove(c);
}
parameterContainer.setLayout(new BoxLayout(parameterContainer, BoxLayout.Y_AXIS));
JPanel addMaskPanel = new JPanel();
......@@ -153,11 +156,16 @@ public class SourceSelectionPanel extends JPanel {
parameterContainer.add(addMaskPanel);
if (multiDateRadioButton.isSelected()) {
JPanel useSequenceMaskPanel = new JPanel();
useSequenceMaskPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
sequenceMaskCheckBox = new JCheckBox(Messages.getString("source.22")); //$NON-NLS-1$
parameterContainer.add(sequenceMaskCheckBox);
useSequenceMaskPanel.add(sequenceMaskCheckBox);
parameterContainer.add(useSequenceMaskPanel);
} else {
sequenceMaskCheckBox = null;
}
//parameterContainer.validate();
parameterContainer.updateUI();
}
......@@ -320,6 +328,8 @@ public class SourceSelectionPanel extends JPanel {
}
fatherContainer.setFileSources(fatherContainer
.getSequenceDialog().getSequenceData());
fatherContainer.setImageSessions(fatherContainer
.getSequenceDialog().getSequenceSessions());
} catch (FormatException e) {
e.printStackTrace();
}
......@@ -338,6 +348,9 @@ public class SourceSelectionPanel extends JPanel {
filesPath.add(allImageDesktopFrames[index]
.getImageSession().getImageFilePath());
fatherContainer.setFileSources(filesPath);
Vector<ImageSession> imageSessions = new Vector<ImageSession>();
imageSessions.add(allImageDesktopFrames[index].getImageSession());
fatherContainer.setImageSessions(imageSessions);
}
}
......@@ -346,7 +359,7 @@ public class SourceSelectionPanel extends JPanel {
//TODO we should also initialize the sequenceDialog
}
public boolean issequenceMaskSelected() {
public boolean isSequenceMaskSelected() {
if (sequenceMaskCheckBox == null) {
return false;
}
......
......@@ -825,7 +825,7 @@ public class RawImage implements Serializable, MemoryFlush {
* <p>
* Returns the current mask of this image.
* </p>
* @return the image's mask.
* @return the image's mask, null if none
*/
public Mask getMask() {
return this.mask;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment