toxTree.tree
Class AbstractTree

java.lang.Object
  extended by java.util.Observable
      extended by toxTree.tree.AbstractTree
All Implemented Interfaces:
ambit2.core.data.IStructureDiagramHighlights, java.io.Serializable, java.lang.Cloneable, java.util.Observer, IDecisionMethod, IDecisionMethodPrority, XMLSerializable
Direct Known Subclasses:
UserDefinedTree

public abstract class AbstractTree
extends java.util.Observable
implements IDecisionMethod, java.util.Observer, XMLSerializable

An astract class, implementing IDecisionMethod interface. Used as a base class for the decision trees in ToxTreeApp. The default editor is TreeEditorPanel.

Author:
Nina Jeliazkova
Modified 2005-4-30
See Also:
Serialized Form

Field Summary
protected  IDecisionCategories categories
           
protected  java.beans.PropertyChangeSupport changes
           
protected  java.lang.String explanation
           
protected  boolean falseIfRuleNotImplemented
           
protected  java.awt.Dimension imageSize
           
protected static TTLogger logger
           
protected  boolean modified
           
protected  java.lang.String name
           
protected  int priority
           
protected  IDecisionRuleList rules
           
protected  int treeRoot
           
protected  boolean web
           
 
Fields inherited from interface toxTree.core.XMLSerializable
xmltag_CATEGORIES, xmltag_CATEGORY, xmltag_CATEGORYTHRESHOLD, xmltag_CLASS, xmltag_EXPLANATION, xmltag_ID, xmltag_METHOD, xmltag_METHODPARAMETER, xmltag_METHODS, xmltag_NAME, xmltag_RULE, xmltag_RULEEXAMPLE, xmltag_RULES, xmltag_TREEROOT
 
Constructor Summary
AbstractTree()
          Constructor
AbstractTree(IDecisionCategories categories)
           
AbstractTree(IDecisionCategories categories, IDecisionRuleList rules)
           
 
Method Summary
 void addDecisionRule(IDecisionRule rule)
           
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
           
 boolean classify(org.openscience.cdk.interfaces.IAtomContainer mol, IDecisionResult result)
           
