uk.ac.essex.ia.media
Class OperatorManager

java.lang.Object
  extended by uk.ac.essex.ia.media.OperatorManager

public class OperatorManager
extends java.lang.Object

Class that manages the initilisation of operators. It uses an xml file to store names of operators and parses the file at runtime so it knows what operators are available. This allows users of ImageApp to create there own operators and integrate them into ImageApp without any changes to the core code.


Field Summary
protected  java.util.ArrayList actions
           
protected  java.lang.String fileName
           
static int HEIGHT
          Height of the opertors vertex
static int INCREMENT
          The increment used to seperate the ports
static int NO_OF_DEST_PORTS
          Default number of output ports
static int NO_OF_SOURCE_PORTS
          Default number of input ports
protected  java.util.HashMap opClassesToTags
           
static java.lang.String OPERATOR_DIR_XML
           
protected  java.lang.Class[] operatorClasses
           
protected  OperatorDescriptor[] operatorDescriptors
           
protected  java.util.HashMap opGroupNameToActions
           
protected  java.util.HashMap opGroupNameToOperators
           
protected  java.util.HashMap opGroupToOperators
          This maps every group to its operator descriptors ie/ OperatorGroup --> OperatorDescriptor[]
protected  java.util.HashMap opIDToClass
           
protected  java.util.ArrayList textMenus
           
protected  OperatorGroup[] topLevelOperatorGroups
           
static int WIDTH
          Width of opertors vertex
static int X_POS
          X Position of this fig
static int Y_POS
          Y position of this Fig
 
Method Summary
protected  void createActions()
          This class creates a set of actions, one per operator.
protected  void createClasses()
          This initialises the variables opClassesToTags, opIDToClass and operatorClasses.
protected  javax.swing.JMenu[] createJMenus()
          Creates a new set of menus one for each action group.
static OperatorManager getInstance()
           
 java.util.ArrayList getOperatorActions()
           
 java.lang.Class getOperatorClass(java.lang.String operatorID)
           
 OperatorDescriptor getOperatorDescriptor(java.lang.Class operatorClass)
           
 javax.swing.JMenu[] getTextMenus()
           
 boolean getValidate()
           
static com.jgraph.graph.DefaultGraphCell insert(com.jgraph.JGraph graph, Operator operator, java.awt.Point point)
          TODO: Move this ??? See PersistenceManager.insert(com.jgraph.JGraph, uk.ac.essex.ia.Operator, java.awt.Point, uk.ac.essex.ia.opview.xml.Port[]) Insert an operator into the given graph at the given point
 void loadOperatorsIn(OperatorGroup group)
          Recursive function to load the two hashmaps opGroupNameToOperators and opGroupToOperators.
static void main(java.lang.String[] args)
           
protected  void parseFile()
          Parse the configuration file using castor
 void setValidate(boolean shouldValidate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X_POS

public static final int X_POS
X Position of this fig

See Also:
Constant Field Values

Y_POS

public static final int Y_POS
Y position of this Fig

See Also:
Constant Field Values

WIDTH

public static final int WIDTH
Width of opertors vertex

See Also:
Constant Field Values

HEIGHT

public static final int HEIGHT
Height of the opertors vertex

See Also:
Constant Field Values

INCREMENT

public static final int INCREMENT
The increment used to seperate the ports

See Also:
Constant Field Values

OPERATOR_DIR_XML

public static final java.lang.String OPERATOR_DIR_XML
See Also:
Constant Field Values

NO_OF_SOURCE_PORTS

public static int NO_OF_SOURCE_PORTS
Default number of input ports


NO_OF_DEST_PORTS

public static int NO_OF_DEST_PORTS
Default number of output ports


topLevelOperatorGroups

protected OperatorGroup[] topLevelOperatorGroups

operatorDescriptors

protected OperatorDescriptor[] operatorDescriptors

actions

protected java.util.ArrayList actions

textMenus

protected java.util.ArrayList textMenus

fileName

protected java.lang.String fileName

operatorClasses

protected java.lang.Class[] operatorClasses

opClassesToTags

protected java.util.HashMap opClassesToTags

opIDToClass

protected java.util.HashMap opIDToClass

opGroupToOperators

protected java.util.HashMap opGroupToOperators
This maps every group to its operator descriptors ie/ OperatorGroup --> OperatorDescriptor[]


opGroupNameToOperators

protected java.util.HashMap opGroupNameToOperators

opGroupNameToActions

protected java.util.HashMap opGroupNameToActions
Method Detail

getInstance

public static OperatorManager getInstance()
                                   throws java.lang.Exception
Returns:
OperatorManager - The singleton instance
Throws:
java.lang.Exception

insert

public static com.jgraph.graph.DefaultGraphCell insert(com.jgraph.JGraph graph,
                                                       Operator operator,
                                                       java.awt.Point point)
TODO: Move this ??? See PersistenceManager.insert(com.jgraph.JGraph, uk.ac.essex.ia.Operator, java.awt.Point, uk.ac.essex.ia.opview.xml.Port[]) Insert an operator into the given graph at the given point

Parameters:
graph -
operator -
point -

getValidate

public boolean getValidate()
Returns:
boolean -true if this class should validate the XML it parses

setValidate

public void setValidate(boolean shouldValidate)
Parameters:
shouldValidate - - whether it should validate the XML

getOperatorDescriptor

public OperatorDescriptor getOperatorDescriptor(java.lang.Class operatorClass)
Parameters:
operatorClass - - The class object of the operator whose xml config you want
Returns:
OperatorDescriptor - The operator tag theat wraps the xml config for the operator

getOperatorActions

public java.util.ArrayList getOperatorActions()
Returns:
an array list of all actions that add a new operator to the

getTextMenus

public javax.swing.JMenu[] getTextMenus()
Returns:
JMenu[] - containing the operators actions

getOperatorClass

public java.lang.Class getOperatorClass(java.lang.String operatorID)
Parameters:
operatorID -

loadOperatorsIn

public void loadOperatorsIn(OperatorGroup group)
Recursive function to load the two hashmaps opGroupNameToOperators and opGroupToOperators. This is recursive as operator groups can contain operator groups.

Parameters:
group -

createActions

protected void createActions()
This class creates a set of actions, one per operator. The action handles inserting the operator into the currently selected graph. This also intialises the variables actions and opGroupNameToActions.


createClasses

protected void createClasses()
This initialises the variables opClassesToTags, opIDToClass and operatorClasses.


createJMenus

protected javax.swing.JMenu[] createJMenus()
Creates a new set of menus one for each action group. The entries on the menus are the actions that insert an operator into the current graph

See Also:
createActions()

parseFile

protected void parseFile()
                  throws java.lang.Exception
Parse the configuration file using castor

Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)