Commit 4242aa62 authored by lafabregue's avatar lafabregue

switched from Constraints window to ImageAddon

parent 7e1071e6
......@@ -19,6 +19,7 @@ import mustic.gui.panels.data.DataPanel;
import mustic.io.ImageData;
import mustic.models.gui.ClassificationModel;
import mustic.models.gui.panels.ResultPanel;
import mustic.utils.image.ImageDisplayer;
import net.infonode.tabbedpanel.TabDragEvent;
import net.infonode.tabbedpanel.TabEvent;
import net.infonode.tabbedpanel.TabListener;
......
......@@ -15,6 +15,7 @@ import mustic.gui.panels.ImageInformationPanel;
import mustic.gui.panels.ImagePanel;
import mustic.gui.segmentation.SegmentationPanel;
import mustic.io.RawImage;
import mustic.utils.image.ImageManager;
import net.infonode.tabbedpanel.TabFactory;
import net.infonode.tabbedpanel.TabbedPanel;
import net.infonode.tabbedpanel.titledtab.TitledTab;
......@@ -245,7 +246,7 @@ public class ImageSession extends ImageManager {
if (displayEnable) {
((ImagePanel) this.displayer).applyMask(this.rawImage.getMask());
((ImagePanel) this.displayer).refresh();
((ImagePanel) this.displayer).refresh(true);
}
}
......
......@@ -131,7 +131,7 @@ public class MainFrame extends JFrame {
private JPanel infosPanel;
/** boolean pour lier le birdview avec l'image active */
private boolean linkToAllImages = true;
private boolean linkToAllImages = false;
/** the project root for datas */
private DefaultMutableTreeNode mDataProjectNode;
......@@ -429,7 +429,8 @@ public class MainFrame extends JFrame {
openZip();
}
});
fileMenu.add(menuItemOpenZip);
//TODO regenerate the result import same as imageResultPanel
//fileMenu.add(menuItemOpenZip);
menuItemSave = new JMenuItem(Messages.getString("MainFrame.10")); //$NON-NLS-1$
menuItemSave.addActionListener(new ActionListener() {
......@@ -493,7 +494,7 @@ public class MainFrame extends JFrame {
}
}
});
toolsMenu.add(menuItemClustering);
// toolsMenu.add(menuItemClustering);
menuItemSegmentation = new JMenuItem(Messages.getString("MainFrame.17")); //$NON-NLS-1$
menuItemSegmentation.addActionListener(new ActionListener() {
......@@ -625,7 +626,7 @@ public class MainFrame extends JFrame {
createDistanceMatrix();
}
});
toolsMenu.add(menuDistanceMatrix);
// toolsMenu.add(menuDistanceMatrix);
/** Menu to generate constraints from current image session */
menuConstraints = new JMenuItem(Messages.getString("MainFrame.301"));
......@@ -635,7 +636,7 @@ public class MainFrame extends JFrame {
createConstraints();
}
});
toolsMenu.add(menuConstraints);
// toolsMenu.add(menuConstraints);
menuBar.add(toolsMenu);
......@@ -914,7 +915,8 @@ public class MainFrame extends JFrame {
}
});
menuResult.add(menuOpenRes);
//TODO regenerate the result import same as imageResultPanel
//menuResult.add(menuOpenRes);
menuResult.add(menuSaveRes);
menuRoiEval = new JMenuItem(Messages.getString("MainFrame.52")); //$NON-NLS-1$
......@@ -1490,7 +1492,7 @@ public class MainFrame extends JFrame {
// =============== Creation of the Desktop ================
JPanel panel_desktop = new JPanel(new BorderLayout());
panel_desktop.setOpaque(false);
panel_desktop.setBorder(Borders.DIALOG_BORDER);
panel_desktop.setBorder(Borders.DIALOG);
panel_desktop.add(this.desktop);
sif_desktop = new SimpleInternalFrame(Messages.getString("MainFrame.72")); //$NON-NLS-1$
......@@ -1504,7 +1506,7 @@ public class MainFrame extends JFrame {
JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(false);
panel.setBorder(Borders.DIALOG_BORDER);
panel.setBorder(Borders.DIALOG);
panel.add(pane);
// =============== Creation of the Progress Panel => South
......@@ -1625,7 +1627,7 @@ public class MainFrame extends JFrame {
// =============== Creation of the Desktop ================
JPanel panel_desktop = new JPanel(new BorderLayout());
panel_desktop.setOpaque(false);
panel_desktop.setBorder(Borders.DIALOG_BORDER);
panel_desktop.setBorder(Borders.DIALOG);
panel_desktop.add(this.desktop);
sif_desktop = new SimpleInternalFrame(Messages.getString("MainFrame.72")); //$NON-NLS-1$
......@@ -1639,7 +1641,7 @@ public class MainFrame extends JFrame {
JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(false);
panel.setBorder(Borders.DIALOG_BORDER);
panel.setBorder(Borders.DIALOG);
panel.add(pane);
// =============== Creation of the Progress Panel => South
......@@ -2167,7 +2169,8 @@ public class MainFrame extends JFrame {
}
});
toolBar.add(jbOpen);
//TODO regenerate the result import same as imageResultPanel
//toolBar.add(jbOpen);
toolBar.add(jbSave);
JButton jbRoiEval = new JButton(new ImageIcon(getClass().getResource("/icons/icon_roi_eval.png"))); //$NON-NLS-1$
......@@ -3007,44 +3010,44 @@ public class MainFrame extends JFrame {
// seg = segThread.getS();
// setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
Data data = MainFrame.this.currentImageSession.getImageData();
MainFrame.this.currentImageSession.setData(data);
ClassificationImage ci = new ClassificationImage(data, Messages.getString("MainFrame.190") //$NON-NLS-1$
+ ImageSession.nbClustering, true);
SegmentationResultPanel srp = new SegmentationResultPanel(classif, ci, MainFrame.this.currentImageSession.getRawImage(),
seg, imageLabelisee, -1); // ImageSession.getSession(0).getImage(),ImageSession.getSession(0),
// scene);
Tab tabResult = ClassificationModel.createTab(Messages.getString("MainFrame.191") + ResultPanel.nbResult, //$NON-NLS-1$
new ImageIcon(getClass()
.getResource("/icons/actions/document-open-result.png")), //$NON-NLS-1$
srp, true);
ci.tabbedPane.addTab(tabResult);
tabResult.setSelected(true);
SegmentationResultPanel irp = (SegmentationResultPanel) ci.tabbedPane.getTabAt(ci.tabbedPane.getTabCount() - 1)
.getContentComponent();
irp.historique.addInfosln("******** Classification apres segmentation *********"); //$NON-NLS-1$
irp.historique.addInfosln(Messages.getString("MainFrame.0") //$NON-NLS-1$
+ classif.getData().getDataName() + "\n"); //$NON-NLS-1$
// irp.historique.addInfosln(ci.().getParameters().toString());
final TitledTab tab = new TitledTab(Messages.getString("MainFrame.196") //$NON-NLS-1$
+ ImageSession.nbClustering++, null, ci.tabbedPane, new JPanel());
tab.setFocusableComponent(null);
MainFrame.this.currentImageSession.getWorkSpace().addTab(tab);
MainFrame.this.currentImageSession.getWorkSpace().setSelectedTab(tab);
try {
MainFrame.this.currentImageSession.associatedFrame.setMaximum(true);
} catch (PropertyVetoException e1) {}
irp.updateImageColors();
// Data data = MainFrame.this.currentImageSession.getImageData();
//
// MainFrame.this.currentImageSession.setData(data);
// ClassificationImage ci = new ClassificationImage(data, Messages.getString("MainFrame.190") //$NON-NLS-1$
// + DataSession.nbClustering, true);
//
// SegmentationResultPanel srp = new SegmentationResultPanel(classif, ci, MainFrame.this.currentImageSession.getRawImage(),
// seg, imageLabelisee, -1); // ImageSession.getSession(0).getImage(),ImageSession.getSession(0),
// // scene);
//
// Tab tabResult = ClassificationModel.createTab(Messages.getString("MainFrame.191") + ResultPanel.nbResult, //$NON-NLS-1$
// new ImageIcon(getClass()
// .getResource("/icons/actions/document-open-result.png")), //$NON-NLS-1$
// srp, true);
// ci.tabbedPane.addTab(tabResult);
// tabResult.setSelected(true);
//
// SegmentationResultPanel irp = (SegmentationResultPanel) ci.tabbedPane.getTabAt(ci.tabbedPane.getTabCount() - 1)
// .getContentComponent();
// irp.historique.addInfosln("******** Classification apres segmentation *********"); //$NON-NLS-1$
//
// irp.historique.addInfosln(Messages.getString("MainFrame.0") //$NON-NLS-1$
// + classif.getData().getDataName() + "\n"); //$NON-NLS-1$
//
// // irp.historique.addInfosln(ci.().getParameters().toString());
//
// final TitledTab tab = new TitledTab(Messages.getString("MainFrame.196") //$NON-NLS-1$
// + ImageSession.nbClustering++, null, ci.tabbedPane, new JPanel());
// tab.setFocusableComponent(null);
//
// MainFrame.this.currentImageSession.getWorkSpace().addTab(tab);
// MainFrame.this.currentImageSession.getWorkSpace().setSelectedTab(tab);
//
// try {
// MainFrame.this.currentImageSession.associatedFrame.setMaximum(true);
// } catch (PropertyVetoException e1) {}
//
// irp.updateImageColors();
}
else {
......@@ -3736,8 +3739,8 @@ public class MainFrame extends JFrame {
String resultPath = "/home/baptiste/A2CNES/results/";
String testResultPath = "/home/baptiste/A2CNES/Train_results/";
Data dataTrain = getDataFromFile(dataPath+datasetPath+"/train/"+datasetName+".data", '\t', "train");
Data dataTest = getDataFromFile(dataPath+datasetPath+"/test/"+datasetName+".data", '\t', "test");
Data dataTrain = getDataFromFile(dataPath+datasetPath+"/train/"+datasetName+".data", '\t', "train", null);
Data dataTest = getDataFromFile(dataPath+datasetPath+"/test/"+datasetName+".data", '\t', "test", null);
// AttributeMultiDimSequence.setMode(AttributeMultiDimSequence.EUCLIDIEN);
......@@ -3781,38 +3784,39 @@ public class MainFrame extends JFrame {
// we search for all constraints files
// <<<< START FOR PARAM config
for (int i = 0 ; i < 10 ; i++) {
HybridClassification classif = (HybridClassification) classification.clone();
if (i % 2 == 1 ) {
classification.setParameters(nInf, nSup, minC, 0.4, 0.6, pcr);
}
if (i <= 5)
classif.addAgent(new ParametersKmeans(8, 10, weights), dataTrain);
if (i <= 7)
classif.addAgent(new ParametersKmeans(10, 10, weights), dataTrain);
classif.addAgent(new ParametersKmeans(13, 10, weights), dataTrain);
classif.addAgent(new ParametersKmeans(16, 10, weights), dataTrain);
if (i >= 2)
classif.addAgent(new ParametersKmeans(19, 10, weights), dataTrain);
if (i >= 4)
classif.addAgent(new ParametersKmeans(22, 10, weights), dataTrain);
// classif.addAgent(new ParametersKmeans(3, 10, weights), dataTest);
// classif.addAgent(new ParametersKmeans(4, 10, weights), dataTest);
// classif.addAgent(new ParametersKmeans(6, 10, weights), dataTest);
classif.setName(testResultPath+datasetName+"/clusteing"+i);
classif.setData(dataTrain);
//// >>>> END FOR PARAM config1
// for (int i = 0 ; i < 10 ; i++) {
// HybridClassification classif = (HybridClassification) classification.clone();
//// classif.addAgent(new ParametersKmeans(10, 15, weights), dataTest);
// classif.addAgent(new ParametersKmeans(13, 10, weights), dataTest);
// classif.addAgent(new ParametersKmeans(16, 10, weights), dataTest);
// classif.addAgent(new ParametersKmeans(19, 10, weights), dataTest);
//
// classif.setName(resultPath+datasetPath+"/clustering"+i);
// classif.setData(dataTest);
//// >>>> REPLACE PARAM
// if (i % 2 == 1 ) {
// classification.setParameters(nInf, nSup, minC, 0.4, 0.6, pcr);
// }
// if (i <= 5)
// classif.addAgent(new ParametersKmeans(8, 25, weights), dataTrain);
// if (i <= 7)
// classif.addAgent(new ParametersKmeans(10, 25, weights), dataTrain);
// classif.addAgent(new ParametersKmeans(13, 25, weights), dataTrain);
// classif.addAgent(new ParametersKmeans(16, 25, weights), dataTrain);
// if (i >= 2)
// classif.addAgent(new ParametersKmeans(19, 25, weights), dataTrain);
// if (i >= 4)
// classif.addAgent(new ParametersKmeans(22, 25, weights), dataTrain);
//// classif.addAgent(new ParametersKmeans(3, 10, weights), dataTest);
//// classif.addAgent(new ParametersKmeans(4, 10, weights), dataTest);
//// classif.addAgent(new ParametersKmeans(6, 10, weights), dataTest);
//
// classif.setName(testResultPath+datasetName+"/clusteing"+i);
// classif.setData(dataTrain);
// >>>> END FOR PARAM config1
for (int i = 0 ; i < 10 ; i++) {
HybridClassification classif = (HybridClassification) classification.clone();
// classif.addAgent(new ParametersKmeans(10, 25, weights), dataTest);
classif.addAgent(new ParametersKmeans(13, 25, weights), dataTest);
classif.addAgent(new ParametersKmeans(16, 25, weights), dataTest);
classif.addAgent(new ParametersKmeans(19, 25, weights), dataTest);
// classif.addAgent(new ParametersKmeans(22, 25, weights), dataTest);
classif.setName(resultPath+datasetPath+"/clustering"+i);
classif.setData(dataTest);
// >>>> REPLACE PARAM
Thread t = null;
ClassificationImage classificationImage = new ClassificationImage(testSession,
......@@ -3879,9 +3883,11 @@ public class MainFrame extends JFrame {
// Data currentData = (Data) dataTest.clone();
// currentData.updateAndSetConstraintsToSample(constraints);
//
// classif.addAgent(new ParametersKmeans(4, 15, weights), currentData);
// classif.addAgent(new ParametersKmeans(6, 15, weights), currentData);
// classif.addAgent(new ParametersKmeans(8, 15, weights), currentData);
// classif.addAgent(new ParametersKmeans(10, 25, weights), currentData);
// classif.addAgent(new ParametersKmeans(13, 25, weights), currentData);
// classif.addAgent(new ParametersKmeans(16, 25, weights), currentData);
// classif.addAgent(new ParametersKmeans(19, 25, weights), currentData);
// classif.addAgent(new ParametersKmeans(22, 25, weights), currentData);
//
// classif.setName(resultPath+datasetName+"/"+
// ImageHelper.stripExtension(filename)+
......@@ -3890,9 +3896,9 @@ public class MainFrame extends JFrame {
//
// Thread t = null;
//
// ClassificationImage classificationImage = new ClassificationImage(currentData,
// Messages.getString("ClassifierPanel.73") + DataSession.nbClustering, //$NON-NLS-1$
// true);
// ClassificationImage classificationImage = new ClassificationImage(testSession,
// Messages.getString("ClassifierPanel.73") + DataSession.nbClustering, //$NON-NLS-1$
// true);
//
//
// t = new ClassificationThread(classif, classificationImage.getProgressBar(),
......@@ -3908,7 +3914,6 @@ public class MainFrame extends JFrame {
// } catch (PropertyVetoException e) {
// e.printStackTrace();
// }
// classificationImage.toFront();
// classificationImage.setVisible(true);
//
// threadList.add(t);
......@@ -3946,7 +3951,7 @@ public class MainFrame extends JFrame {
ClassificationFrame.getInstance().dispose();
}
private Data getDataFromFile(String path, char separator, String name) {
private Data getDataFromFile(String path, char separator, String name, String mask) {
Data data = null;
// we create the two data session
......@@ -3955,12 +3960,20 @@ public class MainFrame extends JFrame {
List<DataObject> result = new ArrayList<DataObject>();
CSVUtils reader = null;
CSVUtils maskReader = null;
try {
File file = new File(path);
reader = new CSVUtils(file, separator);
List<String> line;
if (mask != null) {
maskReader = new CSVUtils(new File(mask), separator);
}
List<String> maskLine = null;
while((line = reader.readNext()) != null) {
extractObjectFromLine(result, line, 1);
if (mask != null) {
maskLine = maskReader.readNext();
}
extractObjectFromLine(result, line, 3, maskLine);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
......@@ -3985,10 +3998,14 @@ public class MainFrame extends JFrame {
* @param line
* the line to interpret
*/
private void extractObjectFromLine(List<DataObject> list, List<String> line, int featureNb) {
private void extractObjectFromLine(List<DataObject> list, List<String> line, int featureNb, List<String> maskLine) {
DataObject obj = new DataObject(1);
double[][] seq = new double[line.size()/featureNb][];
for (int i = 0 ; i < line.size()/featureNb ; i++) {
if (maskLine != null) {
if(Integer.parseInt(maskLine.get(i)) == 0)
continue;
}
seq[i] = new double[featureNb];
for (int j = 0 ; j < featureNb ; j++) {
seq[i][j] = Double.parseDouble(line.get(i*featureNb + j));
......
......@@ -50,8 +50,8 @@ public class RgbBandChooserInternalFrame extends JInternalFrame {
public RgbBandChooserInternalFrame(final RawImage rawImage) {
super();
this.scaledMax = rawImage.getScaledMaxValues();
this.scaledMin = rawImage.getScaledMinValues();
this.scaledMax = rawImage.getScaledMaxValues().clone();
this.scaledMin = rawImage.getScaledMinValues().clone();
this.redComboBox = new JComboBox<String>();
this.redMin = new JTextArea();
this.redMax = new JTextArea();
......
......@@ -301,10 +301,10 @@ public class SequenceDialog extends JDialog {
* @throws FormatException
* if the images don't have the same dimensions
*/
public Vector<String> getSequenceData() throws FormatException {
public Vector<RawImage> getSequenceData() throws FormatException {
int nb = this.dlmSeq.getSize();
Donnee donnee;
Vector<String> paths = new Vector<String>();
Vector<RawImage> paths = new Vector<RawImage>();
if (nb > 0) {
ImageDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
......@@ -314,7 +314,7 @@ public class SequenceDialog extends JDialog {
for (int i = 0; i < nb; i++) {
donnee = (Donnee) this.dlmSeq.getElementAt(i);
paths.add(desktopFrames[donnee.index].getImageSession()
.getRawImage().getPath());
.getRawImage());
}
}
......
......@@ -26,19 +26,19 @@ public class ConstraintsColor extends JDialog {
private static final long serialVersionUID = 1L;
/** constraints colors */
private Color mustLinkColor = new Color(124, 252, 0);
private Color cannotLinkColor = new Color(255, 0, 255);
private Vector<Color> labelConstraintColor = new Vector<Color>();
private Color mustLinkColor = new Color(124, 252, 0);
private Color cannotLinkColor = new Color(255, 0, 255);
private Vector<Color> labelConstraintColor = new Vector<Color>();
/** constraints buttons */
private JButton jb_mustLinkChooseColor = new JButton();
private JButton jb_cannotLinkChooseColor = new JButton();
private Vector<JButton> jb_labelConstraintClassChooseColor = new Vector<JButton>();
private JButton jb_mustLinkChooseColor = new JButton();
private JButton jb_cannotLinkChooseColor = new JButton();
private Vector<JButton> jb_labelConstraintClassChooseColor = new Vector<JButton>();
/** dynamic JPanel Colors of Label Constraints Classes*/
JPanel labelColorConstraintPanel = new JPanel(new GridLayout(0,1));
private JPanel labelColorConstraintPanel = new JPanel(new GridLayout(0,1));
private ConstraintsSelectionDialog dialog = null;
private ConstraintsSelectionFrame dialog = null;
/**
* @brief Constructor dialog window that allows the user to change the color of the constraints
......@@ -47,7 +47,7 @@ public class ConstraintsColor extends JDialog {
* @param colorCL
* @param colorVectorLabel
*/
public ConstraintsColor(ConstraintsSelectionDialog d, Color colorML, Color colorCL, Vector<Color> colorVectorLabel) {
public ConstraintsColor(ConstraintsSelectionFrame d, Color colorML, Color colorCL, Vector<Color> colorVectorLabel) {
this.dialog = d;
this.mustLinkColor = colorML;
this.cannotLinkColor = colorCL;
......
......@@ -6,26 +6,19 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileReader;
......@@ -40,14 +33,12 @@ import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JInternalFrame;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSlider;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
......@@ -63,13 +54,9 @@ import jcl.clustering.constraints.LabelConstraint;
import jcl.clustering.constraints.MustLinkConstraint;
import jcl.clustering.constraints.NbClusterConstraint;
import jcl.data.Data;
import jcl.utils.Images.StreamedImageReaderWrapper;
import mustic.gui.panels.ImagePanel;
import mustic.io.RawImage;
import mustic.utils.image.ImageViewer;
import mustic.utils.image.PyramidImageViewer;
import mustic.utils.image.ZoomBoxPanel;
import mustic.utils.image.Zoomable;
import mustic.utils.image.ImageAddOn;
import mustic.utils.image.ImageDisplayer;
import mustic.utils.tools.ProgressPropertyChangeListener;
/**
* Dialog window that allows the user to generate a set of constraints on an imagePanel
......@@ -77,7 +64,7 @@ import mustic.utils.image.Zoomable;
* @author Baptiste LAFABREGUE
*
*/
public class ConstraintsSelectionInternalFrame extends JDialog {
public class ConstraintsSelectionFrame extends JFrame implements ImageAddOn {
private static final long serialVersionUID = 1L;
......@@ -92,7 +79,7 @@ public class ConstraintsSelectionInternalFrame extends JDialog {
/** Panel that contains the displayed image */
private ImagePanel imagePanel = null;
private ImageDisplayer imageDisplayer = null;
public JPanel mainPanel;
......@@ -103,8 +90,6 @@ public class ConstraintsSelectionInternalFrame extends JDialog {
private JPanel cannotLinkContainer = new JPanel();
private JPanel labelContainer = new JPanel();
private JPanel panelImage = new JPanel(new BorderLayout());
/** set of created constraints */
private Vector<Constraint> constraints = new Vector<Constraint>();
/** panels linked to each constraints */
......@@ -139,9 +124,6 @@ public class ConstraintsSelectionInternalFrame extends JDialog {
/** Hide/Display constraints related components */
private JCheckBox check;
/** Dialog for choosing colors for the constraints*/
private JDialog jd_colorsChooser;
/** constraints colors */
private Color mustLinkColor = new Color(124, 252, 0);
private Color cannotLinkColor = new Color(255, 0, 255);
......@@ -169,10 +151,10 @@ public class ConstraintsSelectionInternalFrame extends JDialog {
* @param data
* (optional) the data related to the constraints
*/
public ConstraintsSelectionInternalFrame(ImagePanel imagePanel, Data data) {
public ConstraintsSelectionFrame(ImageDisplayer imgDisplayer, Data data) {
super();
mainPanel = new JPanel(new BorderLayout());
this.imagePanel = imagePanel;
this.imageDisplayer = imgDisplayer;
if (data != null) {
// case of Data provided
......@@ -184,13 +166,14 @@ public class ConstraintsSelectionInternalFrame extends JDialog {
minDistance = 0;
maxDistance = 0;
for (int i = 0 ; i < imagePanel.getRawImage().getMaxValues().length ; i++) {
double d = (imagePanel.getRawImage().getMaxValues()[i]
- imagePanel.getRawImage().getMinValues()[i]);
for (int i = 0 ; i < imageDisplayer.getImageManager().getRawImage().getMaxValues().length ; i++) {
double d = (imageDisplayer.getImageManager().getRawImage().getMaxValues()[i]
- imageDisplayer.getImageManager().getRawImage().getMinValues()[i]);
maxDistance += d*d;
}
maxDistance = Math.sqrt(maxDistance);
}
this.width = imageDisplayer.getImageManager().getRawImage().width;
addListeners();
......@@ -199,10 +182,10 @@ public class ConstraintsSelectionInternalFrame extends JDialog {
buttonOk.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (ConstraintsSelectionInternalFrame.this.data != null) {
ConstraintsSelectionInternalFrame.this.data.updateAndSetConstraintsToSample(getConstraints());
if (ConstraintsSelectionFrame.this.data != null) {
ConstraintsSelectionFrame.this.data.updateAndSetConstraintsToSample(getConstraints());
}
ConstraintsSelectionInternalFrame.this.dispose();
ConstraintsSelectionFrame.this.dispose();
}
});
panelButton.add(buttonOk);
......@@ -212,7 +195,7 @@ public class ConstraintsSelectionInternalFrame extends JDialog {
buttonCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ConstraintsSelectionInternalFrame.this.dispose();
ConstraintsSelectionFrame.this.dispose();
}
});
panelButton.add(buttonCancel);
......@@ -244,9 +227,10 @@ public class ConstraintsSelectionInternalFrame extends JDialog {
@Override
public void actionPerformed(ActionEvent e) {
// action for color chooser
//TODO
// new ConstraintsColor(ConstraintsSelectionInternalFrame.this,mustLinkColor,cannotLinkColor,labelConstraintColor);
displayPixels();
new ConstraintsColor(ConstraintsSelectionFrame.this,
mustLinkColor, cannotLinkColor, labelConstraintColor);
imageDisplayer.refresh(false);
}
});
panelButton.add(constraintsColorChooser);
......@@ -257,10 +241,10 @@ public class ConstraintsSelectionInternalFrame extends JDialog {
@Override
public void actionPerformed(ActionEvent e) {
if(check.isSelected()) {
doZoomedOp();
imageDisplayer.refresh(false);
}
else {
displayPixels();
imageDisplayer.refresh(false);
}
}
});
......@@ -274,7 +258,7 @@ public class ConstraintsSelectionInternalFrame extends JDialog {
zoomBoxChkBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
ConstraintsSelectionInternalFrame.this.imagePanel.getDisplayPanel()
ConstraintsSelectionFrame.this.imageDisplayer.getDisplayPanel()
.setZoomBoxEnabled(e.getStateChange() == ItemEvent.SELECTED);
}