com.lightdev.app.shtm
Class SHTMLTableView.RowView

java.lang.Object
  extended by javax.swing.text.View
      extended by javax.swing.text.CompositeView
          extended by javax.swing.text.BoxView
              extended by com.lightdev.app.shtm.SHTMLTableView.RowView
All Implemented Interfaces:
javax.swing.SwingConstants
Enclosing class:
SHTMLTableView

public class SHTMLTableView.RowView
extends javax.swing.text.BoxView

View of a row in a row-centric table.


Field Summary
 
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
SHTMLTableView.RowView(javax.swing.text.Element elem)
          Constructs a TableView for the given element.
 
Method Summary
protected  javax.swing.SizeRequirements calculateMajorAxisRequirements(int axis, javax.swing.SizeRequirements r)
           
protected  javax.swing.SizeRequirements calculateMinorAxisRequirements(int axis, javax.swing.SizeRequirements r)
          Calculate the height requirements of the table row.
 void changedUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
           
 javax.swing.text.AttributeSet getAttributes()
          Fetches the attributes to use when rendering.
 float getMaximumSpan(int axis)
           
 float getMinimumSpan(int axis)
           
 float getPreferredSpan(int axis)
           
 int getResizeWeight(int axis)
          Determines the resizability of the view along the given axis.
protected  javax.swing.text.html.StyleSheet getStyleSheet()
           
protected  javax.swing.text.View getViewAtPosition(int pos, java.awt.Rectangle a)
          Fetches the child view that represents the given position in the model.
