...
 
Commits (29)
File deleted
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2018 Le laboratoire des sciences de l'ingénieur, de l'informatique et de l'imagerie (UMR7357)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This software have been developped by SDC team from iCube Laboratory.
For installation refer to the "Install Guide MultiCube.pdf"
## Demo Video
![Video](https://icube-forge.unistra.fr/lafabregue/Mustic/-/wikis/uploads/f8acb00bfa0804a2388a513849d4f3c5/MultIcubeVIDEO.mp4)
## MutIcube Install :<a id="install_guide"></a>
### Requirements :<a id="requirements"></a>
You will need java jre 1.8 or above (jdk is recommended) and git installed.
Note that all commands are designed to work with unix bash.
### Installation :<a id="install"></a>
##### Create a MutIcube directory and clone the four git project in it : <a id="cloneGit"></a>
```bash
mkdir MultIcube
cd MultIcube
git clone https://icube-forge.unistra.fr/lafabregue/MultiCubeTools.git
git clone https://icube-forge.unistra.fr/lafabregue/JCL.git
git clone https://icube-forge.unistra.fr/lafabregue/JSL.git
git clone https://icube-forge.unistra.fr/lafabregue/Mustic.git
```
##### Open your favourite java IDE but it is recommended to use eclipse. The following instruction will be based on eclipse interface.
* Change your workspace to the MultiCube directory
* Import the previous four projects into your IDE :
* Import > General > Projects from Folder or Archive
* Choose for each four projects the corresponding folder
* For each projet change its build path :
* JCL : add project MultiCubeTools
* JSL : add project MultiCubeTools
* Mustic :
* add project MultiCubeTools
* add project JCL
* add project JSL
* add the directory « resources » as Class Folder in Libraries build path
* change the Order of importation of ressources in the Order and Export tab to have
the two highlighted libraries on top :
![image 1](https://icube-forge.unistra.fr/lafabregue/Mustic/-/wikis/uploads/c243fa6d76b68f5f5b2c32d9186abc39/image1.png)
* Add gdal external jars to the Mustic project :
![image 2](https://icube-forge.unistra.fr/lafabregue/Mustic/-/wikis/uploads/002a0be48017c19cf0baef306a7ce4cc/image2.png)
* Run the mustic project :
Run > Java Application >
choose «MultiCube - mustic » among the different Main class
Use the Mustic/src/mustic/MultiCube.java if you don’t use eclipse
* Change the Run Configuration :
* add the two following Environment variables :
* Name : GDAL_DATA => Value: *../MultiCubeTools/share/*
* ***for linux only :***
* Name : LD_LIBRARY_PATH => Value: *../MultiCubeTools/lib:./lib*
* ***for Windows and MacOS :***
* add the following VM argument : -Djava.library.path=../MultiCubeTools/lib:./lib
* it is also recommended to change the memory allocated, by adding the VM arguments :
* -Xms<your_min_memory_to_use>m -Xmx<your_max_memory_available>m
On x64 unix platfrom you should normally be able to launch Mustic.
But if you import a picture and still have an error, or you want to use the project on MacOS
Windows, or x32 Unix you will have to change the dynamic libraries :
* For Windows : copy paste content of MultiCubeTools/lib/Windows/xx, xx beeing 64 or 32
depending of your architecture
* For MacOS : copy paste content of MultiCubeTools/lib/MacOS
If it does not fix your problem, you need to get the gdal binaries with java bidings :
* for Windows, you can refer to :
https://trac.osgeo.org/gdal/wiki/DownloadingGdalBinaries
* for Linux, you need to compile GDAL with the –with-java option, make the gdal-*/swig/java
sub-projet, and copy the resulting .so files and jar. For more details, you can refer to :
https://github.com/VertNet/reproject/wiki/GDAL-Java-Bindings (note that now there only one
.so file generated)
* for MacOS, the homebrew build no longer support the –with-java option, you need to
compile it yourself with the –with-java option, make the gdal-*/swig/java sub-projet, and
copy the resulting .so files and jar. For more details, you can refer to :
http://www.ecgs.lu/gilles/enabling-gdal-java-binding-for-geoserver-on-macos/
# libgdalconstjni.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='libgdalconstjni.so.20'
# Names of this library.
library_names='libgdalconstjni.so.20.3.1 libgdalconstjni.so.20 libgdalconstjni.so'
# The name of the static archive.
old_library='libgdalconstjni.a'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=' -pthread'
# Libraries that this one depends upon.
dependency_libs=' /home/baptiste/Downloads/gdal-2.2.2/libgdal.la -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -ljson-c -lfreexl -lqhull -lgeos_c -lwebp /usr/lib/x86_64-linux-gnu/libsqlite3.la -lodbc -lodbcinst -lkmlbase -lkmldom -lkmlengine -lkmlxsd -lkmlregionator /usr/lib/x86_64-linux-gnu/libexpat.la -lxerces-c -lopenjp2 -lnetcdf -lhdf5_hl -lsz -lhdf5 /usr/lib/libmfhdfalt.la /usr/lib/libdfalt.la -logdi -lgif -ljpeg -lgeotiff -ltiff -lpng -lpq -lz -lpthread -lrt -ldl -lpcre /usr/lib/x86_64-linux-gnu/libcurl.la -lxml2'
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libgdalconstjni.
current=23
age=3
revision=1
# Is this an already installed library?
installed=no
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/usr/local/lib'
relink_command="(cd /home/baptiste/Downloads/gdal-2.2.2/swig/java; /bin/bash /home/baptiste/Downloads/gdal-2.2.2/libtool --mode=relink g++ -std=gnu++11 gdalconst_wrap.lo /home/baptiste/Downloads/gdal-2.2.2/libgdal.la -o libgdalconstjni.la -rpath /usr/local/lib -no-undefined -version-info 23:1:3 @inst_prefix_dir@)"
# libgdaljni.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='libgdaljni.so.20'
# Names of this library.
library_names='libgdaljni.so.20.3.1 libgdaljni.so.20 libgdaljni.so'
# The name of the static archive.
old_library='libgdaljni.a'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=' -pthread'
# Libraries that this one depends upon.
dependency_libs=' /home/baptiste/Downloads/gdal-2.2.2/libgdal.la -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -ljson-c -lfreexl -lqhull -lgeos_c -lwebp /usr/lib/x86_64-linux-gnu/libsqlite3.la -lodbc -lodbcinst -lkmlbase -lkmldom -lkmlengine -lkmlxsd -lkmlregionator /usr/lib/x86_64-linux-gnu/libexpat.la -lxerces-c -lopenjp2 -lnetcdf -lhdf5_hl -lsz -lhdf5 /usr/lib/libmfhdfalt.la /usr/lib/libdfalt.la -logdi -lgif -ljpeg -lgeotiff -ltiff -lpng -lpq -lz -lpthread -lrt -ldl -lpcre /usr/lib/x86_64-linux-gnu/libcurl.la -lxml2'
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libgdaljni.
current=23
age=3
revision=1
# Is this an already installed library?
installed=no
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/usr/local/lib'
relink_command="(cd /home/baptiste/Downloads/gdal-2.2.2/swig/java; /bin/bash /home/baptiste/Downloads/gdal-2.2.2/libtool --mode=relink g++ -std=gnu++11 gdal_wrap.lo /home/baptiste/Downloads/gdal-2.2.2/libgdal.la -o libgdaljni.la -rpath /usr/local/lib -no-undefined -version-info 23:1:3 @inst_prefix_dir@)"
# libgnmjni.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='libgnmjni.so.20'
# Names of this library.
library_names='libgnmjni.so.20.3.1 libgnmjni.so.20 libgnmjni.so'
# The name of the static archive.
old_library='libgnmjni.a'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=' -pthread'
# Libraries that this one depends upon.
dependency_libs=' /home/baptiste/Downloads/gdal-2.2.2/libgdal.la -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -ljson-c -lfreexl -lqhull -lgeos_c -lwebp /usr/lib/x86_64-linux-gnu/libsqlite3.la -lodbc -lodbcinst -lkmlbase -lkmldom -lkmlengine -lkmlxsd -lkmlregionator /usr/lib/x86_64-linux-gnu/libexpat.la -lxerces-c -lopenjp2 -lnetcdf -lhdf5_hl -lsz -lhdf5 /usr/lib/libmfhdfalt.la /usr/lib/libdfalt.la -logdi -lgif -ljpeg -lgeotiff -ltiff -lpng -lpq -lz -lpthread -lrt -ldl -lpcre /usr/lib/x86_64-linux-gnu/libcurl.la -lxml2'
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libgnmjni.
current=23
age=3
revision=1
# Is this an already installed library?
installed=no
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/usr/local/lib'
relink_command="(cd /home/baptiste/Downloads/gdal-2.2.2/swig/java; /bin/bash /home/baptiste/Downloads/gdal-2.2.2/libtool --mode=relink g++ -std=gnu++11 gnm_wrap.lo /home/baptiste/Downloads/gdal-2.2.2/libgdal.la -o libgnmjni.la -rpath /usr/local/lib -no-undefined -version-info 23:1:3 @inst_prefix_dir@)"
# libogrjni.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='libogrjni.so.20'
# Names of this library.
library_names='libogrjni.so.20.3.1 libogrjni.so.20 libogrjni.so'
# The name of the static archive.
old_library='libogrjni.a'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=' -pthread'
# Libraries that this one depends upon.
dependency_libs=' /home/baptiste/Downloads/gdal-2.2.2/libgdal.la -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -ljson-c -lfreexl -lqhull -lgeos_c -lwebp /usr/lib/x86_64-linux-gnu/libsqlite3.la -lodbc -lodbcinst -lkmlbase -lkmldom -lkmlengine -lkmlxsd -lkmlregionator /usr/lib/x86_64-linux-gnu/libexpat.la -lxerces-c -lopenjp2 -lnetcdf -lhdf5_hl -lsz -lhdf5 /usr/lib/libmfhdfalt.la /usr/lib/libdfalt.la -logdi -lgif -ljpeg -lgeotiff -ltiff -lpng -lpq -lz -lpthread -lrt -ldl -lpcre /usr/lib/x86_64-linux-gnu/libcurl.la -lxml2'
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libogrjni.
current=23
age=3
revision=1
# Is this an already installed library?
installed=no
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/usr/local/lib'
relink_command="(cd /home/baptiste/Downloads/gdal-2.2.2/swig/java; /bin/bash /home/baptiste/Downloads/gdal-2.2.2/libtool --mode=relink g++ -std=gnu++11 ogr_wrap.lo /home/baptiste/Downloads/gdal-2.2.2/libgdal.la -o libogrjni.la -rpath /usr/local/lib -no-undefined -version-info 23:1:3 @inst_prefix_dir@)"
# libosrjni.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='libosrjni.so.20'
# Names of this library.
library_names='libosrjni.so.20.3.1 libosrjni.so.20 libosrjni.so'
# The name of the static archive.
old_library='libosrjni.a'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=' -pthread'
# Libraries that this one depends upon.
dependency_libs=' /home/baptiste/Downloads/gdal-2.2.2/libgdal.la -L/usr/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial -ljson-c -lfreexl -lqhull -lgeos_c -lwebp /usr/lib/x86_64-linux-gnu/libsqlite3.la -lodbc -lodbcinst -lkmlbase -lkmldom -lkmlengine -lkmlxsd -lkmlregionator /usr/lib/x86_64-linux-gnu/libexpat.la -lxerces-c -lopenjp2 -lnetcdf -lhdf5_hl -lsz -lhdf5 /usr/lib/libmfhdfalt.la /usr/lib/libdfalt.la -logdi -lgif -ljpeg -lgeotiff -ltiff -lpng -lpq -lz -lpthread -lrt -ldl -lpcre /usr/lib/x86_64-linux-gnu/libcurl.la -lxml2'
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for libosrjni.
current=23
age=3
revision=1
# Is this an already installed library?
installed=no
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/usr/local/lib'
relink_command="(cd /home/baptiste/Downloads/gdal-2.2.2/swig/java; /bin/bash /home/baptiste/Downloads/gdal-2.2.2/libtool --mode=relink g++ -std=gnu++11 osr_wrap.lo /home/baptiste/Downloads/gdal-2.2.2/libgdal.la -o libosrjni.la -rpath /usr/local/lib -no-undefined -version-info 23:1:3 @inst_prefix_dir@)"
No preview for this file type
......@@ -10,12 +10,6 @@ import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.beans.PropertyVetoException;
import java.io.*;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.zip.ZipEntry;
......@@ -27,29 +21,21 @@ import javax.swing.border.EmptyBorder;
import javax.swing.event.*;
import javax.swing.tree.*;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import jcl.Classification;
import jcl.clustering.Cluster;
import jcl.clustering.ClusteringResult;
import jcl.clustering.constraints.CannotLinkConstraint;
import jcl.clustering.constraints.Constraint;
import jcl.clustering.constraints.MustLinkConstraint;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.SimpleData;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.io.results.CSVResultWriter;
import jcl.data.distance.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.learning.LearningMethod;
import jcl.learning.methods.monostrategy.SingleClassification;
import jcl.learning.methods.monostrategy.kmeans.ParametersKmeans;
import jcl.learning.methods.multistrategy.samarah.HybridClassification;
import jcl.learning.methods.multistrategy.samarah.SamarahConfig;
import jcl.weights.ClassificationWeights;
import jcl.weights.GlobalWeights;
import jsl.Segmentation;
import multiCube.tools.util.gui.ProgressStatus;
import mustic.gui.dialog.*;
import mustic.gui.dialog.arff.ArffLoadDialog;
import mustic.gui.dialog.arff.ArffToDataDialog;
......@@ -68,14 +54,9 @@ import mustic.gui.progressbar.OpenRawImage;
import mustic.gui.segmentation.*;
import mustic.io.*;
import mustic.models.gui.panels.*;
import mustic.models.thread.ClassificationThread;
import mustic.utils.UnZipSub;
import mustic.utils.filters.ImageFileFilter;
import mustic.utils.filters.ZipFileFilter;
import mustic.utils.image.ImageHelper;
import mustic.utils.io.CSVUtils;
import mustic.utils.io.dataExchange.DataCsvExchange;
import mustic.utils.tools.ProgressStatus;
import net.infonode.tabbedpanel.*;
import net.infonode.tabbedpanel.titledtab.TitledTab;
import net.infonode.util.Direction;
......@@ -736,16 +717,6 @@ public class MainFrame extends JFrame {
});
OGRMenu.add(menuItemLoadOGRToData);
//TODO to delete when no more used
JMenuItem customToDelete = new JMenuItem("custom"); //$NON-NLS-1$
customToDelete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
customClassify();
}
});
CSVMenu.add(customToDelete);
// menuItemResultToCSV = new JMenuItem(Messages.getString("MainFrame.305")); //$NON-NLS-1$
// menuItemResultToCSV.addActionListener(new ActionListener() {
// @Override
......@@ -763,27 +734,27 @@ public class MainFrame extends JFrame {
// Preprocessing
menuPreprocessing = new JMenu(Messages.getString("MainFrame.351"));
menuItemVegetation = new JMenuItem(Messages.getString("MainFrame.352"));
menuItemVegetation.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
menuVegetation();
}
});
menuPreprocessing.add(menuItemVegetation);
menuItemWater = new JMenuItem(Messages.getString("MainFrame.353"));
menuItemWater.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
menuWater();
// menuItemVegetation = new JMenuItem(Messages.getString("MainFrame.352"));
// menuItemVegetation.addActionListener(new ActionListener() {
//
// @Override
// public void actionPerformed(ActionEvent e) {
// menuVegetation();
//
// }
// });
// menuPreprocessing.add(menuItemVegetation);
}
});
menuPreprocessing.add(menuItemWater);
// menuItemWater = new JMenuItem(Messages.getString("MainFrame.353"));
// menuItemWater.addActionListener(new ActionListener() {
//
// @Override
// public void actionPerformed(ActionEvent e) {
// menuWater();
//
// }
// });
// menuPreprocessing.add(menuItemWater);
menuItemConcatenate = new JMenuItem(Messages.getString("MainFrame.354"));
menuItemConcatenate.addActionListener(new ActionListener() {
......@@ -1372,8 +1343,8 @@ public class MainFrame extends JFrame {
menuHClustering.setEnabled(this.actionClustering);
menuItemHelp.setEnabled(this.actionHelp);
menuItemAbout.setEnabled(this.actionAbout);
menuItemVegetation.setEnabled(this.actionNDVI);
menuItemWater.setEnabled(this.actionNDWI);
// menuItemVegetation.setEnabled(this.actionNDVI);
// menuItemWater.setEnabled(this.actionNDWI);
menuItemConcatenate.setEnabled(this.actionConcatenate);
}
......@@ -1545,7 +1516,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);
panel_desktop.setBorder(Borders.DIALOG_BORDER);
panel_desktop.add(this.desktop);
sif_desktop = new SimpleInternalFrame(Messages.getString("MainFrame.72")); //$NON-NLS-1$
......@@ -1559,7 +1530,7 @@ public class MainFrame extends JFrame {
JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(false);
panel.setBorder(Borders.DIALOG);
panel.setBorder(Borders.DIALOG_BORDER);
panel.add(pane);
// =============== Creation of the Progress Panel => South
......@@ -1680,7 +1651,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);
panel_desktop.setBorder(Borders.DIALOG_BORDER);
panel_desktop.add(this.desktop);
sif_desktop = new SimpleInternalFrame(Messages.getString("MainFrame.72")); //$NON-NLS-1$
......@@ -1694,7 +1665,7 @@ public class MainFrame extends JFrame {
JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(false);
panel.setBorder(Borders.DIALOG);
panel.setBorder(Borders.DIALOG_BORDER);
panel.add(pane);
// =============== Creation of the Progress Panel => South
......@@ -2590,15 +2561,15 @@ public class MainFrame extends JFrame {
hp.setVisible(true);
}
private void menuVegetation() {
JFrame vegetation = new VegetationIndiceExtractionDialog();
vegetation.setVisible(true);
}
private void menuWater() {
JFrame water = new WaterIndiceExtractionDialog();
water.setVisible(true);
}
// private void menuVegetation() {
// JFrame vegetation = new VegetationIndiceExtractionDialog();
// vegetation.setVisible(true);
// }
//
// private void menuWater() {
// JFrame water = new WaterIndiceExtractionDialog();
// water.setVisible(true);
// }
private void menuConcatenate() {
JFrame concat = new ConcatenateImagesDialog();
......@@ -3006,14 +2977,6 @@ public class MainFrame extends JFrame {
classifAfterSegmentation = true;
}
else if (entry.getName().equals(Messages.getString("MainFrame.186") + i + "/ParameterMode.ser")) { //$NON-NLS-1$ //$NON-NLS-2$
/**
* Chargement du mode de comparaison des séquences
* @author Francois Petitjean
*/
ObjectInputStream ois = new ObjectInputStream(in);
AttributeMultiDimSequence.setMode((Integer) ois.readObject());
}
else if (entry.getName().equals(Messages.getString("MainFrame.188") + i + "/ParameterSimplify.ser")) { //$NON-NLS-1$ //$NON-NLS-2$
/**
* Chargement du type de simplification des séquences
......@@ -3029,7 +2992,13 @@ public class MainFrame extends JFrame {
result = ClusteringResult.gerenerateDefaultClusteringResult(clusters);
result.setClusterMap(clusterMap);
result.setWeights(weights);
Classification classif = new SingleClassification(name, new SimpleData(dataObjects), method, result);
Classification classif = new SingleClassification(name,
new SimpleData(dataObjects, null, null), method, result);
DistanceModel model = DistanceModel.generateDefaultModel(dataObjects.get(0),
new GlobalWeights(dataObjects.get(0)));
DistanceParameter[][] parameters = DistanceModel.generateDefaultDistanceParameters(1,
model, classif.getData());
classif.getData().setDistanceModel(model, parameters);
// fichierImage = new File(fileName);
if (MainFrame.DEBUG_MODE)
......@@ -3105,7 +3074,12 @@ public class MainFrame extends JFrame {
}
else {
Data data = new SimpleData(dataObjects);
Data data = new SimpleData(dataObjects, null, null);
DistanceModel distModel = DistanceModel.generateDefaultModel(dataObjects.get(0),
new GlobalWeights(dataObjects.get(0)));
DistanceParameter[][] distParameters = DistanceModel
.generateDefaultDistanceParameters(1, model, data);
data.setDistanceModel(distModel, distParameters);
data.setDataName(file.getName());
MainFrame.getInstance().createDataSession(data);
......@@ -3126,7 +3100,8 @@ public class MainFrame extends JFrame {
// classif.setClusteringResult(result);
ci.addResult(classif, name);
// System.out.println("Resultat ajoute a la classif");
ImageResultPanel irp = (ImageResultPanel) ci.tabbedPane.getTabAt(ci.tabbedPane.getTabCount() - 1).getContentComponent();
ImageResultPanel irp = (ImageResultPanel) ci.tabbedPane
.getTabAt(ci.tabbedPane.getTabCount() - 1).getContentComponent();
if (MainFrame.DEBUG_MODE)
System.out.println(qualities);
irp.setQualityPanel(new QualityPanel(classif, qualities));
......@@ -3798,296 +3773,6 @@ public class MainFrame extends JFrame {
this.launchOrthoRect = launchOrthoRect;
}
private void customClassify() {
HybridClassification classification = new HybridClassification();
String datasetName = "FacesUCR";
String datasetPath = "FacesUCR";
String dataPath = "/home/baptiste/A2CNES/";
String resultPath = "/home/baptiste/A2CNES/results/";
String testResultPath = "/home/baptiste/A2CNES/Train_results/";
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);
AttributeMultiDimSequence.setMode(AttributeMultiDimSequence.DTW_BARYCENTRE);
DataDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop().getAllDataDesktopFrames();
DataSession testSession = desktopFrames[desktopFrames.length-2].getDataSession();
final DateTime startTime = DateTime.now();
int nInf = 12;
int nSup = 17;
// parametre pour la precision des conflits
double minC = 0.9;
// parametre pour les classes representatives
double pcr = 0.2;
// parametre qualite/similitude
double ps = 0.2;
double pq = 1.0 - ps;
double constraintsWgt = 80;
double valueKExtern = 60;
double kExtern = valueKExtern * ((100-constraintsWgt)/100);
double kIntern = (100 - valueKExtern) * ((100-constraintsWgt)/100);
int solutionType = 3;
double classRatio = 0.01;
int criterion = 0;
double degradation = 0.9;
int unificationType = SamarahConfig.WITHOUT_UNCLASSIFIED_UNIFICATION;
classification.setParameters(nInf, nSup, minC, ps, pq, pcr);
classification.setAdvancedParameters(degradation, classRatio, solutionType, kIntern,
kExtern, unificationType, criterion, constraintsWgt);
ClassificationWeights weights = new GlobalWeights(dataTrain);
final Vector<Thread> threadList = new Vector<Thread>();
final Vector<Classification> classifList = new Vector<Classification>();
// 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, 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 < 20 ; i++) {
// HybridClassification classif = (HybridClassification) classification.clone();
// classif.addAgent(new ParametersKmeans(13, 20, weights), dataTest);
// classif.addAgent(new ParametersKmeans(16, 20, weights), dataTest);
// classif.addAgent(new ParametersKmeans(19, 20, weights), dataTest);
//
// classif.setName(resultPath+datasetPath+"/clustering"+i);
// classif.setData(dataTest);
//// >>>> REPLACE PARAM
// Thread t = null;
//
// ClassificationImage classificationImage = new ClassificationImage(testSession,
// Messages.getString("ClassifierPanel.73") + DataSession.nbClustering, //$NON-NLS-1$
// true);
//
//
// t = new ClassificationThread(classif, classificationImage.getProgressBar(),
// classificationImage, null);
// t.start();
// try {
// testSession.associatedFrame.setMaximum(true);
// } catch (PropertyVetoException e1) {}
// testSession.addClassifier(classificationImage);
// try {
// testSession.associatedFrame.setSelected(true);
// testSession.associatedFrame.toFront();
// } catch (PropertyVetoException e) {
// e.printStackTrace();
// }
// classificationImage.setVisible(true);
//
// threadList.add(t);
// classifList.add(classif);
// }
// <<<< CONSTRAINTS
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(
Paths.get(dataPath+datasetName+"/train/"), "*1_10.constraints")) {
Iterator<Path> iter = dirStream.iterator();
while(iter.hasNext()) {
Vector<Constraint> constraints = new Vector<Constraint>();
String filename = iter.next().getFileName().toString();
System.out.println(filename);
CSVUtils reader = null;
try {
reader = new CSVUtils(new File(dataPath+datasetName+"/test/"+filename), '\t');
List<String> line;
while((line = reader.readNext()) != null) {
switch (Integer.parseInt(line.get(line.size()-1))) {
case Constraint.MUST_LINK_TYPE :
try {
int index1 = Integer.parseInt(line.get(0))-1;
int index2 = Integer.parseInt(line.get(1))-1;
constraints.add(new MustLinkConstraint(index1, index2));
} catch(Exception e) {
e.printStackTrace();
}
break;
case Constraint.CANNOT_LINK_TYPE :
try {
int index1 = Integer.parseInt(line.get(0))-1;
int index2 = Integer.parseInt(line.get(1))-1;
constraints.add(new CannotLinkConstraint(index1, index2));
} catch(Exception e) {
e.printStackTrace();
}
break;
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
for(int i = 0 ; i < 1; i++) {
HybridClassification classif = (HybridClassification) classification.clone();
Data currentData = (Data) dataTest.clone();
currentData.updateAndSetConstraintsToSample(constraints);
classif.addAgent(new ParametersKmeans(16, 15, weights), currentData);
classif.addAgent(new ParametersKmeans(20, 15, weights), currentData);
classif.addAgent(new ParametersKmeans(24, 15, weights), currentData);
classif.setName(resultPath+datasetName+"/"+
ImageHelper.stripExtension(filename)+"-"+i+
".clustering");
classif.setData(currentData);
Thread t = null;
ClassificationImage classificationImage = new ClassificationImage(testSession,
classif.getName(), //$NON-NLS-1$
true);
t = new ClassificationThread(classif, classificationImage.getProgressBar(),classificationImage.getStatusBar(),
classificationImage, null, false, null);
t.start();
try {
testSession.associatedFrame.setMaximum(true);
} catch (PropertyVetoException e1) {}
testSession.addClassifier(classificationImage);
try {
testSession.associatedFrame.setSelected(true);
testSession.associatedFrame.toFront();
} catch (PropertyVetoException e) {
e.printStackTrace();
}
classificationImage.setVisible(true);
threadList.add(t);
classifList.add(classif);
}
}
} catch (IOException e2) {
e2.printStackTrace();
}
// >>>> CONSTRAINTS
new Thread() {
@Override
public void run() {
try {
for (Thread thread : threadList) {
thread.join();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
for(Classification cl : classifList) {
try {
new CSVResultWriter(cl, cl.getName()).write();
} catch (IOException e) {
e.printStackTrace();
}
}
DateTimeFormatter formatter = DateTimeFormat.forPattern("MM/dd/yyyy HH:mm:ss");
System.out.println("Start at "+ formatter.print(startTime));
System.out.println("wrote final results at "+ formatter.print(DateTime.now()));
}
}.start();
ClassificationFrame.getInstance().updateClassifierPanel();
ClassificationFrame.getInstance().dispose();
}
private Data getDataFromFile(String path, char separator, String name, String mask) {
Data data = null;
// we create the two data session
// the first session is used for training, the second for classification
try {
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) {
if (mask != null) {
maskLine = maskReader.readNext();
}
extractObjectFromLine(result, line, 1, maskLine);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
result = null;
}
data = new SimpleData(result);
data.setDataName(name);
MainFrame.getInstance().createDataSession(data);
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
/**
* Construct a DataObject from a set of Strings and add it to a List
* @param list
* the list to add the DataObject to
* @param line
* the line to interpret
*/
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));
}
}
obj.setAttribute(0, new AttributeMultiDimSequence(seq));
list.add(obj);
}
private void extractcustomESV() {
DataCsvExchange.dataToCSV("/home/baptiste/dataExtraite.csv", this.currentDataSession.getData(),
"\t", false);
}
/**
* Return the currently selected session
* @return the DataSession/ImageSession
......
......@@ -16,8 +16,10 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.gdal.gdal.Driver;
import org.gdal.gdal.gdal;
import mustic.utils.filters.ImageFileFilter;
import otbAppWrapping.ExecCommand;
public class ConcatenateImagesDialog extends JFrame {
......@@ -166,7 +168,10 @@ public class ConcatenateImagesDialog extends JFrame {
index++;
}
}
ExecCommand.ConcatenateImages(il, path);
gdal.AllRegister();
Driver driver = gdal.GetDriverByName("GTiff");
// gdal.Warp(dstDS, object_list_count, warpAppOptions);
JOptionPane.showMessageDialog(this, "Concatenation successful");
......
......@@ -6,13 +6,11 @@ import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.swing.*;
import mustic.gui.ImageSession;
import mustic.gui.MainFrame;
import mustic.io.Picture;
import mustic.io.RawImage;
public class CropDialog extends JInternalFrame {
......@@ -58,7 +56,6 @@ public class CropDialog extends JInternalFrame {
int band = 0;
double[][][] dataSource = img.load(rec.x, rec.y, rec.width, rec.height);
this.setReplacer(img.getReplacer());
for (int x = 0; x < rec.width; x++) {
for (int y = 0; y < rec.height; y++) {
band = 0;
......
......@@ -18,11 +18,11 @@ import javax.swing.JTextField;
import jcl.data.mask.IntArrayMask;
import jcl.data.mask.Mask;
import jcl.data.mask.MultiIDIntArrayMask;
import multiCube.tools.image.reader.GDALImageReaderWrapper;
import multiCube.tools.image.reader.ReaderWrapper;
import mustic.gui.dialog.Messages;
import mustic.gui.panels.data.DataConstructPanel;
import mustic.io.RawImage;
import mustic.utils.image.reader.GDALImageReaderWrapper;
import mustic.utils.image.reader.ReaderWrapper;
import mustic.utils.io.CSVUtils;
......
......@@ -29,11 +29,9 @@ import javax.swing.JScrollPane;
import javax.swing.event.ListSelectionEvent;
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;
import mustic.utils.documentFilter.ToUpdateObject;
......@@ -297,11 +295,8 @@ public class SequenceDialog extends JDialog {
* Return the list of image path constituting the selected sequence
*
* @return the list of ordered file path
*
* @throws FormatException
* if the images don't have the same dimensions
*/
public Vector<RawImage> getSequenceData() throws FormatException {
public Vector<RawImage> getSequenceData() {
int nb = this.dlmSeq.getSize();
Donnee donnee;
Vector<RawImage> paths = new Vector<RawImage>();
......@@ -325,11 +320,8 @@ public class SequenceDialog extends JDialog {
* 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 {
public Vector<ImageSession> getSequenceSessions() {
int nb = this.dlmSeq.getSize();
Donnee donnee;
Vector<ImageSession> paths = new Vector<ImageSession>();
......
package mustic.gui.dialog;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerNumberModel;
import javax.swing.text.NumberFormatter;
import mustic.utils.filters.ImageFileFilter;
import otbAppWrapping.ExecCommand;
public class VegetationIndiceExtractionDialog extends JFrame {
/** */
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();
JPanel mainPanel = new JPanel(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(5, 2));
JPanel pInput = new JPanel(new BorderLayout());
// Input browse
panel.add(new JLabel(Messages.getString("VegetationIndiceExtractionDialog.2")), BorderLayout.WEST); //$NON-NLS-1$
pInput.add(this.textInput, 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(VegetationIndiceExtractionDialog.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
if (fileChooser.getSelectedFile().getPath().endsWith(".tif")) //$NON-NLS-1$
VegetationIndiceExtractionDialog.this.textInput.setText(fileChooser.getSelectedFile().getPath());
else {
JOptionPane.showMessageDialog(VegetationIndiceExtractionDialog.this, Messages.getString("VegetationIndiceExtractionDialog.21"), Messages.getString("VegetationIndiceExtractionDialog.22"), //$NON-NLS-1$ //$NON-NLS-2$
JOptionPane.WARNING_MESSAGE);
}
}
}
});
pInput.add(buttonBrowse, BorderLayout.EAST);
panel.add(pInput);
// ComboBox
panel.add(new JLabel("Indice"));
String[] indices = new String[]{
"NDVI", "TNDVI", "RVI", "SAVI", "TSAVI", "MSAVI", "MSAVI2", "GEMI", "IPVI"
};
indiceComboBox = new JComboBox<String>(indices);
panel.add(indiceComboBox);
// Red
panel.add(new JLabel(Messages.getString("VegetationIndiceExtractionDialog.4")), BorderLayout.WEST); //$NON-NLS-1$
JPanel pRed = new JPanel(new BorderLayout());
spinnerRed = new JSpinner();
spinnerRed.setModel(new SpinnerNumberModel(1, 1, 500, 1));
spinnerRed.setEditor(new JSpinner.NumberEditor(spinnerRed, "##"));
JFormattedTextField txtRed = ((JSpinner.NumberEditor) spinnerRed.getEditor()).getTextField();
((NumberFormatter) txtRed.getFormatter()).setAllowsInvalid(false);
pRed.add(spinnerRed);
panel.add(pRed);
// NIR
panel.add(new JLabel(Messages.getString("VegetationIndiceExtractionDialog.5")), 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);
// Output Browse
panel.add(new JLabel(Messages.getString("VegetationIndiceExtractionDialog.3")), BorderLayout.WEST); //$NON-NLS-1$
JPanel pOutput = new JPanel(new BorderLayout());
pOutput.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 (!VegetationIndiceExtractionDialog.this.textInput.getText().isEmpty())
fileChooser.setSelectedFile(new File(VegetationIndiceExtractionDialog.this.textInput.getText().substring(0,
VegetationIndiceExtractionDialog.this.textInput.getText().indexOf(".tif"))
+"_"+indiceComboBox.getSelectedItem()+".tif"));
ImageFileFilter filter = new ImageFileFilter();
fileChooser.addChoosableFileFilter(filter);
fileChooser.setFileFilter(filter);
int returnVal = fileChooser.showSaveDialog(VegetationIndiceExtractionDialog.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
String path;
if (fileChooser.getSelectedFile().getPath().endsWith(".tif")) {
path = fileChooser.getSelectedFile().getPath();
} else {
path = fileChooser.getSelectedFile().getPath() + ".tif";
}
VegetationIndiceExtractionDialog.this.textOutput.setText(path);
}
}
});
pOutput.add(buttonBrowse2, BorderLayout.EAST);
panel.add(pOutput);
// Panel OK
this.textInput.setPreferredSize(new Dimension(200, 30));
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.NORTH);
mainPanel.add(panelButton, BorderLayout.SOUTH);
this.setContentPane(mainPanel);
this.setTitle(Messages.getString("VegetationIndiceExtractionDialog.1")); //$NON-NLS-1$
this.setSize(350, 200);
this.setResizable(true);
this.setVisible(true);
}
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";
}
ExecCommand.NdviExtraction(textInput.getText(), "temporary/vegetation.tif", (int) spinnerRed.getValue(), (int) spinnerNir.getValue(), (String) indiceComboBox.getSelectedItem());
ExecCommand.Rescale("temporary/vegetation.tif", path, 0, 255);
JOptionPane.showMessageDialog(this, "Vegetation indice extraction successful");
this.dispose();
setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));
// cccccccccccccc JOptionPane.ERROR_MESSAGE);
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "An error has occured", "Error", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
}
}
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;
import javax.swing.JFileChooser;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerNumberModel;
import javax.swing.text.NumberFormatter;