Commit 316e16a4 authored by lafabregue's avatar lafabregue

modification of index computation dialogs

parent a7759999
......@@ -66,7 +66,7 @@ public class ImageSession {
public SSHParameters sshparameters = null;
/** enable the image to display the image or not, for a memory usage matter */
private boolean displayEnable = true;
private boolean displayEnable = false;
/**
* @param aImage
......
......@@ -686,6 +686,17 @@ public class MainFrame extends JFrame {
}
});
menuPreprocessing.add(menuItemWater);
menuItemConcatenate = new JMenuItem(Messages.getString("MainFrame.354"));
menuItemConcatenate.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
menuConcatenate();
}
});
menuPreprocessing.add(menuItemConcatenate);
menuBar.add(menuPreprocessing);
......@@ -1037,6 +1048,8 @@ public class MainFrame extends JFrame {
private Boolean actionNDVI;
private JMenuItem menuItemWater;
private Boolean actionNDWI;
private JMenuItem menuItemConcatenate;
private Boolean actionConcatenate;
private JMenuItem menuZoomIn;
private Boolean actionZoomIn;
private JMenuItem menuZoomOut;
......@@ -1129,6 +1142,7 @@ public class MainFrame extends JFrame {
this.actionTransformationBmp = true;
this.actionNDVI = true;
this.actionNDWI = true;
this.actionConcatenate = true;
this.actionBrightM = false;
this.actionBrightP = false;
this.actionChooseRgb = false;
......@@ -1175,6 +1189,7 @@ public class MainFrame extends JFrame {
this.actionNew = true;
this.actionNDVI = true;
this.actionNDWI = true;
this.actionConcatenate = true;
this.actionQuit = true;
this.actionRefresh = true;
this.actionResetAll = true;
......@@ -1237,6 +1252,7 @@ public class MainFrame extends JFrame {
menuItemAbout.setEnabled(this.actionAbout);
menuItemVegetation.setEnabled(this.actionNDVI);
menuItemWater.setEnabled(this.actionNDWI);
menuItemConcatenate.setEnabled(this.actionConcatenate);
}
public void setTextMenu() {
......@@ -1277,6 +1293,7 @@ public class MainFrame extends JFrame {
menuItemArffImage.setText(Messages.getString("MainFrame.35"));
menuItemVegetation.setText(Messages.getString("MainFrame.352"));
menuItemWater.setText(Messages.getString("MainFrame.353"));
menuItemConcatenate.setText(Messages.getString("MainFrame.354"));
menuZoomIn.setText(Messages.getString("MainFrame.38"));
menuZoomOut.setText(Messages.getString("MainFrame.39"));
menuBrightP.setText(Messages.getString("MainFrame.41"));
......@@ -2424,6 +2441,11 @@ public class MainFrame extends JFrame {
JFrame water = new WaterIndiceExtractionDialog();
water.setVisible(true);
}
private void menuConcatenate() {
JFrame concat = new ConcatenateImagesDialog();
concat.setVisible(true);
}
/**
* Utilise dans ActionListener du MenuItem Delete all sessions.
......@@ -3199,7 +3221,8 @@ public class MainFrame extends JFrame {
// Classif de segmentation
}
else if (((TabbedPanel) session.getWorkSpace().getTabAt(j).getContentComponent()).getTabAt(1).toString()
else if (((TabbedPanel) session.getWorkSpace().getTabAt(j).getContentComponent()).getTabCount() > 1 &&
((TabbedPanel) session.getWorkSpace().getTabAt(j).getContentComponent()).getTabAt(1).toString()
.startsWith(Messages.getString("MainFrame.240"))) { //$NON-NLS-1$
// classification mono strategie
......@@ -3218,8 +3241,8 @@ public class MainFrame extends JFrame {
buttonGroup.add(bouton);
this.panelResSave.add(bouton);
HybridClassificationMonitor hcm = (HybridClassificationMonitor) ((TabbedPanel) session.getWorkSpace().getTabAt(j)
.getContentComponent()).getTabAt(1).getContentComponent();
ImageResultPanel irp = (ImageResultPanel) hcm.tabbedPane.getTabAt(0).getContentComponent();
.getContentComponent()).getTabAt(0).getContentComponent();
ImageResultPanel irp = (ImageResultPanel) hcm.tabbedPane.getTabAt(hcm.tabbedPane.getTabCount()-1).getContentComponent();
vecRes.add(irp);
nbClustering++;
}
......
package mustic.gui.dialog;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import mustic.utils.filters.ImageFileFilter;
import otbAppWrapping.ExecCommand;
public class ConcatenateImagesDialog extends JFrame {
/** */
private static final long serialVersionUID = 1L;
private Vector<JTextField> textInput = new Vector<JTextField>();
private JTextField textOutput = new JTextField();
private JPanel inPanel;
public ConcatenateImagesDialog() {
super();
JPanel subPanel= new JPanel(new BorderLayout());
JPanel mainPanel = new JPanel(new BorderLayout());
inPanel = new JPanel(new GridLayout(0, 2));
addImageInputPanel();
addImageInputPanel();
subPanel.add(inPanel, BorderLayout.CENTER);
JButton addButton = new JButton(Messages.getString("ConcatenateImagesDialog.7"));
addButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addImageInputPanel();
}
});
JPanel addPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
addPanel.add(addButton);
subPanel.add(addPanel, BorderLayout.SOUTH);
// Output Browse
JPanel outPanel = new JPanel(new BorderLayout());
outPanel.add(new JLabel(Messages.getString("ConcatenateImagesDialog.3")), BorderLayout.WEST); //$NON-NLS-1$
outPanel.add(this.textOutput, BorderLayout.CENTER);
JButton buttonBrowse2 = new JButton("..."); //$NON-NLS-1$
buttonBrowse2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
if (ConcatenateImagesDialog.this.textInput.size() > 0 &&
!ConcatenateImagesDialog.this.textInput.get(0).getText().isEmpty()) {
fileChooser.setSelectedFile(new File(ConcatenateImagesDialog.this.textInput.get(0).getText().substring(0,
ConcatenateImagesDialog.this.textInput.get(0).getText().indexOf(".tif"))
+"_concat"+".tif"));
}
ImageFileFilter filter = new ImageFileFilter();
fileChooser.addChoosableFileFilter(filter);
fileChooser.setFileFilter(filter);
int returnVal = fileChooser.showSaveDialog(ConcatenateImagesDialog.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
String path;
if (fileChooser.getSelectedFile().getPath().endsWith(".tif")) {
path = fileChooser.getSelectedFile().getPath();
} else {
path = fileChooser.getSelectedFile().getPath() + ".tif";
}
ConcatenateImagesDialog.this.textOutput.setText(path);
}
}
});
outPanel.add(buttonBrowse2, BorderLayout.EAST);
JPanel panel = new JPanel(new BorderLayout());
panel.add(subPanel, BorderLayout.CENTER);
panel.add(outPanel, BorderLayout.SOUTH);
// Panel OK
JPanel panelButton = new JPanel();
JButton buttonOk = new JButton("Ok"); //$NON-NLS-1$
panelButton.add(buttonOk);
buttonOk.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
buttonOk_actionPerformed();
}
});
mainPanel.add(panel, BorderLayout.CENTER);
mainPanel.add(panelButton, BorderLayout.SOUTH);
this.setContentPane(mainPanel);
this.setTitle(Messages.getString("WaterIndiceExtractionDialog.1")); //$NON-NLS-1$
this.setSize(350, 200);
this.setResizable(true);
this.setVisible(true);
}
private void addImageInputPanel() {
JPanel pInput = new JPanel(new BorderLayout());
final JTextField txtField = new JTextField();
//txtField.setPreferredSize(new Dimension(200, 30));
textInput.add(txtField);
// Input browse
inPanel.add(new JLabel(Messages.getString("ConcatenateImagesDialog.2")), BorderLayout.WEST); //$NON-NLS-1$
pInput.add(this.textInput.get(textInput.size()-1), BorderLayout.CENTER);
JButton buttonBrowse = new JButton("..."); //$NON-NLS-1$
buttonBrowse.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser = new JFileChooser();
ImageFileFilter filter = new ImageFileFilter();
fileChooser.addChoosableFileFilter(filter);
fileChooser.setFileFilter(filter);
int returnVal = fileChooser.showOpenDialog(ConcatenateImagesDialog.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
txtField.setText(fileChooser.getSelectedFile().getPath());
}
}
});
pInput.add(buttonBrowse, BorderLayout.EAST);
inPanel.add(pInput);
inPanel.updateUI();
}
protected void buttonOk_actionPerformed() {
try {
File temp = new File("temporary");
temp.mkdir();
String path;
if (textOutput.getText().endsWith(".tif")) {
path = textOutput.getText();
} else {
path = textOutput.getText() + ".tif";
}
int count = 0;
for (JTextField tf : textInput) {
if (tf.getText() != "") {
count++;
}
}
if(count < 2) {
JOptionPane.showMessageDialog(this, Messages.getString("ConcatenateImagesDialog.10"), //$NON-NLS-1$
Messages.getString("ConcatenateImagesDialog.9"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$
}
String[] il = new String[count];
int index = 0;
for (JTextField tf : textInput) {
if (tf.getText() != "") {
il[index] = tf.getText();
index++;
}
}
ExecCommand.ConcatenateImages(il, path);
JOptionPane.showMessageDialog(this, "Concatenation successful");
this.dispose();
setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
// File concateResult = new File(path);
// boolean imageOuvre = MainFrame.getInstance().openSession(concateResult);
// if (!imageOuvre)
// JOptionPane.showMessageDialog(this, Messages.getString("ConcatenateImagesDialog.8"), //$NON-NLS-1$
// Messages.getString("ConcatenateImagesDialog.9"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$
} catch (Exception e) {
JOptionPane.showMessageDialog(this, Messages.getString("ConcatenateImagesDialog.8"), //$NON-NLS-1$
Messages.getString("ConcatenateImagesDialog.9"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$
e.printStackTrace();
}
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
}
}
......@@ -20,17 +20,19 @@ import javax.swing.JTextField;
import javax.swing.SpinnerNumberModel;
import javax.swing.text.NumberFormatter;
import mustic.gui.MainFrame;
import mustic.utils.filters.ImageFileFilter;
import otbAppWrapping.ExecCommand;
public class VegetationIndiceExtractionDialog extends JFrame {
private JTextField textInput = new JTextField();
private JTextField textOutput = new JTextField();
private JComboBox<String> indiceComboBox;
private JSpinner spinnerRed;
private JSpinner spinnerNir;
/** */
private static final long serialVersionUID = 1L;
private JTextField textInput = new JTextField();
private JTextField textOutput = new JTextField();
private JComboBox<String> indiceComboBox;
private JSpinner spinnerRed;
private JSpinner spinnerNir;
public VegetationIndiceExtractionDialog() {
super();
......@@ -68,7 +70,6 @@ public class VegetationIndiceExtractionDialog extends JFrame {
// ComboBox
JPanel indiceSelectionPanel = new JPanel();
panel.add(new JLabel("Indice"));
String[] indices = new String[]{
"NDVI", "TNDVI", "RVI", "SAVI", "TSAVI", "MSAVI", "MSAVI2", "GEMI", "IPVI"
......@@ -174,11 +175,8 @@ public class VegetationIndiceExtractionDialog extends JFrame {
this.dispose();
setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
File vegetation = new File(path);
boolean imageOuvre = MainFrame.getInstance().openSession(vegetation);
if (!imageOuvre)
JOptionPane.showMessageDialog(MainFrame.getInstance(), Messages.getString("MainFrame.151"), Messages.getString("MainFrame.152"), //$NON-NLS-1$ //$NON-NLS-2$
JOptionPane.ERROR_MESSAGE);
// cccccccccccccc JOptionPane.ERROR_MESSAGE);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "An error has occured", "Error", JOptionPane.ERROR_MESSAGE);
......
......@@ -84,6 +84,16 @@ ArffToDataDialog.65=The number of image's channels does not match the sequence f
ArffToDataDialog.7=OK
ArffToDataDialog.8=ARFF
ArffToDataDialog.9=%% Dimension
ConcatenateImagesDialog.1=Image concatenation
ConcatenateImagesDialog.2=Input image
ConcatenateImagesDialog.21=You should select at least two files
ConcatenateImagesDialog.22=Warning
ConcatenateImagesDialog.3=Output image
ConcatenateImagesDialog.6=Ok
ConcatenateImagesDialog.7=Add
ConcatenateImagesDialog.8=An error has occured
ConcatenateImagesDialog.9=Error
ConcatenateImagesDialog.10=You must have at least to images to concatenate
ConfigDialog.0=Display a tool bar
ConfigDialog.1=Configuration
ConfigDialog.10=middle
......
......@@ -170,6 +170,7 @@ MainFrame.35=ARFF to image...
MainFrame.351=Preprocessing
MainFrame.352=Vegetation Indice Extraction
MainFrame.353=Water Indice Extraction
MainFrame.354=Concatenate Images
MainFrame.36=View
MainFrame.37=Zoom
MainFrame.38=Zoom in
......
......@@ -168,8 +168,9 @@ MainFrame.33=Image en ARFF...
MainFrame.34=Charger Arff...
MainFrame.35=ARFF en image...
MainFrame.351=Pretraitement
MainFrame.352=Vegetation Indice Extraction
MainFrame.353=Water Indice Extraction
MainFrame.352=Extraction d'indices de vgtation
MainFrame.353=Extraction d'indices d'eau
MainFrame.354=Concatner des images
MainFrame.36=Vue
MainFrame.37=Zoom
MainFrame.38=Agrandir
......
......@@ -625,7 +625,7 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
setListenerImage();
if (MainFrame.DEBUG_MODE)
System.out.println("updateImageColors from irp");
//TODO remove comments to allow display again
//TODO comment line bellow to disable display
updateImageColors();
if (imgData.getAssociatedImageSessions() != null && imgData.getAssociatedImageSessions().size() > 0) {
......@@ -771,8 +771,20 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));
for (int i = 0; i < result.length; i++) {
if (result[i]) {
ImageResultPanel imgPanel = (ImageResultPanel) this.classFrame
.tabbedPane.getTabAt(i).getContentComponent();
ImageResultPanel imgPanel = null;
if (!this.classFrame.tabbedPane.getTabAt(0).toString().startsWith("Hybrid")) {
imgPanel = (ImageResultPanel) this.classFrame
.tabbedPane.getTabAt(i).getContentComponent();
} else {
HybridClassificationMonitor hcm = (HybridClassificationMonitor) this.classFrame.tabbedPane.getTabAt(0).getContentComponent();
if (i < hcm.tabbedPane.getTabCount()-1) {
imgPanel = (ImageResultPanel) hcm.tabbedPane.getTabAt(i).getContentComponent();
} else {
imgPanel = (ImageResultPanel) this.classFrame
.tabbedPane.getTabAt(i - (hcm.tabbedPane.getTabCount() - 1)).getContentComponent();
}
}
String name = "Result" + nbRes++;
/* Sauvegarde des diverses informations */
......@@ -1014,10 +1026,10 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
nbRes = hcm.tabbedPane.getTabCount();
}
if (this.classFrame.tabbedPane.getTabCount() > 1) {
for (int i = 2; i < this.classFrame.tabbedPane.getTabCount(); i++) {
for (int i = 1; i < this.classFrame.tabbedPane.getTabCount(); i++) {
this.panelResSave.add(new JCheckBox(this.classFrame.tabbedPane.getTabAt(i).toString()));
nbRes++;
}
nbRes += this.classFrame.tabbedPane.getTabCount();
}
this.resultSave = new boolean[nbRes];
}
......@@ -1284,7 +1296,6 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
getImageResultPanel().exportKML();
}
......
......@@ -6,4 +6,28 @@ public class ImageHelper {
public static Image createBirdview(Image image) {
return null;
}
/**
* Remove extension from a file name
* @param str
* the file name
* @return the file name without extension
*/
public static String stripExtension (String str) {
// Handle null case specially.
if (str == null) return null;
// Get position of last '.'.
int pos = str.lastIndexOf(".");
// If there wasn't any '.' just return the string as is.
if (pos == -1) return str;
// Otherwise return the string, up to the dot.
return str.substring(0, pos);
}
}
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