protected  void layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
          Perform layout for the major axis of the box (i.e.
protected  void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
          Perform layout for the minor axis of the box (i.e.
 void paint(java.awt.Graphics g, java.awt.Shape allocation)
          Renders using the given rendering surface and area on that surface.
 void preferenceChanged(javax.swing.text.View child, boolean width, boolean height)
          This is called by a child to indicate its preferred span has changed.
 void replace(int offset, int length, javax.swing.text.View[] views)
          Change the child views.
 
Methods inherited from class javax.swing.text.BoxView
baselineLayout, baselineRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAlignment, getAxis, getChildAllocation, getHeight, getOffset, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, modelToView, paintChild, setAxis, setSize, viewToModel
 
Methods inherited from class javax.swing.text.CompositeView
getBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewCount, getViewIndex, getViewIndexAtPosition, loadChildren, modelToView, setInsets, setParagraphInsets, setParent
 
Methods inherited from class javax.swing.text.View
append, breakView, createFragment, forwardUpdateToView, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, insertUpdate, isVisible, modelToView, remove, removeAll, removeUpdate, updateChildren, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SHTMLTableView.RowView

public SHTMLTableView.RowView(javax.swing.text.Element elem)
Constructs a TableView for the given element.

Parameters:
elem - the element that this view is responsible for
Method Detail

getAttributes

public javax.swing.text.AttributeSet getAttributes()
Fetches the attributes to use when rendering. This is implemented to multiplex the attributes specified in the model with a StyleSheet.

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

getStyleSheet

protected javax.swing.text.html.StyleSheet getStyleSheet()

preferenceChanged

public void preferenceChanged(javax.swing.text.View child,
                              boolean width,
                              boolean height)
This is called by a child to indicate its preferred span has changed. This is implemented to execute the superclass behavior and well as try to determine if a row with a multi-row cell hangs across this row. If a multi-row cell covers this row it also needs to propagate a preferenceChanged so that it will recalculate the multi-row cell.

Overrides:
preferenceChanged in class javax.swing.text.BoxView
Parameters:
child - the child view
width - true if the width preference should change
height - true if the height preference should change

calculateMajorAxisRequirements

protected javax.swing.SizeRequirements calculateMajorAxisRequirements(int axis,
                                                                      javax.swing.SizeRequirements r)
Overrides:
calculateMajorAxisRequirements in class javax.swing.text.BoxView

getMinimumSpan

public float getMinimumSpan(int axis)
Overrides:
getMinimumSpan in class javax.swing.text.BoxView

getMaximumSpan

public float getMaximumSpan(int axis)
Overrides:
getMaximumSpan in class javax.swing.text.BoxView

getPreferredSpan

public float getPreferredSpan(int axis)
Overrides:
getPreferredSpan in class javax.swing.text.BoxView

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

paint

public void paint(java.awt.Graphics g,
                  java.awt.Shape allocation)
Renders using the given rendering surface and area on that surface. This is implemented to delegate to the css box painter to paint the border and background prior to the interior.

Overrides:
paint in class javax.swing.text.BoxView
Parameters:
g - the rendering surface to use
allocation - the allocated region to render into
See Also:
View.paint(java.awt.Graphics, java.awt.Shape)

replace

public void replace(int offset,
                    int length,
                    javax.swing.text.View[] views)
Change the child views. This is implemented to provide the superclass behavior and invalidate the grid so that rows and columns will be recalculated.

Overrides:
replace in class javax.swing.text.BoxView

calculateMinorAxisRequirements

protected javax.swing.SizeRequirements calculateMinorAxisRequirements(int axis,
                                                                      javax.swing.SizeRequirements r)
Calculate the height requirements of the table row. The requirements of multi-row cells are not considered for this calculation. The table itself will check and adjust the row requirements for all the rows that have multi-row cells spanning them. This method updates the multi-row flag that indicates that this row and rows below need additional consideration.

Overrides:
calculateMinorAxisRequirements in class javax.swing.text.BoxView

layoutMajorAxis

protected void layoutMajorAxis(int targetSpan,
                               int axis,
                               int[] offsets,
                               int[] spans)
Perform layout for the major axis of the box (i.e. the axis that it represents). The results of the layout should be placed in the given arrays which represent the allocations to the children along the major axis.

This is re-implemented to give each child the span of the column width for the table, and to give cells that span multiple columns the multi-column span.

Overrides:
layoutMajorAxis in class javax.swing.text.BoxView
Parameters:
targetSpan - the total span given to the view, which whould be used to layout the children
axis - the axis being layed out
offsets - the offsets from the origin of the view for each of the child views; this is a return value and is filled in by the implementation of this method
spans - the span of each child view; this is a return value and is filled in by the implementation of this method

layoutMinorAxis

protected void layoutMinorAxis(int targetSpan,
                               int axis,
                               int[] offsets,
                               int[] spans)
Perform layout for the minor axis of the box (i.e. the axis orthoginal to the axis that it represents). The results of the layout should be placed in the given arrays which represent the allocations to the children along the minor axis. This is called by the superclass whenever the layout needs to be updated along the minor axis.

This is implemented to delegate to the superclass, then adjust the span for any cell that spans multiple rows.

Overrides:
layoutMinorAxis in class javax.swing.text.BoxView
Parameters:
targetSpan - the total span given to the view, which whould be used to layout the children
axis - the axis being layed out
offsets - the offsets from the origin of the view for each of the child views; this is a return value and is filled in by the implementation of this method
spans - the span of each child view; this is a return value and is filled in by the implementation of this method

getResizeWeight

public int getResizeWeight(int axis)
Determines the resizability of the view along the given axis. A value of 0 or less is not resizable.

Overrides:
getResizeWeight in class javax.swing.text.BoxView
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the resize weight
Throws:
java.lang.IllegalArgumentException - for an invalid axis

getViewAtPosition

protected javax.swing.text.View getViewAtPosition(int pos,
                                                  java.awt.Rectangle a)
Fetches the child view that represents the given position in the model. This is implemented to walk through the children looking for a range that contains the given position. In this view the children do not necessarily have a one to one mapping with the child elements.

Overrides:
getViewAtPosition in class javax.swing.text.CompositeView
Parameters:
pos - the search position >= 0
a - the allocation to the table on entry, and the allocation of the view containing the position on exit
Returns:
the view representing the given position, or null if there isn't one