jdk/src/java.desktop/share/classes/javax/swing/text/TableView.java
author smarks
Tue, 29 Aug 2017 12:16:28 -0700
changeset 47020 2c55106dc37b
parent 44155 1bf93336ea45
permissions -rw-r--r--
8186851: fix misspellings of "dependent" and "independent" in the JDK repo Reviewed-by: bpb, psadhukhan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
44155
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
     2
 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing.text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.BitSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.swing.SizeRequirements;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.event.DocumentEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.swing.text.html.HTML;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * Implements View interface for a table, that is composed of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * element structure where the child elements of the element
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * this view is responsible for represent rows and the child
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * elements of the row elements are cells.  The cell elements can
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * have an arbitrary element structure under them, which will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * be built with the ViewFactory returned by the getViewFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * &nbsp;  TABLE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * &nbsp;    ROW
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * &nbsp;      CELL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * &nbsp;      CELL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * &nbsp;    ROW
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * &nbsp;      CELL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * &nbsp;      CELL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * This is implemented as a hierarchy of boxes, the table itself
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * is a vertical box, the rows are horizontal boxes, and the cells
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * are vertical boxes.  The cells are allowed to span multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * columns and rows.  By default, the table can be thought of as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * being formed over a grid (i.e. somewhat like one would find in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * gridbag layout), where table cells can request to span more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * than one grid cell.  The default horizontal span of table cells
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * will be based upon this grid, but can be changed by reimplementing
47020
2c55106dc37b 8186851: fix misspellings of "dependent" and "independent" in the JDK repo
smarks
parents: 44155
diff changeset
    64
 * the requested span of the cell (i.e. table cells can have independent
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * spans if desired).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * @author  Timothy Prinzing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * @see     View
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
public abstract class TableView extends BoxView {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * Constructs a TableView for the given element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @param elem the element that this view is responsible for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public TableView(Element elem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        super(elem, View.Y_AXIS);
1287
a04aca99c77a 6722802: Code improvement and warnings removing from the javax.swing.text package
rupashka
parents: 2
diff changeset
    79
        rows = new Vector<TableRow>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        gridValid = false;
44155
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
    81
        totalColumnRequirements = new SizeRequirements();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Creates a new table row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @param elem an element
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @return the row
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    protected TableRow createTableRow(Element elem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        return new TableRow(elem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @deprecated Table cells can now be any arbitrary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * View implementation and should be produced by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * ViewFactory rather than the table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @param elem an element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @return the cell
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    protected TableCell createTableCell(Element elem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        return new TableCell(elem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * The number of columns in the table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    int getColumnCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        return columnSpans.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Fetches the span (width) of the given column.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * This is used by the nested cells to query the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * sizes of grid locations outside of themselves.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    int getColumnSpan(int col) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        return columnSpans[col];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * The number of rows in the table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    int getRowCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        return rows.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Fetches the span (height) of the given row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    int getRowSpan(int row) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        View rv = getRow(row);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        if (rv != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            return (int) rv.getPreferredSpan(Y_AXIS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    TableRow getRow(int row) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        if (row < rows.size()) {
1287
a04aca99c77a 6722802: Code improvement and warnings removing from the javax.swing.text package
rupashka
parents: 2
diff changeset
   143
            return rows.elementAt(row);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * Determines the number of columns occupied by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * the table cell represented by given element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /*protected*/ int getColumnsOccupied(View v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        // PENDING(prinz) this code should be in the html
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        // paragraph, but we can't add api to enable it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        AttributeSet a = v.getElement().getAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        String s = (String) a.getAttribute(HTML.Attribute.COLSPAN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        if (s != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                return Integer.parseInt(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            } catch (NumberFormatException nfe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                // fall through to one column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * Determines the number of rows occupied by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * the table cell represented by given element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /*protected*/ int getRowsOccupied(View v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        // PENDING(prinz) this code should be in the html
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        // paragraph, but we can't add api to enable it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        AttributeSet a = v.getElement().getAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        String s = (String) a.getAttribute(HTML.Attribute.ROWSPAN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        if (s != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                return Integer.parseInt(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            } catch (NumberFormatException nfe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                // fall through to one row
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    /*protected*/ void invalidateGrid() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        gridValid = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    protected void forwardUpdate(DocumentEvent.ElementChange ec,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                                     DocumentEvent e, Shape a, ViewFactory f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        super.forwardUpdate(ec, e, a, f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        // A change in any of the table cells usually effects the whole table,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        // so redraw it all!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        if (a != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            Component c = getContainer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            if (c != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                                   a.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                c.repaint(alloc.x, alloc.y, alloc.width, alloc.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * Change the child views.  This is implemented to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * provide the superclass behavior and invalidate the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * grid so that rows and columns will be recalculated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    public void replace(int offset, int length, View[] views) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        super.replace(offset, length, views);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        invalidateGrid();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * Fill in the grid locations that are placeholders
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * for multi-column, multi-row, and missing grid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * locations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    void updateGrid() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        if (! gridValid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            // determine which views are table rows and clear out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            // grid points marked filled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            rows.removeAllElements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            int n = getViewCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            for (int i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                View v = getView(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                if (v instanceof TableRow) {
1287
a04aca99c77a 6722802: Code improvement and warnings removing from the javax.swing.text package
rupashka
parents: 2
diff changeset
   231
                    rows.addElement((TableRow) v);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                    TableRow rv = (TableRow) v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                    rv.clearFilledColumns();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                    rv.setRow(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            int maxColumns = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            int nrows = rows.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            for (int row = 0; row < nrows; row++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                TableRow rv = getRow(row);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                int col = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                for (int cell = 0; cell < rv.getViewCount(); cell++, col++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                    View cv = rv.getView(cell);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                    // advance to a free column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                    for (; rv.isFilled(col); col++);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                    int rowSpan = getRowsOccupied(cv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                    int colSpan = getColumnsOccupied(cv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                    if ((colSpan > 1) || (rowSpan > 1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                        // fill in the overflow entries for this cell
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                        int rowLimit = row + rowSpan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                        int colLimit = col + colSpan;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                        for (int i = row; i < rowLimit; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                            for (int j = col; j < colLimit; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                                if (i != row || j != col) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                                    addFill(i, j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                        if (colSpan > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                            col += colSpan - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                maxColumns = Math.max(maxColumns, col);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            // setup the column layout/requirements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            columnSpans = new int[maxColumns];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            columnOffsets = new int[maxColumns];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            columnRequirements = new SizeRequirements[maxColumns];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            for (int i = 0; i < maxColumns; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                columnRequirements[i] = new SizeRequirements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            gridValid = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * Mark a grid location as filled in for a cells overflow.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    void addFill(int row, int col) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        TableRow rv = getRow(row);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        if (rv != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            rv.fillColumn(col);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * Lays out the columns to fit within the given target span.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Returns the results through {@code offsets} and {@code spans}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @param targetSpan the given span for total of all the table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     *  columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @param reqs the requirements desired for each column.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     *  is the column maximum of the cells minimum, preferred, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     *  maximum requested span
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @param spans the return value of how much to allocated to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *  each column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @param offsets the return value of the offset from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     *  origin for each column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    protected void layoutColumns(int targetSpan, int[] offsets, int[] spans,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                                 SizeRequirements[] reqs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        // allocate using the convenience method on SizeRequirements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        SizeRequirements.calculateTiledPositions(targetSpan, null, reqs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                                                 offsets, spans);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * Perform layout for the minor axis of the box (i.e. the
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20158
diff changeset
   312
     * axis orthogonal to the axis that it represents).  The results
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * of the layout should be placed in the given arrays which represent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * the allocations to the children along the minor axis.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * is called by the superclass whenever the layout needs to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * updated along the minor axis.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * This is implemented to call the
7959
2e05332a8f5c 6589952: Swing: dead links in API documentation
rupashka
parents: 5506
diff changeset
   319
     * {@link #layoutColumns layoutColumns} method, and then
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * forward to the superclass to actually carry out the layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * of the tables rows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @param targetSpan the total span given to the view, which
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20158
diff changeset
   324
     *  would be used to layout the children.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @param axis the axis being layed out.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @param offsets the offsets from the origin of the view for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *  each of the child views.  This is a return value and is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     *  filled in by the implementation of this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @param spans the span of each child view.  This is a return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *  value and is filled in by the implementation of this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        // make grid is properly represented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        updateGrid();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        // all of the row layouts are invalid, so mark them that way
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        int n = getRowCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        for (int i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            TableRow row = getRow(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            row.layoutChanged(axis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        // calculate column spans
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        layoutColumns(targetSpan, columnOffsets, columnSpans, columnRequirements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        // continue normal layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        super.layoutMinorAxis(targetSpan, axis, offsets, spans);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * Calculate the requirements for the minor axis.  This is called by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * the superclass whenever the requirements need to be updated (i.e.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * a preferenceChanged was messaged through this view).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * This is implemented to calculate the requirements as the sum of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * requirements of the columns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        updateGrid();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        // calculate column requirements for each column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        calculateColumnRequirements(axis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        // the requirements are the sum of the columns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        if (r == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            r = new SizeRequirements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        long min = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        long pref = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        long max = 0;
1287
a04aca99c77a 6722802: Code improvement and warnings removing from the javax.swing.text package
rupashka
parents: 2
diff changeset
   372
        for (SizeRequirements req : columnRequirements) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            min += req.minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            pref += req.preferred;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            max += req.maximum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        r.minimum = (int) min;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        r.preferred = (int) pref;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        r.maximum = (int) max;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        r.alignment = 0;
44155
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   381
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   382
        totalColumnRequirements.minimum = r.minimum;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   383
        totalColumnRequirements.preferred = r.preferred;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   384
        totalColumnRequirements.maximum = r.maximum;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   385
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        return r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    boolean shouldTrace() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        AttributeSet a = getElement().getAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        Object o = a.getAttribute(HTML.Attribute.ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        if ((o != null) && o.equals("debug")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * Calculate the requirements for each column.  The calculation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * is done as two passes over the table.  The table cells that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * occupy a single column are scanned first to determine the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * maximum of minimum, preferred, and maximum spans along the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * give axis.  Table cells that span multiple columns are excluded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * from the first pass.  A second pass is made to determine if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * the cells that span multiple columns are satisfied.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * column requirements are not satisified, the needs of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * multi-column cell is mixed into the existing column requirements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * The calculation of the multi-column distribution is based upon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * the proportions of the existing column requirements and taking
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * into consideration any constraining maximums.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    void calculateColumnRequirements(int axis) {
44155
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   415
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   416
        for (SizeRequirements req : columnRequirements) {
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   417
            req.minimum = 0;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   418
            req.preferred = 0;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   419
            req.maximum = Integer.MAX_VALUE;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   420
        }
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   421
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        // pass 1 - single column cells
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        boolean hasMultiColumn = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        int nrows = getRowCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        for (int i = 0; i < nrows; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            TableRow row = getRow(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            int col = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            int ncells = row.getViewCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            for (int cell = 0; cell < ncells; cell++, col++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                View cv = row.getView(cell);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                for (; row.isFilled(col); col++); // advance to a free column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                int rowSpan = getRowsOccupied(cv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                int colSpan = getColumnsOccupied(cv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                if (colSpan == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                    checkSingleColumnCell(axis, col, cv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                    hasMultiColumn = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                    col += colSpan - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        // pass 2 - multi-column cells
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        if (hasMultiColumn) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            for (int i = 0; i < nrows; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                TableRow row = getRow(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                int col = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                int ncells = row.getViewCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                for (int cell = 0; cell < ncells; cell++, col++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                    View cv = row.getView(cell);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                    for (; row.isFilled(col); col++); // advance to a free column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                    int colSpan = getColumnsOccupied(cv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                    if (colSpan > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                        checkMultiColumnCell(axis, col, colSpan, cv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                        col += colSpan - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        if (shouldTrace()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            System.err.println("calc:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            for (int i = 0; i < columnRequirements.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                System.err.println(" " + i + ": " + columnRequirements[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * check the requirements of a table cell that spans a single column.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    void checkSingleColumnCell(int axis, int col, View v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        SizeRequirements req = columnRequirements[col];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        req.minimum = Math.max((int) v.getMinimumSpan(axis), req.minimum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        req.preferred = Math.max((int) v.getPreferredSpan(axis), req.preferred);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        req.maximum = Math.max((int) v.getMaximumSpan(axis), req.maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * check the requirements of a table cell that spans multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * columns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    void checkMultiColumnCell(int axis, int col, int ncols, View v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        // calculate the totals
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        long min = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        long pref = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        long max = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        for (int i = 0; i < ncols; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            SizeRequirements req = columnRequirements[col + i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            min += req.minimum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            pref += req.preferred;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            max += req.maximum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        // check if the minimum size needs adjustment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        int cmin = (int) v.getMinimumSpan(axis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        if (cmin > min) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
             * the columns that this cell spans need adjustment to fit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
             * this table cell.... calculate the adjustments.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
             * maximum for each cell is the maximum of the existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
             * maximum or the amount needed by the cell.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            SizeRequirements[] reqs = new SizeRequirements[ncols];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            for (int i = 0; i < ncols; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
                SizeRequirements r = reqs[i] = columnRequirements[col + i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                r.maximum = Math.max(r.maximum, (int) v.getMaximumSpan(axis));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            int[] spans = new int[ncols];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            int[] offsets = new int[ncols];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
            SizeRequirements.calculateTiledPositions(cmin, null, reqs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                                                     offsets, spans);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            // apply the adjustments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            for (int i = 0; i < ncols; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                SizeRequirements req = reqs[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                req.minimum = Math.max(spans[i], req.minimum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                req.preferred = Math.max(req.minimum, req.preferred);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                req.maximum = Math.max(req.preferred, req.maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        // check if the preferred size needs adjustment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        int cpref = (int) v.getPreferredSpan(axis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        if (cpref > pref) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
             * the columns that this cell spans need adjustment to fit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
             * this table cell.... calculate the adjustments.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
             * maximum for each cell is the maximum of the existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
             * maximum or the amount needed by the cell.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            SizeRequirements[] reqs = new SizeRequirements[ncols];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            for (int i = 0; i < ncols; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                SizeRequirements r = reqs[i] = columnRequirements[col + i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
            int[] spans = new int[ncols];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            int[] offsets = new int[ncols];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            SizeRequirements.calculateTiledPositions(cpref, null, reqs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                                                     offsets, spans);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
            // apply the adjustments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
            for (int i = 0; i < ncols; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                SizeRequirements req = reqs[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                req.preferred = Math.max(spans[i], req.preferred);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                req.maximum = Math.max(req.preferred, req.maximum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * Fetches the child view that represents the given position in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * the model.  This is implemented to walk through the children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * looking for a range that contains the given position.  In this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * view the children do not necessarily have a one to one mapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * with the child elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     *
20158
1c5d22e5b898 8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents: 9035
diff changeset
   558
     * @param pos  the search position &gt;= 0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * @param a  the allocation to the table on entry, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     *   allocation of the view containing the position on exit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * @return  the view representing the given position, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     *   <code>null</code> if there isn't one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    protected View getViewAtPosition(int pos, Rectangle a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        int n = getViewCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        for (int i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            View v = getView(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            int p0 = v.getStartOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            int p1 = v.getEndOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
            if ((pos >= p0) && (pos < p1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                // it's in this view.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                if (a != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                    childAllocation(i, a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                return v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        if (pos == getEndOffset()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            View v = getView(n - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            if (a != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                this.childAllocation(n - 1, a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            return v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    // ---- variables ----------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    int[] columnSpans;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    int[] columnOffsets;
44155
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   592
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   593
    SizeRequirements totalColumnRequirements;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   594
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    SizeRequirements[] columnRequirements;
1287
a04aca99c77a 6722802: Code improvement and warnings removing from the javax.swing.text package
rupashka
parents: 2
diff changeset
   596
    Vector<TableRow> rows;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    boolean gridValid;
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 25859
diff changeset
   598
    private static final BitSet EMPTY = new BitSet();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * View of a row in a row-centric table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    public class TableRow extends BoxView {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
         * Constructs a TableView for the given element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
         * @param elem the element that this view is responsible for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
         * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        public TableRow(Element elem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            super(elem, View.X_AXIS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            fillColumns = new BitSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        void clearFilledColumns() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            fillColumns.and(EMPTY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        void fillColumn(int col) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            fillColumns.set(col);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        boolean isFilled(int col) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
            return fillColumns.get(col);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        /** get location in the overall set of rows */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        int getRow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            return row;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
         * set location in the overall set of rows, this is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
         * set by the TableView.updateGrid() method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        void setRow(int row) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            this.row = row;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
         * The number of columns present in this row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        int getColumnCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
            int nfill = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            int n = fillColumns.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            for (int i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                if (fillColumns.get(i)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
                    nfill ++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            return getViewCount() + nfill;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
         * Change the child views.  This is implemented to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
         * provide the superclass behavior and invalidate the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
         * grid so that rows and columns will be recalculated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        public void replace(int offset, int length, View[] views) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
            super.replace(offset, length, views);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
            invalidateGrid();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
44155
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   665
        @Override
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   666
        protected SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements r) {
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   667
            SizeRequirements req = new SizeRequirements();
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   668
            req.minimum = totalColumnRequirements.minimum;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   669
            req.maximum = totalColumnRequirements.maximum;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   670
            req.preferred = totalColumnRequirements.preferred;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   671
            req.alignment = 0f;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   672
            return req;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   673
        }
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   674
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   675
        @Override
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   676
        public float getMinimumSpan(int axis) {
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   677
            float value;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   678
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   679
            if (axis == View.X_AXIS) {
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   680
                value = totalColumnRequirements.minimum + getLeftInset() + getRightInset();
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   681
            } else {
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   682
                value = super.getMinimumSpan(axis);
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   683
            }
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   684
            return value;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   685
        }
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   686
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   687
        @Override
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   688
        public float getMaximumSpan(int axis) {
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   689
            float value;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   690
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   691
            if (axis == View.X_AXIS) {
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   692
                // We're flexible.
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   693
                value = (float) Integer.MAX_VALUE;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   694
            } else {
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   695
                value = super.getMaximumSpan(axis);
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   696
            }
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   697
            return value;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   698
        }
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   699
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   700
        @Override
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   701
        public float getPreferredSpan(int axis) {
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   702
            float value;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   703
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   704
            if (axis == View.X_AXIS) {
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   705
                value = totalColumnRequirements.preferred + getLeftInset() + getRightInset();
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   706
            } else {
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   707
                value = super.getPreferredSpan(axis);
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   708
            }
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   709
            return value;
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   710
        }
1bf93336ea45 8158209: Editing in TableView breaks the layout, when the document is I18n
serb
parents: 32865
diff changeset
   711
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
         * Perform layout for the major axis of the box (i.e. the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
         * axis that it represents).  The results of the layout should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
         * be placed in the given arrays which represent the allocations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
         * to the children along the major axis.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
         * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
         * This is re-implemented to give each child the span of the column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
         * width for the table, and to give cells that span multiple columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
         * the multi-column span.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
         * @param targetSpan the total span given to the view, which
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20158
diff changeset
   723
         *  would be used to layout the children.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
         * @param axis the axis being layed out.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
         * @param offsets the offsets from the origin of the view for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
         *  each of the child views.  This is a return value and is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
         *  filled in by the implementation of this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
         * @param spans the span of each child view.  This is a return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
         *  value and is filled in by the implementation of this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets, int[] spans) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
            int col = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
            int ncells = getViewCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
            for (int cell = 0; cell < ncells; cell++, col++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                View cv = getView(cell);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                for (; isFilled(col); col++); // advance to a free column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                int colSpan = getColumnsOccupied(cv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                spans[cell] = columnSpans[col];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
                offsets[cell] = columnOffsets[col];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                if (colSpan > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
                    int n = columnSpans.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
                    for (int j = 1; j < colSpan; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                        // Because the table may be only partially formed, some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                        // of the columns may not yet exist.  Therefore we check
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
                        // the bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
                        if ((col+j) < n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                            spans[cell] += columnSpans[col+j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
                    col += colSpan - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
         * Perform layout for the minor axis of the box (i.e. the
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20158
diff changeset
   757
         * axis orthogonal to the axis that it represents).  The results
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
         * of the layout should be placed in the given arrays which represent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
         * the allocations to the children along the minor axis.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
         * is called by the superclass whenever the layout needs to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
         * updated along the minor axis.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
         * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
         * This is implemented to delegate to the superclass, then adjust
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
         * the span for any cell that spans multiple rows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
         * @param targetSpan the total span given to the view, which
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 20158
diff changeset
   767
         *  would be used to layout the children.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
         * @param axis the axis being layed out.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
         * @param offsets the offsets from the origin of the view for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
         *  each of the child views.  This is a return value and is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
         *  filled in by the implementation of this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
         * @param spans the span of each child view.  This is a return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
         *  value and is filled in by the implementation of this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        protected void layoutMinorAxis(int targetSpan, int axis, int[] offsets, int[] spans) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
            super.layoutMinorAxis(targetSpan, axis, offsets, spans);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
            int col = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
            int ncells = getViewCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            for (int cell = 0; cell < ncells; cell++, col++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
                View cv = getView(cell);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                for (; isFilled(col); col++); // advance to a free column
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
                int colSpan = getColumnsOccupied(cv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                int rowSpan = getRowsOccupied(cv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                if (rowSpan > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                    for (int j = 1; j < rowSpan; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                        // test bounds of each row because it may not exist
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
                        // either because of error or because the table isn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                        // fully loaded yet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                        int row = getRow() + j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                        if (row < TableView.this.getViewCount()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                            int span = TableView.this.getSpan(Y_AXIS, getRow()+j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
                            spans[cell] += span;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
                if (colSpan > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
                    col += colSpan - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
         * Determines the resizability of the view along the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
         * given axis.  A value of 0 or less is not resizable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
         * @param axis may be either View.X_AXIS or View.Y_AXIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
         * @return the resize weight
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
         * @exception IllegalArgumentException for an invalid axis
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        public int getResizeWeight(int axis) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
            return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
         * Fetches the child view that represents the given position in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
         * the model.  This is implemented to walk through the children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
         * looking for a range that contains the given position.  In this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
         * view the children do not necessarily have a one to one mapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
         * with the child elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
         *
20158
1c5d22e5b898 8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents: 9035
diff changeset
   821
         * @param pos  the search position &gt;= 0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
         * @param a  the allocation to the table on entry, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
         *   allocation of the view containing the position on exit
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
         * @return  the view representing the given position, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
         *   <code>null</code> if there isn't one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        protected View getViewAtPosition(int pos, Rectangle a) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
            int n = getViewCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
            for (int i = 0; i < n; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                View v = getView(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                int p0 = v.getStartOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
                int p1 = v.getEndOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
                if ((pos >= p0) && (pos < p1)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
                    // it's in this view.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                    if (a != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
                        childAllocation(i, a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
                    return v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
            if (pos == getEndOffset()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
                View v = getView(n - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
                if (a != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                    this.childAllocation(n - 1, a);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                return v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        /** columns filled by multi-column or multi-row cells */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        BitSet fillColumns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        /** the row within the overall grid */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        int row;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
     * @deprecated  A table cell can now be any View implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
    public class TableCell extends BoxView implements GridCell {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
         * Constructs a TableCell for the given element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
         * @param elem the element that this view is responsible for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
         * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        public TableCell(Element elem) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
            super(elem, View.Y_AXIS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        // --- GridCell methods -------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
         * Gets the number of columns this cell spans (e.g. the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
         * grid width).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
         * @return the number of columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        public int getColumnCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
         * Gets the number of rows this cell spans (that is, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
         * grid height).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
         * @return the number of rows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        public int getRowCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
            return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
         * Sets the grid location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
         *
20158
1c5d22e5b898 8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents: 9035
diff changeset
   899
         * @param row the row &gt;= 0
1c5d22e5b898 8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents: 9035
diff changeset
   900
         * @param col the column &gt;= 0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        public void setGridLocation(int row, int col) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
            this.row = row;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
            this.col = col;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
         * Gets the row of the grid location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
        public int getGridRow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
            return row;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
         * Gets the column of the grid location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
        public int getGridColumn() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
            return col;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        int row;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
        int col;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     * <em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     * THIS IS NO LONGER USED, AND WILL BE REMOVED IN THE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     * NEXT RELEASE.  THE JCK SIGNATURE TEST THINKS THIS INTERFACE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
     * SHOULD EXIST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
     * </em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
    interface GridCell {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
         * Sets the grid location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
         *
20158
1c5d22e5b898 8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents: 9035
diff changeset
   937
         * @param row the row &gt;= 0
1c5d22e5b898 8025117: [cleanup] Eliminate doclint errors in javax/swing/text classes
yan
parents: 9035
diff changeset
   938
         * @param col the column &gt;= 0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        public void setGridLocation(int row, int col);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
         * Gets the row of the grid location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
        public int getGridRow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
         * Gets the column of the grid location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
        public int getGridColumn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
         * Gets the number of columns this cell spans (e.g. the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
         * grid width).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
         * @return the number of columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        public int getColumnCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
         * Gets the number of rows this cell spans (that is, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
         * grid height).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
         * @return the number of rows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        public int getRowCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
}