Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MultiCube
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lafabregue
MultiCube
Commits
316e16a4
Commit
316e16a4
authored
Jun 01, 2017
by
lafabregue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modification of index computation dialogs
parent
a7759999
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
559 additions
and
121 deletions
+559
-121
src/mustic/gui/ImageSession.java
src/mustic/gui/ImageSession.java
+1
-1
src/mustic/gui/MainFrame.java
src/mustic/gui/MainFrame.java
+26
-3
src/mustic/gui/dialog/ConcatenateImagesDialog.java
src/mustic/gui/dialog/ConcatenateImagesDialog.java
+190
-0
src/mustic/gui/dialog/VegetationIndiceExtractionDialog.java
src/mustic/gui/dialog/VegetationIndiceExtractionDialog.java
+10
-12
src/mustic/gui/dialog/WaterIndiceExtractionDialog.java
src/mustic/gui/dialog/WaterIndiceExtractionDialog.java
+277
-97
src/mustic/gui/dialog/messages_en.properties
src/mustic/gui/dialog/messages_en.properties
+10
-0
src/mustic/gui/messages_en.properties
src/mustic/gui/messages_en.properties
+1
-0
src/mustic/gui/messages_fr.properties
src/mustic/gui/messages_fr.properties
+3
-2
src/mustic/gui/panels/ImageResultPanel.java
src/mustic/gui/panels/ImageResultPanel.java
+17
-6
src/mustic/utils/ImageHelper.java
src/mustic/utils/ImageHelper.java
+24
-0
No files found.
src/mustic/gui/ImageSession.java
View file @
316e16a4
...
...
@@ -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
=
tru
e
;
private
boolean
displayEnable
=
fals
e
;
/**
* @param aImage
...
...
src/mustic/gui/MainFrame.java
View file @
316e16a4
...
...
@@ -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
++;
}
...
...
src/mustic/gui/dialog/ConcatenateImagesDialog.java
0 → 100644
View file @
316e16a4
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
));
}
}
src/mustic/gui/dialog/VegetationIndiceExtractionDialog.java
View file @
316e16a4
...
...
@@ -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
);
...
...
src/mustic/gui/dialog/WaterIndiceExtractionDialog.java
View file @
316e16a4
...
...
@@ -2,10 +2,12 @@ package mustic.gui.dialog;
import
java.awt.BorderLayout
;
import
java.awt.Dimension
;
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.JComboBox
;
...
...
@@ -21,60 +23,59 @@ import javax.swing.SpinnerNumberModel;
import
javax.swing.text.NumberFormatter
;
import
mustic.gui.MainFrame
;
import
mustic.utils.ImageHelper
;
import
mustic.utils.filters.ImageFileFilter
;
import
otbAppWrapping.ExecCommand
;
public
class
WaterIndiceExtractionDialog
extends
JFrame
{
private
JTextField
textInput
=
new
JTextField
();
private
JTextField
textOutput
=
new
JTextField
();
/** */
private
static
final
long
serialVersionUID
=
1L
;
private
Vector
<
JTextField
>
textInput
=
new
Vector
<
JTextField
>();
private
JPanel
inPanel
;
private
JTextField
textOutput
=
new
JTextField
();
private
JComboBox
<
String
>
indiceComboBox
;
private
JSpinner
spinnerNir
;
private
JSpinner
spinnerFirstB
;
private
JPanel
panel
;
private
JLabel
firstBandLabel
;
private
JLabel
secondBandLabel
;
private
JSpinner
spinnerBand1
;
private
JSpinner
spinnerBand2
;
private
JSpinner
spinnerBand3
;
private
JSpinner
spinnerBand4
;
private
JSpinner
spinnerBand5
;
private
JLabel
labelBand1
;
private
JLabel
labelBand2
;
private
JLabel
labelBand3
;
private
JLabel
labelBand4
;
private
JLabel
labelBand5
;
public
WaterIndiceExtractionDialog
()
{
super
();
panel
=
new
JPanel
(
new
GridLayout
(
5
,
2
));
JPanel
subPanel1
=
new
JPanel
(
new
BorderLayout
());
JPanel
subPanel2
=
new
JPanel
(
new
BorderLayout
());
JPanel
mainPanel
=
new
JPanel
(
new
BorderLayout
());
inPanel
=
new
JPanel
(
new
GridLayout
(
0
,
2
));
addImageInputPanel
();
JPanel
pInput
=
new
JPanel
(
new
BorderLayout
());
// Input browse
panel
.
add
(
new
JLabel
(
Messages
.
getString
(
"WaterIndiceExtractionDialog.2"
)),
BorderLayout
.
WEST
);
//$NON-NLS-1$
pInput
.
add
(
this
.
textInput
,
BorderLayout
.
CENTER
);
JButton
buttonBrowse
=
new
JButton
(
"..."
);
//$NON-NLS-1$
buttonBrowse
.
addActionListener
(
new
ActionListener
()
{
JButton
addButton
=
new
JButton
(
Messages
.
getString
(
"ConcatenateImagesDialog.7"
));
addButton
.
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
(
WaterIndiceExtractionDialog
.
this
);
if
(
returnVal
==
JFileChooser
.
APPROVE_OPTION
)
{
if
(
fileChooser
.
getSelectedFile
().
getPath
().
endsWith
(
".tif"
))
//$NON-NLS-1$
WaterIndiceExtractionDialog
.
this
.
textInput
.
setText
(
fileChooser
.
getSelectedFile
().
getPath
());
else
{
JOptionPane
.
showMessageDialog
(
WaterIndiceExtractionDialog
.
this
,
Messages
.
getString
(
"WaterIndiceExtractionDialog.21"
),
Messages
.
getString
(
"WaterIndiceExtractionDialog.22"
),
//$NON-NLS-1$ //$NON-NLS-2$
JOptionPane
.
WARNING_MESSAGE
);
}
}
addImageInputPanel
();
}
});
pInput
.
add
(
buttonBrowse
,
BorderLayout
.
EAST
);
panel
.
add
(
pInput
);
JPanel
addPanel
=
new
JPanel
(
new
FlowLayout
(
FlowLayout
.
CENTER
));
addPanel
.
add
(
addButton
);
JPanel
inSubPanel
=
new
JPanel
(
new
BorderLayout
());
inSubPanel
.
add
(
inPanel
,
BorderLayout
.
NORTH
);
inSubPanel
.
add
(
addPanel
,
BorderLayout
.
SOUTH
);
subPanel1
.
add
(
inSubPanel
,
BorderLayout
.
NORTH
);
JPanel
indicePanel
=
new
JPanel
(
new
GridLayout
(
0
,
2
));
// ComboBox
JPanel
indiceSelectionPanel
=
new
JPanel
();
panel
.
add
(
new
JLabel
(
"Indice"
));
indicePanel
.
add
(
new
JLabel
(
"Indice"
));
String
[]
indices
=
new
String
[]{
"NDWI"
,
"NDWI2"
,
"MNDWI"
,
"NDPI"
,
"NDTI"
"NDWI"
,
"NDWI2"
,
"MNDWI"
,
"NDPI"
,
"NDTI"
,
"AWEIsh"
,
"AWEInsh"
,
"WI"
};
indiceComboBox
=
new
JComboBox
<
String
>(
indices
);
indiceComboBox
.
addActionListener
(
new
ActionListener
()
{
...
...
@@ -85,52 +86,94 @@ public class WaterIndiceExtractionDialog extends JFrame {
}
});
p
anel
.
add
(
indiceComboBox
);
indiceP
anel
.
add
(
indiceComboBox
);
// FirstBand
firstBandLabel
=
new
JLabel
(
"NIR"
);
panel
.
add
(
firstBandLabel
,
BorderLayout
.
WEST
);
//$NON-NLS-1$
JPanel
p
FirstB
=
new
JPanel
(
new
BorderLayout
());
spinner
FirstB
=
new
JSpinner
();
spinner
FirstB
.
setModel
(
new
SpinnerNumberModel
(
1
,
1
,
500
,
1
));
spinner
FirstB
.
setEditor
(
new
JSpinner
.
NumberEditor
(
spinnerFirstB
,
"##"
));
JFormattedTextField
txt
FirstB
=
((
JSpinner
.
NumberEditor
)
spinnerFirstB
.
getEditor
()).
getTextField
();
((
NumberFormatter
)
txt
FirstB
.
getFormatter
()).
setAllowsInvalid
(
false
);
p
FirstB
.
add
(
spinnerFirstB
);
panel
.
add
(
pFirstB
);
labelBand1
=
new
JLabel
(
"NIR"
);
indicePanel
.
add
(
labelBand1
,
BorderLayout
.
WEST
);
//$NON-NLS-1$
JPanel
p
Band1
=
new
JPanel
(
new
BorderLayout
());
spinner
Band1
=
new
JSpinner
();
spinner
Band1
.
setModel
(
new
SpinnerNumberModel
(
1
,
1
,
500
,
1
));
spinner
Band1
.
setEditor
(
new
JSpinner
.
NumberEditor
(
spinnerBand1
,
"##"
));
JFormattedTextField
txt
Band1
=
((
JSpinner
.
NumberEditor
)
spinnerBand1
.
getEditor
()).
getTextField
();
((
NumberFormatter
)
txt
Band1
.
getFormatter
()).
setAllowsInvalid
(
false
);
p
Band1
.
add
(
spinnerBand1
);
indicePanel
.
add
(
pBand1
);
// SecondBand
secondBandLabel
=
new
JLabel
(
"MIR"
);
panel
.
add
(
secondBandLabel
,
BorderLayout
.
WEST
);
//$NON-NLS-1$
JPanel
pNIR
=
new
JPanel
(
new
BorderLayout
());
spinnerNir
=
new
JSpinner
();
spinnerNir
.
setModel
(
new
SpinnerNumberModel
(
1
,
1
,
500
,
1
));
spinnerNir
.
setEditor
(
new
JSpinner
.
NumberEditor
(
spinnerNir
,
"##"
));
JFormattedTextField
txtNir
=
((
JSpinner
.
NumberEditor
)
spinnerNir
.
getEditor
()).
getTextField
();
((
NumberFormatter
)
txtNir
.
getFormatter
()).
setAllowsInvalid
(
false
);
pNIR
.
add
(
spinnerNir
);
panel
.
add
(
pNIR
);
labelBand2
=
new
JLabel
(
"MIR"
);
indicePanel
.
add
(
labelBand2
,
BorderLayout
.
WEST
);
//$NON-NLS-1$
JPanel
pBand2
=
new
JPanel
(
new
BorderLayout
());
spinnerBand2
=
new
JSpinner
();
spinnerBand2
.
setModel
(
new
SpinnerNumberModel
(
1
,
1
,
500
,
1
));
spinnerBand2
.
setEditor
(
new
JSpinner
.
NumberEditor
(
spinnerBand2
,
"##"
));
JFormattedTextField
txtBand2
=
((
JSpinner
.
NumberEditor
)
spinnerBand2
.
getEditor
()).
getTextField
();
((
NumberFormatter
)
txtBand2
.
getFormatter
()).
setAllowsInvalid
(
false
);
pBand2
.
add
(
spinnerBand2
);
indicePanel
.
add
(
pBand2
);
// ThirdBand
labelBand3
=
new
JLabel
(
"_"
);
indicePanel
.
add
(
labelBand3
,
BorderLayout
.
WEST
);
//$NON-NLS-1$
JPanel
pBand3
=
new
JPanel
(
new
BorderLayout
());
spinnerBand3
=
new
JSpinner
();
spinnerBand3
.
setModel
(
new
SpinnerNumberModel
(
1
,
1
,
500
,
1
));
spinnerBand3
.
setEditor
(
new
JSpinner
.
NumberEditor
(
spinnerBand3
,
"##"
));
JFormattedTextField
txtBand3
=
((
JSpinner
.
NumberEditor
)
spinnerBand3
.
getEditor
()).
getTextField
();
((
NumberFormatter
)
txtBand3
.
getFormatter
()).
setAllowsInvalid
(
false
);
pBand3
.
add
(
spinnerBand3
);
indicePanel
.
add
(
pBand3
);
// FourthBand
labelBand4
=
new
JLabel
(
"_"
);
indicePanel
.
add
(
labelBand4
,
BorderLayout
.
WEST
);
//$NON-NLS-1$
JPanel
pBand4
=
new
JPanel
(
new
BorderLayout
());
spinnerBand4
=
new
JSpinner
();
spinnerBand4
.
setModel
(
new
SpinnerNumberModel
(
1
,
1
,
500
,
1
));
spinnerBand4
.
setEditor
(
new
JSpinner
.
NumberEditor
(
spinnerBand4
,
"##"
));
JFormattedTextField
txtBand4
=
((
JSpinner
.
NumberEditor
)
spinnerBand4
.
getEditor
()).
getTextField
();
((
NumberFormatter
)
txtBand4
.
getFormatter
()).
setAllowsInvalid
(
false
);
pBand4
.
add
(
spinnerBand4
);
indicePanel
.
add
(
pBand4
);
// FifthBand
labelBand5
=
new
JLabel
(
"_"
);
indicePanel
.
add
(
labelBand5
,
BorderLayout
.
WEST
);
//$NON-NLS-1$
JPanel
pBand5
=
new
JPanel
(
new
BorderLayout
());
spinnerBand5
=
new
JSpinner
();
spinnerBand5
.
setModel
(
new
SpinnerNumberModel
(
1
,
1
,
500
,
1
));
spinnerBand5
.
setEditor
(
new
JSpinner
.
NumberEditor
(
spinnerBand5
,
"##"
));
JFormattedTextField
txtBand5
=
((
JSpinner
.
NumberEditor
)
spinnerBand5
.
getEditor
()).
getTextField
();
((
NumberFormatter
)
txtBand5
.
getFormatter
()).
setAllowsInvalid
(
false
);
pBand5
.
add
(
spinnerBand5
);
indicePanel
.
add
(
pBand5
);
subPanel1
.
add
(
indicePanel
,
BorderLayout
.
SOUTH
);
setIndiceLabel
();
// Output Browse
panel
.
add
(
new
JLabel
(
Messages
.
getString
(
"WaterIndiceExtractionDialog.3"
)),
BorderLayout
.
WEST
);
//$NON-NLS-1$
JPanel
pOutput
=
new
JPanel
(
new
BorderLayout
());
pOutput
.
add
(
this
.
textOutput
,
BorderLayout
.
CENTER
);
JPanel
outPanel
=
new
JPanel
(
new
BorderLayout
());
outPanel
.
add
(
new
JLabel
(
Messages
.
getString
(
"WaterIndiceExtractionDialog.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
(!
WaterIndiceExtractionDialog
.
this
.
textInput
.
getText
().
isEmpty
())
fileChooser
.
setSelectedFile
(
new
File
(
WaterIndiceExtractionDialog
.
this
.
textInput
.
getText
().
substring
(
0
,
WaterIndiceExtractionDialog
.
this
.
textInput
.
getText
().
indexOf
(
".tif"
))
JFileChooser
fileChooser
=
new
JFileChooser
(
MainFrame
.
getInstance
().
getCurrentDirectory
());
if
(
WaterIndiceExtractionDialog
.
this
.
textInput
.
size
()
>
0
&&
!
WaterIndiceExtractionDialog
.
this
.
textInput
.
get
(
0
).
getText
().
isEmpty
())
{
fileChooser
.
setSelectedFile
(
new
File
(
WaterIndiceExtractionDialog
.
this
.
textInput
.
get
(
0
).
getText
().
substring
(
0
,
WaterIndiceExtractionDialog
.
this
.
textInput
.
get
(
0
).
getText
().
indexOf
(
".tif"
))
+
"_"
+
indiceComboBox
.
getSelectedItem
()+
".tif"
));
}
ImageFileFilter
filter
=
new
ImageFileFilter
();
fileChooser
.
addChoosableFileFilter
(
filter
);
fileChooser
.
setFileFilter
(
filter
);
int
returnVal
=
fileChooser
.
showSaveDialog
(
WaterIndiceExtractionDialog
.
this
);
if
(
returnVal
==
JFileChooser
.
APPROVE_OPTION
)
{
MainFrame
.
getInstance
().
setCurrentDirectory
(
fileChooser
.
getCurrentDirectory
());
String
path
;
if
(
fileChooser
.
getSelectedFile
().
getPath
().
endsWith
(
".tif"
))
{
...
...
@@ -143,11 +186,12 @@ public class WaterIndiceExtractionDialog extends JFrame {
}
}
});
pOutput
.
add
(
buttonBrowse2
,
BorderLayout
.
EAST
);
panel
.
add
(
pOutput
);
outPanel
.
add
(
buttonBrowse2
,
BorderLayout
.
EAST
);
subPanel2
.
add
(
subPanel1
,
BorderLayout
.
NORTH
);
subPanel2
.
add
(
outPanel
,
BorderLayout
.
SOUTH
);
// Panel OK
this
.
textInput
.
setPreferredSize
(
new
Dimension
(
200
,
30
));
JPanel
panelButton
=
new
JPanel
();
JButton
buttonOk
=
new
JButton
(
"Ok"
);
//$NON-NLS-1$
panelButton
.
add
(
buttonOk
);
...
...
@@ -159,41 +203,112 @@ public class WaterIndiceExtractionDialog extends JFrame {