2362N/A * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @author Timothy Prinzing 0N/A * Constructs a TableView for the given element. 0N/A * @param elem the element that this view is responsible for 0N/A * Creates a new table row. 0N/A * @param elem an element 0N/A // PENDING(prinz) need to add support for some of the other 0N/A // elements, but for now just ignore anything that is not 0N/A * The number of columns in the table. 0N/A * Fetches the span (width) of the given column. 0N/A * This is used by the nested cells to query the 0N/A * sizes of grid locations outside of themselves. 0N/A * The number of rows in the table. 0N/A * Fetch the span of multiple rows. This includes 0N/A * Fetches the span (height) of the given row. 0N/A for (
int i =
0; i < n; i++) {
0N/A * Determines the number of columns occupied by 0N/A * the table cell represented by given element. 0N/A // fall through to one column 0N/A * Determines the number of rows occupied by 0N/A * the table cell represented by given element. 0N/A // fall through to one row 0N/A * Update the insets, which contain the caption if there 0N/A * Update any cached values that come from attributes. 4379N/A // Default cell spacing equals 2 0N/A * Fill in the grid locations that are placeholders 0N/A * for multi-column, multi-row, and missing grid 0N/A // determine which views are table rows and clear out 0N/A // grid points marked filled. 0N/A for (
int i =
0; i < n; i++) {
0N/A // advance to a free column 0N/A // fill in the overflow entries for this cell 0N/A * Mark a grid location as filled in for a cells overflow. 0N/A * Layout the columns to fit within the given target span. 0N/A * @param targetSpan the given span for total of all the table 0N/A * @param reqs the requirements desired for each column. This 0N/A * is the column maximum of the cells minimum, preferred, and 0N/A * maximum requested span 0N/A * @param spans the return value of how much to allocated to 0N/A * @param offsets the return value of the offset from the 0N/A * origin for each column 0N/A * @return the offset from the origin and the span for each column 0N/A * in the offsets and spans parameters 0N/A //clean offsets and spans 0N/A * Calculate the requirements for each column. The calculation 0N/A * is done as two passes over the table. The table cells that 0N/A * occupy a single column are scanned first to determine the 0N/A * maximum of minimum, preferred, and maximum spans along the 0N/A * give axis. Table cells that span multiple columns are excluded 0N/A * from the first pass. A second pass is made to determine if 0N/A * the cells that span multiple columns are satisfied. If the 0N/A * column requirements are not satisified, the needs of the 0N/A * multi-column cell is mixed into the existing column requirements. 0N/A * The calculation of the multi-column distribution is based upon 0N/A * the proportions of the existing column requirements and taking 0N/A * into consideration any constraining maximums. 0N/A // clean columnRequirements 0N/A // pass 1 - single column cells 0N/A // pass 2 - multi-column cells 0N/A * check the requirements of a table cell that spans a single column. 0N/A * check the requirements of a table cell that spans multiple 0N/A // calculate the totals 0N/A // check if the minimum size needs adjustment. 0N/A * the columns that this cell spans need adjustment to fit 0N/A * this table cell.... calculate the adjustments. 0N/A // apply the adjustments 0N/A // check if the preferred size needs adjustment. 0N/A * the columns that this cell spans need adjustment to fit 0N/A * this table cell.... calculate the adjustments. 0N/A // apply the adjustments 0N/A // --- BoxView methods ----------------------------------------- 0N/A * Calculate the requirements for the minor axis. This is called by 0N/A * the superclass whenever the requirements need to be updated (i.e. 0N/A * a preferenceChanged was messaged through this view). 0N/A * This is implemented to calculate the requirements as the sum of the 0N/A * requirements of the columns and then adjust it if the 0N/A * CSS width or height attribute is specified and applicable to 0N/A // calculate column requirements for each column 0N/A // the requirements are the sum of the columns. 0N/A for (
int i =
0; i < n; i++) {
0N/A // The user has requested a smaller size than is needed to 0N/A // show the table, override it. 0N/A // set the alignment 0N/A // set horizontal alignment 0N/A * Calculate the requirements for the major axis. This is called by 0N/A * the superclass whenever the requirements need to be updated (i.e. 0N/A * a preferenceChanged was messaged through this view). 0N/A * This is implemented to provide the superclass behavior adjusted for 0N/A * multi-row table cells. 0N/A * Perform layout for the minor axis of the box (i.e. the 0N/A * axis orthoginal to the axis that it represents). The results 0N/A * of the layout should be placed in the given arrays which represent 0N/A * the allocations to the children along the minor axis. This 0N/A * is called by the superclass whenever the layout needs to be 0N/A * updated along the minor axis. 0N/A * This is implemented to call the 0N/A * <a href="#layoutColumns">layoutColumns</a> method, and then 0N/A * forward to the superclass to actually carry out the layout 0N/A * of the tables rows. 0N/A * @param targetSpan the total span given to the view, which 0N/A * whould be used to layout the children 0N/A * @param axis the axis being layed out 0N/A * @param offsets the offsets from the origin of the view for 0N/A * each of the child views. This is a return value and is 0N/A * filled in by the implementation of this method 0N/A * @param spans the span of each child view; this is a return 0N/A * value and is filled in by the implementation of this method 0N/A * @return the offset and span for each child view in the 0N/A * offsets and spans parameters 0N/A // make grid is properly represented 0N/A // all of the row layouts are invalid, so mark them that way 0N/A for (
int i =
0; i < n; i++) {
0N/A // calculate column spans 0N/A // continue normal layout 0N/A * Perform layout for the major axis of the box (i.e. the 0N/A * axis that it represents). The results 0N/A * of the layout should be placed in the given arrays which represent 0N/A * the allocations to the children along the minor axis. This 0N/A * is called by the superclass whenever the layout needs to be 0N/A * updated along the minor axis. 0N/A * This method is where the layout of the table rows within the 0N/A * table takes place. This method is implemented to call the use 0N/A * the RowIterator and the CSS collapsing tile to layout 0N/A * with border spacing and border collapsing capabilities. 0N/A * @param targetSpan the total span given to the view, which 0N/A * whould be used to layout the children 0N/A * @param axis the axis being layed out 0N/A * @param offsets the offsets from the origin of the view for 0N/A * each of the child views; this is a return value and is 0N/A * filled in by the implementation of this method 0N/A * @param spans the span of each child view; this is a return 0N/A * value and is filled in by the implementation of this method 0N/A * @return the offset and span for each child view in the 0N/A * offsets and spans parameters 0N/A // place the caption 0N/A * Fetches the child view that represents the given position in 0N/A * the model. This is implemented to walk through the children 0N/A * looking for a range that contains the given position. In this 0N/A * view the children do not necessarily have a one to one mapping 0N/A * with the child elements. 0N/A * @param pos the search position >= 0 0N/A * @param a the allocation to the table on entry, and the 0N/A * allocation of the view containing the position on exit 0N/A * @return the view representing the given position, or 0N/A * null if there isn't one 0N/A for (
int i =
0; i < n; i++) {
0N/A // it's in this view. 0N/A // --- View methods --------------------------------------------- 0N/A * Fetches the attributes to use when rendering. This is 0N/A * implemented to multiplex the attributes specified in the 0N/A * model with a StyleSheet. 0N/A * Renders using the given rendering surface and area on that 0N/A * surface. This is implemented to delegate to the css box 0N/A * painter to paint the border and background prior to the 0N/A * interior. The superclass culls rendering the children 0N/A * that don't directly intersect the clip and the row may 0N/A * have cells hanging from a row above in it. The table 0N/A * does not use the superclass rendering behavior and instead 0N/A * paints all of the rows and lets the rows cull those 0N/A * cells not intersecting the clip region. 0N/A * @param g the rendering surface to use 0N/A * @param allocation the allocated region to render into 0N/A // adjust the border for the caption 0N/A for (
int i =
0; i < n; i++) {
0N/A //super.paint(g, a); 0N/A * Establishes the parent view for this view. This is 0N/A * guaranteed to be called before any other methods if the 0N/A * parent view is functioning properly. 0N/A * This is implemented 0N/A * to forward to the superclass as well as call the 0N/A * <a href="#setPropertiesFromAttributes">setPropertiesFromAttributes</a> 0N/A * method to set the paragraph properties from the css 0N/A * attributes. The call is made at this time to ensure 0N/A * the ability to resolve upward through the parents 0N/A * @param parent the new parent, or null if the view is 0N/A * being removed from a parent it was previously added 0N/A * Fetches the ViewFactory implementation that is feeding 0N/A * the view hierarchy. 0N/A * This replaces the ViewFactory with an implementation that 0N/A * calls through to the createTableRow and createTableCell 0N/A * methods. If the element given to the factory isn't a 0N/A * table row or cell, the request is delegated to the factory 0N/A * produced by the superclass behavior. 0N/A * @return the factory, null if none 0N/A * Gives notification that something was inserted into 0N/A * the document in a location that this view is responsible for. 0N/A * This replaces the ViewFactory with an implementation that 0N/A * calls through to the createTableRow and createTableCell 0N/A * methods. If the element given to the factory isn't a 0N/A * table row or cell, the request is delegated to the factory 0N/A * passed as an argument. 0N/A * @param e the change information from the associated document 0N/A * @param a the current allocation of the view 0N/A * @param f the factory to use to rebuild if the view has children 0N/A * @see View#insertUpdate 0N/A * Gives notification that something was removed from the document 0N/A * in a location that this view is responsible for. 0N/A * This replaces the ViewFactory with an implementation that 0N/A * calls through to the createTableRow and createTableCell 0N/A * methods. If the element given to the factory isn't a 0N/A * table row or cell, the request is delegated to the factory 0N/A * passed as an argument. 0N/A * @param e the change information from the associated document 0N/A * @param a the current allocation of the view 0N/A * @param f the factory to use to rebuild if the view has children 0N/A * @see View#removeUpdate 0N/A * Gives notification from the document that attributes were changed 0N/A * in a location that this view is responsible for. 0N/A * This replaces the ViewFactory with an implementation that 0N/A * calls through to the createTableRow and createTableCell 0N/A * methods. If the element given to the factory isn't a 0N/A * table row or cell, the request is delegated to the factory 0N/A * passed as an argument. 0N/A * @param e the change information from the associated document 0N/A * @param a the current allocation of the view 0N/A * @param f the factory to use to rebuild if the view has children 0N/A * @see View#changedUpdate 0N/A // A change in any of the table cells usually effects the whole table, 0N/A // so redraw it all! 0N/A * Change the child views. This is implemented to 0N/A * provide the superclass behavior and invalidate the 0N/A * grid so that rows and columns will be recalculated. 0N/A // --- ViewFactory methods ------------------------------------------ 0N/A * The table itself acts as a factory for the various 0N/A * views that actually represent pieces of the table. 0N/A * All other factory activity is delegated to the factory 0N/A * returned by the parent of the table. 0N/A // default is to delegate to the normal factory 0N/A // ---- variables ---------------------------------------------------- 0N/A * The index of the caption view if there is a caption. 0N/A * This has a value of -1 if there is no caption. The 0N/A * caption lives in the inset area of the table, and is 0N/A * updated with each time the grid is recalculated. 0N/A * Do any of the table cells contain a relative size 0N/A * specification? This is updated with each call to 0N/A * updateGrid(). If this is true, the ColumnIterator 0N/A * will do extra work to calculate relative cell 0N/A * Do any of the table cells span multiple rows? If 0N/A * true, the RowRequirementIterator will do additional 0N/A * work to adjust the requirements of rows spanned by 0N/A * a single table cell. This is updated with each call to 0N/A * SizeRequirements for all the columns. 0N/A // whether to display comments inside table or not. 0N/A * Disable percentage adjustments which should only apply 0N/A * when calculating layout, not requirements. 0N/A * Update percentage adjustments if they are needed. 0N/A // add a percentage requirement 0N/A * Set the layout arrays to use for holding layout results 0N/A // --- RequirementIterator methods ------------------- 0N/A // do not care for percentages, since min span can't 0N/A // be less than columnRequirements[col].minimum, 0N/A // but can be less than percentage value. 0N/A * Current column index 0N/A * percentage values (may be null since there 0N/A * might not be any). 0N/A // adjust requirements of multi-row cells 0N/A for (
int i =
0; i < n; i++) {
0N/A * Fixup preferences to accomodate a multi-row table cell 0N/A * if not already covered by existing preferences. This is 0N/A // rows are missing (could be a bad rowspan specification) 0N/A // or not all the rows have arrived. Do the best we can with 0N/A // the current set of rows. 0N/A // --- RequirementIterator methods ------------------- 0N/A * Adjustments to the row requirements to handle multi-row 0N/A * View of a row in a row-centric table. 0N/A * Constructs a TableView for the given element. 0N/A * @param elem the element that this view is responsible for 0N/A * The number of columns present in this row. 0N/A for (
int i =
0; i < n; i++) {
0N/A * Fetches the attributes to use when rendering. This is 0N/A * implemented to multiplex the attributes specified in the 0N/A * model with a StyleSheet. 0N/A for (
int i =
0; i < n; i++) {
0N/A * This is called by a child to indicate its 0N/A * preferred span has changed. This is implemented to 0N/A * execute the superclass behavior and well as try to 0N/A * determine if a row with a multi-row cell hangs across 0N/A * this row. If a multi-row cell covers this row it also 0N/A * needs to propagate a preferenceChanged so that it will 0N/A * recalculate the multi-row cell. 0N/A * @param child the child view 0N/A * @param width true if the width preference should change 0N/A * @param height true if the height preference should change 0N/A // The major axis requirements for a row are dictated by the column 0N/A // requirements. These methods use the value calculated by 0N/A * Renders using the given rendering surface and area on that 0N/A * surface. This is implemented to delegate to the css box 0N/A * painter to paint the border and background prior to the 0N/A * @param g the rendering surface to use 0N/A * @param allocation the allocated region to render into 0N/A * Change the child views. This is implemented to 0N/A * provide the superclass behavior and invalidate the 0N/A * grid so that rows and columns will be recalculated. 0N/A * Calculate the height requirements of the table row. The 0N/A * requirements of multi-row cells are not considered for this 0N/A * calculation. The table itself will check and adjust the row 0N/A * requirements for all the rows that have multi-row cells spanning 0N/A * them. This method updates the multi-row flag that indicates that 0N/A * this row and rows below need additional consideration. 0N/A// return super.calculateMinorAxisRequirements(axis, r); 0N/A for (
int i =
0; i < n; i++) {
0N/A * Perform layout for the major axis of the box (i.e. the 0N/A * axis that it represents). The results of the layout should 0N/A * be placed in the given arrays which represent the allocations 0N/A * to the children along the major axis. 0N/A * This is re-implemented to give each child the span of the column 0N/A * width for the table, and to give cells that span multiple columns 0N/A * the multi-column span. 0N/A * @param targetSpan the total span given to the view, which 0N/A * whould be used to layout the children 0N/A * @param axis the axis being layed out 0N/A * @param offsets the offsets from the origin of the view for 0N/A * each of the child views; this is a return value and is 0N/A * filled in by the implementation of this method 0N/A * @param spans the span of each child view; this is a return 0N/A * value and is filled in by the implementation of this method 0N/A * @return the offset and span for each child view in the 0N/A * offsets and spans parameters 0N/A // Because the table may be only partially formed, some 0N/A // of the columns may not yet exist. Therefore we check 0N/A * Perform layout for the minor axis of the box (i.e. the 0N/A * axis orthoginal to the axis that it represents). The results 0N/A * of the layout should be placed in the given arrays which represent 0N/A * the allocations to the children along the minor axis. This 0N/A * is called by the superclass whenever the layout needs to be 0N/A * updated along the minor axis. 0N/A * This is implemented to delegate to the superclass, then adjust 0N/A * the span for any cell that spans multiple rows. 0N/A * @param targetSpan the total span given to the view, which 0N/A * whould be used to layout the children 0N/A * @param axis the axis being layed out 0N/A * @param offsets the offsets from the origin of the view for 0N/A * each of the child views; this is a return value and is 0N/A * filled in by the implementation of this method 0N/A * @param spans the span of each child view; this is a return 0N/A * value and is filled in by the implementation of this method 0N/A * @return the offset and span for each child view in the 0N/A * offsets and spans parameters 0N/A * Determines the resizability of the view along the 0N/A * given axis. A value of 0 or less is not resizable. 0N/A * @param axis may be either View.X_AXIS or View.Y_AXIS 0N/A * @return the resize weight 0N/A * @exception IllegalArgumentException for an invalid axis 0N/A * Fetches the child view that represents the given position in 0N/A * the model. This is implemented to walk through the children 0N/A * looking for a range that contains the given position. In this 0N/A * view the children do not necessarily have a one to one mapping 0N/A * with the child elements. 0N/A * @param pos the search position >= 0 0N/A * @param a the allocation to the table on entry, and the 0N/A * allocation of the view containing the position on exit 0N/A * @return the view representing the given position, or 0N/A * null if there isn't one 0N/A for (
int i =
0; i < n; i++) {
0N/A // it's in this view. 0N/A * Update any cached values that come from attributes. 0N/A /** columns filled by multi-column or multi-row cells */ 0N/A * The row index within the overall grid 0N/A * The view index (for row index to view index conversion). 0N/A * This is set by the updateGrid method. 0N/A * Does this table row have cells that span multiple rows? 0N/A * Default view of an html table cell. This needs to be moved 0N/A * Constructs a TableCell for the given element. 0N/A * @param elem the element that this view is responsible for 0N/A * Perform layout for the major axis of the box (i.e. the 0N/A * axis that it represents). The results of the layout should 0N/A * be placed in the given arrays which represent the allocations 0N/A * to the children along the major axis. This is called by the 0N/A * superclass to recalculate the positions of the child views 0N/A * when the layout might have changed. 0N/A * This is implemented to delegate to the superclass to 0N/A * tile the children. If the target span is greater than 0N/A * was needed, the offsets are adjusted to align the children 0N/A * (i.e. position according to the html valign attribute). 0N/A * @param targetSpan the total span given to the view, which 0N/A * whould be used to layout the children 0N/A * @param axis the axis being layed out 0N/A * @param offsets the offsets from the origin of the view for 0N/A * each of the child views; this is a return value and is 0N/A * filled in by the implementation of this method 0N/A * @param spans the span of each child view; this is a return 0N/A * value and is filled in by the implementation of this method 0N/A * @return the offset and span for each child view in the 0N/A * offsets and spans parameters 0N/A for (
int i =
0; i < n; i++) {
0N/A // calculate adjustments 0N/A // PENDING(prinz) change to use the css alignment. 0N/A // make adjustments. 0N/A for (
int i =
0; i < n; i++) {
0N/A * Calculate the requirements needed along the major axis. 0N/A * This is called by the superclass whenever the requirements 0N/A * need to be updated (i.e. a preferenceChanged was messaged 0N/A * through this view). 0N/A * This is implemented to delegate to the superclass, but 0N/A * indicate the maximum size is very large (i.e. the cell 0N/A * is willing to expend to occupy the full height of the row). 0N/A * @param axis the axis being layed out. 0N/A * @param r the requirements to fill in. If null, a new one 0N/A * should be allocated. 0N/A //for the cell the minimum should be derived from the child views 0N/A //the parent behaviour is to use CSS for that 0N/A for (
int i =
0; i < n; i++) {