com.mindfusion.diagramming
Class Cell

java.lang.Object
  extended by com.mindfusion.diagramming.Cell
All Implemented Interfaces:
InplaceEditable, java.io.Externalizable, java.io.Serializable, java.lang.Cloneable

public class Cell
extends java.lang.Object
implements java.lang.Cloneable, java.io.Externalizable, InplaceEditable

Represents a cell in a table. Cells are arranged in a grid of rows and columns, and can span more than one rows or columns if needed. Each cell can display an image and a text label.

Cells are the building blocks of tables. They get their height and width indirectly, from the width of table columns and the height of table rows as set via the Column.setWidth(float) and Row.setHeight(float) methods. Cells can be made to span several rows and columns by calling their setRowSpan(int) and setColumnSpan(int) methods.

A cell can display a text label, as set via the setText(java.lang.String) method. The text alignment is set by calling setTextFormat(com.mindfusion.diagramming.TextFormat). Color of the text in the cells is set via the setTextColor(java.awt.Color) method.

The appearance of a cell can be customized further via the setBrush(com.mindfusion.diagramming.Brush), setImage(java.awt.Image) and setImageAlign(int) methods.

See Also:
Serialized Form

Constructor Summary
Cell()
          Used internally to implement serialization functionality.
Cell(TableNode table)
          Initializes a new Cell instance and assigns the specified table as its parent.
 
Method Summary
 java.lang.Object clone()
          Creates a copy of the cell.
 Brush getBrush()
          Gets the Brush used to fill the cell's interior.
 int getColumnSpan()
          Gets the number of columns spanned by this cell.
 java.awt.geom.Rectangle2D getEditRect(java.awt.geom.Point2D mousePosition)
           
 java.awt.Font getFont()
           
 java.lang.String getHyperLink()
          Gets the hyperlink associated with the cell.
 java.awt.Image getImage()
          Gets the image that is displayed inside the cell.
 int getImageAlign()
          Gets a value indicating how the image displayed inside the cell is aligned relatively to the cell bounds.
 java.lang.String getPlainText()
          Gets the plain text extracted from the formatted text by removing the formatting tags.
 int getRowSpan()
          Gets the number of rows spanned by this cell.
 TableNode getTable()
           
 java.lang.String getText()
          Gets the text that is displayed inside the cell.
 java.awt.Color getTextColor()
          Gets the color used to draw the text of this cell.
 TextFormat getTextFormat()
          Gets a TextFormat object specifying how to format and align the text of this cell.
 java.awt.geom.Dimension2D getTextSize()
          Gets the size of the text displayed in this cell.
 java.lang.String getTextToEdit()
           
 java.lang.String getToolTip()
          Gets the tooltip text that is displayed when the mouse pointer rests for a while over the cell.
protected  void loadFromXml(org.w3c.dom.Element xmlElement, XmlPersistContext context)
           
 void readExternal(java.io.ObjectInput in)
          Implements Externalizable.
 void renderText(java.lang.String text, java.awt.geom.Rectangle2D dest, com.mindfusion.diagramming.DrawTextHint hint)
          Styled text rendering callback.
protected  void saveToXml(org.w3c.dom.Element xmlElement, XmlPersistContext context)
           
 void setBrush(Brush value)
          Sets the Brush used to fill the cell's interior.
 void setColumnSpan(int value)
          Sets the number of columns spanned by this cell.
 void setEditedText(java.lang.String newText)
           
 void setFont(java.awt.Font font)
           
 void setHyperLink(java.lang.String value)
          Sets the hyperlink associated with the cell.
 void setImage(java.awt.Image value)
          Sets the image that should be displayed inside the cell.
 void setImageAlign(int value)
          Sets a value indicating how the image displayed inside the cell should be aligned relatively to the cell bounds.
 void setRowSpan(int value)
          Sets the number of rows spanned by this cell.
 void setText(java.lang.String value)
          Sets the text that should be displayed inside the cell.
 void setTextColor(java.awt.Color value)
          Sets the color used to draw the text of this cell.
 void setTextFormat(TextFormat value)
          Sets a TextFormat object specifying how to format and align the text of this cell.
 void setToolTip(java.lang.String value)
          Sets the tooltip text that should be displayed when the mouse pointer rests for a while over the cell.
 void writeExternal(java.io.ObjectOutput out)
          Implements Externalizable.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cell

public Cell(TableNode table)
Initializes a new Cell instance and assigns the specified table as its parent.

Parameters:
table - The TableNode that contains this cell.

Cell

public Cell()
Used internally to implement serialization functionality.

Method Detail

clone

public java.lang.Object clone()
Creates a copy of the cell.

