weka.gui.beans
Class Filter

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byweka.gui.beans.Filter
All Implemented Interfaces:
javax.accessibility.Accessible, BeanCommon, DataSource, DataSourceListener, EventConstraints, java.util.EventListener, java.awt.image.ImageObserver, InstanceListener, java.awt.MenuContainer, java.io.Serializable, TestSetListener, TestSetProducer, TrainingSetListener, TrainingSetProducer, UserRequestAcceptor, Visible, WekaWrapper

public class Filter
extends javax.swing.JPanel
implements BeanCommon, Visible, WekaWrapper, java.io.Serializable, UserRequestAcceptor, TrainingSetListener, TestSetListener, TrainingSetProducer, TestSetProducer, DataSource, DataSourceListener, InstanceListener, EventConstraints

A wrapper bean for Weka filters

Version:
$Revision: 1.5 $
Author:
Mark Hall
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static int FILTERING_TEST
           
private static int FILTERING_TRAINING
           
private static int IDLE
           
private  java.util.Vector m_dataListeners
          Objects listening for data set events
private  Filter m_Filter
          The filter to use.
protected  java.lang.Thread m_filterThread
           
private  InstanceEvent m_ie
          Instance event object for passing on filtered instance streams
private  java.util.Vector m_instanceListeners
          Objects listening for instance events
private  java.util.Hashtable m_listenees
          Objects talking to us
private  Logger m_log
           
private  int m_state
           
private  Instances m_testingSet
           
private  java.util.Vector m_testListeners
          Objects listening for test set events
private  java.util.Vector m_trainingListeners
          Objects listening for training set events
private  Instances m_trainingSet
           
protected  BeanVisual m_visual
           
 
Fields inherited from class javax.swing.JPanel
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Filter()
           
 
Method Summary
 void acceptDataSet(DataSetEvent e)
          Accept a data set
 void acceptInstance(InstanceEvent e)
          Accept an instance for processing by StreamableFilters only
 void acceptTestSet(TestSetEvent e)
          Accept a test set
 void acceptTrainingSet(TrainingSetEvent e)
          Accept a training set
 void addDataSourceListener(DataSourceListener dsl)
          Add a data source listener
 void addInstanceListener(InstanceListener tsl)
          Add an instance listener
 void addTestSetListener(TestSetListener tsl)
          Add a test set listener
 void addTrainingSetListener(TrainingSetListener tsl)
          Add a training set listener
private  void block(boolean tf)
          Function used to stop code that calls acceptTrainingSet, acceptTestSet, or acceptDataSet.
 boolean connectionAllowed(java.lang.String eventName)
          Returns true if, at this time, the object will accept a connection with respect to the supplied event name
 void connectionNotification(java.lang.String eventName, java.lang.Object source)
          Notify this object that it has been registered as a listener with a source with respect to the supplied event name
 void disconnectionNotification(java.lang.String eventName, java.lang.Object source)
          Notify this object that it has been deregistered as a listener with a source with respect to the supplied event name
 java.util.Enumeration enumerateRequests()
          Return an enumeration of user requests
 boolean eventGeneratable(java.lang.String eventName)
          Returns true, if at the current time, the named event could be generated.
 Filter getFilter()
           
 BeanVisual getVisual()
          Get the visual appearance of this bean
 java.lang.Object getWrappedAlgorithm()
          Get the filter wrapped by this bean
private  void notifyDataOrTrainingListeners(java.util.EventObject ce)
           
protected  void notifyInstanceListeners(InstanceEvent tse)
           
private  void notifyTestListeners(TestSetEvent ce)
           
 void performRequest(java.lang.String request)
          Perform the named request
private  void processTrainingOrDataSourceEvents(java.util.EventObject e)
           
 void removeDataSourceListener(DataSourceListener dsl)
          Remove a data source listener
 void removeInstanceListener(InstanceListener tsl)
          Remove an instance listener
 void removeTestSetListener(TestSetListener tsl)
          Remove a test set listener
 void removeTrainingSetListener(TrainingSetListener tsl)
          Remove a training set listener
 void setFilter(Filter c)
          Set the filter to be wrapped by this bean
 void setLog(Logger logger)
          Set a logger
 void setVisual(BeanVisual newVisual)
          Set the visual appearance of this bean
 void setWrappedAlgorithm(java.lang.Object algorithm)
          Set the filter to be wrapped by this bean
 void stop()
          Stop all action if possible
 void useDefaultVisual()
          Use the default visual appearance
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_visual

protected BeanVisual m_visual

IDLE

private static int IDLE

FILTERING_TRAINING

private static int FILTERING_TRAINING

FILTERING_TEST

private static int FILTERING_TEST

m_state

private int m_state

m_filterThread

protected java.lang.Thread m_filterThread

m_trainingSet

private transient Instances m_trainingSet

m_testingSet

private transient Instances m_testingSet

m_listenees

private java.util.Hashtable m_listenees
Objects talking to us


m_trainingListeners

private java.util.Vector m_trainingListeners
Objects listening for training set events


m_testListeners

private java.util.Vector m_testListeners
Objects listening for test set events


m_instanceListeners

private java.util.Vector m_instanceListeners
Objects listening for instance events


m_dataListeners

private java.util.Vector m_dataListeners
Objects listening for data set events


m_Filter

private Filter m_Filter
The filter to use.


m_ie

private InstanceEvent m_ie
Instance event object for passing on filtered instance streams


m_log

private transient Logger m_log
Constructor Detail

Filter

public Filter()
Method Detail

setFilter

public void setFilter(Filter c)
Set the filter to be wrapped by this bean

Parameters:
c - a weka.filters.Filter value

getFilter

public Filter getFilter()

setWrappedAlgorithm

public void setWrappedAlgorithm(java.lang.Object algorithm)
Set the filter to be wrapped by this bean

Specified by:
setWrappedAlgorithm in interface WekaWrapper
Parameters:
algorithm - a weka.filters.Filter
Throws:
java.lang.IllegalArgumentException - if an error occurs

getWrappedAlgorithm

public java.lang.Object getWrappedAlgorithm()
Get the filter wrapped by this bean

Specified by:
getWrappedAlgorithm in interface WekaWrapper
Returns:
an Object value

acceptTrainingSet

public void acceptTrainingSet(TrainingSetEvent e)
Accept a training set

Specified by:
acceptTrainingSet in interface TrainingSetListener
Parameters:
e - a TrainingSetEvent value

acceptInstance

public void acceptInstance(InstanceEvent e)
Accept an instance for processing by StreamableFilters only

Specified by:
acceptInstance in interface InstanceListener
Parameters:
e - an InstanceEvent value

processTrainingOrDataSourceEvents

private void processTrainingOrDataSourceEvents(java.util.EventObject e)

acceptTestSet

public void acceptTestSet(TestSetEvent e)
Accept a test set

Specified by:
acceptTestSet in interface TestSetListener
Parameters:
e - a TestSetEvent value

acceptDataSet

public void acceptDataSet(DataSetEvent e)
Accept a data set

Specified by:
acceptDataSet in interface DataSourceListener
Parameters:
e - a DataSetEvent value

setVisual

public void setVisual(BeanVisual newVisual)
Set the visual appearance of this bean

Specified by:
setVisual in interface Visible
Parameters:
newVisual - a BeanVisual value

getVisual

public BeanVisual getVisual()
Get the visual appearance of this bean

Specified by:
getVisual in interface Visible
Returns:
a BeanVisual value

useDefaultVisual

public void useDefaultVisual()
Use the default visual appearance

Specified by:
useDefaultVisual in interface Visible

addTrainingSetListener

public void addTrainingSetListener(TrainingSetListener tsl)
Add a training set listener

Specified by:
addTrainingSetListener in interface TrainingSetProducer
Parameters:
tsl - a TrainingSetListener value

removeTrainingSetListener

public void removeTrainingSetListener(TrainingSetListener tsl)
Remove a training set listener

Specified by:
removeTrainingSetListener in interface TrainingSetProducer
Parameters:
tsl - a TrainingSetListener value

addTestSetListener

public void addTestSetListener(TestSetListener tsl)
Add a test set listener

Specified by:
addTestSetListener in interface TestSetProducer
Parameters:
tsl - a TestSetListener value

removeTestSetListener

public void removeTestSetListener(TestSetListener tsl)
Remove a test set listener

Specified by:
removeTestSetListener in interface TestSetProducer
Parameters:
tsl - a TestSetListener value

addDataSourceListener

public void addDataSourceListener(DataSourceListener dsl)
Add a data source listener

Specified by:
addDataSourceListener in interface DataSource
Parameters:
dsl - a DataSourceListener value

removeDataSourceListener

public void removeDataSourceListener(DataSourceListener dsl)
Remove a data source listener

Specified by:
removeDataSourceListener in interface DataSource
Parameters:
dsl - a DataSourceListener value

addInstanceListener

public void addInstanceListener(InstanceListener tsl)
Add an instance listener

Specified by:
addInstanceListener in interface DataSource
Parameters:
tsl - an InstanceListener value

removeInstanceListener

public void removeInstanceListener(InstanceListener tsl)
Remove an instance listener

Specified by:
removeInstanceListener in interface DataSource
Parameters:
tsl - an InstanceListener value

notifyDataOrTrainingListeners

private void notifyDataOrTrainingListeners(java.util.EventObject ce)

notifyTestListeners

private void notifyTestListeners(TestSetEvent ce)

notifyInstanceListeners

protected void notifyInstanceListeners(InstanceEvent tse)

connectionAllowed

public boolean connectionAllowed(java.lang.String eventName)
Returns true if, at this time, the object will accept a connection with respect to the supplied event name

Specified by:
connectionAllowed in interface BeanCommon
Parameters:
eventName - the event
Returns:
true if the object will accept a connection

connectionNotification

public void connectionNotification(java.lang.String eventName,
                                   java.lang.Object source)
Notify this object that it has been registered as a listener with a source with respect to the supplied event name

Specified by:
connectionNotification in interface BeanCommon
Parameters:
eventName -
source - the source with which this object has been registered as a listener

disconnectionNotification

public void disconnectionNotification(java.lang.String eventName,
                                      java.lang.Object source)
Notify this object that it has been deregistered as a listener with a source with respect to the supplied event name

Specified by:
disconnectionNotification in interface BeanCommon
Parameters:
eventName - the event
source - the source with which this object has been registered as a listener

block

private void block(boolean tf)
Function used to stop code that calls acceptTrainingSet, acceptTestSet, or acceptDataSet. This is needed as filtering is performed inside a separate thread of execution.

Parameters:
tf - a boolean value

stop

public void stop()
Stop all action if possible

Specified by:
stop in interface BeanCommon

setLog

public void setLog(Logger logger)
Set a logger

Specified by:
setLog in interface BeanCommon
Parameters:
logger - a Logger value

enumerateRequests

public java.util.Enumeration enumerateRequests()
Return an enumeration of user requests

Specified by:
enumerateRequests in interface UserRequestAcceptor
Returns:
an Enumeration value

performRequest

public void performRequest(java.lang.String request)
Perform the named request

Specified by:
performRequest in interface UserRequestAcceptor
Parameters:
request - a String value
Throws:
java.lang.IllegalArgumentException - if an error occurs

eventGeneratable

public boolean eventGeneratable(java.lang.String eventName)
Returns true, if at the current time, the named event could be generated. Assumes that supplied event names are names of events that could be generated by this bean.

Specified by:
eventGeneratable in interface EventConstraints
Parameters:
eventName - the name of the event in question
Returns:
true if the named event could be generated at this point in time