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
3a3a7a41
Commit
3a3a7a41
authored
Apr 19, 2018
by
lafabregue
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ProgressThread_2' into 'master'
Progress thread 2 See merge request
!4
parents
7233b0d7
3125ae9f
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
255 additions
and
158 deletions
+255
-158
src/mustic/gui/ClassificationImage.java
src/mustic/gui/ClassificationImage.java
+103
-101
src/mustic/gui/MainFrame.java
src/mustic/gui/MainFrame.java
+1
-1
src/mustic/gui/panels/ImageResultPanel.java
src/mustic/gui/panels/ImageResultPanel.java
+2
-1
src/mustic/gui/panels/classifier/ClassifierPanel.java
src/mustic/gui/panels/classifier/ClassifierPanel.java
+2
-2
src/mustic/gui/panels/data/DataConstructPanel.java
src/mustic/gui/panels/data/DataConstructPanel.java
+29
-24
src/mustic/gui/panels/data/DataPanel.java
src/mustic/gui/panels/data/DataPanel.java
+2
-1
src/mustic/io/ImageData.java
src/mustic/io/ImageData.java
+8
-7
src/mustic/models/gui/ClassificationFrame.java
src/mustic/models/gui/ClassificationFrame.java
+0
-1
src/mustic/models/gui/ClassificationModel.java
src/mustic/models/gui/ClassificationModel.java
+5
-0
src/mustic/models/gui/panels/ClassifierPanel.java
src/mustic/models/gui/panels/ClassifierPanel.java
+1
-1
src/mustic/models/thread/ClassificationThread.java
src/mustic/models/thread/ClassificationThread.java
+16
-5
src/mustic/models/thread/ProgressThreadJCL.java
src/mustic/models/thread/ProgressThreadJCL.java
+7
-3
src/mustic/utils/image/reader/GDALImageReaderWrapper.java
src/mustic/utils/image/reader/GDALImageReaderWrapper.java
+70
-3
src/mustic/utils/jclAdapters/ImageSampler.java
src/mustic/utils/jclAdapters/ImageSampler.java
+9
-8
No files found.
src/mustic/gui/ClassificationImage.java
View file @
3a3a7a41
package
mustic.gui
;
import
java.lang.management.ManagementFactory
;
import
java.util.ArrayList
;
import
javax.swing.ImageIcon
;
import
javax.swing.WindowConstants
;
import
jcl.Classification
;
import
jcl.data.attribute.AttributeMultiDimSequence
;
import
jcl.learning.methods.multistrategy.samarah4.comm.ClassificationSAM4
;
import
mustic.gui.panels.ImageResultPanel
;
import
mustic.io.ImageData
;
import
mustic.models.gui.ClassificationModel
;
import
mustic.models.gui.panels.ResultPanel
;
import
net.infonode.tabbedpanel.Tab
;
import
net.infonode.tabbedpanel.TabbedPanel
;
public
class
ClassificationImage
extends
ClassificationModel
{
/** */
private
static
final
long
serialVersionUID
=
1L
;
/** */
public
ArrayList
<
Classification
>
results
=
new
ArrayList
<
Classification
>();
/**
*
* @param aRawImage
* @param data
* @param title
*/
public
ClassificationImage
(
DataSession
session
,
String
title
)
{
super
(
session
,
title
,
false
);
}
public
ClassificationImage
(
DataSession
session
,
String
title
,
boolean
justData
)
{
super
(
session
,
title
,
justData
);
}
/**
*
*/
@Override
public
void
addResult
(
Classification
result
,
String
title
)
{
this
.
addResult
(
result
,
title
,
this
.
tabbedPane
);
}
@Override
synchronized
public
void
addResult
(
Classification
result
,
String
title
,
TabbedPanel
pane
)
{
ResultPanel
rpanel
=
null
;
if
(
data
instanceof
ImageData
)
{
rpanel
=
new
ImageResultPanel
(
session
,
result
,
this
,
((
ImageData
)
data
));
}
else
{
rpanel
=
new
ResultPanel
(
result
,
this
);
}
rpanel
.
setName
(
title
);
resultPanels
.
add
(
rpanel
);
Tab
t1
=
ClassificationModel
.
createTab
(
title
,
new
ImageIcon
(
getClass
()
.
getResource
(
"/icons/actions/document-open-result.png"
)),
//$NON-NLS-1$
rpanel
,
true
);
pane
.
addTab
(
t1
);
t1
.
setSelected
(
true
);
}
@Override
public
void
doOperationAfterClassification
(
Classification
result
)
{
if
(!
result
.
isHybrid
()
&&
!(
result
instanceof
ClassificationSAM4
))
{
if
(
result
.
getTimeExec
()
!=
0
)
result
.
setTimeExec
(
ManagementFactory
.
getThreadMXBean
()
.
getCurrentThreadCpuTime
());
this
.
results
.
add
(
result
);
this
.
addResult
(
result
,
Messages
.
getString
(
"ClassificationImage.1"
)
+
ResultPanel
.
nbResult
++);
//$NON-NLS-1$
ResultPanel
irp
=
(
ResultPanel
)
this
.
tabbedPane
.
getTabAt
(
this
.
tabbedPane
.
getTabCount
()
-
1
).
getContentComponent
();
irp
.
historique
.
addInfosln
(
Messages
.
getString
(
"ClassificationImage.2"
));
//$NON-NLS-1$
if
(
result
.
getData
().
getOneDataObject
().
getAttribute
(
0
)
instanceof
AttributeMultiDimSequence
)
{
irp
.
historique
.
addInfosln
(
Messages
.
getString
(
"ClassificationImage.3"
));
//$NON-NLS-1$
if
(
result
.
getData
().
getDataFilesName
().
size
()
>
0
)
{
irp
.
historique
.
addInfosln
(
result
.
getData
().
getDataFilesName
().
get
(
0
));
}
}
else
irp
.
historique
.
addInfosln
(
Messages
.
getString
(
"ClassificationImage.4"
)
//$NON-NLS-1$
+
result
.
getData
().
getDataName
()
+
"\n"
);
//$NON-NLS-1$
if
(
result
.
getLearningMethod
()
!=
null
)
irp
.
historique
.
addInfosln
(
result
.
getLearningMethod
()
.
getParameters
().
toString
());
if
(
result
.
getTimeExec
()
!=
0
)
{
long
exec
=
result
.
getTimeExec
();
irp
.
historique
.
addInfosln
(
Messages
.
getString
(
"ClassificationImage.6"
)
//$NON-NLS-1$
+
(
exec
/
1.0E9
)
+
"s"
);
//$NON-NLS-1$
}
}
}
}
package
mustic.gui
;
import
java.lang.management.ManagementFactory
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Iterator
;
import
javax.swing.ImageIcon
;
import
javax.swing.WindowConstants
;
import
jcl.Classification
;
import
jcl.data.attribute.AttributeMultiDimSequence
;
import
jcl.learning.methods.multistrategy.samarah4.comm.ClassificationSAM4
;
import
mustic.gui.panels.ImageResultPanel
;
import
mustic.io.ImageData
;
import
mustic.models.gui.ClassificationModel
;
import
mustic.models.gui.panels.ResultPanel
;
import
net.infonode.tabbedpanel.Tab
;
import
net.infonode.tabbedpanel.TabbedPanel
;
public
class
ClassificationImage
extends
ClassificationModel
{
/** */
private
static
final
long
serialVersionUID
=
1L
;
/** */
public
ArrayList
<
Classification
>
results
=
new
ArrayList
<
Classification
>();
/**
*
* @param aRawImage
* @param data
* @param title
*/
public
ClassificationImage
(
DataSession
session
,
String
title
)
{
super
(
session
,
title
,
false
);
}
public
ClassificationImage
(
DataSession
session
,
String
title
,
boolean
justData
)
{
super
(
session
,
title
,
justData
);
}
@Override
public
void
addResult
(
Classification
result
,
String
title
)
{
this
.
addResult
(
result
,
title
,
this
.
tabbedPane
);
}
@Override
synchronized
public
void
addResult
(
Classification
result
,
String
title
,
TabbedPanel
pane
)
{
ResultPanel
rpanel
=
null
;
if
(
data
instanceof
ImageData
)
{
rpanel
=
new
ImageResultPanel
(
session
,
result
,
this
,
((
ImageData
)
data
));
}
else
{
rpanel
=
new
ResultPanel
(
result
,
this
);
}
rpanel
.
setName
(
title
);
resultPanels
.
add
(
rpanel
);
Tab
t1
=
ClassificationModel
.
createTab
(
title
,
new
ImageIcon
(
getClass
()
.
getResource
(
"/icons/actions/document-open-result.png"
)),
//$NON-NLS-1$
rpanel
,
true
);
pane
.
addTab
(
t1
);
t1
.
setSelected
(
true
);
}
@Override
public
void
doOperationAfterClassification
(
Classification
result
)
{
// Monitoring the operation status
result
.
setStatus
(
"Step "
+
(
result
.
getProgressableList
().
size
()+
1
)
+
"/"
+
(
result
.
getProgressableList
().
size
()+
1
)
+
" : Displaying"
);
if
(!
result
.
isHybrid
()
&&
!(
result
instanceof
ClassificationSAM4
))
{
if
(
result
.
getTimeExec
()
!=
0
)
result
.
setTimeExec
(
ManagementFactory
.
getThreadMXBean
()
.
getCurrentThreadCpuTime
());
this
.
results
.
add
(
result
);
this
.
addResult
(
result
,
Messages
.
getString
(
"ClassificationImage.1"
)
+
ResultPanel
.
nbResult
++);
//$NON-NLS-1$
ResultPanel
irp
=
(
ResultPanel
)
this
.
tabbedPane
.
getTabAt
(
this
.
tabbedPane
.
getTabCount
()
-
1
).
getContentComponent
();
irp
.
historique
.
addInfosln
(
Messages
.
getString
(
"ClassificationImage.2"
));
//$NON-NLS-1$
if
(
result
.
getData
().
getOneDataObject
().
getAttribute
(
0
)
instanceof
AttributeMultiDimSequence
)
{
irp
.
historique
.
addInfosln
(
Messages
.
getString
(
"ClassificationImage.3"
));
//$NON-NLS-1$
if
(
result
.
getData
().
getDataFilesName
().
size
()
>
0
)
{
irp
.
historique
.
addInfosln
(
result
.
getData
().
getDataFilesName
().
get
(
0
));
}
}
else
irp
.
historique
.
addInfosln
(
Messages
.
getString
(
"ClassificationImage.4"
)
//$NON-NLS-1$
+
result
.
getData
().
getDataName
()
+
"\n"
);
//$NON-NLS-1$
if
(
result
.
getLearningMethod
()
!=
null
)
irp
.
historique
.
addInfosln
(
result
.
getLearningMethod
()
.
getParameters
().
toString
());
if
(
result
.
getTimeExec
()
!=
0
)
{
long
exec
=
result
.
getTimeExec
();
irp
.
historique
.
addInfosln
(
Messages
.
getString
(
"ClassificationImage.6"
)
//$NON-NLS-1$
+
(
exec
/
1.0E9
)
+
"s"
);
//$NON-NLS-1$
}
}
}
}
src/mustic/gui/MainFrame.java
View file @
3a3a7a41
...
...
@@ -3967,7 +3967,7 @@ public class MainFrame extends JFrame {
true);
t = new ClassificationThread(classif, classificationImage.getProgressBar(),
t = new ClassificationThread(classif, classificationImage.getProgressBar(),
classificationImage.getStatusBar(),
classificationImage, null, false, null);
t.start();
try {
...
...
src/mustic/gui/panels/ImageResultPanel.java
View file @
3a3a7a41
...
...
@@ -4,6 +4,8 @@ import java.awt.*;
import
java.awt.event.*
;
import
java.awt.image.*
;
import
java.io.*
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Observable
;
import
java.util.Observer
;
import
java.util.Vector
;
...
...
@@ -201,7 +203,6 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
imgData
.
getHeight
(),
result
.
getClusterMap
(
false
),
this
.
result
.
getClusters
());
this
.
classPanel
.
addTreeSelectionListener
(
this
);
if
(
imgData
.
getRawImages
()
!=
null
&&
imgData
.
getRawImages
().
size
()
>
0
)
{
this
.
viewer
=
new
ClusteringImageViewer
(
new
GDALPyramidImageViewer
(
imgData
.
getRawImages
().
get
(
0
),
true
),
this
.
clusterMap
);
...
...
src/mustic/gui/panels/classifier/ClassifierPanel.java
View file @
3a3a7a41
...
...
@@ -695,8 +695,7 @@ public class ClassifierPanel extends JPanel {
if (this.timeCheckBox.isSelected()) {
classification.setTimeExec(1);
}
new
ClassificationThread
(
classification
,
classificationImage
.
getProgressBar
(),
new ClassificationThread(classification, classificationImage.getProgressBar(),classificationImage.getStatusBar(),
classificationImage, this.rmiServer, false, null).start();
try {
dataSession.associatedFrame.setMaximum(true);
...
...
@@ -717,6 +716,7 @@ public class ClassifierPanel extends JPanel {
// On lance le thread de classif
new ClassificationThread(classification, ((ClassificationModel) this.container_).getProgressBar(),
((ClassificationModel) this.container_).getStatusBar(),
(ClassificationModel) this.container_, this.rmiServer, false, null).start();
}
...
...
src/mustic/gui/panels/data/DataConstructPanel.java
View file @
3a3a7a41
...
...
@@ -124,32 +124,37 @@ public class DataConstructPanel extends JPanel implements ToUpdateObject {
}
private
void
generateData
()
{
ImageData
data
=
null
;
if
(
sourcePanel
.
isSequenceMaskSelected
()
&&
sample
instanceof
ImageSampler
&&
imageSessions
!=
null
)
{
List
<
Mask
>
maskSequence
=
new
ArrayList
<
Mask
>();
boolean
containsAtLeastOne
=
false
;
for
(
ImageSession
session
:
imageSessions
)
{
Mask
m
=
session
.
getRawImage
().
getMask
();
maskSequence
.
add
(
m
);
if
(
m
!=
null
)
{
containsAtLeastOne
=
true
;
new
Thread
()
{
@Override
public
void
run
()
{
ImageData
data
=
null
;
if
(
sourcePanel
.
isSequenceMaskSelected
()
&&
sample
instanceof
ImageSampler
&&
imageSessions
!=
null
)
{
List
<
Mask
>
maskSequence
=
new
ArrayList
<
Mask
>();
boolean
containsAtLeastOne
=
false
;
for
(
ImageSession
session
:
imageSessions
)
{
Mask
m
=
session
.
getRawImage
().
getMask
();
maskSequence
.
add
(
m
);
if
(
m
!=
null
)
{
containsAtLeastOne
=
true
;
}
}
if
(
containsAtLeastOne
)
{
((
ImageSampler
)
sample
).
setMaskSequence
(
maskSequence
);
}
}
if
(
filesPaths
.
size
()
>
1
)
{
data
=
new
ImageData
(
sample
,
filesPaths
);
}
else
{
data
=
new
ImageData
(
sample
,
filesPaths
.
get
(
0
));
}
MainFrame
.
getInstance
().
createDataSession
(
data
);
DataConstructFrame
.
getInstance
().
updateDataConstructPanel
();
DataConstructFrame
.
getInstance
().
dispose
();
}
if
(
containsAtLeastOne
)
{
((
ImageSampler
)
sample
).
setMaskSequence
(
maskSequence
);
}
}
if
(
filesPaths
.
size
()
>
1
)
{
data
=
new
ImageData
(
sample
,
filesPaths
);
}
else
{
data
=
new
ImageData
(
sample
,
filesPaths
.
get
(
0
));
}
MainFrame
.
getInstance
().
createDataSession
(
data
);
DataConstructFrame
.
getInstance
().
updateDataConstructPanel
();
DataConstructFrame
.
getInstance
().
dispose
();
}.
start
();
}
public
void
updateSamplingSelectionPanel
()
{
...
...
src/mustic/gui/panels/data/DataPanel.java
View file @
3a3a7a41
...
...
@@ -137,7 +137,8 @@ public class DataPanel extends JPanel implements ChangeListener {
this
.
data
=
_data
;
JPanel
container
=
buildBody
();
JScrollPane
sp
=
new
JScrollPane
(
container
);
// JScrollPane sp = new JScrollPane(container);
JPanel
sp
=
container
;
//no scroll bars for better visibility
JPanel
dataPane
=
new
JPanel
(
new
BorderLayout
());
// dataPane.setSize(700, 500);
dataPane
.
setPreferredSize
(
new
Dimension
(
700
,
500
));
...
...
src/mustic/io/ImageData.java
View file @
3a3a7a41
...
...
@@ -13,6 +13,7 @@ import jcl.data.sampling.Sampler;
import
jcl.utils.exceptions.MethodNotImplementedException
;
import
mustic.gui.ImageSession
;
import
mustic.gui.MainFrame
;
import
mustic.models.thread.ProgressThreadJCL
;
import
mustic.utils.jclAdapters.ImageSampler
;
/**
...
...
@@ -108,7 +109,7 @@ public class ImageData extends SimpleData implements Serializable {
// Pierre
if
(
MainFrame
.
DEBUG_MODE
==
true
)
System
.
out
.
println
(
"
JJJ
Création de dataObject[] à partir d'une image "
+
this
.
hashCode
());
System
.
out
.
println
(
" Création de dataObject[] à partir d'une image "
+
this
.
hashCode
());
// double[][][] buffer = image.getData();//image.load(0, 0,
// image.getWidth(), image.getHeight());
...
...
@@ -225,7 +226,7 @@ public class ImageData extends SimpleData implements Serializable {
/**
* <p>
* Construcor from an already built set of DataObject of a sampler,
* Construc
t
or from an already built set of DataObject of a sampler,
* the path is only used to gather the image informations
* </p>
*
...
...
@@ -240,9 +241,7 @@ public class ImageData extends SimpleData implements Serializable {
if
(
MainFrame
.
DEBUG_MODE
)
{
System
.
out
.
println
(
">> ImageData(Sampler,String) <<"
);
}
MainFrame
.
getProgressStatus
().
setMessage
(
"loading sampler..."
);
this
.
rawImages
.
add
(
path
);
long
startTime
=
System
.
currentTimeMillis
();
...
...
@@ -269,7 +268,8 @@ public class ImageData extends SimpleData implements Serializable {
dimensions
[
0
]
=
rawImages
.
get
(
0
).
width
;
dimensions
[
1
]
=
rawImages
.
get
(
0
).
height
;
// new ProgressThreadJCL(sampler, MainFrame.getProgressBar(), MainFrame.getProgressStatus()).start();
new
ProgressThreadJCL
(
sampler
,
MainFrame
.
getProgressBar
(),
MainFrame
.
getProgressStatus
()).
start
();
if
(
mask
!=
null
)
{
currentView
=
sampler
.
getDataObjects
(
mask
);
}
else
{
...
...
@@ -294,7 +294,7 @@ public class ImageData extends SimpleData implements Serializable {
/**
* <p>
* Construcor from an already built set of DataObject of a sampler,
* Construc
t
or from an already built set of DataObject of a sampler,
* the path is only used to gather the image informations
* </p>
*
...
...
@@ -322,6 +322,7 @@ public class ImageData extends SimpleData implements Serializable {
* a mask to apply to the sampler
*/
public
ImageData
(
Sampler
sampler
,
Vector
<
RawImage
>
images
,
Mask
mask
)
{
for
(
RawImage
s
:
images
)
{
this
.
rawImages
.
add
(
s
);
}
...
...
src/mustic/models/gui/ClassificationFrame.java
View file @
3a3a7a41
...
...
@@ -44,7 +44,6 @@ public class ClassificationFrame extends ClassificationModel {
ResultPanel
rp
=
new
ResultPanel
(
result
,
this
);
rp
.
setName
(
name
);
resultPanels
.
add
(
rp
);
Tab
tabResult
=
ClassificationModel
.
createTab
(
result
.
getName
(),
new
ImageIcon
(
getClass
().
getResource
(
...
...
src/mustic/models/gui/ClassificationModel.java
View file @
3a3a7a41
...
...
@@ -33,6 +33,7 @@ import mustic.models.gui.panels.HybridClassificationMonitor;
import
mustic.models.gui.panels.MaclawClassificationMonitor
;
import
mustic.models.gui.panels.ResultPanel
;
import
mustic.models.gui.widgets.ClassificationManager
;
import
mustic.utils.tools.ProgressStatus
;
import
net.infonode.tabbedpanel.Tab
;
import
net.infonode.tabbedpanel.TabDragEvent
;
import
net.infonode.tabbedpanel.TabEvent
;
...
...
@@ -289,6 +290,10 @@ public abstract class ClassificationModel extends JPanel {
public
JProgressBar
getProgressBar
()
{
return
MainFrame
.
getProgressBar
();
}
public
ProgressStatus
getStatusBar
()
{
return
MainFrame
.
getProgressStatus
();
}
/**
* <p>
...
...
src/mustic/models/gui/panels/ClassifierPanel.java
View file @
3a3a7a41
...
...
@@ -534,7 +534,7 @@ public class ClassifierPanel extends JPanel {
System
.
out
.
println
(
"DEBUT CLASSIF"
);
/* On lance le thread de classification */
new
ClassificationThread
(
classification
,
this
.
container_
.
getProgressBar
(),
this
.
container_
,
this
.
container_
.
getProgressBar
(),
this
.
container_
.
getStatusBar
(),
this
.
container_
,
this
.
rmiServer
,
false
,
null
).
start
();
}
...
...
src/mustic/models/thread/ClassificationThread.java
View file @
3a3a7a41
...
...
@@ -8,8 +8,10 @@ import jcl.Classification;
import
jcl.clustering.constraints.Constraint
;
import
jcl.jcld.RmiServer
;
import
jcl.learning.IterativeClassification
;
import
jcl.learning.LearningMethod
;
import
jcl.learning.methods.multistrategy.samarah4.comm.ClassificationSAM4
;
import
mustic.models.gui.ClassificationModel
;
import
mustic.utils.tools.ProgressStatus
;
/**
* <p>
...
...
@@ -28,6 +30,9 @@ public class ClassificationThread extends Thread {
/** Barre d'avancement de la classification */
private
JProgressBar
progressBar_
;
/** Etat d'avancement de la classification */
private
ProgressStatus
statusBar_
;
/** Server Rmi ou deporte le calcul */
private
RmiServer
rmiServer_
;
...
...
@@ -55,6 +60,13 @@ public class ClassificationThread extends Thread {
* @param constraints
* constraints used for the new iteration
*/
public
ClassificationThread
(
Classification
classification
,
JProgressBar
progressBar
,
ProgressStatus
statusBar
,
ClassificationModel
container
,
RmiServer
rmiServer
,
boolean
newIterationMode
,
Vector
<
Constraint
>
constraints
)
{
this
(
classification
,
progressBar
,
container
,
rmiServer
,
newIterationMode
,
constraints
);
this
.
statusBar_
=
statusBar
;
}
public
ClassificationThread
(
Classification
classification
,
JProgressBar
progressBar
,
ClassificationModel
container
,
RmiServer
rmiServer
,
boolean
newIterationMode
,
Vector
<
Constraint
>
constraints
)
{
...
...
@@ -69,11 +81,10 @@ public class ClassificationThread extends Thread {
@Override
public
void
run
()
{
/* Si on a une barre de progression on monitore la classification */
if
(
this
.
rmiServer_
!=
null
&&
!
this
.
rmiServer_
.
useRmi
())
if
(
this
.
progressBar_
!=
null
)
new
ProgressThreadJCL
(
this
.
classification_
.
getLearningMethod
(),
this
.
progressBar_
).
start
();
if
(
this
.
rmiServer_
!=
null
&&
!
this
.
rmiServer_
.
useRmi
())
&&
this
.
progressBar_
!=
null
&&
this
.
statusBar_
!=
null
)
{
new
ProgressThreadJCL
(
this
.
classification_
,
this
.
progressBar_
,
this
.
statusBar_
).
start
();
}
/* teste si le calcul est a faire avec rmi */
if
((
this
.
rmiServer_
!=
null
)
&&
(
this
.
rmiServer_
.
useRmi
()))
{
...
...
src/mustic/models/thread/ProgressThreadJCL.java
View file @
3a3a7a41
package
mustic.models.thread
;
import
java.util.Date
;
import
javax.swing.JProgressBar
;
import
jcl.utils.Progressable
;
...
...
@@ -63,11 +65,13 @@ public class ProgressThreadJCL extends Thread {
{
while
(
prog
!=
100
)
{
prog
=
this
.
p
.
getProgress
();
// status = this.p.getStatus();
status
=
this
.
p
.
getStatus
();
// long time = new Date().getTime();
// System.out.println("prog:"+prog+" status:"+status+" time : "+time);
this
.
b
.
setValue
(
prog
);
MainFrame
.
getProgressStatus
().
setMessage
(
status
);
try
{
sleep
(
10
00
);
sleep
(
2
00
);
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
System
.
exit
(
1
);
...
...
@@ -82,7 +86,7 @@ public class ProgressThreadJCL extends Thread {
prog
=
this
.
p
.
getProgress
();
this
.
b
.
setValue
(
prog
);
try
{
sleep
(
10
00
);
sleep
(
2
00
);
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
System
.
exit
(
1
);
...
...
src/mustic/utils/image/reader/GDALImageReaderWrapper.java
View file @
3a3a7a41
package
mustic.utils.image.reader
;
import
javax.swing.SwingWorker
;
import
org.gdal.gdal.Band
;
import
org.gdal.gdal.Dataset
;
import
org.gdal.gdal.ProgressCallback
;
import
org.gdal.gdal.gdal
;
import
org.gdal.gdalconst.gdalconst
;
import
jcl.utils.exceptions.MethodNotImplementedException
;
import
mustic.gui.MainFrame
;
import
mustic.utils.tools.ProgressPropertyChangeListener
;
/**
* Reader tool used to access to the data using the gdal library
...
...
@@ -291,7 +296,7 @@ public class GDALImageReaderWrapper extends ReaderWrapper {
}
/*
/*
*
* Generates overviews if
* @param filePath
* The image file path
...
...
@@ -310,12 +315,74 @@ public class GDALImageReaderWrapper extends ReaderWrapper {
// the factor is the different (just tested for the first band)
if
((
dataSet
.
GetRasterBand
(
1
).
GetOverviewCount
()
!=
overViewIDList
.
length
)
||
((
dataSet
.
GetRasterBand
(
1
).
GetOverview
(
0
).
getXSize
()
-
dataSet
.
getRasterXSize
()/
2
)
>
1
))
{
dataSet
.
BuildOverviews
(
overViewIDList
);
//Layers are generated in a background process using Swingworker.
//A progress bar is incremented to display loading progress
ImgLoadTask
task
=
new
ImgLoadTask
(
dataSet
,
overViewIDList
);
task
.
addPropertyChangeListener
(
new
ProgressPropertyChangeListener
());
task
.
execute
();
task
.
get
();
}
}
}
/**
* SwingWorker which generates pyramids layers in a background process
* and updates a progress bar
*
* @author Jean-Noël BALANCHE
*
*/
static
class
ImgLoadTask
extends
SwingWorker
<
Void
,
Void
>
{
private
int
[]
overViewIDList
=
null
;
private
Dataset
dataSet
=
null
;
private
int
layer
=
1
;
/**
* task to generate pyramide layers in a background process
*
* @param dataSet the dataset where to put the layers
* @param overViewIDList list of layers to generate
*/
public
ImgLoadTask
(
Dataset
dataSet
,
int
[]
overViewIDList
)
{
//initialize
this
.
dataSet
=
dataSet
;
this
.
overViewIDList
=
overViewIDList
;
}
@Override
public
Void
doInBackground
()
throws
Exception
{
System
.
out
.
println
(
"Nb layers to generate : "
+
overViewIDList
.
length
);
MainFrame
.
getProgressStatus
().
setMessage
(
"Generating overview "
+
layer
+
" of "
+
overViewIDList
.
length
);
dataSet
.
BuildOverviews
(
overViewIDList
,
new
ProgressCallback
(){
@Override
public
int
run
(
double
dfComplete
,
String
message
)
{
/* If BuildOverviews is calling ProgressCallback.run() for each layer : */
// double totalProgress = layer*100/overViewIDList.length+dfComplete*100/overViewIDList.length;
// setProgress((int) Math.min(totalProgress,100));
// if(dfComplete*100>=100) {
// layer++;
// MainFrame.getProgressStatus().setMessage("Generating overview "+layer+" of "+overViewIDList.length);
// }
/* If BuildOverviews is calling ProgressCallback.run() only one time :*/
MainFrame
.
getProgressStatus
().
setMessage
(
"Generating overview "
+
layer
+
" of "
+
overViewIDList
.
length
);
setProgress
((
int
)
(
100
*
dfComplete
));
if
(
dfComplete
*
100
>=
layer
*
100
/
overViewIDList
.
length
&&
dfComplete
*
100
<
100
)
{
layer
++;
MainFrame
.
getProgressStatus
().
setMessage
(
"Generating overview "
+
layer
+
" of "
+
overViewIDList
.
length
);
}
return
1
;
}
});