|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object info.monitorenter.gui.chart.io.ADataCollector
public abstract class ADataCollector
A simple Runnable that continuously collects data every latency time period and adds it to the internal ITrace2D instance.
Extend from this class and override the method collectData()
.
Set it up with code like:
Chart2D chart = new Chart2D(); ITrace2D trace = <initialization> chart.addTrace(trace); // Put the chart in your UI... // ... AbstractDataCollector collector = new <subtypename>(200,trace); collector.start();
new Thread(collector).start()
is disallowed and will
throw an exception as it would allow several Threads to run a collector. Use
the start()
instead.
Always connect the trace to a chart first before starting the collector for that trace! (deadlock prevention will raise an exception else).
Constructor Summary | |
---|---|
ADataCollector(ITrace2D trace,
long latency)
Creates an instance that will collect every latency ms a point and add it to the trace. |
Method Summary | |
---|---|
abstract ITracePoint2D |
collectData()
Override this method. |
protected void |
finalize()
|
long |
getLatency()
Returns the interval in ms a point is collected. |
ITrace2D |
getTrace()
Returns the trace that is filled by this collector. |
boolean |
isRunning()
Returns true if this datacollector currently is running. |
void |
run()
|
void |
setLatency(long latency)
Sets the interval for collecting points in ms. |
void |
start()
Starts a Thread using this Runnable . |
void |
stop()
Stops this Thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ADataCollector(ITrace2D trace, long latency)
trace
- the trace to add collected points to.latency
- the interval in ms for collecting points.Method Detail |
---|
public abstract ITracePoint2D collectData()
Override this method. It will be invoked in intervals of the configured latency time. The TracePoint2D that is returned will be added to the constructor given ITrace2D.
Keep your implementation fast. If the computations performed here take longer than the latency time that desired refresh rate will not be reached.
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
Object.finalize()
public long getLatency()
public ITrace2D getTrace()
public boolean isRunning()
public void run()
run
in interface java.lang.Runnable
Runnable.run()
public void setLatency(long latency)
latency
- the interval for collecting points in ms.public void start()
Starts a Thread using this Runnable
.
This method will not start a new Thread if the current one is still running. If you prefer to use your own Threads (e.g. from a ThreadPool) prefer:
AbstractDataCollector collector = new <subtypename>(200,trace); new Thread(collector).start();or more abstract (as proposed for Thread improvement reasons:
AbstractDataCollector collector = new <subtypename>(200,trace); <getSomeThreadInstance>(collector).start();
public void stop()
Note that your application may
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |