|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.groovemanager.sampled.waveform.AbstractWaveFormDisplay
A WaveFormDisplay can be used to display WaveForm objects provided by a WaveFormProvider. This abstract class is intended to be independent of any graphics framework so that implementations are possible in Swing, SWT or whatever.
| Field Summary | |
|---|---|
protected int |
channelSpacing
Left and right offset in pixels |
protected int |
leftOffset
Left and right offset in pixels |
protected java.util.ArrayList |
listeners
List of WaveDisplayListeners registered with this WaveFormDisplay |
protected double |
scrollFactor
The scroll factor: 0 means scroll to the left, 0.5 means scroll to center and 1 means scroll to the right. |
protected WaveFormProvider |
source
The source provider from which the WaveForm data is being provided |
protected int |
topOffset
Left and right offset in pixels |
protected double |
zoomFactor
Factor describing the current zoom state of this WaveFormDisplay. |
| Constructor Summary | |
|---|---|
AbstractWaveFormDisplay()
|
|
| Method Summary | |
|---|---|
void |
addWaveDisplayListener(WaveDisplayListener listener)
Add a WaveDisplayListener to this display that will be notified when the visible area of this display changes, e.g. when scrolling or zooming |
protected static int |
calcY(int top,
int maxheight,
int value)
Calculate the y coordinate for a given WaveForm sample value |
protected int |
dataToPixel(int dataPos)
Convert a data position into a pixel position |
protected void |
drawBackground()
Draw the Background |
protected abstract void |
drawChannelBackground(int x,
int y,
int width,
int height)
Draw one channel´s background into the given area |
protected abstract void |
drawChannelForeground(int x,
int y,
int width,
int height)
Draw the foreground elements of one channel into the given area |
protected void |
drawForeground()
Draw the Foreground elements |
protected abstract void |
drawGlobalBackground(int x,
int y,
int width,
int height)
Draw the global background in the given area. |
protected abstract void |
drawGlobalForeground(int x,
int y,
int width,
int height)
Draw the global foreground elements into the given area |
protected void |
drawWave()
Draw the WaveForm |
protected abstract 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 int |
getChannelHeight()
Get the usable height for displaying a single channel |
int |
getChannels()
Get the number of channels |
int |
getChannelSpacing()
Get the space between two channels |
protected int |
getChannelTop(int channel)
Get the y-coordinate of the top border of the specified channel |
protected abstract int |
getDisplayHeight()
Get the total height available to this WaveDisplay |
protected abstract int |
getDisplayWidth()
Get the total width available to this WaveDisplay |
int |
getFirstData()
Get the frame position of the first visible data |
int |
getLastData()
Get the frame position of the last visible data |
int |
getLeftOffset()
Get the space between the left border and the beginning of the WaveForm as well as the space between the end of the WaveForm and the right border |
protected double |
getPixelFactor()
Get the quotient between one pixel and the real number of sample frames represented by this pixel |
double |
getScroll()
Get the current scroll factor |
WaveFormProvider |
getSource()
Get the current WaveFormProvider of this WaveFormDisplay |
int |
getTopOffset()
Get the space between the top border and the beginning of the WaveForm as well as the space between the end of the WaveForm and the bottom border |
int |
getTotalLength()
Get the total length of the audio data represented by this WaveFormDisplay |
protected int |
getUsableDisplayHeight()
Get the height in pixels that can be used for drawing the WaveForm |
protected int |
getUsableDisplayWidth()
Get the width in pixels that can be used for drawing the WaveForm |
protected WaveForm |
getVisibleWaveForm()
Get the visible WaveForm depending on zommFactor, scrollFactor and source |
double |
getZoom()
Get the current zoom factor |
boolean |
hasData()
Ask this WaveFormDisplay, if it has data to display |
int |
mouseToData(int mousePos)
Convert a mouse position to a data position |
protected int |
pixelToData(int pixelPos)
Convert a pixel position to a data position |
void |
redraw()
Redraw the current display |
void |
removeSource()
Remove the current WaveFormProvider if any |
void |
removeWaveDisplayListener(WaveDisplayListener listener)
Remove a WaveDisplayListener from this display |
void |
scroll(double d)
Scroll to the given scroll factor. |
void |
scrollCenter()
Scroll to center position |
void |
scrollLeft()
Scroll to the most left position |
void |
scrollRight()
Scroll to the most right position |
void |
setChannelSpacing(int spacing)
Set the space between two channels |
void |
setLeftOffset(int offset)
Set the space between the left border and the beginning of the WaveForm as well as the space between the end of the WaveForm and the right border |
void |
setSource(WaveFormProvider source)
Set the WaveFormProvider from which to get the WaveForm data |
void |
setTopOffset(int offset)
Set the space between the top border and the beginning of the WaveForm as well as the space between the end of the WaveForm and the bottom border |
void |
showAll()
Show the whole WaveForm |
void |
showData(int first,
int last)
Adapt the zoom and scroll factor so that the given part of the source will be visible |
void |
zoom(double d)
Zoom to the specified zoom factor. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int channelSpacing
protected int leftOffset
protected java.util.ArrayList listeners
protected double scrollFactor
protected WaveFormProvider source
protected int topOffset
protected double zoomFactor
| Constructor Detail |
|---|
public AbstractWaveFormDisplay()
| Method Detail |
|---|
public void addWaveDisplayListener(WaveDisplayListener listener)
listener - The WaveDisplayListener to add
protected static int calcY(int top,
int maxheight,
int value)
top - The top offsetmaxheight - The total height of the area into which the WaveForm
should be drawnvalue - The sample value gotten from the WaveForm
protected int dataToPixel(int dataPos)
dataPos - The position in the audio data in sample frames
protected void drawBackground()
protected abstract void drawChannelBackground(int x,
int y,
int width,
int height)
x - The x-coordinate of the areay - The y-coordinate of the areawidth - The width of the areaheight - The height of the area
protected abstract void drawChannelForeground(int x,
int y,
int width,
int height)
x - The x-coordinate of the areay - The y-coordinate of the areawidth - The width of the areaheight - The height of the areaprotected void drawForeground()
protected abstract void drawGlobalBackground(int x,
int y,
int width,
int height)
x - The x-coordinate of the areay - The y-coordinate of the areawidth - The width of the areaheight - The height of the area
protected abstract void drawGlobalForeground(int x,
int y,
int width,
int height)
x - The x-coordinate of the areay - The y-coordinate of the areawidth - The width of the areaheight - The height of the areaprotected void drawWave()
protected abstract void drawWaveLine(int x,
int y,
int x2,
int y2)
x - The x-coordinate of the first pointy - The y-coordinate of the first pointx2 - The x-coordinate of the second pointy2 - The y-coordinate of the second pointprotected int getChannelHeight()
public int getChannels()
public int getChannelSpacing()
protected int getChannelTop(int channel)
channel - The zero-based channel
protected abstract int getDisplayHeight()
protected abstract int getDisplayWidth()
public int getFirstData()
public int getLastData()
public int getLeftOffset()
protected double getPixelFactor()
public double getScroll()
public WaveFormProvider getSource()
null, if no provider
is setpublic int getTopOffset()
public int getTotalLength()
protected int getUsableDisplayHeight()
protected int getUsableDisplayWidth()
protected WaveForm getVisibleWaveForm()
null, if no data is available for displayingpublic double getZoom()
public boolean hasData()
public int mouseToData(int mousePos)
mousePos - The x-coordinate of a mouse position including the left
offset
protected int pixelToData(int pixelPos)
pixelPos - The x-coordinate of a pixel, not including the left
offset
public void redraw()
public void removeSource()
public void removeWaveDisplayListener(WaveDisplayListener listener)
listener - The WaveDisplayListener to removepublic void scroll(double d)
d - The new scroll factor. A scroll factor of 0 means scroll to the
left, 0.5 means scroll to center and 1 means scroll to the right. Any
inbetween value is possible.public void scrollCenter()
public void scrollLeft()
public void scrollRight()
public void setChannelSpacing(int spacing)
spacing - The new space in pixelspublic void setLeftOffset(int offset)
offset - The new space in pixelspublic void setSource(WaveFormProvider source)
source - The new providerpublic void setTopOffset(int offset)
offset - The new space in pixelspublic void showAll()
public void showData(int first,
int last)
first - The position of the first sample frame to be made visiblelast - The position of the last sample frame to be made visiblepublic void zoom(double d)
d - The new zoom factor. A zoom factor of 1.0 means, that the whole
WaveForm is visible, a greater value means zooming in and a smaller
value zooming out.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||