GenericObjectNode

Overview | Package | Class | Tree | Deprecated | Index | Help | Weka's home

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weka.gui.ensembleLibraryEditor.tree
Class GenericObjectNode

    java.lang.Object
      javax.swing.tree.DefaultMutableTreeNode
          weka.gui.ensembleLibraryEditor.tree.GenericObjectNode

All Implemented Interfaces:
  java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

    public class GenericObjectNode

extends javax.swing.tree.DefaultMutableTreeNode
implements java.beans.PropertyChangeListener

This class is responsible for allowing users to choose an object that was provided with a GenericObjectEditor. Just about every one of these Objects is a Weka Classifier. There are two important things that these nodes are responsible for beyond the other parameter node types. First, they must discover all of the parameters that need to be added in the model as child nodes. This is done through a loop of introspection that was copied and adapted from the weka.gui.PropertySheetPanel class. Second, this class is also responsible for discovering all possible combinations of GenericObject parameters that are stored in its child nodes. This is accomplished by first discovering all of the child node parameters in the getValues method and then finding all combinations of these values with the combinAllValues method.

Version:
  $Revision: 1.1 $
Author:
  Robert Jung (mrbobjung@gmail.com)
See Also:
  Serialized Form

Field Summary

Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
`EMPTY_ENUMERATION`

Constructor Summary
`GenericObjectNode(AddModelsPanel panel, java.lang.Object value, GenericObjectEditor genericObjectEditor, java.lang.String toolTipText)` The constructor initialiazes the member variables of this node, Note that the "value" of this generic object is stored as the treeNode user object.

Method Summary
`void` | `combineAllValues(java.util.Vector previouslySelected, java.util.Vector remainingValues)` This method is responsible for returning all possible values through a recursive loop.
`GenericObjectEditor` | `getEditor()` A getter for the GenericObjectEditor for this node
`java.lang.StringBuffer` | `getHelpText()` getter for the tooltip text
`java.lang.Object` | `getObject()` getter for this node's object
`javax.swing.JPanel` | `getParentPanel()` getter for the parent panel
`java.lang.String` | `getToolTipText()` getter for the tooltip text
`javax.swing.JTree` | `getTree()` returns the current tree
`java.util.Vector` | `getValues()` This method iterates over all of the child nodes of this GenericObjectNode and requests the verious sets of values that the user has presumably specified.
`void` | `propertyChange(java.beans.PropertyChangeEvent evt)` This implements the PropertyChangeListener for this node that gets registered with its Editor.
`void` | `setObject(java.lang.Object newValue)` setter for this nodes object
`void` | `setTree(javax.swing.JTree tree)` It seems kind of dumb that the reference to the tree model is passed in seperately - but know that this is actually necessary.
`void` | `setUserObject(java.lang.Object o)` this is a simple filter for the setUserObject method.
`java.lang.String` | `toString()` returns always null
`void` | `updateTree()` This method uses introspection to programatically discover all of the parameters for this generic object.

Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
`add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### GenericObjectNode

    public GenericObjectNode(AddModelsPanel panel,
                             java.lang.Object value,
                             GenericObjectEditor genericObjectEditor,
                             java.lang.String toolTipText)

  The constructor initialiazes the member variables of this node, Note that the "value" of this generic object is stored as the treeNode user object.

  Parameters:
    `panel` - the reference to the parent panel for calls to JDialog
    `value` - the value stored at this tree node
    `genericObjectEditor` - the GenericObjectEditor for this object
    `toolTipText` - the tipText to be displayed for this object

Method Detail

### setTree

    public void setTree(javax.swing.JTree tree)

  It seems kind of dumb that the reference to the tree model is passed in seperately - but know that this is actually necessary. There is a really weird chicken before the egg problem. You cannot create a TreeModel without giving it its root node. However, the nodes in your tree can't update the structure of the tree unless they have a reference to the TreeModel. So in the end this was the only compromise that I could get to work well

  Parameters:
    `tree` - the tree to use

### getTree

    public javax.swing.JTree getTree()

  returns the current tree

  Returns:
    the current tree

### getEditor

    public GenericObjectEditor getEditor()

  A getter for the GenericObjectEditor for this node

  Returns:
    the editor

### getHelpText

    public java.lang.StringBuffer getHelpText()

  getter for the tooltip text

  Returns:
    tooltip text

### getToolTipText

    public java.lang.String getToolTipText()

  getter for the tooltip text

  Returns:
    tooltip text

### getObject

    public java.lang.Object getObject()

  getter for this node's object

  Returns:
    the node's object

### setObject

    public void setObject(java.lang.Object newValue)

  setter for this nodes object

  Parameters:
    `newValue` - sets the new object

### setUserObject

    public void setUserObject(java.lang.Object o)

  this is a simple filter for the setUserObject method. We basically don't want null values to be passed in.

  Specified by:
    `setUserObject` in interface `javax.swing.tree.MutableTreeNode`
  Overrides:
    `setUserObject` in class `javax.swing.tree.DefaultMutableTreeNode`
  Parameters:
    `o` - the object to set

### getParentPanel

    public javax.swing.JPanel getParentPanel()

  getter for the parent panel

  Returns:
    the parent panel

### toString

    public java.lang.String toString()

  returns always null

  Overrides:
    `toString` in class `javax.swing.tree.DefaultMutableTreeNode`
  Returns:
    always null

### propertyChange

    public void propertyChange(java.beans.PropertyChangeEvent evt)

  This implements the PropertyChangeListener for this node that gets registered with its Editor. All we really have to do is change the Object value stored internally at this node when its editor says the value changed.

  Specified by:
    `propertyChange` in interface `java.beans.PropertyChangeListener`
  Parameters:
    `evt` - the event

### updateTree

    public void updateTree()

  This method uses introspection to programatically discover all of the parameters for this generic object. For each one of them it uses the TreeModel reference to create a new subtree to represent that parameter and its value ranges. Note that all of these nodes are PropertyNodes which themselves hold the logic of figuring out what type of parameter it is they are representing and thus what type of subtree to build.

  We need to be careful because this was molded from the code inside of the PropertySheetPanel class. Which means that we are wide open to copy/paste problems. In the future, when that code changes to adapt to other changes in Weka then this could easily become broken.

### getValues

    public java.util.Vector getValues()

  This method iterates over all of the child nodes of this GenericObjectNode and requests the verious sets of values that the user has presumably specified. Once these sets of values are

  Returns:
    a Vector consisting of all parameter combinations

### combineAllValues

    public void combineAllValues(java.util.Vector previouslySelected,
                                 java.util.Vector remainingValues)

  This method is responsible for returning all possible values through a recursive loop. When the recursion terminates that means that there are no more parameter sets to branch out through so all we have to do is save the current Vector in the working set of combinations. Otherwise we iterate through all possible values left in the next set of parameter values and recursively call this function.

  Parameters:
    `previouslySelected` - stores the values chosen in this branch of the recursion
    `remainingValues` - the sets of values left

Overview | Package | Class | Tree | Deprecated | Index | Help | Weka's home

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD