com.inet.html.views
Class TableView

java.lang.Object
  extended by javax.swing.text.View
      extended by com.inet.html.views.BoxView
          extended by com.inet.html.views.TableView
All Implemented Interfaces:
ILayouted, javax.swing.SwingConstants

public class TableView
extends BoxView
implements ILayouted

This view is represents a table container. It is responsible to build a consistent table structure. Doing so it may move views which are not correct as defined by the HTML standard.
NOTE: This class only structures, it does no layout operations! This is part of the TableLayout


Nested Class Summary
 class TableView.TableCellInfo
          Contains informations about a table cell.
 class TableView.TableColumnGroupInfo
          Contains informations about a table column group.
 class TableView.TableColumnInfo
          Contains informations about a table column.
 class TableView.TableContainer
          The table content except the caption.
 class TableView.TableRowGroup
          Contains informations about a group of rows.
 class TableView.TableRowInfo
          Contains informations about a table row.
 
Field Summary
 
Fields inherited from class com.inet.html.views.BoxView
BASELINE, STATUS_REQ_LAYOUT, STATUS_REQ_PRELAYOUT, STATUS_UPTODATE
 
Fields inherited from class javax.swing.text.View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
TableView(javax.swing.text.Element elem)
          Reads all table data an initiates subviews
TableView(javax.swing.text.Element elem, ViewPainter viewPainter)
          Reads all table data an initiates subviews
 
Method Summary
 void appendElement(javax.swing.text.Element elem)
          Adds an element to this table.
 void changedUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
          
 int getHTMLBorderValue()
          Returns the html border property or -1 if none is set
 Layout getLayout()
          Returns the used Layout Object
 float getMinimumSpan(int axis)
          
 float getPreferredSpan(int axis)
          
 java.awt.Rectangle getSpan()
          Returns the span of this view.
 TableView.TableContainer getTableContainer()
          Returns the table container, which contains a structured and correct model of the table
 javax.swing.text.View getView(int n)
          
 int getViewCount()
          
 void insertUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
          
static boolean isTableContainerElement(javax.swing.text.Element elem)
          Indicates whether elem is da table element which can hold other table elements
 java.awt.Shape modelToView(int pos, java.awt.Shape a, javax.swing.text.Position.Bias b)
          
 void paint(java.awt.Graphics g, java.awt.Shape allocation)
          
 java.awt.Rectangle performLayout(boolean hard)
          This is the final layout method.
 void performLayoutVAlign(int baseline)
          If this box has a overall vertical align, like in table cells for instance, this method calculates teh offset to align the content.
 void performLayoutWidth()
          Layout what is required to determin the width of this view.
 void performPreLayout()
          Causes this view to layout all fixed values and to calculate it's minimum and preferred width.
 void predictWidth(int width)
          Can be used to force a view to a specified width.
 void removeUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
          
 void setParent(javax.swing.text.View parent)
          Sets the parent and constructs the table from the element tree
 java.lang.String toString()
          
 int viewToModel(float x, float y, java.awt.Shape a, javax.swing.text.Position.Bias[] biasReturn)
          
 
Methods inherited from class com.inet.html.views.BoxView
addBoxPainter, factoryPreset, forceLayout, forceLayout, getAlignment, getAutoMarginJustify, getBackgroundValue, getBorderBottomColor, getBorderLeftColor, getBorderRightColor, getBorderTopColor, getBottomInset, getBox, getBoxPainter, getClear, getCompleteHight, getContentHeight, getContentVerticalOffset, getContentWidth, getDirection, getDisplay, getEndOffset, getFirstLineBaseLine, getFloat, getFontSize, getHeightUnit, getHTMLRoot, getJustification, getLeftInset, getLineHeight, getMargins, getOuterHeight, getOuterWidth, getOverflow, getPainter, getPosition, getRenderContext, getResizeWeight, getRightInset, getStartOffset, getStatus, getSwingAlign, getTopInset, getUnicodeBidi, getViewForPosition, getViewIndex, getViewIndex, getVisibility, getWhiteSpace, getWidthUnit, isAbsolutePositioned, isBlock, isBreak, isBreakable, isFloating, isInFlow, isListItemWithMarker, isLTR, isMarker, isNativeLTR, isTableCell, isWidthSet, setBackgroundValue, setBorderBottomColor, setBorderLeftColor, setBorderRightColor, setBorderTopColor, setContentVerticalOffset, setContentWidth, setFirstLineBaseLine, setIsNativeLTR, setJustification, setMarker, setPainter, setRoot, setSize, setSizeContent, setStartAndEndOffset, setStatus, setStatusLocal
 
Methods inherited from class javax.swing.text.View
append, breakView, createFragment, getAttributes, getBreakWeight, getChildAllocation, getContainer, getDocument, getElement, getGraphics, getMaximumSpan, getNextVisualPositionFrom, getParent, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, replace, viewToModel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableView

public TableView(javax.swing.text.Element elem)
Reads all table data an initiates subviews

Parameters:
elem - Table root element

TableView

public TableView(javax.swing.text.Element elem,
                 ViewPainter viewPainter)
Reads all table data an initiates subviews

Parameters:
elem - Table root element
viewPainter - painter to use for painting the view
Method Detail

setParent

public void setParent(javax.swing.text.View parent)
Sets the parent and constructs the table from the element tree

Overrides:
setParent in class BoxView
Parameters:
parent - The parent view of this table

appendElement

public void appendElement(javax.swing.text.Element elem)
Adds an element to this table. The parent is used to resolve the relation between the element and the table within the table model. For instance, if you add a cell directly to an empty table this will automatically create a tbody and a row between the table and the cell. If the element is a content element even the cell would have to be created.

Parameters:
elem - the element to add subclasses

isTableContainerElement

public static boolean isTableContainerElement(javax.swing.text.Element elem)
Indicates whether elem is da table element which can hold other table elements

Parameters:
elem - the inspected element
Returns:
true, if elem is a container, false wotherwise

performLayout

public java.awt.Rectangle performLayout(boolean hard)
This is the final layout method. It has to perform a layout of this view and call the layout of all children. Every change to the size of any view in the document will at least call the performLayout method!

Specified by:
performLayout in class BoxView
Parameters:
hard - If set to true, the status of the children will be ignored and all views will be layouted. This should be done on view-size changes. If set to false the status of the children will be respected and up-to-date views will not be layouted again.
Returns:
the bottom-right point of the layout span, required for overflow calculations

performLayoutWidth

public void performLayoutWidth()
Layout what is required to determin the width of this view. In most cases this method only requires the CSS width setting, the parent's width and the minumum and preferred span. ATTENTION: This method mus be called before layouting the children of a view. Otherwise the children don't get a corrent parent's size.

Specified by:
performLayoutWidth in class BoxView

getPreferredSpan

public float getPreferredSpan(int axis)

Specified by:
getPreferredSpan in class javax.swing.text.View

getMinimumSpan

public float getMinimumSpan(int axis)

Overrides:
getMinimumSpan in class javax.swing.text.View

modelToView

public java.awt.Shape modelToView(int pos,
                                  java.awt.Shape a,
                                  javax.swing.text.Position.Bias b)
                           throws javax.swing.text.BadLocationException

Specified by:
modelToView in class javax.swing.text.View
Throws:
javax.swing.text.BadLocationException

viewToModel

public int viewToModel(float x,
                       float y,
                       java.awt.Shape a,
                       javax.swing.text.Position.Bias[] biasReturn)

Specified by:
viewToModel in class javax.swing.text.View

paint

public void paint(java.awt.Graphics g,
                  java.awt.Shape allocation)

Overrides:
paint in class BoxView

getTableContainer

public TableView.TableContainer getTableContainer()
Returns the table container, which contains a structured and correct model of the table

Returns:
The root container of the table

performPreLayout

public void performPreLayout()
Causes this view to layout all fixed values and to calculate it's minimum and preferred width. Uses the CSS-Values set by setPropertiesFromAttributes.

Specified by:
performPreLayout in interface ILayouted
Overrides:
performPreLayout in class BoxView

getLayout

public Layout getLayout()
Returns the used Layout Object

Specified by:
getLayout in interface ILayouted
Returns:
Layout Object

predictWidth

public void predictWidth(int width)
Can be used to force a view to a specified width. This will ignore the minWidh!

Specified by:
predictWidth in interface ILayouted
Parameters:
width - Width to set

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

performLayoutVAlign

public void performLayoutVAlign(int baseline)
If this box has a overall vertical align, like in table cells for instance, this method calculates teh offset to align the content. It has to be called after the box has it's final size an was layouted. NOTE: If the content is larger than the box or valign is top this method will have no visible effect!

Specified by:
performLayoutVAlign in class BoxView
Parameters:
baseline - external prediction of the first baseline for BASELINE alignment

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent e,
                         java.awt.Shape a,
                         javax.swing.text.ViewFactory f)

Overrides:
insertUpdate in class javax.swing.text.View

removeUpdate

public void removeUpdate(javax.swing.event.DocumentEvent e,
                         java.awt.Shape a,
                         javax.swing.text.ViewFactory f)

Overrides:
removeUpdate in class javax.swing.text.View

changedUpdate

public void changedUpdate(javax.swing.event.DocumentEvent e,
                          java.awt.Shape a,
                          javax.swing.text.ViewFactory f)

Overrides:
changedUpdate in class javax.swing.text.View

getHTMLBorderValue

public int getHTMLBorderValue()
Returns the html border property or -1 if none is set

Returns:
Returns the html border property or -1 if none is set

getViewCount

public int getViewCount()

Overrides:
getViewCount in class javax.swing.text.View

getView

public javax.swing.text.View getView(int n)

Overrides:
getView in class javax.swing.text.View

getSpan

public java.awt.Rectangle getSpan()
Returns the span of this view. The span is the bounding rectangle from the top left of this subtree to the bottom right. It's relative to the elements top left corner of it's outer box. It may be larger than the element itself.

Overrides:
getSpan in class BoxView
Returns:
the bounding outer rectangle of this subtree