com.groovemanager.gui.custom
Class WaveFormDisplay

java.lang.Object
  extended by com.groovemanager.sampled.waveform.AbstractWaveFormDisplay
      extended by com.groovemanager.sampled.waveform.SelectableWaveFormDisplay
          extended by com.groovemanager.sampled.waveform.MarkableWaveFormDisplay
              extended by com.groovemanager.gui.custom.WaveFormDisplay
All Implemented Interfaces:
Markable, Selectable

public class WaveFormDisplay
extends MarkableWaveFormDisplay

This class is an implementation of the abstract MarkableWaveFormDisplay using SWT

Author:
Manu Robledo

Field Summary
protected  org.eclipse.swt.graphics.GC backgroundGC
          Different Graphic Context Objects used for different drawing operations
protected  org.eclipse.swt.graphics.GC channelBgGC
          Different Graphic Context Objects used for different drawing operations
protected  org.eclipse.swt.graphics.GC channelFgGC
          Different Graphic Context Objects used for different drawing operations
protected  org.eclipse.swt.widgets.Canvas comp
          The main Composite
protected  org.eclipse.swt.graphics.Cursor deleteMarkerCursor
          The default cursor
protected  java.util.HashMap drawedMarkers
          Map of all drawed Markers as DrawedRectangle instances
protected  DrawedRectangle drawedPosition
          DrawedRectangle for the drawed selection
protected  DrawedRectangle drawedSelection
          DrawedRectangle for the drawed selection
protected  org.eclipse.swt.graphics.Cursor editMarkerCursor
          The default cursor
protected  boolean gradient
          If this variable is false, selection events coming from the scrollbar will be ignored
protected  org.eclipse.swt.graphics.Color markerColor
          Color to use for not selected Markers
protected  org.eclipse.swt.graphics.GC markerGC
          Different Graphic Context Objects used for different drawing operations
protected  org.eclipse.swt.graphics.Color markerHighlightColor
          Color to use for not selected Markers
protected  org.eclipse.swt.graphics.Cursor moveMarkerCursor
          The default cursor
protected  int moveStep
          The number of sample frames to move a Marker with one arrow press
protected  org.eclipse.swt.graphics.Cursor normalCursor
          The default cursor
protected  org.eclipse.swt.graphics.GC positionGC
          Different Graphic Context Objects used for different drawing operations
protected  boolean reactToScrollBar
          If this variable is false, selection events coming from the scrollbar will be ignored
protected  org.eclipse.swt.graphics.GC selectionGC
          Different Graphic Context Objects used for different drawing operations
protected  org.eclipse.swt.graphics.GC waveGC
          Different Graphic Context Objects used for different drawing operations
 
Fields inherited from class com.groovemanager.sampled.waveform.MarkableWaveFormDisplay
editMarkers, markableListeners, markers, MOUSE_TOLERANCE, selectedMarker
 
Fields inherited from class com.groovemanager.sampled.waveform.SelectableWaveFormDisplay
left, mouseDown, pos, right, selectableListeners, selStartedAt
 
Fields inherited from class com.groovemanager.sampled.waveform.AbstractWaveFormDisplay
channelSpacing, leftOffset, listeners, scrollFactor, source, topOffset, zoomFactor
 
Constructor Summary
WaveFormDisplay(org.eclipse.swt.widgets.Composite parent, boolean gradientBackground)
          Construct a new WaveFormDisplay
WaveFormDisplay(org.eclipse.swt.widgets.Composite parent, int style, boolean gradientBackground)
          Construct a new WaveFormDisplay
 
Method Summary
 void addMarker(Marker m)
          Internal method for adding a Marker
protected  void addMouseListeners(org.eclipse.swt.widgets.Composite comp)
          Add the needed MouseListeners to the given Composite
protected  void drawChannelBackground(int x, int y, int width, int height)
          Draw one channel´s background into the given area
protected  void drawChannelForeground(int x, int y, int width, int height)
          Draw the foreground elements of one channel into the given area
protected  void drawGlobalBackground(int x, int y, int width, int height)
          Draw the global background in the given area.
protected  void drawGlobalForeground(int x, int y, int width, int height)
          Draw the global foreground elements into the given area
protected  void drawHighlightedMarker(Marker m)
          Draw the given Marker in selected state
protected  void drawMarker(Marker m)
          Draw the given Marker on the WaveFormDisplay
protected  void drawPosition(int x, int y, int height)
          Draw the position pointer at the given position
