2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
* FilterCustomizer.java
19
* Copyright (C) 2002 University of Waikato, Hamilton, New Zealand
23
package weka.gui.beans;
25
import weka.filters.Filter;
26
import weka.gui.GenericObjectEditor;
28
import java.awt.BorderLayout;
29
import java.beans.Customizer;
30
import java.beans.PropertyChangeEvent;
31
import java.beans.PropertyChangeListener;
32
import java.beans.PropertyChangeSupport;
34
import javax.swing.JPanel;
37
* GUI customizer for the filter bean
39
* @author <a href="mailto:mhall@cs.waikato.ac.nz">Mark Hall</a>
40
* @version $Revision: 1.9 $
42
public class FilterCustomizer
44
implements Customizer {
46
/** for serialization */
47
private static final long serialVersionUID = 2049895469240109738L;
50
GenericObjectEditor.registerEditors();
53
private PropertyChangeSupport m_pcSupport =
54
new PropertyChangeSupport(this);
56
private weka.gui.beans.Filter m_filter;
57
private GenericObjectEditor m_filterEditor =
58
new GenericObjectEditor(true);
60
public FilterCustomizer() {
63
setClassType(Filter.class);
64
m_filterEditor.setValue(new weka.filters.unsupervised.attribute.Add());
65
m_filterEditor.addPropertyChangeListener(new PropertyChangeListener() {
66
public void propertyChange(PropertyChangeEvent e) {
68
if (m_filter != null) {
69
Filter editedF = (Filter)m_filterEditor.getValue();
70
m_filter.setFilter(editedF);
71
// should pass on the property change to any other interested
76
// System.out.println("Here");
78
} catch (Exception ex) {
82
setLayout(new BorderLayout());
83
add(m_filterEditor.getCustomEditor(), BorderLayout.CENTER);
87
* Set the filter bean to be edited
89
* @param object a Filter bean
91
public void setObject(Object object) {
92
m_filter = (weka.gui.beans.Filter)object;
93
m_filterEditor.setValue(m_filter.getFilter());
97
* Add a property change listener
99
* @param pcl a <code>PropertyChangeListener</code> value
101
public void addPropertyChangeListener(PropertyChangeListener pcl) {
102
m_pcSupport.addPropertyChangeListener(pcl);
106
* Remove a property change listener
108
* @param pcl a <code>PropertyChangeListener</code> value
110
public void removePropertyChangeListener(PropertyChangeListener pcl) {
111
m_pcSupport.removePropertyChangeListener(pcl);