Class AbstractExperimentRunner<T>
- java.lang.Object
-
- java.lang.Thread
-
- adams.gui.tools.wekamultiexperimenter.runner.AbstractExperimentRunner<T>
-
- All Implemented Interfaces:
Serializable,Runnable
- Direct Known Subclasses:
AbstractAdamsExperimentRunner,AbstractWekaExperimentRunner
public abstract class AbstractExperimentRunner<T> extends Thread implements Serializable
Ancestor for classes that handle running a copy of the experiment in a separate thread.- See Also:
RunPanel.ExperimentRunner, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_Abortedwhether the user cancelled the experiment.protected Tm_Expthe copy of the experiment.protected ExperimenterPanelm_Ownerthe experimenter this runner belongs to.protected booleanm_Runningwhether the experiment is still running.protected static StringNOT_RUNNINGThe message displayed when no experiment is running-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description AbstractExperimentRunner(ExperimenterPanel owner)Initializes the thread.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidabortExperiment()Aborts the experiment.protected abstract voiddoInitialize()Initializes the experiment.protected abstract voiddoRun()Performs the actual running of the experiment.booleanisRunning()Whether the experiment is still running.voidlogError(String msg, String title)Logs the error message and also displays an error dialog.voidlogError(Throwable t, String title)Logs the exception and also displays an error dialog.voidlogMessage(String msg)Logs the message.voidlogMessage(Throwable t)Logs the exception with no dialog.protected voidpostRun(boolean success)Hook method that gets executed after the experiment has finished (successfully or not).protected voidpreRun()Hook method that gets executed before the experiment gets initialized.voidrun()Starts running the experiment.voidshowStatus(String msg)Displays a message.voidupdate()Updates the owner's state.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
NOT_RUNNING
protected static final String NOT_RUNNING
The message displayed when no experiment is running- See Also:
- Constant Field Values
-
m_Owner
protected ExperimenterPanel m_Owner
the experimenter this runner belongs to.
-
m_Exp
protected T m_Exp
the copy of the experiment.
-
m_Running
protected boolean m_Running
whether the experiment is still running.
-
m_Aborted
protected boolean m_Aborted
whether the user cancelled the experiment.
-
-
Constructor Detail
-
AbstractExperimentRunner
public AbstractExperimentRunner(ExperimenterPanel owner) throws Exception
Initializes the thread.- Parameters:
owner- the experimenter this runner belongs to- Throws:
Exception- if experiment is null or cannot be copied via serialization
-
-
Method Detail
-
abortExperiment
public void abortExperiment()
Aborts the experiment.
-
isRunning
public boolean isRunning()
Whether the experiment is still running.- Returns:
- true if still running
-
logMessage
public void logMessage(Throwable t)
Logs the exception with no dialog.- Parameters:
t- the exception
-
logMessage
public void logMessage(String msg)
Logs the message.- Parameters:
msg- the log message
-
logError
public void logError(Throwable t, String title)
Logs the exception and also displays an error dialog.- Parameters:
t- the exceptiontitle- the title for the dialog
-
logError
public void logError(String msg, String title)
Logs the error message and also displays an error dialog.- Parameters:
msg- the error messagetitle- the title for the dialog
-
showStatus
public void showStatus(String msg)
Displays a message.- Parameters:
msg- the message to display
-
update
public void update()
Updates the owner's state.
-
preRun
protected void preRun() throws ExceptionHook method that gets executed before the experiment gets initialized.- Throws:
Exception- fails due to some error
-
doInitialize
protected abstract void doInitialize() throws ExceptionInitializes the experiment.- Throws:
Exception- fails due to some error
-
doRun
protected abstract void doRun() throws ExceptionPerforms the actual running of the experiment.- Throws:
Exception- fails due to some error
-
postRun
protected void postRun(boolean success)
Hook method that gets executed after the experiment has finished (successfully or not).- Parameters:
success- whether successfully finished (neither error, nor aborted)
-
-