com.groovemanager.sampled.waveform
Class SelectableWaveFormDisplay

java.lang.Object
  extended by com.groovemanager.sampled.waveform.AbstractWaveFormDisplay
      extended by com.groovemanager.sampled.waveform.SelectableWaveFormDisplay
All Implemented Interfaces:
Selectable
Direct Known Subclasses:
MarkableWaveFormDisplay

public abstract class SelectableWaveFormDisplay
extends AbstractWaveFormDisplay
implements Selectable

This class extends AbstractWaveFormDisplay to implement the Selectable interface. The position and selection of the Display are made visible.

Author:
Manu Robledo

Field Summary
protected  int left
          Current selection´s left border
protected  boolean mouseDown
          Indicates whether the mouse button is currently pressed or not
protected  int pos
          Current selection´s left border
protected  int right
          Current selection´s left border
protected  java.util.ArrayList selectableListeners
          List of SelectableListeners registered with this Display
protected  int selStartedAt
          Current selection´s left border
 
Fields inherited from class com.groovemanager.sampled.waveform.AbstractWaveFormDisplay
channelSpacing, leftOffset, listeners, scrollFactor, source, topOffset, zoomFactor
 
Constructor Summary
SelectableWaveFormDisplay()
           
 
Method Summary
 void addSelectableListener(SelectableListener listener)
          Add a SelectableListener that will be notified of changes to this Selectable´s Selection or position
protected abstract  void drawPosition(int x, int y, int height)
          Draw the position pointer at the given position
protected abstract  void drawSelection(int x, int y, int width, int height)
          Draw the selection in the given area
protected abstract  void erasePosition()
          Hide the position pointer
protected abstract  void eraseSelection()
          Hide the current selection
 int getPosition()
          Get the current position
 Selection getSelection()
          Get the current Selection
protected  void mouseDown(int realX, int realY, boolean shiftPressed, boolean ctrlPressed)
          Notification about a mouse button being pressed.
protected  void mouseMove(int realX, int realY, boolean shiftPressed, boolean ctrlPressed)
          Notification about the mouse being moved.
protected  void mouseUp(int realX, int realY, boolean shiftPressed, boolean ctrlPressed)
          Notification about a mouse button being released.
protected  void redrawPosition(int x, int y, int height)
          Move the visible position pointer to the specified position or - if it was not visible before - draw it to the given position
protected abstract  void redrawSelection(int x, int y, int width, int height)
          Adapt the visible selection to the given area or - if it was not visible before - draw it to the given area.
 void removeSelectableListener(SelectableListener listener)
          Remove a SelectableListener from this Selectable
 void setPosition(int pos)
          Set the position
 void setSelection(Selection sel)
          Set the Selection
 void showSelection()
          Zoom and scroll this display to the current selection
 
Methods inherited from class com.groovemanager.sampled.waveform.AbstractWaveFormDisplay
addWaveDisplayListener, calcY, dataToPixel, drawBackground, drawChannelBackground, drawChannelForeground, drawForeground, drawGlobalBackground, drawGlobalForeground, drawWave, drawWaveLine, getChannelHeight, getChannels, getChannelSpacing, getChannelTop, getDisplayHeight, getDisplayWidth, getFirstData, getLastData, getLeftOffset, getPixelFactor, getScroll, getSource, getTopOffset, getTotalLength, getUsableDisplayHeight, getUsableDisplayWidth, getVisibleWaveForm, getZoom, hasData, mouseToData, pixelToData, redraw, removeSource, removeWaveDisplayListener, scroll, scrollCenter, scrollLeft, scrollRight, setChannelSpacing, setLeftOffset, setSource, setTopOffset, showAll, showData, zoom
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

left

protected int left
Current selection´s left border


mouseDown

protected boolean mouseDown
Indicates whether the mouse button is currently pressed or not


pos

protected int pos
Current selection´s left border


right

protected int right
Current selection´s left border


selectableListeners

protected java.util.ArrayList selectableListeners
List of SelectableListeners registered with this Display


selStartedAt

protected int selStartedAt
Current selection´s left border

Constructor Detail

SelectableWaveFormDisplay

