Commit b149a2de authored by lafabregue's avatar lafabregue

Update ClassificationImage.java

parent f5164f17
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$
}
}
}
}
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$
}
}
}
}
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