Class WaveformConfig

java.lang.Object
ca.corbett.extras.properties.AbstractProperty
ca.corbett.extras.audio.WaveformConfig

public class WaveformConfig extends AbstractProperty
Represents a preferences object that can be used with AudioUtil.generateWaveform().
Since:
2018-01-03
Author:
scorbo2
  • Constructor Details

    • WaveformConfig

      public WaveformConfig()
    • WaveformConfig

      public WaveformConfig(String fullyQualifiedName)
      Creates a WaveFormPreferences instance with all defaulted values:
      • White background
      • Black outline
      • Light grey fill
      • Dark grey baseline
      • Outline line thickness of 1
      • Horizontal scale of 1/1024
      • Vertical scale of 1/64
      • Top half of waveform will be channel 0
      • Bottom half will be channel 1 (or mirror of channel 0 if single channel).
  • Method Details

    • clonePreferences

      public static WaveformConfig clonePreferences(WaveformConfig other)
      Returns a clone of the given WaveformConfig instance. If you pass in null, you will receive a WaveformConfig instance with all default values, the same as if you had used new WaveformConfig() instead.
      Parameters:
      other - The WaveformConfig instance from which to copy. May be null.
      Returns:
      A clone of the given WaveformConfig, or a defaulted WaveformConfig.
    • setOutlineEnabled

      public void setOutlineEnabled(boolean enable)
      Enables or disables the drawing of an outline around the waveform. If enabled, you should also call setOutlineColor() to choose a colour for the outline. You may also call setOutlineThickness() to set the pixel width of the outline.
      Parameters:
      enable - Whether to enable or disable the outline.
    • isOutlineEnabled

      public boolean isOutlineEnabled()
      Returns whether the drawing of an outline around the waveform is enabled. See also the getOutlineColor() and getOutlineThickness() methods.
      Returns:
      Whether an outline will be drawn around the waveform.
    • getOutlineColor

      public Color getOutlineColor()
      Returns the current outline colour - this is the colour of the line to be drawn on the outline of the waveform.
      Returns:
      The outline colour.
    • getFillColor

      public Color getFillColor()
      Returns the current fill colour - this is the colour that will be used to fill the waveform.
      Returns:
      The fill colour.
    • getBgColor

      public Color getBgColor()
      Returns the current background colour - this is the colour for the area of the image behind the waveform.
      Returns:
      The background color.
    • setBaselineEnabled

      public void setBaselineEnabled(boolean enable)
      Enables or disables the drawing of the baseline at the center of the waveform. If enabled, you should also call setBaselineColor() to choose a colour for the baseline. You may also call setBaselineThickness() to set the pixel width of the outline.
      Parameters:
      enable - Whether to enable or disable the baseline.
    • isBaselineEnabled

      public boolean isBaselineEnabled()
      Returns whether the drawing of a baseline at the center of the waveform is enabled. See also the getBaselineColor() and getBaselineThickness() methods.
      Returns:
      Whether a baseline will be drawn at the center of the waveform.
    • setBaselineThickness

      public void setBaselineThickness(int width)
      Sets the pixel thickness of the baseline, if it is enabled.
      Parameters:
      width - The number of pixels wide for drawing the baseline.
    • getBaselineThickness

      public int getBaselineThickness()
      Returns the pixel width for the baseline, if it is enabled.
      Returns:
      the number of pixels thick for the baseline.
    • getBaselineColor

      public Color getBaselineColor()
      Returns the current baseline colour - this is the colour for the center line of the waveform. Set it to the same as fillColor to disable the baseline.
      Returns:
      The baseline color.
    • getOutlineThickness

      public int getOutlineThickness()
      Returns the thickness of the outline. Default is 1 pixel.
      Returns:
      The pixel width of the line to use to outline the waveform.
    • getTopChannelIndex

      public int getTopChannelIndex()
      Returns the channel index that will be used for the top half of the waveform.
      Returns:
      The index of the channel for the top half of the waveform.
    • getBottomChannelIndex

      public int getBottomChannelIndex()
      Returns the channel inde that will be used for the bottom half of the waveform. If this is the same index as topChannelIndex, the waveform will be a mirror.
      Returns:
      The index of the channel for the bottom half of the waveform.
    • getCompression

      public WaveformConfigField.Compression getCompression()
    • setCompression

      public void setCompression(WaveformConfigField.Compression compression)
    • getWidthLimit

      public WaveformConfigField.WidthLimit getWidthLimit()
    • setWidthLimit

      public void setWidthLimit(WaveformConfigField.WidthLimit limit)
    • setOutlineColor

      public void setOutlineColor(Color outlineColor)
      Sets the colour to use to outline the waveform. Set this to the same as fillColor or bgColor to disable the outline.
      Parameters:
      outlineColor - The colour to use to outline the waveform.
    • setFillColor

      public void setFillColor(Color fillColor)
      Sets the colour to use to fill the waveform. Set this to the same as bgColor to disable the fill.
      Parameters:
      fillColor - The colour to use to fill the waveform.
    • setBaselineColor

      public void setBaselineColor(Color baselineColor)
      Sets the colour to use to draw the horizontal center line. Set this to the same as fillColor to disable the baseline.
      Parameters:
      baselineColor - The colour for the horizontal center line.
    • setOutlineThickness

      public void setOutlineThickness(int thickness)
      Sets the line thickness to use for the outline of the waveform. Set this to 0 to disable the outline. Values less than 0 or greater than 10 are ignored.
      Parameters:
      thickness - The pixel width of the line that outlines the waveform.
    • setBgColor

      public void setBgColor(Color bgColor)
      Sets the colour to use for the background behind the waveform.
      Parameters:
      bgColor - The colour to use for the background.
    • setTopChannelIndex

      public void setTopChannelIndex(int topChannelIndex)
      Sets the index of the audio channel to use for the top half of the waveform. This defaults to 0 and generally shouldn't be changed unless you're doing something unusual. Values will be clipped as needed - for example, if this value is less than 0, or greater than the highest available channel index, it is clipped to be within that range.
      Parameters:
      topChannelIndex - The index of the audio channel for the top half of the waveform.
    • setBottomChannelIndex

      public void setBottomChannelIndex(int bottomChannelIndex)
      Sets the index of the audio channel to use for the bottom half of the waveform. This defafults to 1 and generally shouldn't be changed unless you're doing something unusual. Values will be clipped as needed - for example, if this value is less than 0, or greater than the highest available channel index, it is clipped to be within that range. Set this to the same as topChannelIndex if you want a mirror waveform (this will happen automatically in the case of mono audio input).
      Parameters:
      bottomChannelIndex - The index of the audio channel for the bottom half of the waveform.
    • saveToProps

      public void saveToProps(Properties props)
      Description copied from class: AbstractProperty
      Saves the current value(s) of this property to the given Properties instance.
      Specified by:
      saveToProps in class AbstractProperty
      Parameters:
      props - Any Properties instance which will receive the value(s) of this property.
    • loadFromProps

      public void loadFromProps(Properties props)
      Description copied from class: AbstractProperty
      Loads the value(s) for this property from the given Properties instance, overwriting any current value. The current value of this property will be used as a default value in the event that this property does not exist in the given Properties instance.
      Specified by:
      loadFromProps in class AbstractProperty
      Parameters:
      props - Any Properties instance which contains value(s) for this property.
    • generateFormFieldImpl

      protected FormField generateFormFieldImpl()
      Description copied from class: AbstractProperty
      Descendant classes must implement this method to generate a FormField associated with this property. The generateFormField() method in this class will call this abstract method to create the FormField, which will then be augmented with our fully qualified name, read-only state, help text, and extra attributes.
      Specified by:
      generateFormFieldImpl in class AbstractProperty
      Returns:
      A FormField associated with this property.
    • loadFromFormField

      public void loadFromFormField(FormField field)
      Description copied from class: AbstractProperty
      Populates this Property's value(s) from the given form field, assuming the field is of the correct type.
      Specified by:
      loadFromFormField in class AbstractProperty
      Parameters:
      field - The FormField containing a value for this property.