com.qoppa.pdf.annotations
Class Sound

java.lang.Object
  extended bycom.qoppa.pdf.annotations.Annotation
      extended bycom.qoppa.pdf.annotations.Sound

public class Sound
extends Annotation

Class representing a Sound annotation in a PDF document. Sound annotations are displayed using a speaker icon and can be double-clicked to play back the audio content.

Author:
Qoppa Software

Field Summary
 
Fields inherited from class com.qoppa.pdf.annotations.Annotation
BORDERSTYLE_BEVELED, BORDERSTYLE_DASHED, BORDERSTYLE_INSETS, BORDERSTYLE_SOLID, BORDERSTYLE_UNDERLINE, FLAGS_HIDDEN, FLAGS_INVISIBLE, FLAGS_LOCKED, FLAGS_NOROTATE, FLAGS_NOVIEW, FLAGS_NOZOOM, FLAGS_PRINTABLE, FLAGS_READONLY
 
Constructor Summary
Sound()
          Constructs a sound annotation with no sound.
Sound(AudioFormat format, byte[] content)
          Constructs a sound annotation from an AudioFormat object and an array of bytes containing the audio content.
Sound(AudioInputStream audioStream)
          Constructs a sound annotation from an AudioInputStream.
 
Method Summary
 JComponent createComponent(Point2D cropOrigin, IPDFActionHandler actionHandler)
          Creates a JComponent object capable of displaying this annotation.
 byte[] getContent()
          Return this sound annotation's sound content as a byte array.
 AudioFormat getFormat()
          Return this annotation's audio format.
 Rectangle2D getRectangle()
          Override getRectangle: The bounds of this annotation are always the size of the icon.
 String getSubtype()
          Returns this annotation's subtype: "Sound"
 boolean isPrintable()
          Sound icon never prints.
 void paintImpl(Graphics g, boolean hasFocus)
          Draws the text icon.
 void revalidate()
          Revalidates this annotation.
 void setAudio(AudioInputStream audioStream)
          Sets the audio content of this Sound annotation.
 void setContent(byte[] content)
           
 void setFormat(AudioFormat format)
           
 
Methods inherited from class com.qoppa.pdf.annotations.Annotation
getActions, getAppearStream, getBorderStyle, getBorderWidth, getColor, getComponent, getContents, getCreationDate, getCreator, getFlags, getLayer, getName, getOpacity, getPopup, getTriggerActions, isHidden, isInvisible, isLocked, isNoRotate, isNoView, isNoZoom, isReadOnly, paint, print, setActions, setAppearStream, setBorderStyle, setBorderWidth, setColor, setComponent, setComponentVisible, setCreationDate, setCreator, setFlags, setHidden, setInvisible, setLayer, setLocked, setName, setNoRotate, setNoView, setNoZoom, setOpacity, setPopup, setPrintable, setReadOnly, setRectangle, setTriggerActions, shiftRectangle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sound

public Sound()
Constructs a sound annotation with no sound.


Sound

public Sound(AudioFormat format,
             byte[] content)
Constructs a sound annotation from an AudioFormat object and an array of bytes containing the audio content.

Parameters:
format - The format of the audio.
content - The audio content.

Sound

public Sound(AudioInputStream audioStream)
      throws IOException
Constructs a sound annotation from an AudioInputStream.

Parameters:
audioStream - The audio stream.
Method Detail

setAudio

public void setAudio(AudioInputStream audioStream)
              throws IOException
Sets the audio content of this Sound annotation.

Parameters:
audioStream - Stream containing the sound content.
Throws:
IOException

getContent

public byte[] getContent()
Return this sound annotation's sound content as a byte array. The format of the content is specified by the AudioFormat object returned by getAudioFormat()

Returns:
A byte array containing the sound content.
Throws:
PDFException

getFormat

public AudioFormat getFormat()
Return this annotation's audio format.

Returns:
The audio format.

getSubtype

public String getSubtype()
Returns this annotation's subtype: "Sound"

Specified by:
getSubtype in class Annotation
Returns:
The annotation subtype.

createComponent

public JComponent createComponent(Point2D cropOrigin,
                                  IPDFActionHandler actionHandler)
Creates a JComponent object capable of displaying this annotation.

Specified by:
createComponent in class Annotation
Returns:
JComponent do display this annotation.

paintImpl

public void paintImpl(Graphics g,
                      boolean hasFocus)
Draws the text icon.

Parameters:
g - The graphics object to use when drawing.

revalidate

public void revalidate()
Description copied from class: Annotation
Revalidates this annotation.

Specified by:
revalidate in class Annotation

getRectangle

public Rectangle2D getRectangle()
Override getRectangle: The bounds of this annotation are always the size of the icon.

Overrides:
getRectangle in class Annotation
Returns:
The annotation's location on the page.

isPrintable

public boolean isPrintable()
Sound icon never prints.

Overrides:
isPrintable in class Annotation
Returns:
Value of the PRINTABLE flag

setContent

public void setContent(byte[] content)

setFormat

public void setFormat(AudioFormat format)