Commit 11c0fc90 authored by balanche's avatar balanche

Ajout progress bar pendant la génération de dataset + début progress bar...

Ajout progress bar pendant la génération de dataset + début progress bar classify (Progressable implémenté dans Classification et learningResult
parent a14f220a
...@@ -3967,7 +3967,7 @@ public class MainFrame extends JFrame { ...@@ -3967,7 +3967,7 @@ public class MainFrame extends JFrame {
true); true);
t = new ClassificationThread(classif, classificationImage.getProgressBar(), t = new ClassificationThread(classif, classificationImage.getProgressBar(),classificationImage.getStatusBar(),
classificationImage, null, false, null); classificationImage, null, false, null);
t.start(); t.start();
try { try {
......
...@@ -695,8 +695,7 @@ public class ClassifierPanel extends JPanel { ...@@ -695,8 +695,7 @@ public class ClassifierPanel extends JPanel {
if (this.timeCheckBox.isSelected()) { if (this.timeCheckBox.isSelected()) {
classification.setTimeExec(1); classification.setTimeExec(1);
} }
new ClassificationThread(classification, classificationImage.getProgressBar(),classificationImage.getStatusBar(),
new ClassificationThread(classification, classificationImage.getProgressBar(),
classificationImage, this.rmiServer, false, null).start(); classificationImage, this.rmiServer, false, null).start();
try { try {
dataSession.associatedFrame.setMaximum(true); dataSession.associatedFrame.setMaximum(true);
...@@ -717,6 +716,7 @@ public class ClassifierPanel extends JPanel { ...@@ -717,6 +716,7 @@ public class ClassifierPanel extends JPanel {
// On lance le thread de classif // On lance le thread de classif
new ClassificationThread(classification, ((ClassificationModel) this.container_).getProgressBar(), new ClassificationThread(classification, ((ClassificationModel) this.container_).getProgressBar(),
((ClassificationModel) this.container_).getStatusBar(),
(ClassificationModel) this.container_, this.rmiServer, false, null).start(); (ClassificationModel) this.container_, this.rmiServer, false, null).start();
} }
......
...@@ -124,32 +124,37 @@ public class DataConstructPanel extends JPanel implements ToUpdateObject { ...@@ -124,32 +124,37 @@ public class DataConstructPanel extends JPanel implements ToUpdateObject {
} }
private void generateData() { private void generateData() {
ImageData data = null; new Thread() {
@Override
if (sourcePanel.isSequenceMaskSelected() && sample instanceof ImageSampler public void run() {
&& imageSessions != null) { ImageData data = null;
List<Mask> maskSequence = new ArrayList<Mask>();
boolean containsAtLeastOne = false; if (sourcePanel.isSequenceMaskSelected() && sample instanceof ImageSampler
for (ImageSession session : imageSessions) { && imageSessions != null) {
Mask m = session.getRawImage().getMask(); List<Mask> maskSequence = new ArrayList<Mask>();
maskSequence.add(m); boolean containsAtLeastOne = false;
if (m != null) { for (ImageSession session : imageSessions) {
containsAtLeastOne = true; 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) { }.start();
((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();
} }
public void updateSamplingSelectionPanel() { public void updateSamplingSelectionPanel() {
......
...@@ -13,6 +13,7 @@ import jcl.data.sampling.Sampler; ...@@ -13,6 +13,7 @@ import jcl.data.sampling.Sampler;
import jcl.utils.exceptions.MethodNotImplementedException; import jcl.utils.exceptions.MethodNotImplementedException;
import mustic.gui.ImageSession; import mustic.gui.ImageSession;
import mustic.gui.MainFrame; import mustic.gui.MainFrame;
import mustic.models.thread.ProgressThreadJCL;
import mustic.utils.jclAdapters.ImageSampler; import mustic.utils.jclAdapters.ImageSampler;
/** /**
...@@ -225,7 +226,7 @@ public class ImageData extends SimpleData implements Serializable { ...@@ -225,7 +226,7 @@ public class ImageData extends SimpleData implements Serializable {
/** /**
* <p> * <p>
* Construcor from an already built set of DataObject of a sampler, * Constructor from an already built set of DataObject of a sampler,
* the path is only used to gather the image informations * the path is only used to gather the image informations
* </p> * </p>
* *
...@@ -237,6 +238,7 @@ public class ImageData extends SimpleData implements Serializable { ...@@ -237,6 +238,7 @@ public class ImageData extends SimpleData implements Serializable {
* a mask to apply to the sampler * a mask to apply to the sampler
*/ */
public ImageData(Sampler sampler, RawImage path, Mask mask) { public ImageData(Sampler sampler, RawImage path, Mask mask) {
System.out.println("ImageData(Sampler sampler, RawImage path, Mask mask)");
if (MainFrame.DEBUG_MODE) { if (MainFrame.DEBUG_MODE) {
System.out.println(">> ImageData(Sampler,String) <<"); System.out.println(">> ImageData(Sampler,String) <<");
} }
...@@ -269,7 +271,8 @@ public class ImageData extends SimpleData implements Serializable { ...@@ -269,7 +271,8 @@ public class ImageData extends SimpleData implements Serializable {
dimensions[0] = rawImages.get(0).width; dimensions[0] = rawImages.get(0).width;
dimensions[1] = rawImages.get(0).height; 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) { if (mask != null) {
currentView = sampler.getDataObjects(mask); currentView = sampler.getDataObjects(mask);
} else { } else {
...@@ -294,7 +297,7 @@ public class ImageData extends SimpleData implements Serializable { ...@@ -294,7 +297,7 @@ public class ImageData extends SimpleData implements Serializable {
/** /**
* <p> * <p>
* Construcor from an already built set of DataObject of a sampler, * Constructor from an already built set of DataObject of a sampler,
* the path is only used to gather the image informations * the path is only used to gather the image informations
* </p> * </p>
* *
...@@ -322,6 +325,8 @@ public class ImageData extends SimpleData implements Serializable { ...@@ -322,6 +325,8 @@ public class ImageData extends SimpleData implements Serializable {
* a mask to apply to the sampler * a mask to apply to the sampler
*/ */
public ImageData(Sampler sampler, Vector<RawImage> images, Mask mask) { public ImageData(Sampler sampler, Vector<RawImage> images, Mask mask) {
System.out.println("ImageData(Sampler sampler, Vector<RawImage> images, Mask mask)");
for(RawImage s : images) { for(RawImage s : images) {
this.rawImages.add(s); this.rawImages.add(s);
} }
......
...@@ -33,6 +33,7 @@ import mustic.models.gui.panels.HybridClassificationMonitor; ...@@ -33,6 +33,7 @@ import mustic.models.gui.panels.HybridClassificationMonitor;
import mustic.models.gui.panels.MaclawClassificationMonitor; import mustic.models.gui.panels.MaclawClassificationMonitor;
import mustic.models.gui.panels.ResultPanel; import mustic.models.gui.panels.ResultPanel;
import mustic.models.gui.widgets.ClassificationManager; import mustic.models.gui.widgets.ClassificationManager;
import mustic.utils.tools.ProgressStatus;
import net.infonode.tabbedpanel.Tab; import net.infonode.tabbedpanel.Tab;
import net.infonode.tabbedpanel.TabDragEvent; import net.infonode.tabbedpanel.TabDragEvent;
import net.infonode.tabbedpanel.TabEvent; import net.infonode.tabbedpanel.TabEvent;
...@@ -289,6 +290,10 @@ public abstract class ClassificationModel extends JPanel { ...@@ -289,6 +290,10 @@ public abstract class ClassificationModel extends JPanel {
public JProgressBar getProgressBar() { public JProgressBar getProgressBar() {
return MainFrame.getProgressBar(); return MainFrame.getProgressBar();
} }
public ProgressStatus getStatusBar() {
return MainFrame.getProgressStatus();
}
/** /**
* <p> * <p>
......
...@@ -534,7 +534,7 @@ public class ClassifierPanel extends JPanel { ...@@ -534,7 +534,7 @@ public class ClassifierPanel extends JPanel {
System.out.println("DEBUT CLASSIF"); System.out.println("DEBUT CLASSIF");
/* On lance le thread de classification */ /* On lance le thread de classification */
new ClassificationThread(classification, new ClassificationThread(classification,
this.container_.getProgressBar(), this.container_, this.container_.getProgressBar(),this.container_.getStatusBar(), this.container_,
this.rmiServer, false, null).start(); this.rmiServer, false, null).start();
} }
......
...@@ -8,8 +8,10 @@ import jcl.Classification; ...@@ -8,8 +8,10 @@ import jcl.Classification;
import jcl.clustering.constraints.Constraint; import jcl.clustering.constraints.Constraint;
import jcl.jcld.RmiServer; import jcl.jcld.RmiServer;
import jcl.learning.IterativeClassification; import jcl.learning.IterativeClassification;
import jcl.learning.LearningMethod;
import jcl.learning.methods.multistrategy.samarah4.comm.ClassificationSAM4; import jcl.learning.methods.multistrategy.samarah4.comm.ClassificationSAM4;
import mustic.models.gui.ClassificationModel; import mustic.models.gui.ClassificationModel;
import mustic.utils.tools.ProgressStatus;
/** /**
* <p> * <p>
...@@ -28,6 +30,9 @@ public class ClassificationThread extends Thread { ...@@ -28,6 +30,9 @@ public class ClassificationThread extends Thread {
/** Barre d'avancement de la classification */ /** Barre d'avancement de la classification */
private JProgressBar progressBar_; private JProgressBar progressBar_;
/** Etat d'avancement de la classification */
private ProgressStatus statusBar_;
/** Server Rmi ou deporte le calcul */ /** Server Rmi ou deporte le calcul */
private RmiServer rmiServer_; private RmiServer rmiServer_;
...@@ -55,6 +60,18 @@ public class ClassificationThread extends Thread { ...@@ -55,6 +60,18 @@ public class ClassificationThread extends Thread {
* @param constraints * @param constraints
* constraints used for the new iteration * 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_ = classification;
this.progressBar_ = progressBar;
this.statusBar_ = statusBar;
this.container_ = container;
this.rmiServer_ = rmiServer;
this.newIterationMode = newIterationMode;
this.constraints = constraints;
}
public ClassificationThread(Classification classification, public ClassificationThread(Classification classification,
JProgressBar progressBar, ClassificationModel container, JProgressBar progressBar, ClassificationModel container,
RmiServer rmiServer, boolean newIterationMode, Vector<Constraint> constraints) { RmiServer rmiServer, boolean newIterationMode, Vector<Constraint> constraints) {
...@@ -70,10 +87,13 @@ public class ClassificationThread extends Thread { ...@@ -70,10 +87,13 @@ public class ClassificationThread extends Thread {
public void run() { public void run() {
/* Si on a une barre de progression on monitore la classification */ /* Si on a une barre de progression on monitore la classification */
if (this.rmiServer_ != null && !this.rmiServer_.useRmi())
if (this.progressBar_ != null) if (this.progressBar_ != null && this.statusBar_ != null) {
new ProgressThreadJCL(this.classification_.getLearningMethod(), LearningMethod lm = this.classification_.getLearningMethod();
this.progressBar_).start(); new ProgressThreadJCL(lm, this.progressBar_,this.statusBar_).start();
// lm.incProgress();
// lm.setStatus("Clustering test !");
}
/* teste si le calcul est a faire avec rmi */ /* teste si le calcul est a faire avec rmi */
if ((this.rmiServer_ != null) && (this.rmiServer_.useRmi())) { if ((this.rmiServer_ != null) && (this.rmiServer_.useRmi())) {
......
package mustic.models.thread; package mustic.models.thread;
import java.util.Date;
import javax.swing.JProgressBar; import javax.swing.JProgressBar;
import jcl.utils.Progressable; import jcl.utils.Progressable;
...@@ -63,11 +65,13 @@ public class ProgressThreadJCL extends Thread { ...@@ -63,11 +65,13 @@ public class ProgressThreadJCL extends Thread {
{ {
while (prog != 100) { while (prog != 100) {
prog = this.p.getProgress(); 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); this.b.setValue(prog);
MainFrame.getProgressStatus().setMessage(status); MainFrame.getProgressStatus().setMessage(status);
try { try {
sleep(1000); sleep(200);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
System.exit(1); System.exit(1);
...@@ -82,7 +86,7 @@ public class ProgressThreadJCL extends Thread { ...@@ -82,7 +86,7 @@ public class ProgressThreadJCL extends Thread {
prog = this.p.getProgress(); prog = this.p.getProgress();
this.b.setValue(prog); this.b.setValue(prog);
try { try {
sleep(1000); sleep(200);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
System.exit(1); System.exit(1);
......
...@@ -253,8 +253,9 @@ public class ImageSampler extends Sampler { ...@@ -253,8 +253,9 @@ public class ImageSampler extends Sampler {
* @return the sample * @return the sample
*/ */
private List<DataObject> getDataFromOneImage() { private List<DataObject> getDataFromOneImage() {
//System.out.println("getDataFromOneImage()");
setStatus("Loading sampler...");
List<DataObject> result = new ArrayList<DataObject>(sizeByCount); List<DataObject> result = new ArrayList<DataObject>(sizeByCount);
setStatus("loading sampler...");
int index = 0; int index = 0;
int x = 0; int x = 0;
int y = 0; int y = 0;
...@@ -279,8 +280,7 @@ public class ImageSampler extends Sampler { ...@@ -279,8 +280,7 @@ public class ImageSampler extends Sampler {
} }
resetProgress(); resetProgress();
int jalon = sizeByCount/10; int jalon = sizeByCount/100;
for(int i = 0; i < sizeByCount ; i++) { for(int i = 0; i < sizeByCount ; i++) {
index = getIndex(i); index = getIndex(i);
x = (index) % imageWidth; x = (index) % imageWidth;
...@@ -297,8 +297,11 @@ public class ImageSampler extends Sampler { ...@@ -297,8 +297,11 @@ public class ImageSampler extends Sampler {
if(i == jalon) if(i == jalon)
{ {
jalon+=sizeByCount/10; jalon+=sizeByCount/100;
//System.out.println("jalon:"+jalon);
incProgress(); incProgress();
System.out.print(" p:"+this.progress);
} }
} }
endProgress(); endProgress();
...@@ -317,6 +320,7 @@ public class ImageSampler extends Sampler { ...@@ -317,6 +320,7 @@ public class ImageSampler extends Sampler {
* @return the sample * @return the sample
*/ */
private List<DataObject> getDataFromOneImage(final Mask mask, int mandatoryPixelCount) { private List<DataObject> getDataFromOneImage(final Mask mask, int mandatoryPixelCount) {
System.out.println("getDataFromOneImage(final Mask mask, int mandatoryPixelCount)");
List<DataObject> result = new ArrayList<DataObject>(sizeByCount); List<DataObject> result = new ArrayList<DataObject>(sizeByCount);
setStatus("loading sampler..."); setStatus("loading sampler...");
int x = 0; int x = 0;
...@@ -1265,7 +1269,7 @@ public class ImageSampler extends Sampler { ...@@ -1265,7 +1269,7 @@ public class ImageSampler extends Sampler {
@Override @Override
public void incProgress() public void incProgress()
{ {
this.progress+=progressM/10; this.progress+=progressM/100;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment