net.sourceforge.nite.gui.util
Class SegmentReplayer

java.lang.Object
  extended by net.sourceforge.nite.gui.util.SegmentReplayer
All Implemented Interfaces:
NOMWriteElementContainer, TimeHandler

public class SegmentReplayer
extends java.lang.Object
implements TimeHandler, NOMWriteElementContainer

This util class allows you to control the media-interface on the basis of predefined segments, with actions such as 'goto next segment', 'loop', 'go to previous segment', 'play', 'pause', etc

To use this class, create a SegmentReplayer, then add all segments to it that you want to have available. Usually you would initialize it with data from a layer of non-overlapping selections, in order to annotate something else along that _selection_ of the timeline.

When you create NEW segments, you can add them directly to this replayer.

Next, you should get the Actions from the segmentreplayer and add them to your GUI somewhere. In general, a segmentreplayer needs not have its own physical GUI. For convenience purposes however you can request a panel of the replayer that contains buttons for the actions. The Action objects that you get on request are pointers to the 'real' actions, i.e. if you want to change icons or keyboard shortcuts or mnemonics you can do that, and they will change in the convenience panel as well.

It is possible to automatically open a SegmentReplayer for all elements in a certain layer for the ContinuousVideoLabeler. To do this, add the attributes segmentreplayer="true" and replaysegmentname="" to the corpussettingsnode in the config XML file. THIS OPTINO WILL MOST PROBABLY DISAPPEAR IN THE FUTURE. USE IT FOR TESTING, BUT DON"T DEPEND ON IT TOO MUCH!

Author:
Dennis Reidsma, UTwente

Field Summary
static java.lang.String FIRST_SEGMENT_ACTION
          Go to first segment
static int INACTIVE
           
static java.lang.String LAST_SEGMENT_ACTION
          Go to last segment
static int LOOP
           
static java.lang.String LOOP_ACTION
          Start loop-replaying the current segment
static java.lang.String NEXT_SEGMENT_ACTION
          Next segment action: go to the next segment.
static java.lang.String PAUSE_ACTION
          Pause replay
static int PLAYONCE
           
static java.lang.String PLAYONCE_ACTION
          Play the current segment once
static java.lang.String PREVIOUS_SEGMENT_ACTION
          Previous segment action: go to the previous segment.
 
Constructor Summary
SegmentReplayer(ClockFace c)
          the playing will be started and stopped through the clockface.
 
Method Summary
 void acceptTimeChange(double systemTime)
          The reaction to changes in the system time depends on the state.
 void acceptTimeSpanChange(double start, double end)
          Accept a new time span from another registered time handler.
 void addAvailableSegment(NOMElement newSegment)
          Arg: a new NOMElement (at the end).
 void addAvailableSegment(NOMElement newSegment, int index)
          Arg: a new NOMElement (at the given index, -1 means at end.
 javax.swing.ActionMap getActionMap()
           
 Clock getClock()
          Return the Clock that is currently syncronising this TimeHandler
 NOMWriteElement getCurrentElement()
          Very useful to have if you want to be able to e.g.
 javax.swing.JPanel getGuiPanel()
          returns a trivially simple gui panel for controlling this replayer.
 double getMaxTime()
          get the latest time handled by this TimeHandler - this returns 0.0 because we're not responsible for actual media here!
 void setAvailableSegments(java.util.List newSegments)
          Arg: a list of NOMElements.
 void setClock(Clock clock)
          Set the Clock to which this TimeHandler is registered
 void setCurrentSegment(NOMElement newSegment)
          Sets the segment that is now going to be replayed.
 void setState(int newState)
          effect depends on newstate.
 void setTime(double time)
          Broadcast a new time.
 void setTimeHighlightColor(java.awt.Color color)
          Change the Color used for all registered TimeHandlers to highlight times
 void setTimeSpan(double start, double end)
          Broadcast a new span to all registered TimeHandlers.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INACTIVE

public static final int INACTIVE
See Also:
Constant Field Values

PLAYONCE

public static final int PLAYONCE
See Also:
Constant Field Values

LOOP

public static final int LOOP
See Also:
Constant Field Values

NEXT_SEGMENT_ACTION

public static final java.lang.String NEXT_SEGMENT_ACTION
Next segment action: go to the next segment.

See Also:
Constant Field Values

PREVIOUS_SEGMENT_ACTION

public static final java.lang.String PREVIOUS_SEGMENT_ACTION
Previous segment action: go to the previous segment.

See Also:
Constant Field Values

FIRST_SEGMENT_ACTION

public static final java.lang.String FIRST_SEGMENT_ACTION
Go to first segment

See Also:
Constant Field Values

LAST_SEGMENT_ACTION

public static final java.lang.String LAST_SEGMENT_ACTION
Go to last segment

See Also:
Constant Field Values

LOOP_ACTION

public static final java.lang.String LOOP_ACTION
Start loop-replaying the current segment

See Also:
Constant Field Values

PLAYONCE_ACTION

public static final java.lang.String PLAYONCE_ACTION
Play the current segment once

See Also:
Constant Field Values

PAUSE_ACTION

public static final java.lang.String PAUSE_ACTION
Pause replay

See Also:
Constant Field Values
Constructor Detail

SegmentReplayer

public SegmentReplayer(ClockFace c)
the playing will be started and stopped through the clockface.

Method Detail

setState

public void setState(int newState)
effect depends on newstate. LOOP: jump to start, start playing, keep looping PLAYONCE: jump to start, start playing INACTIVE: stop playing


setAvailableSegments

public void setAvailableSegments(java.util.List newSegments)
Arg: a list of NOMElements. These elements are checked for proper timing. All elements that are OK for timing are then added to this segmentreplayer. the state of the replayer is set to inactive.


addAvailableSegment

public void addAvailableSegment(NOMElement newSegment)
Arg: a new NOMElement (at the end). It will be checked for proper timing. If it's OK for timing, it's added to this segmentreplayer. The state of the replayer is kept as it was.


addAvailableSegment

public void addAvailableSegment(NOMElement newSegment,
                                int index)
Arg: a new NOMElement (at the given index, -1 means at end. It will be checked for proper timing. If it's OK for timing, it's added to this segmentreplayer. The state of the replayer is kept as it was.


getCurrentElement

public NOMWriteElement getCurrentElement()
Very useful to have if you want to be able to e.g. inspect the current element of the replayer on other attributes using another GUI element.

Specified by:
getCurrentElement in interface NOMWriteElementContainer

setCurrentSegment

public void setCurrentSegment(NOMElement newSegment)
Sets the segment that is now going to be replayed. Afterwards, currentSegment and currentIndex will be in agreement If the segment is not properly timed, a message is logged and the element is null and index -1. If the segment is not in the list of availablesegments, currentsegment will be null and index -1.

Further reaction depends on state:
LOOP: state stays in LOOP, clock jumps to start of new segment
INACTIVE: stay INACTIVE. Only jump to start if current time outside segment time
PLAYONCE: stay PLAYONCE, clock jumps to start of new segment.


getActionMap

public javax.swing.ActionMap getActionMap()

getGuiPanel

public javax.swing.JPanel getGuiPanel()
returns a trivially simple gui panel for controlling this replayer.


acceptTimeChange

public void acceptTimeChange(double systemTime)
The reaction to changes in the system time depends on the state. LOOP: check if we reached end of segment; if so, jump to start. PLAYONCE: check if we reached end of segment; if so: stop playing. INACTIVE: nothing.

Specified by:
acceptTimeChange in interface TimeHandler

acceptTimeSpanChange

public void acceptTimeSpanChange(double start,
                                 double end)
Description copied from interface: TimeHandler
Accept a new time span from another registered time handler. This may involve changing our on-screen appearance to introduce some new time highlights, or playing a stretch of video, depending on the type of handler.

Specified by:
acceptTimeSpanChange in interface TimeHandler

getClock

public Clock getClock()
Description copied from interface: TimeHandler
Return the Clock that is currently syncronising this TimeHandler

Specified by:
getClock in interface TimeHandler

setClock

public void setClock(Clock clock)
Description copied from interface: TimeHandler
Set the Clock to which this TimeHandler is registered

Specified by:
setClock in interface TimeHandler

setTime

public void setTime(double time)
Description copied from interface: TimeHandler
Broadcast a new time. Implement by sending a setSystemTime call to the current Clock.

Specified by:
setTime in interface TimeHandler

setTimeHighlightColor

public void setTimeHighlightColor(java.awt.Color color)
Description copied from interface: TimeHandler
Change the Color used for all registered TimeHandlers to highlight times

Specified by:
setTimeHighlightColor in interface TimeHandler

setTimeSpan

public void setTimeSpan(double start,
                        double end)
Description copied from interface: TimeHandler
Broadcast a new span to all registered TimeHandlers.

Specified by:
setTimeSpan in interface TimeHandler

getMaxTime

public double getMaxTime()
get the latest time handled by this TimeHandler - this returns 0.0 because we're not responsible for actual media here!

Specified by:
getMaxTime in interface TimeHandler