protected  void drawSelection(int x, int y, int width, int height)
          Draw the selection in the given area
protected  void drawWaveLine(int x, int y, int x2, int y2)
          Draw one line of the WaveForm, this is either a vertical connection from a maximum to a minmum or a connection from the average value of pixel x to the average value of pixel x + 1
protected  void eraseHighlightedMarker(Marker m)
          Erase the given Marker that has been drawn in selected state before
protected  void eraseMarker(Marker m)
          Erase the given marker from the WaveformDisplay
protected  void erasePosition()
          Hide the position pointer
protected  void eraseSelection()
          Hide the current selection
 org.eclipse.swt.widgets.Composite getComposite()
          Get the main Composite of this WaveFormDisplay
protected  int getDisplayHeight()
          Get the total height available to this WaveDisplay
protected  int getDisplayWidth()
          Get the total width available to this WaveDisplay
protected  void initColors()
          Set the colors for the different drawing elements to default colors
 void redraw()
          Redraw the current display
protected  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.
protected  void removeMarker(Marker m)
          Internal Method for removing a marker
 void setChannelBackgroundColor(org.eclipse.swt.graphics.Color c)
          Set the background color used for each channel
 void setHighlightedMarkerColor(org.eclipse.swt.graphics.Color c)
          Change the Color used for drawing highlighted markers
 void setMarkerColor(org.eclipse.swt.graphics.Color c)
          Change the Color used for drawing markers
 void setMiddleLineColor(org.eclipse.swt.graphics.Color c)
          Set the color of the middle line
 void setMoveStep(int newStep)
          Set the number of sample frames a Marker should be moved, when an arrow key is pressed
 void setPositionColor(org.eclipse.swt.graphics.Color c)
          Set the color used for drawing the position pointer
 void setSelectionColor(org.eclipse.swt.graphics.Color c)
          Set the Color for drawing the selection
 void setWaveColor(org.eclipse.swt.graphics.Color c)
          Set the color used for drawing the WaveForm itself
 
Methods inherited from class com.groovemanager.sampled.waveform.MarkableWaveFormDisplay
addMarkableListener, addMarker, deselectMarker, getMarker, getMarkerCount, getMarkerFromMousePos, getMarkers, getSelectedMarker, identifyMarker, identifyMarker, identifyMarker, identifyMarkerIndex, mouseDown, mouseMove, mouseUp, moveMarker, moveMarker, moveMarker, moveMarker, moveMarkerIndex, redrawMarker, removeMarkableListener, removeMarker, removeMarker, removeMarker, removeMarkerIndex, selectMarker, selectMarker, selectMarker, selectMarker, selectMarkerIndex, setEditMarkers
 
Methods inherited from class com.groovemanager.sampled.waveform.SelectableWaveFormDisplay
addSelectableListener, getPosition, getSelection, redrawPosition, removeSelectableListener, setPosition, setSelection, showSelection
 
Methods inherited from class com.groovemanager.sampled.waveform.AbstractWaveFormDisplay
addWaveDisplayListener, calcY, dataToPixel, drawBackground, drawForeground, drawWave, getChannelHeight, getChannels, getChannelSpacing, getChannelTop, getFirstData, getLastData, getLeftOffset, getPixelFactor, getScroll, getSource, getTopOffset, getTotalLength, getUsableDisplayHeight, getUsableDisplayWidth, getVisibleWaveForm, getZoom, hasData, mouseToData, pixelToData, 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

backgroundGC

protected org.eclipse.swt.graphics.GC backgroundGC
Different Graphic Context Objects used for different drawing operations


channelBgGC

protected org.eclipse.swt.graphics.GC channelBgGC
Different Graphic Context Objects used for different drawing operations


channelFgGC

protected org.eclipse.swt.graphics.GC channelFgGC
Different Graphic Context Objects used for different drawing operations


comp

protected org.eclipse.swt.widgets.Canvas comp
The main Composite


deleteMarkerCursor

protected org.eclipse.swt.graphics.Cursor deleteMarkerCursor
The default cursor


drawedMarkers

protected java.util.HashMap drawedMarkers
Map of all drawed Markers as DrawedRectangle instances


drawedPosition

protected DrawedRectangle drawedPosition
DrawedRectangle for the drawed selection


drawedSelection

protected DrawedRectangle drawedSelection
DrawedRectangle for the drawed selection


editMarkerCursor

protected org.eclipse.swt.graphics.Cursor editMarkerCursor
The default cursor


gradient

protected boolean gradient
If this variable is false, selection events coming from the scrollbar will be ignored


markerColor

protected org.eclipse.swt.graphics.Color markerColor
Color to use for not selected Markers


markerGC

protected org.eclipse.swt.graphics.GC markerGC
Different Graphic Context Objects used for different drawing operations


markerHighlightColor

protected org.eclipse.swt.graphics.Color markerHighlightColor
Color to use for not selected Markers


moveMarkerCursor

protected org.eclipse.swt.graphics.Cursor moveMarkerCursor
The default cursor


moveStep

protected int moveStep
The number of sample frames to move a Marker with one arrow press


normalCursor

protected org.eclipse.swt.graphics.Cursor normalCursor
The default cursor


positionGC

protected org.eclipse.swt.graphics.GC positionGC
Different Graphic Context Objects used for different drawing operations


reactToScrollBar

protected boolean reactToScrollBar
If this variable is false, selection events coming from the scrollbar will be ignored


selectionGC

protected org.eclipse.swt.graphics.GC selectionGC
Different Graphic Context Objects used for different drawing operations


waveGC

protected org.eclipse.swt.graphics.GC waveGC
Different Graphic Context Objects used for different drawing operations

Constructor Detail

WaveFormDisplay

public WaveFormDisplay(org.eclipse.swt.widgets.Composite parent,
                       boolean gradientBackground)
Construct a new WaveFormDisplay

Parameters:
parent - The parent Composite
gradientBackground - true, if a gradient background should be used, false otherwise

WaveFormDisplay

public WaveFormDisplay(org.eclipse.swt.widgets.Composite parent,
                       int style,
                       boolean gradientBackground)
Construct a new WaveFormDisplay

Parameters:
parent - The parent Composite
style - Combination of SWT.* style constants for the main Composite
gradientBackground - true, if a gradient background should be used, false otherwise
Method Detail

addMarker

public void addMarker(Marker m)
Description copied from class: MarkableWaveFormDisplay
Internal method for adding a Marker

Overrides:
addMarker in class MarkableWaveFormDisplay
Parameters:
m - The Marker to add

addMouseListeners

protected void addMouseListeners(org.eclipse.swt.widgets.Composite comp)
Add the needed MouseListeners to the given Composite

Parameters:
comp - The main Composite

drawChannelBackground

protected void drawChannelBackground(int x,
                                     int y,
                                     int width,
                                     int height)
Description copied from class: AbstractWaveFormDisplay
Draw one channel´s background into the given area

Specified by:
drawChannelBackground in class AbstractWaveFormDisplay
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

drawChannelForeground

protected void drawChannelForeground(int x,
                                     int y,
                                     int width,
                                     int height)
Description copied from class: AbstractWaveFormDisplay
Draw the foreground elements of one channel into the given area

Specified by:
drawChannelForeground in class AbstractWaveFormDisplay
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

drawGlobalBackground

protected void drawGlobalBackground(int x,
                                    int y,
                                    int width,
                                    int height)
Description copied from class: AbstractWaveFormDisplay
Draw the global background in the given area. Most implementations will just fill this background

Specified by:
drawGlobalBackground in class AbstractWaveFormDisplay
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

drawGlobalForeground

protected void drawGlobalForeground(int x,
                                    int y,
                                    int width,
                                    int height)
Description copied from class: AbstractWaveFormDisplay
Draw the global foreground elements into the given area

Specified by:
drawGlobalForeground in class AbstractWaveFormDisplay
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

drawHighlightedMarker

protected void drawHighlightedMarker(Marker m)
Description copied from class: MarkableWaveFormDisplay
Draw the given Marker in selected state

Specified by:
drawHighlightedMarker in class MarkableWaveFormDisplay
Parameters:
m - The Marker to draw

drawMarker

protected void drawMarker(Marker m)
Description copied from class: MarkableWaveFormDisplay
Draw the given Marker on the WaveFormDisplay

Specified by:
drawMarker in class MarkableWaveFormDisplay
Parameters:
m - The Marker to draw

drawPosition

protected void drawPosition(int x,
                            int y,
                            int height)
Description copied from class: SelectableWaveFormDisplay
Draw the position pointer at the given position

Specified by:
drawPosition in class SelectableWaveFormDisplay
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 void drawSelection(int x,
                             int y,
                             int width,
                             int height)
Description copied from class: SelectableWaveFormDisplay
Draw the selection in the given area

Specified by:
drawSelection in class SelectableWaveFormDisplay
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

drawWaveLine

protected void drawWaveLine(int x,
                            int y,
                            int x2,
                            int y2)
Description copied from class: AbstractWaveFormDisplay
Draw one line of the WaveForm, this is either a vertical connection from a maximum to a minmum or a connection from the average value of pixel x to the average value of pixel x + 1

Specified by:
drawWaveLine in class AbstractWaveFormDisplay
Parameters:
x - The x-coordinate of the first point
y - The y-coordinate of the first point
x2 - The x-coordinate of the second point
y2 - The y-coordinate of the second point

eraseHighlightedMarker

protected void eraseHighlightedMarker(Marker m)
Description copied from class: MarkableWaveFormDisplay
Erase the given Marker that has been drawn in selected state before

Specified by:
eraseHighlightedMarker in class MarkableWaveFormDisplay
Parameters:
m - The Marker to erase

eraseMarker

protected void eraseMarker(Marker m)
Description copied from class: MarkableWaveFormDisplay
Erase the given marker from the WaveformDisplay

Specified by:
eraseMarker in class MarkableWaveFormDisplay
Parameters:
m - The Marker to erase

erasePosition

protected void erasePosition()
Description copied from class: SelectableWaveFormDisplay
Hide the position pointer

Specified by:
erasePosition in class SelectableWaveFormDisplay

eraseSelection

protected void eraseSelection()
Description copied from class: SelectableWaveFormDisplay
Hide the current selection

Specified by:
eraseSelection in class SelectableWaveFormDisplay

getComposite

public org.eclipse.swt.widgets.Composite getComposite()
Get the main Composite of this WaveFormDisplay

Returns:
This WaveFormDisplay´s main Composite

getDisplayHeight

protected int getDisplayHeight()
Description copied from class: AbstractWaveFormDisplay
Get the total height available to this WaveDisplay

Specified by:
getDisplayHeight in class AbstractWaveFormDisplay
Returns:
This WaveDisplay´s total height

getDisplayWidth

protected int getDisplayWidth()
Description copied from class: AbstractWaveFormDisplay
Get the total width available to this WaveDisplay

Specified by:
getDisplayWidth in class AbstractWaveFormDisplay
Returns:
This WaveDisplay´s total width

initColors

protected void initColors()
Set the colors for the different drawing elements to default colors


redraw

public void redraw()
Description copied from class: AbstractWaveFormDisplay
Redraw the current display

Overrides:
redraw in class AbstractWaveFormDisplay

redrawSelection

protected void redrawSelection(int x,
                               int y,
                               int width,
                               int height)
Description copied from class: SelectableWaveFormDisplay
Adapt the visible selection to the given area or - if it was not visible before - draw it to the given area.

Specified by:
redrawSelection in class SelectableWaveFormDisplay
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

removeMarker

protected void removeMarker(Marker m)
Description copied from class: MarkableWaveFormDisplay
Internal Method for removing a marker

Overrides:
removeMarker in class MarkableWaveFormDisplay
Parameters:
m - The Marker to remove

setChannelBackgroundColor

public void setChannelBackgroundColor(org.eclipse.swt.graphics.Color c)
Set the background color used for each channel

Parameters:
c - The new channel background color

setHighlightedMarkerColor

public void setHighlightedMarkerColor(org.eclipse.swt.graphics.Color c)
Change the Color used for drawing highlighted markers

Parameters:
c - The new Color to be used for drawing highlighted markers

setMarkerColor

public void setMarkerColor(org.eclipse.swt.graphics.Color c)
Change the Color used for drawing markers

Parameters:
c - The new Color to be used for drawing markers

setMiddleLineColor

public void setMiddleLineColor(org.eclipse.swt.graphics.Color c)
Set the color of the middle line

Parameters:
c - The middle line´s color

setMoveStep

public void setMoveStep(int newStep)
Set the number of sample frames a Marker should be moved, when an arrow key is pressed

Parameters:
newStep - The number of sample frames to move a Marker with the arrow keys

setPositionColor

public void setPositionColor(org.eclipse.swt.graphics.Color c)
Set the color used for drawing the position pointer

Parameters:
c - The Color for the position pointer

setSelectionColor

public void setSelectionColor(org.eclipse.swt.graphics.Color c)
Set the Color for drawing the selection

Parameters:
c - The new selection Color

setWaveColor

public void setWaveColor(org.eclipse.swt.graphics.Color c)
Set the color used for drawing the WaveForm itself

Parameters:
c - The waveform´s color