?? accessiblehtml.java
字號(hào):
* presented to a blind user to give an indication of the purpose * of the icon. * * @return the description of the icon */ public String getAccessibleIconDescription() { return ((ImageView)getView()).getAltText(); } /** * Sets the description of the icon. This is meant to be a brief * textual description of the object. For example, it might be * presented to a blind user to give an indication of the purpose * of the icon. * * @param description the description of the icon */ public void setAccessibleIconDescription(String description) { } /** * Gets the width of the icon * * @return the width of the icon. */ public int getAccessibleIconWidth() { if (width == -1) { width = getImageSize(HTML.Attribute.WIDTH); } return width; } /** * Gets the height of the icon * * @return the height of the icon. */ public int getAccessibleIconHeight() { if (height == -1) { height = getImageSize(HTML.Attribute.HEIGHT); } return height; } } // ... end AccessibleIconImplementation } /** * TableElementInfo encapsulates information about a HTML.Tag.TABLE. * To make access fast it crates a grid containing the children to * allow for access by row, column. TableElementInfo will contain * TableRowElementInfos, which will contain TableCellElementInfos. * Any time one of the rows or columns becomes invalid the table is * invalidated. This is because any time one of the child attributes * changes the size of the grid may have changed. */ private class TableElementInfo extends ElementInfo implements Accessible { protected ElementInfo caption; /** * Allocation of the table by row x column. There may be holes (eg * nulls) depending upon the html, any cell that has a rowspan/colspan * > 1 will be contained multiple times in the grid. */ private TableCellElementInfo[][] grid; TableElementInfo(Element e, ElementInfo parent) { super(e, parent); } public ElementInfo getCaptionInfo() { return caption; } /** * Overriden to update the grid when validating. */ protected void validate() { super.validate(); updateGrid(); } /** * Overriden to only alloc instances of TableRowElementInfos. */ protected void loadChildren(Element e) { for (int counter = 0; counter < e.getElementCount(); counter++) { Element child = e.getElement(counter); AttributeSet attrs = child.getAttributes(); if (attrs.getAttribute(StyleConstants.NameAttribute) == HTML.Tag.TR) { addChild(new TableRowElementInfo(child, this, counter)); } else if (attrs.getAttribute(StyleConstants.NameAttribute) == HTML.Tag.CAPTION) { // Handle captions as a special case since all other // children are table rows. caption = createElementInfo(child, this); } } } /** * Updates the grid. */ private void updateGrid() { // Determine the max row/col count. int delta = 0; int maxCols = 0; int rows = 0; for (int counter = 0; counter < getChildCount(); counter++) { TableRowElementInfo row = getRow(counter); int prev = 0; for (int y = 0; y < delta; y++) { prev = Math.max(prev, getRow(counter - y - 1). getColumnCount(y + 2)); } delta = Math.max(row.getRowCount(), delta); delta--; maxCols = Math.max(maxCols, row.getColumnCount() + prev); } rows = getChildCount() + delta; // Alloc grid = new TableCellElementInfo[rows][]; for (int counter = 0; counter < rows; counter++) { grid[counter] = new TableCellElementInfo[maxCols]; } // Update for (int counter = 0; counter < rows; counter++) { getRow(counter).updateGrid(counter); } } /** * Returns the TableCellElementInfo at the specified index. */ public TableRowElementInfo getRow(int index) { return (TableRowElementInfo)getChild(index); } /** * Returns the TableCellElementInfo by row and column. */ public TableCellElementInfo getCell(int r, int c) { if (validateIfNecessary() && r < grid.length && c < grid[0].length) { return grid[r][c]; } return null; } /** * Returns the rowspan of the specified entry. */ public int getRowExtentAt(int r, int c) { TableCellElementInfo cell = getCell(r, c); if (cell != null) { int rows = cell.getRowCount(); int delta = 1; while ((r - delta) >= 0 && grid[r - delta][c] == cell) { delta++; } return rows - delta + 1; } return 0; } /** * Returns the colspan of the specified entry. */ public int getColumnExtentAt(int r, int c) { TableCellElementInfo cell = getCell(r, c); if (cell != null) { int cols = cell.getColumnCount(); int delta = 1; while ((c - delta) >= 0 && grid[r][c - delta] == cell) { delta++; } return cols - delta + 1; } return 0; } /** * Returns the number of rows in the table. */ public int getRowCount() { if (validateIfNecessary()) { return grid.length; } return 0; } /** * Returns the number of columns in the table. */ public int getColumnCount() { if (validateIfNecessary() && grid.length > 0) { return grid[0].length; } return 0; } // begin AccessibleTable implementation ... private AccessibleContext accessibleContext; public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new TableAccessibleContext(this); } return accessibleContext; } /* * AccessibleContext for tables */ public class TableAccessibleContext extends HTMLAccessibleContext implements AccessibleTable { private AccessibleHeadersTable rowHeadersTable; public TableAccessibleContext(ElementInfo elementInfo) { super(elementInfo); } /** * Gets the accessibleName property of this object. The accessibleName * property of an object is a localized String that designates the purpose * of the object. For example, the accessibleName property of a label * or button might be the text of the label or button itself. In the * case of an object that doesn't display its name, the accessibleName * should still be set. For example, in the case of a text field used * to enter the name of a city, the accessibleName for the en_US locale * could be 'city.' * * @return the localized name of the object; null if this * object does not have a name * * @see #setAccessibleName */ public String getAccessibleName() { // return the role of the object return getAccessibleRole().toString(); } /** * Gets the accessibleDescription property of this object. If this * property isn't set, returns the content type of this * <code>JEditorPane</code> instead (e.g. "plain/text", "html/text"). * * @return the localized description of the object; <code>null</code> * if this object does not have a description * * @see #setAccessibleName */ public String getAccessibleDescription() { return editor.getContentType(); } /** * Gets the role of this object. The role of the object is the generic * purpose or use of the class of this object. For example, the role * of a push button is AccessibleRole.PUSH_BUTTON. The roles in * AccessibleRole are provided so component developers can pick from * a set of predefined roles. This enables assistive technologies to * provide a consistent interface to various tweaked subclasses of * components (e.g., use AccessibleRole.PUSH_BUTTON for all components * that act like a push button) as well as distinguish between sublasses * that behave differently (e.g., AccessibleRole.CHECK_BOX for check boxes * and AccessibleRole.RADIO_BUTTON for radio buttons). * <p>Note that the AccessibleRole class is also extensible, so * custom component developers can define their own AccessibleRole's * if the set of predefined roles is inadequate. * * @return an instance of AccessibleRole describing the role of the object * @see AccessibleRole */ public AccessibleRole getAccessibleRole() { return AccessibleRole.TABLE; } /** * Gets the 0-based index of this object in its accessible parent. * * @return the 0-based index of this object in its parent; -1 if this * object does not have an accessible parent. * * @see #getAccessibleParent * @see #getAccessibleChildrenCount * @gsee #getAccessibleChild */ public int getAccessibleIndexInParent() { return elementInfo.getIndexInParent(); } /** * Returns the number of accessible children of the object. * * @return the number of accessible children of the object. */ public int getAccessibleChildrenCount() { return ((TableElementInfo)elementInfo).getRowCount() * ((TableElementInfo)elementInfo).getColumnCount(); } /** * Returns the specified Accessible child of the object. The Accessible * children of an Accessible object are zero-based, so the first child * of an Accessible child is at index 0, the second child is at index 1, * and so on. * * @param i zero-based index of child * @return the Accessible child of the object * @see #getAccessibleChildrenCount */ public Accessible getAccessibleChild(int i) { int rowCount = ((TableElementInfo)elementInfo).getRowCount(); int columnCount = ((TableElementInfo)elementInfo).getColumnCount(); int r = i / rowCount; int c = i % columnCount; if (r < 0 || r >= rowCount || c < 0 || c >= columnCount) { return null; } else { return getAccessibleAt(r, c); } } public AccessibleTable getAccessibleTable() { return this; } /** * Returns the caption for the table. * * @return the caption for the table */ public Accessible getAccessibleCaption() { ElementInfo captionInfo = getCaptionInfo(); if (captionInfo instanceof Accessible) { return (Accessible)caption; } else { 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 ((TableElementInfo)elementInfo).getRowCount(); } /** * Returns the number of columns in the table. * * @return the number of columns in the table */ public int getAccessibleColumnCount() { return ((TableElementInfo)elementInfo).getColumnCount(); } /** * 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) { TableCellElementInfo cellInfo = getCell(r, c); if (cellInfo != null) { return cellInfo.getAccessible(); } 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) { return ((TableElementInfo)elementInfo).getRowExtentAt(r, c); } /** * Returns the number of columns occupied by the Accessible at * a specified row and column in the table. * * @return the number of columns occupied by the Accessible at a * given specified row and column */ public int getAccessibleColumnExtentAt(int r, int c) { return ((TableElementInfo)elementInfo).getColumnExtentAt(r, c); } /** * Returns the row headers as an AccessibleTable. * * @return an AccessibleTable representing the row * headers */ public AccessibleTable getAccessibleRowHeader() {
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -