com.icdif.audio.graph
Class Plot

java.lang.Object
  extended by com.icdif.audio.graph.Plot

public class Plot
extends java.lang.Object

A class that allows to plot values (float[] or ArrayList[Float]) to a swing window.

Author:
wanderer

Constructor Summary
Plot(java.lang.String title, int width, int height)
          Instantiates a new Plot with the given title and dimensions.
 
Method Summary
 void clear()
          It clears the plot, i.e., paints the original rectangle with the background color and sets the attribute cleared to true
 void PlayInPlot(float samplesPerPixel, AudioDecoder decoder)
          Plays the audio associated with the plot and adds a marker dynamically to the plot
 void plot(java.util.ArrayList<java.lang.Float> samples, float samplesPerPixel, java.awt.Color color)
          This method plots the arraylist of samples, with the Window defined as parameter
 void plot(java.util.ArrayList<java.lang.Float> samples, float samplesPerPixel, float verticalOffset, boolean useLastScale, java.awt.Color color)
          This plots the samples, with the Window defined as parameter.
 void plot(float[] samples, float samplesPerPixel, java.awt.Color color)
          This plots the values passed, with the Window defined as parameter.
 void plot(float[] samples, float samplesPerPixel, float verticalOffset, boolean useLastScale, java.awt.Color color)
          This plots the samples, with the Window defined as parameter.
 void setMarker(int x, java.awt.Color color)
          Sets a marker (vertical line)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Plot

public Plot(java.lang.String title,
            int width,
            int height)
Instantiates a new Plot with the given title and dimensions.

Parameters:
title - The title.
width - The width of the plot in pixels.
height - The height of the plot in pixels.
Method Detail

clear

public void clear()
It clears the plot, i.e., paints the original rectangle with the background color and sets the attribute cleared to true


plot

public void plot(float[] samples,
                 float samplesPerPixel,
                 java.awt.Color color)
This plots the values passed, with the Window defined as parameter. It updates the image initialized in the constructor.

Parameters:
samples - the samples to plot
samplesPerPixel - The number of samples in each pixel
color - The color of the line

plot

public void plot(java.util.ArrayList<java.lang.Float> samples,
                 float samplesPerPixel,
                 java.awt.Color color)
This method plots the arraylist of samples, with the Window defined as parameter

Parameters:
samples - the samples to plot
samplesPerPixel - The number of samples in each pixel
color - The color of the line

plot

public void plot(float[] samples,
                 float samplesPerPixel,
                 float verticalOffset,
                 boolean useLastScale,
                 java.awt.Color color)
This plots the samples, with the Window defined as parameter. It can used the scale of the last plot and a vertical offset.

Parameters:
samples - the samples to plot
samplesPerPixel - The number of samples in each pixel
verticalOffset - The vertical offSet (in order to plot several frequencies in the same image)
useLastScale - boolean that tells to user or not the last scale
color - The color of the line

plot

public void plot(java.util.ArrayList<java.lang.Float> samples,
                 float samplesPerPixel,
                 float verticalOffset,
                 boolean useLastScale,
                 java.awt.Color color)
This plots the samples, with the Window defined as parameter. It can used the scale of the last plot and a vertical offset.

Parameters:
samples - the samples to plot
samplesPerPixel - The number of samples in each pixel
verticalOffset - The vertical offSet (in order to plot several frequencies in the same image)
useLastScale - boolean that tells to user or not the last scale
color - The color of the line

PlayInPlot

public void PlayInPlot(float samplesPerPixel,
                       AudioDecoder decoder)
                throws java.lang.Exception
Plays the audio associated with the plot and adds a marker dynamically to the plot

Parameters:
samplesPerPixel -
decoder -
Throws:
java.lang.Exception

setMarker

public void setMarker(int x,
                      java.awt.Color color)
Sets a marker (vertical line)

Parameters:
x - the position to set the marker
color - the colour of the marker