fi.hut.tml.xsmiles.mlfc.smil.viewer.awt.media
Class TextMedia

java.lang.Object
  extended byfi.hut.tml.xsmiles.mlfc.smil.viewer.awt.media.TextMedia
All Implemented Interfaces:
java.util.EventListener, Media, java.awt.event.MouseListener, java.lang.Runnable

public class TextMedia
extends java.lang.Object
implements Media, java.lang.Runnable, java.awt.event.MouseListener

This is the implementation of image media.


Nested Class Summary
 class TextMedia.MyLabel
           
 
Constructor Summary
TextMedia()
           
TextMedia(java.lang.String d)
          Extra constructor for data.
 
Method Summary
 void addMediaListener(MediaListener listener)
          Adds a MediaListener for this media.
 void close()
          This will freeze all memory and references to this media.
protected  void format(java.lang.String content, java.awt.Component comp)
           
 int getOriginalHeight()
          Get the real height of the media.
 int getOriginalWidth()
          Get the real width of the media.
 boolean isStatic()
          Checks if this media is static or continuous.
 void mouseClicked(java.awt.event.MouseEvent e)
          Mouse listener...
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void pause()
          Pauses the media.
 void play()
          Plays the media.
 void prefetch()
          Prefetches media.
 void run()
           
 void setBounds(int x, int y, int width, int height)
          Set the coordinates for the media.
 void setContainer(java.awt.Container container)
          Sets the container the media will be rendered in.
 void setMediaTime(int millisecs)
          This moves the time position in media.
 void setSoundVolume(int percentage)
          Set the sound volume for media.
 void setText(java.lang.String text)
          Set the text for this text component.
 void setUrl(java.net.URL url)
          Set the url for this text component.
 void stop()
          Stops the media.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextMedia

public TextMedia()

TextMedia

public TextMedia(java.lang.String d)
Extra constructor for data.

Method Detail

isStatic

public boolean isStatic()
Checks if this media is static or continuous.

Specified by:
isStatic in interface Media
Returns:
true if media is static.

setUrl

public void setUrl(java.net.URL url)
Set the url for this text component. Text will have higher priority than URL.

Specified by:
setUrl in interface Media
Parameters:
url - URL string to show

setText

public void setText(java.lang.String text)
Set the text for this text component. Text has higher priority than URL.

Parameters:
text - String to show

setContainer

public void setContainer(java.awt.Container container)
Description copied from interface: Media
Sets the container the media will be rendered in. If media is audio, this can be null.

Specified by:
setContainer in interface Media
Parameters:
container - This container will contain the media.

play

public void play()
Description copied from interface: Media
Plays the media. The media will be added to the container set using setContainer(). It will be visible. It will also play any animation it possibly has. Also, audio media is started using this method.

If the media is not yet prefetched, it will first be prefetched.

Specified by:
play in interface Media

run

public void run()
Specified by:
run in interface java.lang.Runnable

pause

public void pause()
Description copied from interface: Media
Pauses the media. The media will stay visible, but any animations will be paused. Audio media will be silent. NOT IMPLEMENTED YET. ?How to restart paused media?

Specified by:
pause in interface Media

stop

public void stop()
Description copied from interface: Media
Stops the media. The media will be stopped and it will be invisible. Audio will be silent.

Specified by:
stop in interface Media

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Description copied from interface: Media
Set the coordinates for the media. These are relative to the given container, set using setContainer().

Specified by:
setBounds in interface Media

close

public void close()
Description copied from interface: Media
This will freeze all memory and references to this media. If the media is not yet stopped, it will first be stopped.

Specified by:
close in interface Media

setMediaTime

public void setMediaTime(int millisecs)
This moves the time position in media. Not effective for this media.

Specified by:
setMediaTime in interface Media
Parameters:
millisecs - Time in millisecs

getOriginalWidth

public int getOriginalWidth()
Get the real width of the media.

Specified by:
getOriginalWidth in interface Media
Returns:
Original width of the media.

getOriginalHeight

public int getOriginalHeight()
Get the real height of the media.

Specified by:
getOriginalHeight in interface Media
Returns:
Original height of the media.

setSoundVolume

public void setSoundVolume(int percentage)
Set the sound volume for media. Only applicable for sound media formats.

Specified by:
setSoundVolume in interface Media
Parameters:
percentage - Sound volume, 0-100- (0 is quiet, 100 is original loudness, 200 twice as loud; dB change in signal level = 20 log10(percentage / 100) )

addMediaListener

public void addMediaListener(MediaListener listener)
Description copied from interface: Media
Adds a MediaListener for this media. The listener will be called
  1. When the media has been prefetched. (NOT IMPLEMENTED YET).
  2. When the media ends. (animation or audio media)
Static media, such as text and images will end immediately, notifying immediately about the end of the media.

Specified by:
addMediaListener in interface Media

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Mouse listener...

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

prefetch

public void prefetch()
Description copied from interface: Media
Prefetches media. The URL must have been set using setUrl(). The data will be downloaded from the URL. After calling this method, the media will be in memory and can be played. This is a blocking method.

Specified by:
prefetch in interface Media

format

protected void format(java.lang.String content,
                      java.awt.Component comp)


X-Smiles 1.2