protected  void clearChanged()
           
 IDecisionResult createDecisionResult()
           
 boolean equals(java.lang.Object obj)
           
 java.lang.StringBuffer explainRules(IDecisionResult result, boolean verbose)
           
 void fromXML(org.w3c.dom.Element xml)
           
 IDecisionCategories getCategories()
           
 IDecisionMethodEditor getEditor()
          Each rule provides an editor, which is a class implementing IDecisionMethodEditor.
 java.lang.String getExplanation()
           
 java.awt.image.BufferedImage getImage(org.openscience.cdk.interfaces.IAtomContainer mol)
           
 java.awt.image.BufferedImage getImage(org.openscience.cdk.interfaces.IAtomContainer mol, java.lang.String ruleID, int width, int height, boolean atomnumbers)
           
 java.awt.Dimension getImageSize()
           
 java.awt.image.BufferedImage getLegend(int width, int height)
           
 int getNumberOfClasses()
           
 int getNumberOfRules()
           
 int getPriority()
           
 IDecisionRule getRule(int id)
           
 IDecisionRule getRule(java.lang.String name)
           
 IDecisionRuleList getRules()
           
 java.lang.String getTitle()
          returns the decision tree title (e.g.
 IDecisionRule getTopRule()
           
protected abstract  IDecisionRuleList initRules()
          public AbstractTree( IDecisionCategories classes, String[] customRules, int[][] customTransitions) throws DecisionMethodException { this(categories,customRules,customTransitions); } public AbstractTree( String[] customRules, int[][] customTransitions) throws DecisionMethodException { this(); setRules(customRules); setTransitions(customTransitions); setChanged(); notifyObservers(); }
 boolean isFalseIfRuleNotImplemented()
           
 boolean isModified()
           
 boolean isWeb()
           
 javax.swing.JComponent optionsPanel(org.openscience.cdk.interfaces.IAtomContainer atomContainer)
           
 void printResults(java.lang.String filename)
           
 void printToStream(java.io.OutputStream os)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
           
protected  java.lang.String retrieveExplanation(java.lang.String resourceBundle)
           
 void setCategories(IDecisionCategories categories)
           
protected  void setChanged()
           
 void setDecisionRule(IDecisionRule rule)
           
 void setExplanation(java.lang.String explanation)
           
 void setFalseIfRuleNotImplemented(boolean falseIfRuleNotImplemented)
           
 void setImageSize(java.awt.Dimension imageSize)
           
 void setModified(boolean value)
           
abstract  void setParameters(org.openscience.cdk.interfaces.IAtomContainer mol)
          Can be used to display some options before applying the rules.
 void setPriority(int priority)
           
 void setRules(IDecisionRuleList rules)
           
protected  void setRules(java.lang.String[] customRules)
           
 void setTitle(java.lang.String value)
          sets decision tree title (e.g.
protected abstract  void setTransitions(int[][] customTransitions)
           
 void setWeb(java.lang.Boolean web)
           
 int testRulesWithSelector()
           
 org.w3c.dom.Element toShallowXML(org.w3c.dom.Document document)
           
 java.lang.String toString()
           
 org.w3c.dom.Element toXML(org.w3c.dom.Document document)
           
 void update(java.util.Observable o, java.lang.Object arg)
           
protected  boolean verifyResidues(org.openscience.cdk.interfaces.IAtomContainerSet mols, IDecisionResult result, IDecisionRule rule)
           
 boolean verifyRules(org.openscience.cdk.interfaces.IAtomContainer mol, IDecisionResult result)
          IDecisionRule.verifyRule(IAtomContainer)
protected abstract  boolean verifyRules(org.openscience.cdk.interfaces.IAtomContainer mol, IDecisionResult result, IDecisionRule rule)
          abstract method, to be implemented in the child class
protected  void walkRules(IDecisionRule rule, java.util.ArrayList<java.lang.Integer> visited, IProcessRule processor)
           
 void walkRules(IDecisionRule rule, IProcessRule processor)
           
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface toxTree.core.IDecisionMethod
getBranch, getCategory, hasUnreachableRules, hasUnusedCategories, isEditable, setEditable
 

Field Detail

logger

protected static transient TTLogger logger

imageSize

protected java.awt.Dimension imageSize

web

protected boolean web

changes

protected transient java.beans.PropertyChangeSupport changes

rules

protected IDecisionRuleList rules

categories

protected IDecisionCategories categories

falseIfRuleNotImplemented

protected boolean falseIfRuleNotImplemented

treeRoot

protected int treeRoot

name

protected java.lang.String name

explanation

protected java.lang.String explanation

modified

protected transient boolean modified

priority

protected int priority
Constructor Detail

AbstractTree

public AbstractTree()
Constructor


AbstractTree

public AbstractTree(IDecisionCategories categories)

AbstractTree

public AbstractTree(IDecisionCategories categories,
                    IDecisionRuleList rules)
Method Detail

getImageSize

public java.awt.Dimension getImageSize()
Specified by:
getImageSize in interface ambit2.core.data.IStructureDiagramHighlights

setImageSize

public void setImageSize(java.awt.Dimension imageSize)
Specified by:
setImageSize in interface ambit2.core.data.IStructureDiagramHighlights

initRules

protected abstract IDecisionRuleList initRules()
public AbstractTree( IDecisionCategories classes, String[] customRules, int[][] customTransitions) throws DecisionMethodException { this(categories,customRules,customTransitions); } public AbstractTree( String[] customRules, int[][] customTransitions) throws DecisionMethodException { this(); setRules(customRules); setTransitions(customTransitions); setChanged(); notifyObservers(); }


setRules

protected void setRules(java.lang.String[] customRules)
                 throws DecisionMethodException
Throws:
DecisionMethodException

setTransitions

protected abstract void setTransitions(int[][] customTransitions)

getTitle

public java.lang.String getTitle()
returns the decision tree title (e.g. "Cramer rules")

Specified by:
getTitle in interface IDecisionMethod

setTitle

public void setTitle(java.lang.String value)
sets decision tree title (e.g. "Cramer rules")

Specified by:
setTitle in interface IDecisionMethod

addDecisionRule

public void addDecisionRule(IDecisionRule rule)
                     throws DecisionMethodException
Specified by:
addDecisionRule in interface IDecisionMethod
Throws:
DecisionMethodException
See Also:
IDecisionMethod.addDecisionRule(toxTree.core.IDecisionRule)

setDecisionRule

public void setDecisionRule(IDecisionRule rule)
                     throws DecisionMethodException
Specified by:
setDecisionRule in interface IDecisionMethod
Throws:
DecisionMethodException
See Also:
IDecisionMethod.setDecisionRule(toxTree.core.IDecisionRule)

explainRules

public java.lang.StringBuffer explainRules(IDecisionResult result,
                                           boolean verbose)
                                    throws DecisionMethodException
Specified by:
explainRules in interface IDecisionMethod
Throws:
DecisionMethodException
See Also:
IDecisionMethod.explainRules(IDecisionResult,boolean)

verifyResidues

protected boolean verifyResidues(org.openscience.cdk.interfaces.IAtomContainerSet mols,
                                 IDecisionResult result,
                                 IDecisionRule rule)
                          throws DecisionMethodException
Throws:
DecisionMethodException

verifyRules

public boolean verifyRules(org.openscience.cdk.interfaces.IAtomContainer mol,
                           IDecisionResult result)
                    throws DecisionMethodException
IDecisionRule.verifyRule(IAtomContainer)

Specified by:
verifyRules in interface IDecisionMethod
Throws:
DecisionMethodException

verifyRules

protected abstract boolean verifyRules(org.openscience.cdk.interfaces.IAtomContainer mol,
                                       IDecisionResult result,
                                       IDecisionRule rule)
                                throws DecisionMethodException
abstract method, to be implemented in the child class

Parameters:
mol - - org.openscience.cdk.interfaces.AtomContainer to be analyzed
result - - IDecisionResult the result from the decision tree application
rule - - the starting rule
Returns:
Throws:
DecisionMethodException

classify

public boolean classify(org.openscience.cdk.interfaces.IAtomContainer mol,
                        IDecisionResult result)
                 throws DecisionMethodException
Specified by:
classify in interface IDecisionMethod
Throws:
DecisionMethodException

setParameters

public abstract void setParameters(org.openscience.cdk.interfaces.IAtomContainer mol)
Can be used to display some options before applying the rules.

Specified by:
setParameters in interface IDecisionMethod
Parameters:
mol -

optionsPanel

public javax.swing.JComponent optionsPanel(org.openscience.cdk.interfaces.IAtomContainer atomContainer)

getNumberOfRules

public int getNumberOfRules()
Specified by:
getNumberOfRules in interface IDecisionMethod

getRule

public IDecisionRule getRule(int id)
Specified by:
getRule in interface IDecisionMethod
See Also:
IDecisionMethod.getRule(int)

getRule

public IDecisionRule getRule(java.lang.String name)
Specified by:
getRule in interface IDecisionMethod
See Also:
IDecisionMethod.getRule(java.lang.String)

printToStream

public void printToStream(java.io.OutputStream os)
                   throws java.io.IOException
Parameters:
os -
Throws:
java.io.IOException

printResults

public void printResults(java.lang.String filename)
                  throws java.io.IOException
Parameters:
filename -
Throws:
java.io.IOException

isFalseIfRuleNotImplemented

public boolean isFalseIfRuleNotImplemented()

setFalseIfRuleNotImplemented

public void setFalseIfRuleNotImplemented(boolean falseIfRuleNotImplemented)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Specified by:
addPropertyChangeListener in interface IDecisionMethod

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Specified by:
removePropertyChangeListener in interface IDecisionMethod

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getCategories

public IDecisionCategories getCategories()
Specified by:
getCategories in interface IDecisionMethod

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

createDecisionResult

public IDecisionResult createDecisionResult()
Specified by:
createDecisionResult in interface IDecisionMethod

getNumberOfClasses

public int getNumberOfClasses()
Specified by:
getNumberOfClasses in interface IDecisionMethod

getRules

public IDecisionRuleList getRules()
Specified by:
getRules in interface IDecisionMethod

getExplanation

public java.lang.String getExplanation()
Specified by:
getExplanation in interface IDecisionMethod

setExplanation

public void setExplanation(java.lang.String explanation)
Specified by:
setExplanation in interface IDecisionMethod

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

getTopRule

public IDecisionRule getTopRule()
Specified by:
getTopRule in interface IDecisionMethod

setChanged

protected void setChanged()
Overrides:
setChanged in class java.util.Observable

clearChanged

protected void clearChanged()
Overrides:
clearChanged in class java.util.Observable

isModified

public boolean isModified()
Specified by:
isModified in interface IDecisionMethod

setModified

public void setModified(boolean value)
Specified by:
setModified in interface IDecisionMethod

getEditor

public IDecisionMethodEditor getEditor()
Description copied from interface: IDecisionMethod
Each rule provides an editor, which is a class implementing IDecisionMethodEditor. The editor shall provide user interface for visualization and modification of various method settings.

Specified by:
getEditor in interface IDecisionMethod
Returns:
IDecisionMethodEditor

fromXML

public void fromXML(org.w3c.dom.Element xml)
             throws XMLDecisionMethodException
Specified by:
fromXML in interface XMLSerializable
Throws:
XMLDecisionMethodException

toShallowXML

public org.w3c.dom.Element toShallowXML(org.w3c.dom.Document document)
                                 throws XMLDecisionMethodException
Specified by:
toShallowXML in interface XMLSerializable
Throws:
XMLDecisionMethodException

toXML

public org.w3c.dom.Element toXML(org.w3c.dom.Document document)
                          throws XMLDecisionMethodException
Specified by:
toXML in interface XMLSerializable
Throws:
XMLDecisionMethodException

setRules

public void setRules(IDecisionRuleList rules)

setCategories

public void setCategories(IDecisionCategories categories)

getPriority

public int getPriority()
Specified by:
getPriority in interface IDecisionMethodPrority

setPriority

public void setPriority(int priority)
Specified by:
setPriority in interface IDecisionMethodPrority

testRulesWithSelector

public int testRulesWithSelector()
                          throws java.lang.Exception
Throws:
java.lang.Exception

walkRules

public void walkRules(IDecisionRule rule,
                      IProcessRule processor)
               throws DecisionMethodException
Specified by:
walkRules in interface IDecisionMethod
Throws:
DecisionMethodException

walkRules

protected void walkRules(IDecisionRule rule,
                         java.util.ArrayList<java.lang.Integer> visited,
                         IProcessRule processor)
                  throws DecisionMethodException
Throws:
DecisionMethodException

getImage

public java.awt.image.BufferedImage getImage(org.openscience.cdk.interfaces.IAtomContainer mol)
                                      throws ambit2.base.exceptions.AmbitException
Specified by:
getImage in interface ambit2.core.data.IStructureDiagramHighlights
Throws:
ambit2.base.exceptions.AmbitException

getImage

public java.awt.image.BufferedImage getImage(org.openscience.cdk.interfaces.IAtomContainer mol,
                                             java.lang.String ruleID,
                                             int width,
                                             int height,
                                             boolean atomnumbers)
                                      throws ambit2.base.exceptions.AmbitException
Specified by:
getImage in interface ambit2.core.data.IStructureDiagramHighlights
Throws:
ambit2.base.exceptions.AmbitException

setWeb

public void setWeb(java.lang.Boolean web)
Specified by:
setWeb in interface IDecisionMethod

isWeb

public boolean isWeb()
Specified by:
isWeb in interface IDecisionMethod

getLegend

public java.awt.image.BufferedImage getLegend(int width,
                                              int height)
                                       throws ambit2.base.exceptions.AmbitException
Specified by:
getLegend in interface ambit2.core.data.IStructureDiagramHighlights
Throws:
ambit2.base.exceptions.AmbitException

retrieveExplanation

protected java.lang.String retrieveExplanation(java.lang.String resourceBundle)


Copyright © 2004-2012 Ideaconsult Ltd.. All Rights Reserved.