|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.nebula.widgets.oscilloscope.OscilloscopeDispatcher
public abstract class OscilloscopeDispatcher
This class keeps the oscilloscope animation running and is used to set various attributes of the scope.
You need to provide anOscilloscope
widget by overriding the
getOscilloscope()
method. The Control.redraw()
method
will be called every getDelayLoop()
milliseconds. The higher the
value, the slower the animation will run.
Just before the redraw and just after the redraw the hook..Draw
methods are called. Don't do any expensive calculations there because this
will slow down the animation.
Then a counter is incremented and if the counter reaches the
getPulse()
value, then the hookSetValues(int)
method is
called. This is you opportunity to provide a value to the scope by calling
its setValue or setValues method. The hookSetValues method is only called if
the getPulse()
value is greater than NO_PULSE
You can also be called back by the widget if it runs out of values by setting
a listener in the
Oscilloscope.addStackListener(OscilloscopeStackAdapter)
method.
Nested Class Summary | |
---|---|
class |
OscilloscopeDispatcher.PlayClip
Plays a sound clip. |
Field Summary | |
---|---|
static int[] |
BACKGROUND_MONITOR
Contains a small image that can serve as the background of the scope. |
static int[] |
BACKGROUND_MONITOR_SMALL
Contains a small image that can serve as the background of the scope. |
static int |
NO_PULSE
This is a special value indicating there is no pulse which means that hookPulse(Oscilloscope, int) will never be called. |
Constructor Summary | |
---|---|
OscilloscopeDispatcher()
|
Method Summary | |
---|---|
void |
dispatch()
This method will get the animation going. |
org.eclipse.swt.graphics.Color |
getActiveForegoundColor()
Is used to get the color of the foreground when the thing that the scope is measuring is still alive. |
java.io.File |
getActiveSoundfile()
Override this to return a soundfile that will be played by the dispatcher in the hookPulse(Oscilloscope, int) method if the
isSoundRequired() method returns true. |
org.eclipse.swt.graphics.Image |
getBackgroundImage()
Override this to return the background image for the scope. |
int |
getBaseOffset()
Override this to set the offset of the scope line in percentages where 100 is the top of the widget and 0 is the bottom. |
OscilloscopeDispatcher.PlayClip |
getClipper()
Override this to return the Clip player. |
int |
getDelayLoop()
Override this to return a draw delay in milliseconds. |
boolean |
getFade()
|
org.eclipse.swt.graphics.Color |
getInactiveForegoundColor()
Is used to get the color of the foreground when the thing that the scope is measuring is not active. |
java.io.File |
getInactiveSoundfile()
|
int |
getLineWidth()
|
abstract Oscilloscope |
getOscilloscope()
|
int |
getProgression()
Override this to set the number of steps that is calculated before it is actually drawn on the display. |
int |
getPulse()
|
int |
getSteadyPosition()
|
int |
getTailFade()
|
int |
getTailSize()
|
void |
hookAfterDraw(Oscilloscope oscilloscope,
int counter)
Is called just after the widget is redrawn every getDelayLoop()
milliseconds. |
void |
hookBeforeDraw(Oscilloscope oscilloscope,
int counter)
Is called just before the widget is redrawn every getDelayLoop()
milliseconds. |
void |
hookChangeAttributes()
This method sets the values in the scope by calling the individual value methods in the dispatcher. |
void |
hookPulse(Oscilloscope oscilloscope,
int pulse)
This method is called every time the dispatcher reaches the getPulse() counter. |
abstract void |
hookSetValues(int pulse)
This method will be called every getPulse() times the scope is
redrawn which will occur every getDelayLoop() milliseconds (if
your hardware is capable of doing so). |
void |
init()
Will be called only once. |
boolean |
isPercentage()
|
boolean |
isServiceActive()
|
boolean |
isSoundRequired()
|
boolean |
isSteady()
|
boolean |
isTailSizeMax()
|
boolean |
mustConnect()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int[] BACKGROUND_MONITOR
public static final int[] BACKGROUND_MONITOR_SMALL
public static final int NO_PULSE
hookPulse(Oscilloscope, int)
will never be called.
getPulse()
,
Constant Field ValuesConstructor Detail |
---|
public OscilloscopeDispatcher()
Method Detail |
---|
public void dispatch()
getPulse()
value and if this is
reached then the counter is reset. The counter is passed to the hook
methods so that they can prepare for the next pulse.
After the hook methods are called, the runnable is placed in the user
interface thread with a timer of getDelayLoop()
milliseconds.
However, if the delay loop is set to 1, it will dispatch using
Display.asyncExec(Runnable)
for maximum speed.
This method is not meant to be overridden, override
hookBeforeDraw(Oscilloscope, int)
,
hookAfterDraw(Oscilloscope, int)
and
hookPulse(Oscilloscope, int)
.
public org.eclipse.swt.graphics.Color getActiveForegoundColor()
isServiceActive()
method. The result
of this method will be used in the
Control.setForeground(Color)
method.
getInactiveForegoundColor()
,
Control.setForeground(Color)
public java.io.File getActiveSoundfile()
hookPulse(Oscilloscope, int)
method if the
isSoundRequired()
method returns true.
null
. Override to return a file that can be played
by your sound hardware.public org.eclipse.swt.graphics.Image getBackgroundImage()
BACKGROUND_MONITOR
. Override to
supply your own Image.public OscilloscopeDispatcher.PlayClip getClipper()
public int getDelayLoop()
getProgression()
steps.
public boolean getFade()
public org.eclipse.swt.graphics.Color getInactiveForegoundColor()
isServiceActive()
method. The result
of this method will be used in the
Control.setForeground(Color)
method.
getActiveForegoundColor()
,
Control.setForeground(Color)
public java.io.File getInactiveSoundfile()
public int getLineWidth()
public abstract Oscilloscope getOscilloscope()
public int getPulse()
public int getSteadyPosition()
public int getTailFade()
public int getTailSize()
public void hookAfterDraw(Oscilloscope oscilloscope, int counter)
getDelayLoop()
milliseconds. The pulse counter will be set to zero when it reaches
getPulse()
.
oscilloscope
- counter
- public void hookBeforeDraw(Oscilloscope oscilloscope, int counter)
getDelayLoop()
milliseconds. It will also call the hookChangeAttributes()
method if the number of times this method is called matches the
getPulse()
value. The pulse counter will be set to zero when it
reaches getPulse()
.
If you override this method, don't forget to call
hookChangeAttributes()
every now and then.
oscilloscope
- counter
- public void hookChangeAttributes()
public int getProgression()
getProgression()
values consumed so make
sure that the value stack contains enough entries.
If the getDelayLoop()
is 10 and the getPulse()
is 1 and
the getProgression()
is 5 then every 10 milliseconds the graph
will have progressed 5 pixels. If you want to avoid gaps in your graph,
you need to input 5 values every time you reach
hookSetValues(int)
. If the getPulse()
is 3, you need to
input 15 values for a gapless graph.
public int getBaseOffset()
Oscilloscope.BASE_CENTER
which positions in the center.
Override for other values.public void hookPulse(Oscilloscope oscilloscope, int pulse)
isSoundRequired()
method or override this method.
oscilloscope
- pulse
- public abstract void hookSetValues(int pulse)
getPulse()
times the scope is
redrawn which will occur every getDelayLoop()
milliseconds (if
your hardware is capable of doing so). The scope will progress one pixel
every getDelayLoop()
milliseconds and will draw the next value
from the queue of the scope. If the scope is out of values it will
progress one pixel without a value (draw a pixel at his center).
If the delay loop is 10 and the pulse is 20, you have an opportunity to
set a value in the scope every 200 milliseconds. In this time the scope
will have progressed 20 pixels. If you supply 10 values by calling the
setValue(int) 10 times or if you call the setValues(int[]) with 10 ints
then you will see 10 pixels of movement and a straight line of 10 pixels.
If the setPulse method is not overridden or if you supply
NO_PULSE
then this method will not be called unless you override
the dispatch method (not recommended). To still set values in the scope
you can set a stack listener in the widget that will be called when there
are no more values in the stack. Alternatively you can set the return
value of getPulse()
to 1 so you have the opportunity to provide
a value every cycle.
pulse
- Oscilloscope.setValue(int)
,
Oscilloscope.setValues(int[])
,
Oscilloscope.addStackListener(OscilloscopeStackAdapter)
public void init()
public boolean isPercentage()
public boolean isServiceActive()
public boolean isSoundRequired()
public boolean isSteady()
public boolean isTailSizeMax()
public boolean mustConnect()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |