# HG changeset patch # User jgiles # Date 1358813977 -46800 # Node ID 2c55d2dc23bfe06213f54e8612b81f4ba6beacea # Parent a5f4d40a0d4f95556394b8ce7848fdcc46a10048 RT-27832: Remove cell spanning API (from JavaFX 8.0) diff --git a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkin.java b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkin.java +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkin.java @@ -36,7 +36,6 @@ import javafx.collections.ObservableList; import javafx.scene.Node; import javafx.scene.control.Control; -import javafx.scene.control.SpanModel; import javafx.scene.control.TableColumnBase; /** @@ -70,8 +69,8 @@ } this.tableView = getSkinnable().getTableView(); - spanModel = tableView.getSpanModel(); - registerChangeListener(tableView.spanModelProperty(), "SPAN_MODEL"); +// spanModel = tableView.getSpanModel(); +// registerChangeListener(tableView.spanModelProperty(), "SPAN_MODEL"); } } @@ -91,9 +90,9 @@ return tableView.getVisibleLeafColumns(); } - @Override protected ObjectProperty> spanModelProperty() { - return tableView.spanModelProperty(); - } +// @Override protected ObjectProperty> spanModelProperty() { +// return tableView.spanModelProperty(); +// } @Override protected void updateCell(TableCell cell, TableRow row) { cell.updateTableRow(row); diff --git a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkinBase.java b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkinBase.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkinBase.java +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkinBase.java @@ -44,10 +44,8 @@ import javafx.geometry.VPos; import javafx.scene.Group; import javafx.scene.Node; -import javafx.scene.control.CellSpan; import javafx.scene.control.Control; import javafx.scene.control.IndexedCell; -import javafx.scene.control.SpanModel; import javafx.scene.control.TableColumnBase; import javafx.util.Duration; @@ -120,7 +118,7 @@ protected abstract Control getVirtualFlowOwner(); // return TableView / TreeTableView protected abstract ObservableList*/> getVisibleLeafColumns(); - protected abstract ObjectProperty> spanModelProperty(); +// protected abstract ObjectProperty> spanModelProperty(); protected abstract void updateCell(R cell, C row); // cell.updateTableRow(skinnable); (i.e cell.updateTableRow(row)) @@ -183,8 +181,8 @@ } }; - // spanning support - protected SpanModel spanModel; +// // spanning support +// protected SpanModel spanModel; // supports variable row heights public static double getTableRowHeight(int index, C tableRow) { @@ -221,86 +219,86 @@ node.setVisible(true); } - // TODO we can optimise this code if we cache the spanTypeArray, which at - // present is created for every query - // TODO we can optimise this code if we set a maximum span distance - private SpanType getSpanType(final int row, final int column) { - SpanType[][] spanTypeArray; -// if (spanMap.containsKey(tableView)) { -// spanTypeArray = spanMap.get(tableView); +// // TODO we can optimise this code if we cache the spanTypeArray, which at +// // present is created for every query +// // TODO we can optimise this code if we set a maximum span distance +// private SpanType getSpanType(final int row, final int column) { +// SpanType[][] spanTypeArray; +//// if (spanMap.containsKey(tableView)) { +//// spanTypeArray = spanMap.get(tableView); +//// +//// // if we already have an array, lets check it for the result +//// if (spanTypeArray != null && row < spanTypeArray.length && column < spanTypeArray[0].length) { +//// SpanType cachedResult = spanTypeArray[row][column]; +//// if (cachedResult != SpanType.UNSET) { +//// return cachedResult; +//// } +//// } +//// } else { +// int rowCount = itemsProperty().get().size(); +// int columnCount = getVisibleLeafColumns().size(); +// spanTypeArray = new SpanType[rowCount][columnCount]; +//// spanMap.put(tableView, spanTypeArray); // -// // if we already have an array, lets check it for the result -// if (spanTypeArray != null && row < spanTypeArray.length && column < spanTypeArray[0].length) { -// SpanType cachedResult = spanTypeArray[row][column]; -// if (cachedResult != SpanType.UNSET) { -// return cachedResult; +// // initialise the array to be SpanType.UNSET +// for (int _row = 0; _row < rowCount; _row++) { +// for (int _column = 0; _column < columnCount; _column++) { +// spanTypeArray[_row][_column] = SpanType.UNSET; // } // } -// } else { - int rowCount = itemsProperty().get().size(); - int columnCount = getVisibleLeafColumns().size(); - spanTypeArray = new SpanType[rowCount][columnCount]; -// spanMap.put(tableView, spanTypeArray); - - // initialise the array to be SpanType.UNSET - for (int _row = 0; _row < rowCount; _row++) { - for (int _column = 0; _column < columnCount; _column++) { - spanTypeArray[_row][_column] = SpanType.UNSET; - } - } +//// } +// +// if (spanModel == null) { +// spanTypeArray[row][column] = SpanType.NONE; +// return SpanType.NONE; // } - - if (spanModel == null) { - spanTypeArray[row][column] = SpanType.NONE; - return SpanType.NONE; - } - - // for the given row / column position, we need to see if anything in - // the spanModel will prevent this column from being shown - - // Firstly we will check along the x-axis (i.e. whether there is an - // earlier TableColumn that covers this column index) - int distance = 0; - for (int _col = column - 1; _col >= 0; _col--) { - distance++; - CellSpan cellSpan = getCellSpanAt(spanModel, row, _col); - if (cellSpan == null) continue; - if (cellSpan.getColumnSpan() > distance) { - spanTypeArray[row][column] = SpanType.COLUMN; - return SpanType.COLUMN; - } - } - - // secondly we'll try along the y-axis - distance = 0; - for (int _row = row - 1; _row >= 0; _row--) { - distance++; - CellSpan cellSpan = getCellSpanAt(spanModel, _row, column); - if (cellSpan == null) continue; - if (cellSpan.getRowSpan() > distance) { - spanTypeArray[row][column] = SpanType.ROW; - return SpanType.ROW; - } - } - - // finally, we have to try diagonally - int rowDistance = 0; - int columnDistance = 0; - for (int _col = column - 1, _row = row - 1; _col >= 0 && _row >= 0; _col--, _row--) { - rowDistance++; - columnDistance++; - CellSpan cellSpan = getCellSpanAt(spanModel, _row, _col); - if (cellSpan == null) continue; - if (cellSpan.getRowSpan() > rowDistance && - cellSpan.getColumnSpan() > columnDistance) { - spanTypeArray[row][column] = SpanType.BOTH; - return SpanType.BOTH; - } - } - - spanTypeArray[row][column] = SpanType.NONE; - return SpanType.NONE; - } +// +// // for the given row / column position, we need to see if anything in +// // the spanModel will prevent this column from being shown +// +// // Firstly we will check along the x-axis (i.e. whether there is an +// // earlier TableColumn that covers this column index) +// int distance = 0; +// for (int _col = column - 1; _col >= 0; _col--) { +// distance++; +// CellSpan cellSpan = getCellSpanAt(spanModel, row, _col); +// if (cellSpan == null) continue; +// if (cellSpan.getColumnSpan() > distance) { +// spanTypeArray[row][column] = SpanType.COLUMN; +// return SpanType.COLUMN; +// } +// } +// +// // secondly we'll try along the y-axis +// distance = 0; +// for (int _row = row - 1; _row >= 0; _row--) { +// distance++; +// CellSpan cellSpan = getCellSpanAt(spanModel, _row, column); +// if (cellSpan == null) continue; +// if (cellSpan.getRowSpan() > distance) { +// spanTypeArray[row][column] = SpanType.ROW; +// return SpanType.ROW; +// } +// } +// +// // finally, we have to try diagonally +// int rowDistance = 0; +// int columnDistance = 0; +// for (int _col = column - 1, _row = row - 1; _col >= 0 && _row >= 0; _col--, _row--) { +// rowDistance++; +// columnDistance++; +// CellSpan cellSpan = getCellSpanAt(spanModel, _row, _col); +// if (cellSpan == null) continue; +// if (cellSpan.getRowSpan() > rowDistance && +// cellSpan.getColumnSpan() > columnDistance) { +// spanTypeArray[row][column] = SpanType.BOTH; +// return SpanType.BOTH; +// } +// } +// +// spanTypeArray[row][column] = SpanType.NONE; +// return SpanType.NONE; +// } @@ -340,9 +338,9 @@ // registerChangeListener(control.editingProperty(), "EDITING"); registerChangeListener(control.itemProperty(), "ITEM"); - // add listener to cell span model - spanModel = spanModelProperty().get(); - registerChangeListener(spanModelProperty(), "SPAN_MODEL"); +// // add listener to cell span model +// spanModel = spanModelProperty().get(); +// registerChangeListener(spanModelProperty(), "SPAN_MODEL"); } @Override protected void handleControlPropertyChanged(String p) { @@ -361,10 +359,10 @@ // Required to fix RT-24725 getSkinnable().layout(); - } else if (p == "SPAN_MODEL") { - // TODO update layout based on changes to span model - spanModel = spanModelProperty().get(); - getSkinnable().requestLayout(); +// } else if (p == "SPAN_MODEL") { +// // TODO update layout based on changes to span model +// spanModel = spanModelProperty().get(); +// getSkinnable().requestLayout(); } } @@ -520,57 +518,57 @@ // further indentation code ends here /////////////////////////////////////////// - /////////////////////////////////////////// - // cell spanning code starts here - /////////////////////////////////////////// - if (spanModel != null) { - // cell span check - basically, see if there is a cell span - // impacting upon the cell at the given row / column index - SpanType spanType = getSpanType(row, column); - switch (spanType) { - case ROW: - case BOTH: x += width; // fall through is on purpose here - case COLUMN: - hide(tableCell); - tableCell.resize(0, 0); - tableCell.relocate(x, insets.getTop()); - continue; // we don't want to fall through - // infact, we return to the loop here - case NONE: - case UNSET: // fall through and carry on - } - - CellSpan cellSpan = getCellSpanAt(spanModel, row, column); - if (cellSpan != null) { - if (cellSpan.getColumnSpan() > 1) { - // we need to span multiple columns, so we sum up - // the width of the additional columns, adding it - // to the width variable - for (int i = 1, - colSpan = cellSpan.getColumnSpan(), - maxColumns = getChildren().size() - column; - i < colSpan && i < maxColumns; i++) { - // calculate the width - Node adjacentNode = getChildren().get(column + i); - width += snapSize(adjacentNode.prefWidth(-1)); - } - } - - if (cellSpan.getRowSpan() > 1) { - // we need to span multiple rows, so we sum up - // the height of the additional rows, adding it - // to the height variable - for (int i = 1; i < cellSpan.getRowSpan(); i++) { - // calculate the height - double rowHeight = getTableRowHeight(row + i, getSkinnable()); - height += snapSize(rowHeight); - } - } - } - } - /////////////////////////////////////////// - // cell spanning code ends here - /////////////////////////////////////////// +// /////////////////////////////////////////// +// // cell spanning code starts here +// /////////////////////////////////////////// +// if (spanModel != null) { +// // cell span check - basically, see if there is a cell span +// // impacting upon the cell at the given row / column index +// SpanType spanType = getSpanType(row, column); +// switch (spanType) { +// case ROW: +// case BOTH: x += width; // fall through is on purpose here +// case COLUMN: +// hide(tableCell); +// tableCell.resize(0, 0); +// tableCell.relocate(x, insets.getTop()); +// continue; // we don't want to fall through +// // infact, we return to the loop here +// case NONE: +// case UNSET: // fall through and carry on +// } +// +// CellSpan cellSpan = getCellSpanAt(spanModel, row, column); +// if (cellSpan != null) { +// if (cellSpan.getColumnSpan() > 1) { +// // we need to span multiple columns, so we sum up +// // the width of the additional columns, adding it +// // to the width variable +// for (int i = 1, +// colSpan = cellSpan.getColumnSpan(), +// maxColumns = getChildren().size() - column; +// i < colSpan && i < maxColumns; i++) { +// // calculate the width +// Node adjacentNode = getChildren().get(column + i); +// width += snapSize(adjacentNode.prefWidth(-1)); +// } +// } +// +// if (cellSpan.getRowSpan() > 1) { +// // we need to span multiple rows, so we sum up +// // the height of the additional rows, adding it +// // to the height variable +// for (int i = 1; i < cellSpan.getRowSpan(); i++) { +// // calculate the height +// double rowHeight = getTableRowHeight(row + i, getSkinnable()); +// height += snapSize(rowHeight); +// } +// } +// } +// } +// /////////////////////////////////////////// +// // cell spanning code ends here +// /////////////////////////////////////////// tableCell.resize(width, height); @@ -599,11 +597,11 @@ } } - private CellSpan getCellSpanAt(SpanModel spanModel, int row, int column) { - T rowObject = itemsProperty().get().get(row); - TableColumnBase tableColumn = getVisibleLeafColumn(column); - return spanModel.getCellSpanAt(row, column, rowObject, tableColumn); - } +// private CellSpan getCellSpanAt(SpanModel spanModel, int row, int column) { +// T rowObject = itemsProperty().get().get(row); +// TableColumnBase tableColumn = getVisibleLeafColumn(column); +// return spanModel.getCellSpanAt(row, column, rowObject, tableColumn); +// } private int columnCount = 0; diff --git a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableRowSkin.java @@ -45,7 +45,6 @@ import javafx.collections.ObservableList; import javafx.css.StyleableProperty; import javafx.scene.control.Control; -import javafx.scene.control.SpanModel; import javafx.scene.control.TableColumnBase; import javafx.scene.control.TableRow; import javafx.scene.control.TreeTableCell; @@ -213,9 +212,9 @@ return getSkinnable().getTreeTableView().getVisibleLeafColumns(); } - @Override protected ObjectProperty>> spanModelProperty() { - return getSkinnable().getTreeTableView().spanModelProperty(); - } +// @Override protected ObjectProperty>> spanModelProperty() { +// return getSkinnable().getTreeTableView().spanModelProperty(); +// } @Override protected void updateCell(TreeTableCell cell, TreeTableRow row) { cell.updateTreeTableRow(row); diff --git a/javafx-ui-controls/src/javafx/scene/control/CellSpan.java b/javafx-ui-controls/src/javafx/scene/control/CellSpan.java deleted file mode 100644 --- a/javafx-ui-controls/src/javafx/scene/control/CellSpan.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package javafx.scene.control; - -/** - * Specifies the amount of spanning a single cell will have in controls such as - * {@link TableView} and {@link TreeTableView}, when their respective - * {@link SpanModel span models} are non-null and returning CellSpan instances. - * - *

A row or column span of one means that the cell will span no more than - * usual in that direction, whereas a span of two or more means the cell will - * begin to 'overlap' neighbouring cells. Any span of zero or less will be - * ignored, with the value being replaced by one. - */ -public final class CellSpan { - private final int rowSpan; - private final int columnSpan; - - /** - * Creates a new immutable CellSpan instance with specified rowSpan and - * columnSpan values, assuming that they are greater than zero (any value of - * less than or equal to zero will be ignored with the span in that direction - * being set as one). - * - * @param rowSpan The number of cells to span in the vertical direction. - * @param columnSpan The number of cells to span in the horizontal direction. - */ - public CellSpan(int rowSpan, int columnSpan) { - this.rowSpan = rowSpan < 1 ? 1 : rowSpan; - this.columnSpan = columnSpan < 1 ? 1 : columnSpan; - } - - /** - * Returns the amount of spanning to perform in the vertical direction. - * @return An integer representing how many rows to span, where one represents - * no additional span. - */ - public int getRowSpan() { - return rowSpan; - } - - /** - * Returns the amount of spanning to perform in the horizontal direction. - * @return An integer representing how many columns to span, where one represents - * no additional span. - */ - public int getColumnSpan() { - return columnSpan; - } - - @Override public String toString() { - return "CellSpan: [ rowSpan: " + rowSpan + ", columnSpan: " + columnSpan + " ] "; - } -} diff --git a/javafx-ui-controls/src/javafx/scene/control/SpanModel.java b/javafx-ui-controls/src/javafx/scene/control/SpanModel.java deleted file mode 100644 --- a/javafx-ui-controls/src/javafx/scene/control/SpanModel.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package javafx.scene.control; - -/** - * A simple interface used by controls such as {@link TableView} and - * {@link TreeTableView} to allow for specification of {@link CellSpan cell spans} - * for a given row/column intersection. - * - * @see CellSpan - * @see TableView#spanModelProperty() - * @see TreeTableView#spanModelProperty() - */ -public interface SpanModel { - - /** - * A method that, when called, should return a {@link CellSpan} instance for - * the given row/column intersection to specify whether there should be any - * cell spanning for that given cell. It is valid to return null - this simply - * states that there should be no cell spanning for the given cell. - * - *

Note that this method is called very frequently, so it is critical that - * it be performant. If possible, the CellSpan instances should be pre-built - * and reused, rather than creating new instances for every request. - * - * @param rowIndex The row index of the cell whose cell span is being requested. - * @param columnIndex The column index of the cell whose cell span is being requested. - * @param rowObject The backing object for the entire row, from which the cell - * retrieves its value. - * @param tableColumn A concrete subclass of {@link TableColumnBase} that - * represents the column that the cell is located within. - * @return A CellSpan representing the amount of spanning that the given cell - * intersection should possess, or null if no cell spanning is desired. - */ - public CellSpan getCellSpanAt(final int rowIndex, final int columnIndex, - final T rowObject, final TableColumnBase tableColumn); -} diff --git a/javafx-ui-controls/src/javafx/scene/control/TableView.java b/javafx-ui-controls/src/javafx/scene/control/TableView.java --- a/javafx-ui-controls/src/javafx/scene/control/TableView.java +++ b/javafx-ui-controls/src/javafx/scene/control/TableView.java @@ -744,30 +744,30 @@ } - // --- Span Model - private ObjectProperty> spanModel - = new SimpleObjectProperty>(this, "spanModel") { - - @Override protected void invalidated() { - ObservableList styleClass = getStyleClass(); - if (getSpanModel() == null) { - styleClass.remove(CELL_SPAN_TABLE_VIEW_STYLE_CLASS); - } else if (! styleClass.contains(CELL_SPAN_TABLE_VIEW_STYLE_CLASS)) { - styleClass.add(CELL_SPAN_TABLE_VIEW_STYLE_CLASS); - } - } - }; - - public final ObjectProperty> spanModelProperty() { - return spanModel; - } - public final void setSpanModel(SpanModel value) { - spanModelProperty().set(value); - } - - public final SpanModel getSpanModel() { - return spanModel.get(); - } +// // --- Span Model +// private ObjectProperty> spanModel +// = new SimpleObjectProperty>(this, "spanModel") { +// +// @Override protected void invalidated() { +// ObservableList styleClass = getStyleClass(); +// if (getSpanModel() == null) { +// styleClass.remove(CELL_SPAN_TABLE_VIEW_STYLE_CLASS); +// } else if (! styleClass.contains(CELL_SPAN_TABLE_VIEW_STYLE_CLASS)) { +// styleClass.add(CELL_SPAN_TABLE_VIEW_STYLE_CLASS); +// } +// } +// }; +// +// public final ObjectProperty> spanModelProperty() { +// return spanModel; +// } +// public final void setSpanModel(SpanModel value) { +// spanModelProperty().set(value); +// } +// +// public final SpanModel getSpanModel() { +// return spanModel.get(); +// } // --- Editable private BooleanProperty editable; diff --git a/javafx-ui-controls/src/javafx/scene/control/TreeTableView.java b/javafx-ui-controls/src/javafx/scene/control/TreeTableView.java --- a/javafx-ui-controls/src/javafx/scene/control/TreeTableView.java +++ b/javafx-ui-controls/src/javafx/scene/control/TreeTableView.java @@ -821,30 +821,30 @@ - // --- Span Model - private ObjectProperty>> spanModel - = new SimpleObjectProperty>>(this, "spanModel") { - - @Override protected void invalidated() { - ObservableList styleClass = getStyleClass(); - if (getSpanModel() == null) { - styleClass.remove(CELL_SPAN_TABLE_VIEW_STYLE_CLASS); - } else if (! styleClass.contains(CELL_SPAN_TABLE_VIEW_STYLE_CLASS)) { - styleClass.add(CELL_SPAN_TABLE_VIEW_STYLE_CLASS); - } - } - }; - - public final ObjectProperty>> spanModelProperty() { - return spanModel; - } - public final void setSpanModel(SpanModel> value) { - spanModelProperty().set(value); - } - - public final SpanModel> getSpanModel() { - return spanModel.get(); - } +// // --- Span Model +// private ObjectProperty>> spanModel +// = new SimpleObjectProperty>>(this, "spanModel") { +// +// @Override protected void invalidated() { +// ObservableList styleClass = getStyleClass(); +// if (getSpanModel() == null) { +// styleClass.remove(CELL_SPAN_TABLE_VIEW_STYLE_CLASS); +// } else if (! styleClass.contains(CELL_SPAN_TABLE_VIEW_STYLE_CLASS)) { +// styleClass.add(CELL_SPAN_TABLE_VIEW_STYLE_CLASS); +// } +// } +// }; +// +// public final ObjectProperty>> spanModelProperty() { +// return spanModel; +// } +// public final void setSpanModel(SpanModel> value) { +// spanModelProperty().set(value); +// } +// +// public final SpanModel> getSpanModel() { +// return spanModel.get(); +// }