Spreadsheet Toolkit

corpus.excel
Class Cell

java.lang.Object
  |
  +--corpus.excel.Component
        |
        +--corpus.excel.Cell
All Implemented Interfaces:
java.io.Serializable

public class Cell
extends Component

Used to store the internal representation of a Cell.
TODO:

See Also:
Serialized Form

Field Summary
protected  int[] coords
          The coordinates of this cell 0: Column 1: Row 2: Depth
protected  java.lang.String excelref
          The exact reference Excel gave this Cell.
protected  java.lang.String formula
          The formula in the cell.
protected  java.lang.String value
          The value in the cell.
 
Fields inherited from class corpus.excel.Component
haltOnErrors
 
Constructor Summary
Cell(int col, int row)
          Creates a new Cell at Col x and Row y
Cell(int col, int row, java.lang.String value, java.lang.String formula)
          Creates a new Cell at Col x and Row y with a value and a formula (both as strings).
Cell(int col, int row, java.lang.String value, java.lang.String formula, java.lang.String[] sheetnames)
          Creates a new Cell at Col x and Row y with a value and a formula.
 
Method Summary
 boolean absCol()
           
 boolean absRow()
           
 void addReferredFrom(Cell r)
          Add a cell that refers to this cell.
 void addReferTo(Cell r)
          Add a cell that this Cell refers to.
static int alphaTodig(java.lang.String in)
          Special converter to change an Alpha style Excel reference into a Row number
 Grid ancestorTreeDepthDFS()
           
 double angleBetweenDeg(Cell c2)
          The angle between this cell and the parameter cell, as measured from a vertial line going up the screen from this cell.
 int[] anglesOutgoing(int size)
           
static void classification(Cell c)
          Dumps the classification of the cell to System.out
static java.lang.String classificationString(Cell c)
           
static java.lang.String digToalpha(int d)
          Special converter to change a Excel row reference into a Alpha style reference
 void display()
          Displays a window containing details about this particular cell.
 void display(WorkSheet ws)
          Displays a window containing details about this particular cell.
static double distanceBetween(Cell c1, Cell c2)
           
 double distanceFrom(Cell c2)
           
 java.util.Vector getAllConnectedCells()
          Traces all the cells that are in some way connected to the start cell.
static java.util.Vector getAllConnectedCells(Cell start, java.util.Vector visited)
          Traces all the cells that are in some way connected to the start cell.
 java.util.Vector getAncestors()
          Finds all the cells that refer to this cell.
 int getCol()
           
 java.util.Vector getDescendents()
          Finds all the cells that this cell refers to.
static java.util.Vector getFamilyTree(Cell target)
          Constructs an array of cells that are either dependent on the value in this cell or that this cell depends on.
 Formula getFormula()
           
 java.lang.String getFormulaString()
           
 java.lang.String getHTMLFormulaString()
           
 java.awt.Point getPoint()
           
 java.util.Vector getReferredFrom()
           
 java.util.Iterator getReferredFromIterator()
           
 java.util.Vector getReferTo()
           
 java.util.Iterator getReferToIterator()
           
 Cell getRelativeCell(WorkSheet ws, int x, int y)
          Retrives the cell that is x columns and y rows relative from this cell.
 int getRow()
           
 java.lang.String getValueString()
           
 WorkSheet getWorkSheet()
           
 boolean hasFormula()
           
 boolean isCopyEquivalent(Cell c)
          Copy-Equivalence exists, if the formulas are absolutely identical (i.e. the cell contents has been copied from one cell into the other, either by copy and paste, or by retyping the same formula).
 boolean isEmpty()
           
 boolean isEndCell()
           
 boolean isInBetween()
           
 boolean isInput()
           
 boolean isLogicallyEquivalent(Cell c)
          2.
 boolean isOrphan()
           
 boolean isPureCalculation()
           
 boolean isRoot()
           
 boolean isStructurallyEquivalent(Cell c)
          3.
 boolean isTranslation()
           
 int length()
          The length of the excel style reference as a string.
static void main(java.lang.String[] args)
          You should know what this does.
static double ManhattanDistanceBetween(Cell c1, Cell c2)
           
 Formula process(java.lang.String[] sheetnames)
          Given the sheetnames for this cell, create the Formula object.
static void reference(Cell from, Cell to)
          The first cell (from) references the second cell(to).
 int referredFrom()
           
 int referTo()
           
 void setFormula(java.lang.String newFormula)
          Sets cells formula and creates Formula object.
 void setSheetNames(java.lang.String[] sheetnames)
          Sheetnames are used to determine cell depth during parsing.
 void setValue(java.lang.String newValue)
           
static Grid toGrid(Cell[] cells)
          Converts an array of cells into a Grid.
static Grid toGrid(java.util.Vector cells)
          Converts an array of cells into a Grid.
 java.lang.String toHTMLString()
          Converts information about this component into an HTML formatted String.
 java.lang.String toString()
          Converts information about this cell into a String.
 java.lang.String toStringBasic()
           
 java.lang.String toStringRC()
          Converts information about this cell into a String.
 int treeDepthDFS()
           
 Grid treeGrid()
          Creates a grid to display the individual tree.
 int treeMaxBreadthDFS()
           
 java.lang.String treeToGraph()
          Convert a dependency tree into a brace style format.
 java.lang.String treeToString()
          Convert a dependency tree into a brace style format.
static int[] xydistanceBetween(Cell c1, Cell c2)
           
 int[] xydistanceFrom(Cell c2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

excelref

protected java.lang.String excelref
The exact reference Excel gave this Cell.


coords

protected int[] coords
The coordinates of this cell 0: Column 1: Row 2: Depth


value

protected java.lang.String value
The value in the cell. I.e. "3.14"


formula

protected java.lang.String formula
The formula in the cell. "=A1"

Constructor Detail

Cell

public Cell(int col,
            int row)
Creates a new Cell at Col x and Row y


Cell

public Cell(int col,
            int row,
            java.lang.String value,
            java.lang.String formula)
Creates a new Cell at Col x and Row y with a value and a formula (both as strings).


Cell

public Cell(int col,
            int row,
            java.lang.String value,
            java.lang.String formula,
            java.lang.String[] sheetnames)
Creates a new Cell at Col x and Row y with a value and a formula. Also records sheetnames.

Method Detail

process

public Formula process(java.lang.String[] sheetnames)
                throws java.lang.Exception
Given the sheetnames for this cell, create the Formula object. Called proir to serialisation.

java.lang.Exception

getCol

public int getCol()
Returns:
the x position of the cell as an int.

getRow

public int getRow()
Returns:
the y position of the cell as an int.

getPoint

public java.awt.Point getPoint()
Returns:
a point containing the column as x and the row as y

absCol

public boolean absCol()
Returns:
if the column reference is absolute.

absRow

public boolean absRow()
Returns:
if the row reference is absolute.

setValue

public void setValue(java.lang.String newValue)
Parameters:
newValue - the new value for the cell.

setFormula

public void setFormula(java.lang.String newFormula)
Sets cells formula and creates Formula object.

Parameters:
newFormula - the new formula for the cell.

getFormula

public Formula getFormula()
Returns:
the formula for the cell as parsed from the String formula.

hasFormula

public boolean hasFormula()
Returns:
true if this cell contains a formula.

getValueString

public java.lang.String getValueString()
Returns:
the value for the cell.

getFormulaString

public java.lang.String getFormulaString()
Returns:
the String version of the formula for the cell.

getHTMLFormulaString

public java.lang.String getHTMLFormulaString()
Returns:
the String version of the formula for the cell.

getWorkSheet

public WorkSheet getWorkSheet()
Returns:
the WorkSheet for the cell.

setSheetNames

public void setSheetNames(java.lang.String[] sheetnames)
Sheetnames are used to determine cell depth during parsing.


getRelativeCell

public Cell getRelativeCell(WorkSheet ws,
                            int x,
                            int y)
Retrives the cell that is x columns and y rows relative from this cell.


reference

public static void reference(Cell from,
                             Cell to)
The first cell (from) references the second cell(to). Performs addReferTo and addReferredFrom pair.


addReferTo

public void addReferTo(Cell r)
Add a cell that this Cell refers to. An Ancestor.

Parameters:
r - the cell referred to.

referTo

public int referTo()
Returns:
The number of cells that are referred to from this cell (Fan out). The Ancestors.

getReferTo

public java.util.Vector getReferTo()
Returns:
A vector of cells that are referred to by this cell (Fan out). The Ancestors.

getReferToIterator

public java.util.Iterator getReferToIterator()
Returns:
An iterator to the cells that are referred to by this cell. The Ancestors.

addReferredFrom

public void addReferredFrom(Cell r)
Add a cell that refers to this cell. A Descendent.

Parameters:
r - the refering cell.

referredFrom

public int referredFrom()
Returns:
The number of cells that refer to this cell (Fan in). The Descendents.

getReferredFrom

public java.util.Vector getReferredFrom()
Returns:
A vector of cells that refer to this cell. The Descendents.

getReferredFromIterator

public java.util.Iterator getReferredFromIterator()
Returns:
An iterator to the cells that refer to this cell. The Descendents.

isOrphan

public boolean isOrphan()
Returns:
true if the cell is an orphan, (no incomming or outgoing references present)

isEmpty

public boolean isEmpty()
Returns:
true if the cell does not contain a Value or Formula.

isInput

public boolean isInput()
Returns:
true if the cell contains a Value but no Formula.

isRoot

public boolean isRoot()
Returns:
true if the cell is referenced by other cells but makes no references itself. I.e. a cell that has no ancestors and has at least one descendent.

isInBetween

public boolean isInBetween()
Returns:
true if the cell both referecnes and is referenced by other cells.

isEndCell

public boolean isEndCell()
Returns:
true if the cell referecnes other cells and is _not_ referenced by other cells.

isPureCalculation

public boolean isPureCalculation()
Returns:
true if the cell contains a Formula but makes no reference to any other cells value.

isTranslation

public boolean isTranslation()
Returns:
true if the cell contains only a single reference to another cell, i.e. "=B3".

isCopyEquivalent

public boolean isCopyEquivalent(Cell c)
Copy-Equivalence exists, if the formulas are absolutely identical (i.e. the cell contents has been copied from one cell into the other, either by copy and paste, or by retyping the same formula).


isLogicallyEquivalent

public boolean isLogicallyEquivalent(Cell c)
2. Logical- Equivalence exists, if the formulas differ only in constant values and absolute references.


isStructurallyEquivalent

public boolean isStructurallyEquivalent(Cell c)
3. Structural- Equivalence exists, if the formulas consist of the same operators in the same order, but the operators may be applied to different arguments.


toString

public java.lang.String toString()
Converts information about this cell into a String. A1 style

Specified by:
toString in class Component

toHTMLString

public java.lang.String toHTMLString()
Converts information about this component into an HTML formatted String.

Specified by:
toHTMLString in class Component

toStringRC

public java.lang.String toStringRC()
Converts information about this cell into a String. R1C1 style


toStringBasic

public java.lang.String toStringBasic()
Returns:
The prefix reference for this cell.

distanceFrom

public double distanceFrom(Cell c2)
Returns:
The euclidian distance between this and the parameter cell.

distanceBetween

public static double distanceBetween(Cell c1,
                                     Cell c2)
Returns:
The euclidian distance between two cells.

ManhattanDistanceBetween

public static double ManhattanDistanceBetween(Cell c1,
                                              Cell c2)
Returns:
The Manhattan distance (city block) between two cells.

xydistanceFrom

public int[] xydistanceFrom(Cell c2)
Returns:
The x and y distance components between this and the parameter cell.

xydistanceBetween

public static int[] xydistanceBetween(Cell c1,
                                      Cell c2)
Returns:
The x[0] and y[1] distance components between two cells.

alphaTodig

public static int alphaTodig(java.lang.String in)
Special converter to change an Alpha style Excel reference into a Row number


digToalpha

public static java.lang.String digToalpha(int d)
Special converter to change a Excel row reference into a Alpha style reference


length

public int length()
The length of the excel style reference as a string.


getDescendents

public java.util.Vector getDescendents()
Finds all the cells that this cell refers to. Descendents


getAncestors

public java.util.Vector getAncestors()
Finds all the cells that refer to this cell. Ancestors


getFamilyTree

public static java.util.Vector getFamilyTree(Cell target)
Constructs an array of cells that are either dependent on the value in this cell or that this cell depends on. The combination of Ancestors and Descendents.


getAllConnectedCells

public java.util.Vector getAllConnectedCells()
Traces all the cells that are in some way connected to the start cell.


getAllConnectedCells

public static java.util.Vector getAllConnectedCells(Cell start,
                                                    java.util.Vector visited)
Traces all the cells that are in some way connected to the start cell.


toGrid

public static Grid toGrid(Cell[] cells)
Converts an array of cells into a Grid.


toGrid

public static Grid toGrid(java.util.Vector cells)
Converts an array of cells into a Grid.


treeGrid

public Grid treeGrid()
Creates a grid to display the individual tree.


treeDepthDFS

public int treeDepthDFS()
Returns:
The deepest level that can be reached in a dependency tree from this node.

ancestorTreeDepthDFS

public Grid ancestorTreeDepthDFS()
Returns:
The deepest level that can be reached in a ancestor tree from this node.

treeMaxBreadthDFS

public int treeMaxBreadthDFS()
Returns:
The maximal breadth that can be found in a dependency tree from this node following dependents.

treeToString

public java.lang.String treeToString()
Convert a dependency tree into a brace style format.


treeToGraph

public java.lang.String treeToGraph()
Convert a dependency tree into a brace style format. Using Basic notation.


anglesOutgoing

public int[] anglesOutgoing(int size)
Returns:
An int[] containing the number of outgoing references in each angle range. The number of angles is determined by

angleBetweenDeg

public double angleBetweenDeg(Cell c2)
The angle between this cell and the parameter cell, as measured from a vertial line going up the screen from this cell.


display

public void display()
Displays a window containing details about this particular cell.


display

public void display(WorkSheet ws)
Displays a window containing details about this particular cell.


main

public static void main(java.lang.String[] args)
You should know what this does. Various tests to Cell class functionallity.


classificationString

public static java.lang.String classificationString(Cell c)

classification

public static void classification(Cell c)
Dumps the classification of the cell to System.out


Spreadsheet Toolkit

Project Home Page