weka.gui
Class EnsembleLibraryEditor

java.lang.Object
  extended by weka.gui.EnsembleLibraryEditor
All Implemented Interfaces:
java.beans.PropertyEditor
Direct Known Subclasses:
EnsembleSelectionLibraryEditor

public class EnsembleLibraryEditor
extends java.lang.Object
implements java.beans.PropertyEditor

Class for editing Library objects. Brings up a custom editing panel for the user to edit the library model list, as well as save load libraries from files.

A model list file is simply a flat file with a single classifier on each line. Each of these classifier is represented by the command line string that would be used to create that specific model with the specified set of paramters.

This code in class is based on other custom editors in weka.gui such as the CostMatrixEditor to try and maintain some consistency throughout the package.

Version:
$Revision: 1.1 $
Author:
Robert Jung (mrbobjung@gmail.com)

Constructor Summary
EnsembleLibraryEditor()
          Constructs a new LibraryEditor.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds an object to the list of those that wish to be informed when the library changes.
static java.awt.Component createGenericObjectRenderer(GenericObjectEditor classifierEditor)
          This is a helper function that creates a renderer for GenericObjects
 java.lang.String getAsText()
          Some objects can be represented as text, but a library cannot.
 java.awt.Component getCustomEditor()
          Gets a GUI component with which the user can edit the cost matrix.
static java.awt.Component getDefaultRenderer(java.beans.PropertyEditor nodeEditor)
          This is a helper function that creates a renderer for Default Objects.
static java.lang.Object getEditorValue(java.lang.Object source)
          This method handles the different object editor types in weka to obtain their current values.
 java.lang.String getJavaInitializationString()
          Returns the Java code that generates an object the same as the one being edited.
 java.lang.String[] getTags()
          Some objects can return tags, but a cost matrix cannot.
 java.lang.Object getValue()
          Gets the cost matrix that is being edited.
 boolean isPaintable()
          Indicates whether the object can be represented graphically.
static void main(java.lang.String[] args)
          This is a simple main method that lets you run a LibraryEditor on its own without having to deal with the Explorer, etc...
 void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box)
          Paints a graphical representation of the Object.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes an object from the list of those that wish to be informed when the cost matrix changes.
 void setAsText(java.lang.String text)
          Some objects can be represented as text, but a library cannot.
 void setValue(java.lang.Object value)
          Sets the value of the Library to be edited.
 boolean supportsCustomEditor()
          Indicates whether the library can be edited in a GUI, which it can.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnsembleLibraryEditor

public EnsembleLibraryEditor()
Constructs a new LibraryEditor.

Method Detail

setValue

public void setValue(java.lang.Object value)
Sets the value of the Library to be edited.

Specified by:
setValue in interface java.beans.PropertyEditor
Parameters:
value - a Library object to be edited

getValue

public java.lang.Object getValue()
Gets the cost matrix that is being edited.

Specified by:
getValue in interface java.beans.PropertyEditor
Returns:
the edited CostMatrix object

isPaintable

public boolean isPaintable()
Indicates whether the object can be represented graphically. In this case it can.

Specified by:
isPaintable in interface java.beans.PropertyEditor
Returns:
true

paintValue

public void paintValue(java.awt.Graphics gfx,
                       java.awt.Rectangle box)
Paints a graphical representation of the Object. For the ensemble library it prints out the working directory as well as the number of models in the library

Specified by:
paintValue in interface java.beans.PropertyEditor
Parameters:
gfx - the graphics context to draw the representation to
box - the bounds within which the representation should fit.

getJavaInitializationString

public java.lang.String getJavaInitializationString()
Returns the Java code that generates an object the same as the one being edited. Unfortunately this can't be done in a single line of code, so the code returned will only build a default cost matrix of the same size.

Specified by:
getJavaInitializationString in interface java.beans.PropertyEditor
Returns:
the initialization string

getAsText

public java.lang.String getAsText()
Some objects can be represented as text, but a library cannot.

Specified by:
getAsText in interface java.beans.PropertyEditor
Returns:
null

setAsText

public void setAsText(java.lang.String text)
Some objects can be represented as text, but a library cannot.

Specified by:
setAsText in interface java.beans.PropertyEditor
Parameters:
text - ignored
Throws:
always - throws an IllegalArgumentException

getTags

public java.lang.String[] getTags()
Some objects can return tags, but a cost matrix cannot.

Specified by:
getTags in interface java.beans.PropertyEditor
Returns:
null

getCustomEditor

public java.awt.Component getCustomEditor()
Gets a GUI component with which the user can edit the cost matrix.

Specified by:
getCustomEditor in interface java.beans.PropertyEditor
Returns:
an editor GUI component

supportsCustomEditor

public boolean supportsCustomEditor()
Indicates whether the library can be edited in a GUI, which it can.

Specified by:
supportsCustomEditor in interface java.beans.PropertyEditor
Returns:
true

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds an object to the list of those that wish to be informed when the library changes.

Specified by:
addPropertyChangeListener in interface java.beans.PropertyEditor
Parameters:
listener - a new listener to add to the list

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes an object from the list of those that wish to be informed when the cost matrix changes.

Specified by:
removePropertyChangeListener in interface java.beans.PropertyEditor
Parameters:
listener - the listener to remove from the list

getEditorValue

public static java.lang.Object getEditorValue(java.lang.Object source)
This method handles the different object editor types in weka to obtain their current values.

Parameters:
source - an Editor
Returns:
the value of the editor

getDefaultRenderer

public static java.awt.Component getDefaultRenderer(java.beans.PropertyEditor nodeEditor)
This is a helper function that creates a renderer for Default Objects. These are basically objects that are not numeric, nominal, or generic objects. These are objects that we don't want to do anything special with and just display their values as normal. We simply create the editor the same way that they would have been created in the PropertySheetPanel class.

Parameters:
nodeEditor - the editor created for the defaultNode
Returns:
the Component to dispaly the defaultNode

createGenericObjectRenderer

public static java.awt.Component createGenericObjectRenderer(GenericObjectEditor classifierEditor)
This is a helper function that creates a renderer for GenericObjects

Parameters:
classifierEditor - the editor created for this
Returns:
object renderer

main

public static void main(java.lang.String[] args)
This is a simple main method that lets you run a LibraryEditor on its own without having to deal with the Explorer, etc... This is useful only for building model lists.

Parameters:
args - the commandline arguments