📄 accessiblehtml.java
字号:
return rowHeadersTable; } /** * Sets the row headers. * * @param table an AccessibleTable representing the * row headers */ public void setAccessibleRowHeader(AccessibleTable table) { } /** * Returns the column headers as an AccessibleTable. * * @return an AccessibleTable representing the column * headers */ public AccessibleTable getAccessibleColumnHeader() { return null; } /** * Sets the column headers. * * @param table an AccessibleTable representing the * column headers */ public void setAccessibleColumnHeader(AccessibleTable table) { } /** * Returns the description of the specified row in the table. * * @param r zero-based row of the table * @return the description of the row */ public Accessible getAccessibleRowDescription(int r) { return null; } /** * Sets the description text of the specified row of the table. * * @param r zero-based row of the table * @param a the description of the row */ public void setAccessibleRowDescription(int r, Accessible a) { } /** * Returns the description text of the specified column in the table. * * @param c zero-based column of the table * @return the text description of the column */ public Accessible getAccessibleColumnDescription(int c) { return null; } /** * Sets the description text of the specified column in the table. * * @param c zero-based column of the table * @param a the text description of the column */ public void setAccessibleColumnDescription(int c, Accessible a) { } /** * Returns a boolean value indicating whether the accessible at * a specified row and column is selected. * * @param r zero-based row of the table * @param c zero-based column of the table * @return the boolean value true if the accessible at the * row and column is selected. Otherwise, the boolean value * false */ public boolean isAccessibleSelected(int r, int c) { if (validateIfNecessary()) { if (r < 0 || r >= getAccessibleRowCount() || c < 0 || c >= getAccessibleColumnCount()) { return false; } TableCellElementInfo cell = getCell(r, c); if (cell != null) { Element elem = cell.getElement(); int start = elem.getStartOffset(); int end = elem.getEndOffset(); return start >= editor.getSelectionStart() && end <= editor.getSelectionEnd(); } } return false; } /** * Returns a boolean value indicating whether the specified row * is selected. * * @param r zero-based row of the table * @return the boolean value true if the specified row is selected. * Otherwise, false. */ public boolean isAccessibleRowSelected(int r) { if (validateIfNecessary()) { if (r < 0 || r >= getAccessibleRowCount()) { return false; } int nColumns = getAccessibleColumnCount(); TableCellElementInfo startCell = getCell(r, 0); if (startCell == null) { return false; } int start = startCell.getElement().getStartOffset(); TableCellElementInfo endCell = getCell(r, nColumns-1); if (endCell == null) { return false; } int end = endCell.getElement().getEndOffset(); return start >= editor.getSelectionStart() && end <= editor.getSelectionEnd(); } return false; } /** * Returns a boolean value indicating whether the specified column * is selected. * * @param r zero-based column of the table * @return the boolean value true if the specified column is selected. * Otherwise, false. */ public boolean isAccessibleColumnSelected(int c) { if (validateIfNecessary()) { if (c < 0 || c >= getAccessibleColumnCount()) { return false; } int nRows = getAccessibleRowCount(); TableCellElementInfo startCell = getCell(0, c); if (startCell == null) { return false; } int start = startCell.getElement().getStartOffset(); TableCellElementInfo endCell = getCell(nRows-1, c); if (endCell == null) { return false; } int end = endCell.getElement().getEndOffset(); return start >= editor.getSelectionStart() && end <= editor.getSelectionEnd(); } return false; } /** * Returns the selected rows in a table. * * @return an array of selected rows where each element is a * zero-based row of the table */ public int [] getSelectedAccessibleRows() { if (validateIfNecessary()) { int nRows = getAccessibleRowCount(); Vector vec = new Vector(); for (int i = 0; i < nRows; i++) { if (isAccessibleRowSelected(i)) { vec.addElement(new Integer(i)); } } int retval[] = new int[vec.size()]; for (int i = 0; i < retval.length; i++) { retval[i] = ((Integer)vec.elementAt(i)).intValue(); } return retval; } return new int[0]; } /** * Returns the selected columns in a table. * * @return an array of selected columns where each element is a * zero-based column of the table */ public int [] getSelectedAccessibleColumns() { if (validateIfNecessary()) { int nColumns = getAccessibleRowCount(); Vector vec = new Vector(); for (int i = 0; i < nColumns; i++) { if (isAccessibleColumnSelected(i)) { vec.addElement(new Integer(i)); } } int retval[] = new int[vec.size()]; for (int i = 0; i < retval.length; i++) { retval[i] = ((Integer)vec.elementAt(i)).intValue(); } return retval; } return new int[0]; } // begin AccessibleExtendedTable implementation ------------- /** * Returns the row number of an index in the table. * * @param index the zero-based index in the table * @return the zero-based row of the table if one exists; * otherwise -1. */ public int getAccessibleRow(int index) { if (validateIfNecessary()) { int numCells = getAccessibleColumnCount() * getAccessibleRowCount(); if (index >= numCells) { return -1; } else { return index / getAccessibleColumnCount(); } } return -1; } /** * Returns the column number of an index in the table. * * @param index the zero-based index in the table * @return the zero-based column of the table if one exists; * otherwise -1. */ public int getAccessibleColumn(int index) { if (validateIfNecessary()) { int numCells = getAccessibleColumnCount() * getAccessibleRowCount(); if (index >= numCells) { return -1; } else { return index % getAccessibleColumnCount(); } } return -1; } /** * Returns the index at a row and column in the table. * * @param r zero-based row of the table * @param c zero-based column of the table * @return the zero-based index in the table if one exists; * otherwise -1. */ public int getAccessibleIndex(int r, int c) { if (validateIfNecessary()) { if (r >= getAccessibleRowCount() || c >= getAccessibleColumnCount()) { return -1; } else { return r * getAccessibleColumnCount() + c; } } return -1; } /** * Returns the row header at a row in a table. * @param r zero-based row of the table * * @return a String representing the row header * if one exists; otherwise null. */ public String getAccessibleRowHeader(int r) { if (validateIfNecessary()) { TableCellElementInfo cellInfo = getCell(r, 0); if (cellInfo.isHeaderCell()) { View v = cellInfo.getView(); if (v != null && model != null) { try { return model.getText(v.getStartOffset(), v.getEndOffset() - v.getStartOffset()); } catch (BadLocationException e) { return null; } } } } return null; } /** * Returns the column header at a column in a table. * @param c zero-based column of the table * * @return a String representing the column header * if one exists; otherwise null. */ public String getAccessibleColumnHeader(int c) { if (validateIfNecessary()) { TableCellElementInfo cellInfo = getCell(0, c); if (cellInfo.isHeaderCell()) { View v = cellInfo.getView(); if (v != null && model != null) { try { return model.getText(v.getStartOffset(), v.getEndOffset() - v.getStartOffset()); } catch (BadLocationException e) { return null; } } } } return null; } public void addRowHeader(TableCellElementInfo cellInfo, int rowNumber) { if (rowHeadersTable == null) { rowHeadersTable = new AccessibleHeadersTable(); } rowHeadersTable.addHeader(cellInfo, rowNumber); } // end of AccessibleExtendedTable implementation ------------ protected class AccessibleHeadersTable implements AccessibleTable { // Header information is modeled as a Hashtable of // ArrayLists where each Hashtable entry represents // a row containing one or more headers. private Hashtable headers = new Hashtable(); private int rowCount = 0; private int columnCount = 0; public void addHeader(TableCellElementInfo cellInfo, int rowNumber) { Integer rowInteger = new Integer(rowNumber); ArrayList list = (ArrayList)headers.get(rowInteger); if (list == null) { list = new ArrayList(); headers.put(rowInteger, list); } list.add(cellInfo); } /** * Returns the caption for the table. * * @return the caption for the table */ public Accessible getAccessibleCaption() { return null; } /** * Sets the caption for the table. * * @param a the caption for the table */ public void setAccessibleCaption(Accessible a) { } /** * Returns the summary description of the table. * * @return the summary description of the table */ public Accessible getAccessibleSummary() { return null; } /** * Sets the summary description of the table * * @param a the summary description of the table */ public void setAccessibleSummary(Accessible a) { } /** * Returns the number of rows in the table. * * @return the number of rows in the table */ public int getAccessibleRowCount() { return rowCount; } /** * Returns the number of columns in the table. * * @return the number of columns in the table */ public int getAccessibleColumnCount() { return columnCount; } private TableCellElementInfo getElementInfoAt(int r, int c) { ArrayList list = (ArrayList)headers.get(new Integer(r)); if (list != null) { return (TableCellElementInfo)list.get(c); } else { return null; } } /** * Returns the Accessible at a specified row and column * in the table. * * @param r zero-based row of the table * @param c zero-based column of the table * @return the Accessible at the specified row and column */ public Accessible getAccessibleAt(int r, int c) { ElementInfo elementInfo = getElementInfoAt(r, c); if (elementInfo instanceof Accessible) { return (Accessible)elementInfo; } else { return null; } } /** * Returns the number of rows occupied by the Accessible at * a specified row and column in the table. * * @return the number of rows occupied by the Accessible at a * given specified (row, column) */ public int getAccessibleRowExtentAt(int r, int c) { TableCellElementInfo elementInfo = getElementInfoAt(r, c); if
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -