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 boolean
m_Aborted
whether the user cancelled the experiment.protected T
m_Exp
the copy of the experiment.protected ExperimenterPanel
m_Owner
the experimenter this runner belongs to.protected boolean
m_Running
whether the experiment is still running.protected static String
NOT_RUNNING
The 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 void
abortExperiment()
Aborts the experiment.protected abstract void
doInitialize()
Initializes the experiment.protected abstract void
doRun()
Performs the actual running of the experiment.boolean
isRunning()
Whether the experiment is still running.void
logError(String msg, String title)
Logs the error message and also displays an error dialog.void
logError(Throwable t, String title)
Logs the exception and also displays an error dialog.void
logMessage(String msg)
Logs the message.void
logMessage(Throwable t)
Logs the exception with no dialog.protected void
postRun(boolean success)
Hook method that gets executed after the experiment has finished (successfully or not).protected void
preRun()
Hook method that gets executed before the experiment gets initialized.void
run()
Starts running the experiment.void
showStatus(String msg)
Displays a message.void
update()
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 Exception
Hook method that gets executed before the experiment gets initialized.- Throws:
Exception
- fails due to some error
-
doInitialize
protected abstract void doInitialize() throws Exception
Initializes the experiment.- Throws:
Exception
- fails due to some error
-
doRun
protected abstract void doRun() throws Exception
Performs 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)
-
-