3909N/A * Copyright (c) 1997, 2011, 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 * Implements View interface for a table, that is composed of an 0N/A * element structure where the child elements of the element 0N/A * this view is responsible for represent rows and the child 0N/A * elements of the row elements are cells. The cell elements can 0N/A * have an arbitrary element structure under them, which will 0N/A * be built with the ViewFactory returned by the getViewFactory 0N/A * This is implemented as a hierarchy of boxes, the table itself 0N/A * is a vertical box, the rows are horizontal boxes, and the cells 0N/A * are vertical boxes. The cells are allowed to span multiple 0N/A * columns and rows. By default, the table can be thought of as 0N/A * being formed over a grid (i.e. somewhat like one would find in 0N/A * gridbag layout), where table cells can request to span more 0N/A * than one grid cell. The default horizontal span of table cells 0N/A * will be based upon this grid, but can be changed by reimplementing 0N/A * the requested span of the cell (i.e. table cells can have independant 0N/A * spans if desired). 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 * @deprecated Table cells can now be any arbitrary 0N/A * View implementation and should be produced by the 0N/A * ViewFactory rather than the table. 0N/A * @param elem an element 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 * Fetches the span (height) of the given row. 0N/A * Determines the number of columns occupied by 0N/A * the table cell represented by given element. 0N/A // PENDING(prinz) this code should be in the html 0N/A // paragraph, but we can't add api to enable it. 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 // PENDING(prinz) this code should be in the html 0N/A // paragraph, but we can't add api to enable it. 0N/A // fall through to one row 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 * 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 * Lays out the columns to fit within the given target span. 0N/A * Returns the results through {@code offsets} and {@code spans}. 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 // allocate using the convenience method on SizeRequirements 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 3370N/A * {@link #layoutColumns layoutColumns} 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 // 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 * 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. 0N/A // calculate column requirements for each column 0N/A // the requirements are the sum of the columns. 0N/A boolean shouldTrace() { 0N/A AttributeSet a = getElement().getAttributes(); 0N/A Object o = a.getAttribute(HTML.Attribute.ID); 0N/A if ((o != null) && o.equals("debug")) { 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 // pass 1 - single column cells 0N/A // pass 2 - multi-column cells 0N/A if (shouldTrace()) { 0N/A System.err.println("calc:"); 0N/A for (int i = 0; i < columnRequirements.length; i++) { 0N/A System.err.println(" " + i + ": " + columnRequirements[i]); 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. The 0N/A * maximum for each cell is the maximum of the existing 0N/A * maximum or the amount needed by the cell. 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. The 0N/A * maximum for each cell is the maximum of the existing 0N/A * maximum or the amount needed by the cell. 0N/A // apply the adjustments 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 * <code>null</code> if there isn't one 0N/A for (
int i =
0; i < n; i++) {
0N/A // it's in this view. 0N/A // ---- variables ---------------------------------------------------- 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 /** get location in the overall set of rows */ 0N/A * set location in the overall set of rows, this is 0N/A * set by the TableView.updateGrid() method. 0N/A * The number of columns present in this row. 0N/A for (
int i =
0; i < n; i++) {
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 * 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 // 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 // test bounds of each row because it may not exist 0N/A // either because of error or because the table isn't 0N/A // fully loaded yet. 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 * <code>null</code> if there isn't one 0N/A for (
int i =
0; i < n; i++) {
0N/A // it's in this view. 0N/A /** columns filled by multi-column or multi-row cells */ 0N/A /** the row within the overall grid */ 0N/A * @deprecated A table cell can now be any View implementation. 0N/A * Constructs a TableCell for the given element. 0N/A * @param elem the element that this view is responsible for 0N/A // --- GridCell methods ------------------------------------- 0N/A * Gets the number of columns this cell spans (e.g. the 0N/A * @return the number of columns 0N/A * Gets the number of rows this cell spans (that is, the 0N/A * @return the number of rows 0N/A * Sets the grid location. 0N/A * @param row the row >= 0 0N/A * @param col the column >= 0 0N/A * Gets the row of the grid location 0N/A * Gets the column of the grid location 0N/A * THIS IS NO LONGER USED, AND WILL BE REMOVED IN THE 0N/A * NEXT RELEASE. THE JCK SIGNATURE TEST THINKS THIS INTERFACE 0N/A * Sets the grid location. 0N/A * @param row the row >= 0 0N/A * @param col the column >= 0 0N/A * Gets the row of the grid location 0N/A * Gets the column of the grid location 0N/A * Gets the number of columns this cell spans (e.g. the 0N/A * @return the number of columns 0N/A * Gets the number of rows this cell spans (that is, the 0N/A * @return the number of rows