org.opensourcephysics.media.core
Class FilterStack

java.lang.Object
  extended by org.opensourcephysics.media.core.Filter
      extended by org.opensourcephysics.media.core.FilterStack
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener

public class FilterStack
extends Filter
implements java.beans.PropertyChangeListener

This is a Filter that contains and manages a series of Filters.

Version:
1.0
Author:
Douglas Brown

Field Summary
 
Fields inherited from class org.opensourcephysics.media.core.Filter
ableButton, clearButton, closeButton, deleteItem, enabledAction, enabledItem, frame, hasInspector, inspectorVisible, inspectorX, inspectorY, propertiesItem, stack, support, vidPanel
 
Constructor Summary
FilterStack()
          Constructs a FilterStack object.
 
Method Summary
 void addFilter(Filter filter)
          Adds a filter to the end of the stack.
 void clear()
          Clears the filter stack.
 Filter getFilter(java.lang.Class<?> filterClass)
          Gets the first instance of the specified filter class.
 java.awt.image.BufferedImage getFilteredImage(java.awt.image.BufferedImage image)
          Returns the current filtered image.
 java.util.ArrayList<Filter> getFilters()
          Returns a copy of the filters in this filter stack.
 javax.swing.JDialog getInspector()
          Implements abstract Filter method.
 Filter getPostFilter()
          Gets the post filter.
 void insertFilter(Filter filter, int index)
          Adds a filter at the specified index.
 boolean isEmpty()
          Returns true if this contains no filters.
 int lastIndexRemoved()
          Gets the index of the last removed filter, or -1 if none removed.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Responds to property change events.
 void refresh()
          Refreshes this filter's GUI
 void removeFilter(Filter filter)
          Removes the specified filter from the stack.
 void setInspectorsVisible(boolean vis)
          Shows/hides all inspectors.
 void setPostFilter(Filter filter)
          Sets the post filter.
 
Methods inherited from class org.opensourcephysics.media.core.Filter
addPropertyChangeListener, addPropertyChangeListener, getMenu, isEnabled, removePropertyChangeListener, removePropertyChangeListener, setEnabled, setVideoPanel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterStack

public FilterStack()
Constructs a FilterStack object.

Method Detail

addFilter

public void addFilter(Filter filter)
Adds a filter to the end of the stack. Multiple filters are applied in the order they are added.

Parameters:
filter - the filter

insertFilter

public void insertFilter(Filter filter,
                         int index)
Adds a filter at the specified index. Multiple filters are applied in index order.

Parameters:
filter - the filter
index - the index

lastIndexRemoved

public int lastIndexRemoved()
Gets the index of the last removed filter, or -1 if none removed.

Returns:
the stack index.

setPostFilter

public void setPostFilter(Filter filter)
Sets the post filter. If non-null, the post filter is applied after all other filters.

Parameters:
filter - a filter

getPostFilter

public Filter getPostFilter()
Gets the post filter.

Returns:
the post filter

getFilter

public Filter getFilter(java.lang.Class<?> filterClass)
Gets the first instance of the specified filter class. May return null.

Parameters:
filterClass - the filter class
Returns:
the first filter of the specified class, if any

removeFilter

public void removeFilter(Filter filter)
Removes the specified filter from the stack.

Parameters:
filter - the filter

clear

public void clear()
Clears the filter stack.

Overrides:
clear in class Filter

isEmpty

public boolean isEmpty()
Returns true if this contains no filters.

Returns:
true if this is empty

getFilters

public java.util.ArrayList<Filter> getFilters()
Returns a copy of the filters in this filter stack.

Returns:
a collection of filters

getFilteredImage

public java.awt.image.BufferedImage getFilteredImage(java.awt.image.BufferedImage image)
Returns the current filtered image.

Specified by:
getFilteredImage in class Filter
Parameters:
image - the image to filter
Returns:
the filtered image

getInspector

public javax.swing.JDialog getInspector()
Implements abstract Filter method.

Specified by:
getInspector in class Filter
Returns:
the inspector

setInspectorsVisible

public void setInspectorsVisible(boolean vis)
Shows/hides all inspectors.

Parameters:
vis - true to show inspectors

refresh

public void refresh()
Refreshes this filter's GUI

Overrides:
refresh in class Filter

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Responds to property change events. FilterStack listens for the following events: all events from its filters.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - the property change event