Overrides:
clone in class java.lang.Object
Returns:
A Cell instance.

getText

public java.lang.String getText()
Gets the text that is displayed inside the cell.

Returns:
A String containing the cell's text.

setText

public void setText(java.lang.String value)
Sets the text that should be displayed inside the cell.

Parameters:
value - A String containing the cell's text.

getHyperLink

public java.lang.String getHyperLink()
Gets the hyperlink associated with the cell.

Returns:
A String containing the cell's hyperlink.

setHyperLink

public void setHyperLink(java.lang.String value)
Sets the hyperlink associated with the cell.

Parameters:
value - A String containing the cell's hyperlink.

getTextFormat

public TextFormat getTextFormat()
Gets a TextFormat object specifying how to format and align the text of this cell.

Returns:
A TextFormat object specifying the text format and alignment.

setTextFormat

public void setTextFormat(TextFormat value)
Sets a TextFormat object specifying how to format and align the text of this cell.

Parameters:
value - A TextFormat object specifying the text format and alignment.

getTextColor

public java.awt.Color getTextColor()
Gets the color used to draw the text of this cell.

Returns:
A Color object representing the text color.

setTextColor

public void setTextColor(java.awt.Color value)
Sets the color used to draw the text of this cell.

Parameters:
value - A Color object representing the text color.

getTextSize

public java.awt.geom.Dimension2D getTextSize()
Gets the size of the text displayed in this cell.


renderText

public void renderText(java.lang.String text,
                       java.awt.geom.Rectangle2D dest,
                       com.mindfusion.diagramming.DrawTextHint hint)
Styled text rendering callback.


getPlainText

public java.lang.String getPlainText()
Gets the plain text extracted from the formatted text by removing the formatting tags.

Returns:
A String containing the cell's text stripped from formatting tags.

getToolTip

public java.lang.String getToolTip()
Gets the tooltip text that is displayed when the mouse pointer rests for a while over the cell.

Returns:
A String containing the cell's tooltip.

setToolTip

public void setToolTip(java.lang.String value)
Sets the tooltip text that should be displayed when the mouse pointer rests for a while over the cell.

Parameters:
value - A String containing the cell's tooltip.

getImage

public java.awt.Image getImage()
Gets the image that is displayed inside the cell.

Returns:
A java.awt.Image object.

setImage

public void setImage(java.awt.Image value)
Sets the image that should be displayed inside the cell.

Parameters:
value - A java.awt.Image object.

getImageAlign

public int getImageAlign()
Gets a value indicating how the image displayed inside the cell is aligned relatively to the cell bounds.

Returns:
One of the ImageAlign constants.

setImageAlign

public void setImageAlign(int value)
Sets a value indicating how the image displayed inside the cell should be aligned relatively to the cell bounds.

Parameters:
value - One of the ImageAlign constants.

getBrush

public Brush getBrush()
Gets the Brush used to fill the cell's interior.

Returns:
A Brush object.

setBrush

public void setBrush(Brush value)
Sets the Brush used to fill the cell's interior.

Parameters:
value - A Brush object.

getTextToEdit

public java.lang.String getTextToEdit()
Specified by:
getTextToEdit in interface InplaceEditable

setEditedText

public void setEditedText(java.lang.String newText)
Specified by:
setEditedText in interface InplaceEditable

getEditRect

public java.awt.geom.Rectangle2D getEditRect(java.awt.geom.Point2D mousePosition)
Specified by:
getEditRect in interface InplaceEditable

getColumnSpan

public int getColumnSpan()
Gets the number of columns spanned by this cell.

Returns:
An integer value specifying the number of spanned columns.

setColumnSpan

public void setColumnSpan(int value)
Sets the number of columns spanned by this cell.

Parameters:
value - An integer value specifying the number of spanned columns.

getRowSpan

public int getRowSpan()
Gets the number of rows spanned by this cell.

Returns:
An integer value specifying the number of spanned rows.

setRowSpan

public void setRowSpan(int value)
Sets the number of rows spanned by this cell.

Parameters:
value - An integer value specifying the number of spanned rows.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Implements Externalizable.

Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Implements Externalizable.

Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

saveToXml

protected void saveToXml(org.w3c.dom.Element xmlElement,
                         XmlPersistContext context)

loadFromXml

protected void loadFromXml(org.w3c.dom.Element xmlElement,
                           XmlPersistContext context)
                    throws javax.xml.transform.TransformerException
Throws:
javax.xml.transform.TransformerException

getTable

public TableNode getTable()

setFont

public void setFont(java.awt.Font font)

getFont

public java.awt.Font getFont()