uk.ac.ic.doc.automed.reps
Class Network

java.lang.Object
  extended by uk.ac.ic.doc.automed.reps.Network
All Implemented Interfaces:
Positionable

public class Network
extends java.lang.Object
implements Positionable


Nested Class Summary
(package private) static class Network.NetworkSchemaChangeListener
          Add to a Schema to make it listen to changes, and update the corresponding Network and Node
 
Field Summary
private static java.util.List allNetworks
           
private  java.awt.Color bgColor
           
private  boolean cyclic
           
static int DEFAULT_INDENT
           
private  boolean deleted
           
private  boolean directed
           
private  java.awt.Color fgColor
           
private  int lblxpos
           
private  int lblypos
           
private  boolean maximal
           
private  java.lang.String name
           
(package private)  java.util.Set networkChangeListeners
           
(package private) static java.util.Set networksListeners
           
(package private)  java.util.Map nodes
           
static java.lang.String NONVIRTUAL_SCHEMA_SEPARATOR
          The string to put between any non-virtual schemas in the network name
private  java.awt.Color textColor
           
private  boolean tree
           
private  int xpos
           
private  int ypos
           
 
Constructor Summary
  Network(Schema[][] paths, int indent)
          Constructs a directed network from the schema paths supplied.
private Network(java.lang.String name, boolean directed, boolean maximal, int indent)
           
  Network(java.lang.String name, Schema[][] paths, boolean directed, boolean maximal, int indent)
          Constructs a network from the schema paths supplied.
  Network(java.lang.String name, Schema[][] paths, int indent)
          Constructs a directed network from the schema paths supplied.
 
Method Summary
private  void activateNetwork(int indent)
           
 boolean addNetworkChangeListener(NetworkChangeListener scl)
           
static boolean addNetworksListener(NetworksListener nl)
           
 boolean areRelativesMaximal()
           
 boolean contains(Node node)
          Returns whether or not the network contains the supplied node.
 boolean contains(Schema schema)
          Returns whether or not the network contains the supplied schema
 boolean contains(java.lang.String name)
          Returns whether or not the network contains the named schema
 boolean deleted()
          Return true when the Network class is finished with, after all Schemas have been deleted from it
(package private)  void fireNetworkChangeEvent(int type, java.lang.Object delta)
           
(package private) static void fireNetworksEvent(int type, java.lang.Object delta)
           
 java.awt.Point getAbsolutePosition()
          Same behaviour as getPosition() since Network instances are not placed relative to other Positionables.
private static Network[] getAllNetworks(int indent)
          Returns an array of all networks in the repository.
 Node[] getAllNodes()
           
 java.awt.Color getBackgroundColor()
           
 java.awt.Color getForegroundColor()
           
 java.lang.String getLabel()
          Get the text used to label this Network.
 java.awt.Point getLabelPosition()
           
 int getLabelXPos()
           
 int getLabelYPos()
           
 Node[] getLeafs()
           
 java.lang.String getName()
           
static Network getNetwork(Schema s)
          Returns the complete undirected network that contains schema s.
static java.util.List getNetworks(boolean recompute, int indent)
          Return a list that contains all Networks held in the repository.
static java.util.List getNetworks(int indent)
          Return a List that contains all Networks held in the repository.
 Node getNode(Node node)
          Deprecated.  
 Node getNode(Schema schema)
          Returns the network node representing the supplied schema
 Node getNode(java.lang.String name)
          Returns the network node representing the named schema
 java.awt.Point getPosition()
          Return the Point that represents the position of this Positionable in a Panel.
 Positionable getPositionedRelativeTo()
          Return the Positionable this is relative to.
 java.lang.Object getRepObject()
           
 Node[] getRoots()
           
 Schema[] getSchemas()
          Return all the Schemas in this network.
 java.awt.Color getTextColor()
           
 int getXPos()
           
 int getYPos()
           
 boolean isCyclic()
           
 boolean isDirected()
           
 boolean isTree()
           
private  void remove()
          Only the Network class should remove itself, when it finds that it no longer contains any Schemas.
 boolean removeNetworkChangeListener(NetworkChangeListener scl)
           
static boolean removeNetworksListener(NetworksListener nl)
           
 void setAbsolutePosition(int x, int y)
          Same behaviour as #setPosition() since Network instances are not placed relative to other Positionables.
 void setBackgroundColor(java.awt.Color c)
           
 void setForegroundColor(java.awt.Color c)
           
 void setLabel(java.lang.String label)
           
 void setLabelPosition(int x, int y)
           
 void setLabelXPos(int x)
           
 void setLabelYPos(int y)
           
 void setPosition(int x, int y)
           
 void setTextColor(java.awt.Color c)
           
 void setXPos(int x)
           
 void setYPos(int y)
           
private  java.lang.String suggestName()
           
 java.lang.String toString()
           
private  void trawlNetwork(Node ns, java.util.Set visited)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

private java.lang.String name

directed

private boolean directed

maximal

private boolean maximal

cyclic

private boolean cyclic

tree

private boolean tree

deleted

private boolean deleted

xpos

private int xpos

ypos

private int ypos

lblxpos

private int lblxpos

lblypos

private int lblypos

DEFAULT_INDENT

public static final int DEFAULT_INDENT
See Also:
Constant Field Values

NONVIRTUAL_SCHEMA_SEPARATOR

public static final java.lang.String NONVIRTUAL_SCHEMA_SEPARATOR
The string to put between any non-virtual schemas in the network name

See Also:
Constant Field Values

nodes

java.util.Map nodes

allNetworks

private static java.util.List allNetworks

fgColor

private java.awt.Color fgColor

bgColor

private java.awt.Color bgColor

textColor

private java.awt.Color textColor

networkChangeListeners

java.util.Set networkChangeListeners

networksListeners

static java.util.Set networksListeners
Constructor Detail

Network

public Network(Schema[][] paths,
               int indent)
        throws IntegrityException
Constructs a directed network from the schema paths supplied. Each path's first schema is a root of the network. Not sure what this will do if the paths don't all overlap. Note that the paths don't have to bear any relationship to the contents of the repository - most likely use is to represent a sub-network of a complete network.

Throws:
IntegrityException

Network

public Network(java.lang.String name,
               Schema[][] paths,
               int indent)
        throws IntegrityException
Constructs a directed network from the schema paths supplied. Not sure what this will do if the paths don't all overlap. Note that the paths don't have to bear any relationship to the contents of the repository - most likely use is to represent a sub-network of a complete network.

Parameters:
name - The name to give the network
Throws:
IntegrityException

Network

public Network(java.lang.String name,
               Schema[][] paths,
               boolean directed,
               boolean maximal,
               int indent)
        throws IntegrityException
Constructs a network from the schema paths supplied. Not sure what this will do if the paths don't all overlap. Note that the paths don't have to bear any relationship to the contents of the repository - most likely use is to represent a sub-network of a complete network.

Parameters:
name - The name to give the network
directed - Shoud the network be directed
maximal - If not directed, should each nodes parents and children be the empty set or the same as the adjacent set for the node
Throws:
IntegrityException

Network

private Network(java.lang.String name,
                boolean directed,
                boolean maximal,
                int indent)
Method Detail

getName

public java.lang.String getName()

isDirected

public boolean isDirected()

isCyclic

public boolean isCyclic()

isTree

public boolean isTree()

areRelativesMaximal

public boolean areRelativesMaximal()

contains

public boolean contains(java.lang.String name)
Returns whether or not the network contains the named schema

Parameters:
name - The name of the schema
Returns:
true if the network contatins the schema, false otherwise

contains

public boolean contains(Schema schema)
Returns whether or not the network contains the supplied schema

Parameters:
name - The schema to be tested
Returns:
true if the network contatins the schema, false otherwise

contains

public boolean contains(Node node)
Returns whether or not the network contains the supplied node. Note that the network may contain the schema represented by the node but not contain the node - the node may represent the schema in a different network instance.

Parameters:
node - A node representing the schema to be tested
Returns:
true if the network contatins the node, false otherwise

getNode

public Node getNode(java.lang.String name)
Returns the network node representing the named schema

Parameters:
name - Name of the schema whose Node is to be returned
Returns:
The Node which represents the named schema

getNode

public Node getNode(Schema schema)
Returns the network node representing the supplied schema

Parameters:
schema - The schema whose Node is to be returned
Returns:
The Node which represents the supplied schema

getNode

public Node getNode(Node node)
Deprecated. 

Probably not the most useful method in the world, should return the parameter passed to it. Don't know why it's here


getAllNodes

public Node[] getAllNodes()

getSchemas

public Schema[] getSchemas()
Return all the Schemas in this network.


getRoots

public Node[] getRoots()

getLeafs

public Node[] getLeafs()

activateNetwork

private void activateNetwork(int indent)

getNetworks

public static java.util.List getNetworks(int indent)
Return a List that contains all Networks held in the repository. If the networks have previously been computed from the stored transformations then they will not be regenerated.

Returns:
List of Networks held in the repository.

getNetworks

public static java.util.List getNetworks(boolean recompute,
                                         int indent)
Return a list that contains all Networks held in the repository.

Parameters:
recompute - If set true, then the set of Networks will be recomputed from the description of pathways held in the recompository, even if this has previously been done. This means that there may be duplicates of the same network being represented by different Network instances. Thus normally this parameter should be false unless some problem is suspected where the existing set of Network instances are suspected not to reflect the contents of the repository

remove

private void remove()
Only the Network class should remove itself, when it finds that it no longer contains any Schemas. To remove a network, you need to remove all the underlying schemas.


deleted

public boolean deleted()
Return true when the Network class is finished with, after all Schemas have been deleted from it


getAllNetworks

private static Network[] getAllNetworks(int indent)
Returns an array of all networks in the repository. The networks are undirected and together partition the repository (every schema in the repository will be in exactly one network)


suggestName

private java.lang.String suggestName()

getNetwork

public static Network getNetwork(Schema s)
Returns the complete undirected network that contains schema s.

Parameters:
s - The schema to trawl the network from
name - The name to give the new network or null for a default name
Returns:
The complete, undirected network containing schema s

trawlNetwork

private void trawlNetwork(Node ns,
                          java.util.Set visited)
                   throws IntegrityException
Throws:
IntegrityException

toString

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

getXPos

public int getXPos()
Specified by:
getXPos in interface Positionable

getYPos

public int getYPos()
Specified by:
getYPos in interface Positionable

getPosition

public java.awt.Point getPosition()
Description copied from interface: Positionable
Return the Point that represents the position of this Positionable in a Panel. Note that depending on the implementation of the interface, this might a coordinate relative to some other positionable

Specified by:
getPosition in interface Positionable

getPositionedRelativeTo

public Positionable getPositionedRelativeTo()
Description copied from interface: Positionable
Return the Positionable this is relative to. If not relative to some other Positionable then return null.

Specified by:
getPositionedRelativeTo in interface Positionable

getAbsolutePosition

public java.awt.Point getAbsolutePosition()
Same behaviour as getPosition() since Network instances are not placed relative to other Positionables.

Specified by:
getAbsolutePosition in interface Positionable

setXPos

public void setXPos(int x)
Specified by:
setXPos in interface Positionable

setYPos

public void setYPos(int y)
Specified by:
setYPos in interface Positionable

setPosition

public void setPosition(int x,
                        int y)
Specified by:
setPosition in interface Positionable

setAbsolutePosition

public void setAbsolutePosition(int x,
                                int y)
Same behaviour as #setPosition() since Network instances are not placed relative to other Positionables.

Specified by:
setAbsolutePosition in interface Positionable

getLabelXPos

public int getLabelXPos()
Specified by:
getLabelXPos in interface Positionable

getLabelYPos

public int getLabelYPos()
Specified by:
getLabelYPos in interface Positionable

setLabelXPos

public void setLabelXPos(int x)
Specified by:
setLabelXPos in interface Positionable

setLabelYPos

public void setLabelYPos(int y)
Specified by:
setLabelYPos in interface Positionable

getLabelPosition

public java.awt.Point getLabelPosition()
Specified by:
getLabelPosition in interface Positionable

setLabelPosition

public void setLabelPosition(int x,
                             int y)
Specified by:
setLabelPosition in interface Positionable

getLabel

public java.lang.String getLabel()
Get the text used to label this Network. Note that this will differ from getName() at least in that any characters that need escaping for printing are escaped.

Specified by:
getLabel in interface Positionable
Returns:
Name of this schema used for writing on to the screen or file

setLabel

public void setLabel(java.lang.String label)
Specified by:
setLabel in interface Positionable

getRepObject

public java.lang.Object getRepObject()
Specified by:
getRepObject in interface Positionable

getForegroundColor

public java.awt.Color getForegroundColor()
Specified by:
getForegroundColor in interface Positionable

setForegroundColor

public void setForegroundColor(java.awt.Color c)
Specified by:
setForegroundColor in interface Positionable

getBackgroundColor

public java.awt.Color getBackgroundColor()
Specified by:
getBackgroundColor in interface Positionable

setBackgroundColor

public void setBackgroundColor(java.awt.Color c)
Specified by:
setBackgroundColor in interface Positionable

getTextColor

public java.awt.Color getTextColor()
Specified by:
getTextColor in interface Positionable

setTextColor

public void setTextColor(java.awt.Color c)
Specified by:
setTextColor in interface Positionable

addNetworkChangeListener

public boolean addNetworkChangeListener(NetworkChangeListener scl)

removeNetworkChangeListener

public boolean removeNetworkChangeListener(NetworkChangeListener scl)

fireNetworkChangeEvent

void fireNetworkChangeEvent(int type,
                            java.lang.Object delta)

addNetworksListener

public static boolean addNetworksListener(NetworksListener nl)

removeNetworksListener

public static boolean removeNetworksListener(NetworksListener nl)

fireNetworksEvent

static void fireNetworksEvent(int type,
                              java.lang.Object delta)