Package weka.gui
Class GenericObjectEditor
java.lang.Object
weka.gui.GenericObjectEditor
- All Implemented Interfaces:
PropertyEditor
,CustomPanelSupplier
A PropertyEditor for objects. It can be used either in a static or a dynamic
way.
In the static way (
If it is used in a dynamic way (the
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).- Version:
- $Revision: 15236 $
- Author:
- 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)
- See Also:
-
GenericPropertiesCreator
GenericPropertiesCreator.useDynamic()
GenericPropertiesCreator.CREATOR_FILE
ClassDiscovery
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
A dialog for selecting Capabilities to look for in the GOE tree.class
Handles the GUI side of editing values.class
A specialized TreeNode for supporting filtering via Capabilities.class
Creates a popup menu containing a tree that is aware of the screen dimensions. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
the properties files containing the class/editor mappings. -
Constructor Summary
ConstructorDescriptionDefault constructor.GenericObjectEditor
(boolean canChangeClassInDialog) Constructor that allows specifying whether it is possible to change the class within the editor dialog. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a PropertyChangeListener who will be notified of value changes.static void
Returns null as we don't support getting/setting values as text.Returns the backup object (may be null if there is no backup.boolean
Returns whether the user can change the class in the dialog.Returns the current Capabilities filter, can be null.Returns a popup menu that allows the user to change the class of object.Returns the array editing component.Gets the custom panel used for editing the object.Returns the history of the used setups.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.boolean
String[]
getTags()
Returns null as we don't support getting values as tags.getValue()
Gets the current, configured object.boolean
Returns true to indicate that we can paint a representation of the Object.static void
Tests out the Object editor from the command line.static Object
Makes a copy of an object using serialization if the given object is not an option handler.void
paintValue
(Graphics gfx, Rectangle box) Paints a representation of the current Object.static void
registerEditor
(String name, String value) static void
registers all the editors in Weka.void
Removes the current Capabilities filter.void
Removes a PropertyChangeListener.void
Returns null as we don't support getting/setting values as text.void
setCanChangeClassInDialog
(boolean value) Sets whether the user can change the class in the dialog.void
Sets the capabilities to use for filtering.void
setClassType
(Class<?> type) Sets the class of values that can be edited.void
Sets the current object to be the default, taken as the first item in the chooser.void
setEnabled
(boolean newVal) Sets whether the editor is "enabled", meaning that the current values will be painted.static void
setShowGlobalInfoToolTips
(boolean show) void
Sets the current Object.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).boolean
Returns true because we do support a custom editor.boolean
True if the cancel button was used to close the editor.
-
Field Details
-
GUIEDITORS_PROPERTY_FILE
the properties files containing the class/editor mappings.- See Also:
-
-
Constructor Details
-
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.- Parameters:
canChangeClassInDialog
- whether the user can change the class
-
-
Method Details
-
setShowGlobalInfoToolTips
public static void setShowGlobalInfoToolTips(boolean show) -
getShowGlobalInfoToolTips
public boolean getShowGlobalInfoToolTips() -
determineClasses
public static void determineClasses() -
registerEditors
public static void registerEditors()registers all the editors in Weka. -
registerEditor
-
setCanChangeClassInDialog
public void setCanChangeClassInDialog(boolean value) Sets whether the user can change the class in the dialog.- Parameters:
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.- Returns:
- true if the user can change the class
-
getBackup
Returns the backup object (may be null if there is no backup.- Returns:
- the backup object
-
sortClassesByRoot
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.- Parameters:
classes
- the classnames to work on- Returns:
- 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.- Parameters:
newVal
- a value of type 'boolean'
-
setClassType
Sets the class of values that can be edited.- Parameters:
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. -
wasCancelPressed
public boolean wasCancelPressed()True if the cancel button was used to close the editor.- Returns:
- true if the cancel button was pressed the last time the editor was closed
-
setValue
Sets the current Object. If the Object is in the Object chooser, this becomes the selected item (and added to the chooser if necessary). Makes a completely independent copy of the incoming object for further use. If the incoming object is not an option handler, this is done by creating a deep copy using serialization.- Specified by:
setValue
in interfacePropertyEditor
- Parameters:
o
- the object to be edited
-
getValue
Gets the current, configured object. Returns a completely independent copy of the configured object for further use.- Specified by:
getValue
in interfacePropertyEditor
- Returns:
- the current, configured object
-
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.- Specified by:
getJavaInitializationString
in interfacePropertyEditor
- Returns:
- the java source code initialisation string
-
isPaintable
public boolean isPaintable()Returns true to indicate that we can paint a representation of the Object.- Specified by:
isPaintable
in interfacePropertyEditor
- Returns:
- true
-
paintValue
Paints a representation of the current Object.- Specified by:
paintValue
in interfacePropertyEditor
- Parameters:
gfx
- the graphics context to usebox
- the area we are allowed to paint into
-
getAsText
Returns null as we don't support getting/setting values as text.- Specified by:
getAsText
in interfacePropertyEditor
- Returns:
- null
-
setAsText
Returns null as we don't support getting/setting values as text.- Specified by:
setAsText
in interfacePropertyEditor
- Parameters:
text
- the text value- Throws:
IllegalArgumentException
- as we don't support getting/setting values as text.
-
getTags
Returns null as we don't support getting values as tags.- Specified by:
getTags
in interfacePropertyEditor
- Returns:
- null
-
supportsCustomEditor
public boolean supportsCustomEditor()Returns true because we do support a custom editor.- Specified by:
supportsCustomEditor
in interfacePropertyEditor
- Returns:
- true
-
getCustomEditor
Returns the array editing component.- Specified by:
getCustomEditor
in interfacePropertyEditor
- Returns:
- a value of type 'java.awt.Component'
-
addPropertyChangeListener
Adds a PropertyChangeListener who will be notified of value changes.- Specified by:
addPropertyChangeListener
in interfacePropertyEditor
- Parameters:
l
- a value of type 'PropertyChangeListener'
-
removePropertyChangeListener
Removes a PropertyChangeListener.- Specified by:
removePropertyChangeListener
in interfacePropertyEditor
- Parameters:
l
- a value of type 'PropertyChangeListener'
-
getCustomPanel
Gets the custom panel used for editing the object.- Specified by:
getCustomPanel
in interfaceCustomPanelSupplier
- Returns:
- the panel
-
getChooseClassPopupMenu
Returns a popup menu that allows the user to change the class of object.- Returns:
- a JPopupMenu that when shown will let the user choose the class
-
setCapabilitiesFilter
Sets the capabilities to use for filtering.- Parameters:
value
- the object to get the filter capabilities from
-
getCapabilitiesFilter
Returns the current Capabilities filter, can be null.- Returns:
- the current Capabiliities used for filtering
-
removeCapabilitiesFilter
public void removeCapabilitiesFilter()Removes the current Capabilities filter. -
makeCopy
Makes a copy of an object using serialization if the given object is not an option handler. Otherwise, it will use the makeCopy() method in OptionHandler.- Parameters:
source
- the object to copy- Returns:
- a copy of the source object
- Throws:
Exception
- if the copy fails
-
getHistory
Returns the history of the used setups.- Returns:
- the history
-
main
Tests out the Object editor from the command line.- Parameters:
args
- may contain the class name of a Object to edit
-