public SelectableWaveFormDisplay()
Method Detail

addSelectableListener

public void addSelectableListener(SelectableListener listener)
Description copied from interface: Selectable
Add a SelectableListener that will be notified of changes to this Selectable´s Selection or position

Specified by:
addSelectableListener in interface Selectable
Parameters:
listener - The SelectableListener to add

drawPosition

protected abstract void drawPosition(int x,
                                     int y,
                                     int height)
Draw the position pointer at the given position

Parameters:
x - The x-coordinate of the position pointer
y - The y-coordinate of the position pointer´s top
height - The height of the position pointer

drawSelection

protected abstract void drawSelection(int x,
                                      int y,
                                      int width,
                                      int height)
Draw the selection in the given area

Parameters:
x - The x-coordinate of the area
y - The y-coordinate of the area
width - The width of the area
height - The height of the area

erasePosition

protected abstract void erasePosition()
Hide the position pointer


eraseSelection

protected abstract void eraseSelection()
Hide the current selection


getPosition

public int getPosition()
Description copied from interface: Selectable
Get the current position

Specified by:
getPosition in interface Selectable
Returns:
The current position

getSelection

public Selection getSelection()
Description copied from interface: Selectable
Get the current Selection

Specified by:
getSelection in interface Selectable
Returns:
The current Selection

mouseDown

protected void mouseDown(int realX,
                         int realY,
                         boolean shiftPressed,
                         boolean ctrlPressed)
Notification about a mouse button being pressed. Subclasses must ensure with MouseListeners, that this method is called, when a mouse button is pressed.

Parameters:
realX - The x-coordinate of where the mouse button was pressed
realY - The y-coordinate of where the mouse button was pressed
shiftPressed - true, if the Shift-Button is currently pressed, false otherwise
ctrlPressed - true, if the CTRL-Button is currently pressed, false otherwise

mouseMove

protected void mouseMove(int realX,
                         int realY,
                         boolean shiftPressed,
                         boolean ctrlPressed)
Notification about the mouse being moved. Subclasses must ensure with MouseListeners, that this method is called, when the mouse is moved.

Parameters:
realX - The x-coordinate of where the mouse was moved to
realY - The y-coordinate of where the mouse was moved to
shiftPressed - true, if the Shift-Button is currently pressed, false otherwise
ctrlPressed - true, if the CTRL-Button is currently pressed, false otherwise

mouseUp

protected void mouseUp(int realX,
                       int realY,
                       boolean shiftPressed,
                       boolean ctrlPressed)
Notification about a mouse button being released. Subclasses must ensure with MouseListeners, that this method is called, when a mouse button is released.

Parameters:
realX - The x-coordinate of where the mouse button was released
realY - The y-coordinate of where the mouse button was released
shiftPressed - true, if the Shift-Button is currently pressed, false otherwise
ctrlPressed - true, if the CTRL-Button is currently pressed, false otherwise

redrawPosition

protected void redrawPosition(int x,
                              int y,
                              int height)
Move the visible position pointer to the specified position or - if it was not visible before - draw it to the given position

Parameters:
x - The x-coordinate of the position pointer
y - The y-coordinate of the position pointer´s top
height - The height of the position pointer

redrawSelection

protected abstract void redrawSelection(int x,
                                        int y,
                                        int width,
                                        int height)
Adapt the visible selection to the given area or - if it was not visible before - draw it to the given area.

Parameters:
x - The x-coordinate of the area
y - The y-coordinate of the area
width - The width of the area
height - The height of the area

removeSelectableListener

public void removeSelectableListener(SelectableListener listener)
Description copied from interface: Selectable
Remove a SelectableListener from this Selectable

Specified by:
removeSelectableListener in interface Selectable
Parameters:
listener - The SelectableListener to remove

setPosition

public void setPosition(int pos)
Description copied from interface: Selectable
Set the position

Specified by:
setPosition in interface Selectable
Parameters:
pos - The new position

setSelection

public void setSelection(Selection sel)
Description copied from interface: Selectable
Set the Selection

Specified by:
setSelection in interface Selectable
Parameters:
sel - The new Selection

showSelection

public void showSelection()
Zoom and scroll this display to the current selection