|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.text.View
javax.swing.text.CompositeView
javax.swing.text.BoxView
com.lightdev.app.shtm.SHTMLTableView
public class SHTMLTableView
HTML table view copied from javax.swing.text.html.TableView.java. The original intention was to implement a box painter other than StyleSheet.BoxPainter which obviously is not complete. This could have been a simple task just overriding TableView.create with our own ViewFactory implementing an alternate BoxPainter. Unfortunately while create is public, TableView itself is not (why???). We have to copy the whole thing and just adapt one line to make inner class CellView a subclass of our own SHTMLBlockView instead of javax.swing.text.html.BlockView. To make things worse, TableView uses some methods from class CSS which are not public as well (again not clear why) so these had to be copied into this class too. All in all a totally ugly solution which hopefully can be corrected once Sun decided to tidy up the CSS part of Swing.
Nested Class Summary | |
---|---|
class |
SHTMLTableView.RowView
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(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)
Calculate the requirements for the major axis. |
protected javax.swing.SizeRequirements |
calculateMinorAxisRequirements(int axis,
javax.swing.SizeRequirements r)
Calculate the requirements for the minor axis. |
void |
changedUpdate(javax.swing.event.DocumentEvent e,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
Gives notification from the document that attributes were changed in a location that this view is responsible for. |
javax.swing.text.View |
create(javax.swing.text.Element elem)
The table itself acts as a factory for the various views that actually represent pieces of the table. |
protected SHTMLTableView.RowView |
createTableRow(javax.swing.text.Element elem)
Creates a new table row. |
protected void |
forwardUpdate(javax.swing.event.DocumentEvent.ElementChange ec,
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. |
int |
getColumnCount()
The number of columns in the table. |
protected int |
getColumnsOccupied(javax.swing.text.View v)
Determines the number of columns occupied by the table cell represented by given element. |
int |
getColumnSpan(int col)
Fetches the span (width) of the given column. |
int |
getMultiRowSpan(int row0,
int row1)
Fetch the span of multiple rows. |
int |
getRowCount()
The number of rows in the table. |
protected int |
getRowsOccupied(javax.swing.text.View v)
Determines the number of rows occupied by the table cell represented by given element. |
int |
getRowSpan(int row)
Fetches the span (height) of the given row. |
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. |
javax.swing.text.ViewFactory |
getViewFactory()
Fetches the ViewFactory implementation that is feeding the view hierarchy. |
void |
insertUpdate(javax.swing.event.DocumentEvent e,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
Gives notification that something was inserted into the document in a location that this view is responsible for. |
protected void |
invalidateGrid()
|
protected void |
layoutColumns(int targetSpan,
int[] offsets,
int[] spans,
javax.swing.SizeRequirements[] reqs)
Layout the columns to fit within the given target span. |
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 |
removeUpdate(javax.swing.event.DocumentEvent e,
java.awt.Shape a,
javax.swing.text.ViewFactory f)
Gives notification that something was removed from the document in a location that this view is responsible for. |
void |
replace(int offset,
int length,
javax.swing.text.View[] views)
Change the child views. |
void |
setParent(javax.swing.text.View parent)
Establishes the parent view for this view. |
protected void |
setPropertiesFromAttributes()
Update any cached values that come from attributes. |
Methods inherited from class javax.swing.text.BoxView |
---|
baselineLayout, baselineRequirements, childAllocation, flipEastAndWestAtEnds, getAlignment, getAxis, getChildAllocation, getHeight, getMaximumSpan, getMinimumSpan, getOffset, getPreferredSpan, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, modelToView, paintChild, preferenceChanged, 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 |
Methods inherited from class javax.swing.text.View |
---|
append, breakView, createFragment, forwardUpdateToView, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewIndex, insert, isVisible, modelToView, remove, removeAll, updateChildren, updateLayout, viewToModel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SHTMLTableView(javax.swing.text.Element elem)
elem
- the element that this view is responsible forMethod Detail |
---|
protected SHTMLTableView.RowView createTableRow(javax.swing.text.Element elem)
elem
- an element
public int getColumnCount()
public int getColumnSpan(int col)
public int getRowCount()
public int getMultiRowSpan(int row0, int row1)
public int getRowSpan(int row)
protected int getColumnsOccupied(javax.swing.text.View v)
protected int getRowsOccupied(javax.swing.text.View v)
protected void invalidateGrid()
protected javax.swing.text.html.StyleSheet getStyleSheet()
protected void setPropertiesFromAttributes()
protected void layoutColumns(int targetSpan, int[] offsets, int[] spans, javax.swing.SizeRequirements[] reqs)
targetSpan
- the given span for total of all the table
columnsreqs
- the requirements desired for each column. This
is the column maximum of the cells minimum, preferred, and
maximum requested spanspans
- the return value of how much to allocated to
each columnoffsets
- the return value of the offset from the
origin for each columnprotected javax.swing.SizeRequirements calculateMinorAxisRequirements(int axis, javax.swing.SizeRequirements r)
This is implemented to calculate the requirements as the sum of the requirements of the columns and then adjust it if the CSS width or height attribute is specified and applicable to the axis.
calculateMinorAxisRequirements
in class javax.swing.text.BoxView
protected javax.swing.SizeRequirements calculateMajorAxisRequirements(int axis, javax.swing.SizeRequirements r)
This is implemented to provide the superclass behavior adjusted for multi-row table cells.
calculateMajorAxisRequirements
in class javax.swing.text.BoxView
protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
This is implemented to call the layoutColumns method, and then forward to the superclass to actually carry out the layout of the tables rows.
layoutMinorAxis
in class javax.swing.text.BoxView
targetSpan
- the total span given to the view, which
whould be used to layout the childrenaxis
- the axis being layed outoffsets
- 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 methodspans
- the span of each child view; this is a return
value and is filled in by the implementation of this methodprotected void layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans)
This method is where the layout of the table rows within the table takes place. This method is implemented to call the use the RowIterator and the CSS collapsing tile to layout with border spacing and border collapsing capabilities.
layoutMajorAxis
in class javax.swing.text.BoxView
targetSpan
- the total span given to the view, which
whould be used to layout the childrenaxis
- the axis being layed outoffsets
- 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 methodspans
- the span of each child view; this is a return
value and is filled in by the implementation of this methodprotected javax.swing.text.View getViewAtPosition(int pos, java.awt.Rectangle a)
getViewAtPosition
in class javax.swing.text.CompositeView
pos
- the search position >= 0a
- the allocation to the table on entry, and the
allocation of the view containing the position on exit
public javax.swing.text.AttributeSet getAttributes()
getAttributes
in class javax.swing.text.View
public void paint(java.awt.Graphics g, java.awt.Shape allocation)
paint
in class javax.swing.text.BoxView
g
- the rendering surface to useallocation
- the allocated region to render intoSHTMLTableView.RowView.paint(java.awt.Graphics, java.awt.Shape)
public void setParent(javax.swing.text.View parent)
This is implemented to forward to the superclass as well as call the setPropertiesFromAttributes method to set the paragraph properties from the css attributes. The call is made at this time to ensure the ability to resolve upward through the parents view attributes.
setParent
in class javax.swing.text.CompositeView
parent
- the new parent, or null if the view is
being removed from a parent it was previously added
topublic javax.swing.text.ViewFactory getViewFactory()
getViewFactory
in class javax.swing.text.View
public void insertUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
insertUpdate
in class javax.swing.text.View
e
- the change information from the associated documenta
- the current allocation of the viewf
- the factory to use to rebuild if the view has childrenView.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public void removeUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
removeUpdate
in class javax.swing.text.View
e
- the change information from the associated documenta
- the current allocation of the viewf
- the factory to use to rebuild if the view has childrenView.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public void changedUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
changedUpdate
in class javax.swing.text.View
e
- the change information from the associated documenta
- the current allocation of the viewf
- the factory to use to rebuild if the view has childrenSHTMLTableView.RowView.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
protected void forwardUpdate(javax.swing.event.DocumentEvent.ElementChange ec, javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
forwardUpdate
in class javax.swing.text.BoxView
public void replace(int offset, int length, javax.swing.text.View[] views)
replace
in class javax.swing.text.BoxView
public javax.swing.text.View create(javax.swing.text.Element elem)
create
in interface javax.swing.text.ViewFactory
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |