程序包 weka.gui

类 GenericObjectEditor

java.lang.Object
weka.gui.GenericObjectEditor
所有已实现的接口:
PropertyEditor, CustomPanelSupplier

public class GenericObjectEditor extends Object implements PropertyEditor, CustomPanelSupplier
A PropertyEditor for objects. It can be used either in a static or a dynamic way.

In the static way (USE_DYNAMIC is false) the objects have been defined as editable in the GenericObjectEditor configuration file, which lists possible values that can be selected from, and themselves configured. The configuration file is called "GenericObjectEditor.props" and may live in either the location given by "user.home" or the current directory (this last will take precedence), and a default properties file is read from the Weka distribution. For speed, the properties file is read only once when the class is first loaded -- this may need to be changed if we ever end up running in a Java OS ;-).

If it is used in a dynamic way (the UseDynamic property of the GenericPropertiesCreator props file is set to true) then the classes to list are discovered by the GenericPropertiesCreator class (it checks the complete classpath).
版本:
$Revision: 11356 $
作者:
Len Trigg (trigg@cs.waikato.ac.nz), Xin Xu (xx5@cs.waikato.ac.nz), Richard Kirkby (rkirkby@cs.waikato.ac.nz), FracPete (fracpete at waikato dot ac dot nz)
另请参阅:
  • 字段详细资料

    • GUIEDITORS_PROPERTY_FILE

      public static final String GUIEDITORS_PROPERTY_FILE
      the properties files containing the class/editor mappings.
      另请参阅:
  • 构造器详细资料

    • GenericObjectEditor

      public GenericObjectEditor()
      Default constructor.
    • GenericObjectEditor

      public GenericObjectEditor(boolean canChangeClassInDialog)
      Constructor that allows specifying whether it is possible to change the class within the editor dialog.
      参数:
      canChangeClassInDialog - whether the user can change the class
  • 方法详细资料

    • registerEditors

      public static void registerEditors()
      registers all the editors in Weka.
    • setCanChangeClassInDialog

      public void setCanChangeClassInDialog(boolean value)
      Sets whether the user can change the class in the dialog.
      参数:
      value - if true then the user can change the class
    • getCanChangeClassInDialog

      public boolean getCanChangeClassInDialog()
      Returns whether the user can change the class in the dialog.
      返回:
      true if the user can change the class
    • getBackup

      public Object getBackup()
      Returns the backup object (may be null if there is no backup.
      返回:
      the backup object
    • sortClassesByRoot

      public static Hashtable sortClassesByRoot(String classes)
      parses the given string of classes separated by ", " and returns the a hashtable with as many entries as there are different root elements in the class names (the key is the root element). E.g. if there's only "weka." as the prefix for all classes the a hashtable of size 1 is returned. if NULL is the input, then NULL is also returned.
      参数:
      classes - the classnames to work on
      返回:
      for each distinct root element in the classnames, one entry in the hashtable (with the root element as key)
    • setEnabled

      public void setEnabled(boolean newVal)
      Sets whether the editor is "enabled", meaning that the current values will be painted.
      参数:
      newVal - a value of type 'boolean'
    • setClassType

      public void setClassType(Class type)
      Sets the class of values that can be edited.
      参数:
      type - a value of type 'Class'
    • setDefaultValue

      public void setDefaultValue()
      Sets the current object to be the default, taken as the first item in the chooser.
    • setValue

      public void setValue(Object o)
      Sets the current Object. If the Object is in the Object chooser, this becomes the selected item (and added to the chooser if necessary).
      指定者:
      setValue 在接口中 PropertyEditor
      参数:
      o - an object that must be a Object.
    • getValue

      public Object getValue()
      Gets the current Object.
      指定者:
      getValue 在接口中 PropertyEditor
      返回:
      the current Object
    • getJavaInitializationString

      public String getJavaInitializationString()
      Supposedly returns an initialization string to create a Object identical to the current one, including it's state, but this doesn't appear possible given that the initialization string isn't supposed to contain multiple statements.
      指定者:
      getJavaInitializationString 在接口中 PropertyEditor
      返回:
      the java source code initialisation string
    • isPaintable

      public boolean isPaintable()
      Returns true to indicate that we can paint a representation of the Object.
      指定者:
      isPaintable 在接口中 PropertyEditor
      返回:
      true
    • paintValue

      public void paintValue(Graphics gfx, Rectangle box)
      Paints a representation of the current Object.
      指定者:
      paintValue 在接口中 PropertyEditor
      参数:
      gfx - the graphics context to use
      box - the area we are allowed to paint into
    • getAsText

      public String getAsText()
      Returns null as we don't support getting/setting values as text.
      指定者:
      getAsText 在接口中 PropertyEditor
      返回:
      null
    • setAsText

      public void setAsText(String text)
      Returns null as we don't support getting/setting values as text.
      指定者:
      setAsText 在接口中 PropertyEditor
      参数:
      text - the text value
      抛出:
      IllegalArgumentException - as we don't support getting/setting values as text.
    • getTags

      public String[] getTags()
      Returns null as we don't support getting values as tags.
      指定者:
      getTags 在接口中 PropertyEditor
      返回:
      null
    • supportsCustomEditor

      public boolean supportsCustomEditor()
      Returns true because we do support a custom editor.
      指定者:
      supportsCustomEditor 在接口中 PropertyEditor
      返回:
      true
    • getCustomEditor

      public Component getCustomEditor()
      Returns the array editing component.
      指定者:
      getCustomEditor 在接口中 PropertyEditor
      返回:
      a value of type 'java.awt.Component'
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener l)
      Adds a PropertyChangeListener who will be notified of value changes.
      指定者:
      addPropertyChangeListener 在接口中 PropertyEditor
      参数:
      l - a value of type 'PropertyChangeListener'
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener l)
      Removes a PropertyChangeListener.
      指定者:
      removePropertyChangeListener 在接口中 PropertyEditor
      参数:
      l - a value of type 'PropertyChangeListener'
    • getCustomPanel

      public JPanel getCustomPanel()
      Gets the custom panel used for editing the object.
      指定者:
      getCustomPanel 在接口中 CustomPanelSupplier
      返回:
      the panel
    • getChooseClassPopupMenu

      public JPopupMenu getChooseClassPopupMenu()
      Returns a popup menu that allows the user to change the class of object.
      返回:
      a JPopupMenu that when shown will let the user choose the class
    • setCapabilitiesFilter

      public void setCapabilitiesFilter(Capabilities value)
      Sets the capabilities to use for filtering.
      参数:
      value - the object to get the filter capabilities from
    • getCapabilitiesFilter

      public Capabilities getCapabilitiesFilter()
      Returns the current Capabilities filter, can be null.
      返回:
      the current Capabiliities used for filtering
    • removeCapabilitiesFilter

      public void removeCapabilitiesFilter()
      Removes the current Capabilities filter.
    • makeCopy

      public static Object makeCopy(Object source) throws Exception
      Makes a copy of an object using serialization.
      参数:
      source - the object to copy
      返回:
      a copy of the source object
      抛出:
      Exception - if the copy fails
    • getClassnames

      public static Vector<String> getClassnames(String property)
      Returns the available classnames for a certain property in the props file.
      参数:
      property - the property to get the classnames for
      返回:
      the classnames
    • main

      public static void main(String[] args)
      Tests out the Object editor from the command line.
      参数:
      args - may contain the class name of a Object to edit