1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
7200 /**
7201 * Returns an <code>Accessible</code> representing the
7202 * specified selected child in the object. If there
7203 * isn't a selection, or there are fewer children selected
7204 * than the integer passed in, the return
7205 * value will be <code>null</code>.
7206 * <p>Note that the index represents the i-th selected child, which
7207 * is different from the i-th child.
7208 *
7209 * @param i the zero-based index of selected children
7210 * @return the i-th selected child
7211 * @see #getAccessibleSelectionCount
7212 */
7213 public Accessible getAccessibleSelection(int i) {
7214 if (i < 0 || i > getAccessibleSelectionCount()) {
7215 return null;
7216 }
7217
7218 int rowsSel = JTable.this.getSelectedRowCount();
7219 int colsSel = JTable.this.getSelectedColumnCount();
7220 int rowIndicies[] = getSelectedRows();
7221 int colIndicies[] = getSelectedColumns();
7222 int ttlCols = JTable.this.getColumnCount();
7223 int ttlRows = JTable.this.getRowCount();
7224 int r;
7225 int c;
7226
7227 if (JTable.this.cellSelectionEnabled) { // a contiguous block
7228 r = rowIndicies[i / colsSel];
7229 c = colIndicies[i % colsSel];
7230 return getAccessibleChild((r * ttlCols) + c);
7231 } else {
7232
7233 // a column swath and a row swath, with a shared block
7234 if (JTable.this.getRowSelectionAllowed() &&
7235 JTable.this.getColumnSelectionAllowed()) {
7236
7237 // Situation:
7238 // We have a table, like the 6x3 table below,
7239 // wherein three colums and one row selected
7240 // (selected cells marked with "*", unselected "0"):
7241 //
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
7200 /**
7201 * Returns an <code>Accessible</code> representing the
7202 * specified selected child in the object. If there
7203 * isn't a selection, or there are fewer children selected
7204 * than the integer passed in, the return
7205 * value will be <code>null</code>.
7206 * <p>Note that the index represents the i-th selected child, which
7207 * is different from the i-th child.
7208 *
7209 * @param i the zero-based index of selected children
7210 * @return the i-th selected child
7211 * @see #getAccessibleSelectionCount
7212 */
7213 public Accessible getAccessibleSelection(int i) {
7214 if (i < 0 || i > getAccessibleSelectionCount()) {
7215 return null;
7216 }
7217
7218 int rowsSel = JTable.this.getSelectedRowCount();
7219 int colsSel = JTable.this.getSelectedColumnCount();
7220 int[] rowIndicies = getSelectedRows();
7221 int[] colIndicies = getSelectedColumns();
7222 int ttlCols = JTable.this.getColumnCount();
7223 int ttlRows = JTable.this.getRowCount();
7224 int r;
7225 int c;
7226
7227 if (JTable.this.cellSelectionEnabled) { // a contiguous block
7228 r = rowIndicies[i / colsSel];
7229 c = colIndicies[i % colsSel];
7230 return getAccessibleChild((r * ttlCols) + c);
7231 } else {
7232
7233 // a column swath and a row swath, with a shared block
7234 if (JTable.this.getRowSelectionAllowed() &&
7235 JTable.this.getColumnSelectionAllowed()) {
7236
7237 // Situation:
7238 // We have a table, like the 6x3 table below,
7239 // wherein three colums and one row selected
7240 // (selected cells marked with "*", unselected "0"):
7241 //
|