use of org.apache.pivot.wtk.Component in project pivot by apache.
the class TablePaneSkin method getBaseline.
@Override
public int getBaseline(int width, int height) {
TablePane tablePane = (TablePane) getComponent();
TablePane.RowSequence rows = tablePane.getRows();
TablePane.ColumnSequence columns = tablePane.getColumns();
int rowCount = rows.getLength();
int columnCount = columns.getLength();
int[] columnWidthsLocal = getColumnWidths(width);
int[] rowHeightsLocal = getRowHeights(height, columnWidthsLocal);
boolean[][] occupiedCells = getOccupiedCells();
int baseline = -1;
int rowY = padding.top;
for (int i = 0; i < rowCount && baseline == -1; i++) {
TablePane.Row row = rows.get(i);
boolean rowVisible = false;
for (int j = 0, n = row.getLength(); j < n && j < columnCount && baseline == -1; j++) {
Component component = row.get(j);
if (component != null && component.isVisible()) {
int columnSpan = Math.min(TablePane.getColumnSpan(component), columnCount - j);
int componentWidth = (columnSpan - 1) * horizontalSpacing;
for (int k = 0; k < columnSpan && j + k < columnCount; k++) {
componentWidth += columnWidthsLocal[j + k];
}
int rowSpan = Math.min(TablePane.getRowSpan(component), rowCount - i);
int componentHeight = (rowSpan - 1) * verticalSpacing;
for (int k = 0; k < rowSpan && i + k < rowCount; k++) {
componentHeight += rowHeightsLocal[i + k];
}
baseline = component.getBaseline(Math.max(componentWidth, 0), Math.max(componentHeight, 0));
if (baseline != -1) {
baseline += rowY;
}
}
rowVisible |= occupiedCells[i][j];
}
if (rowVisible) {
rowY += (rowHeightsLocal[i] + verticalSpacing);
}
}
return baseline;
}
use of org.apache.pivot.wtk.Component in project pivot by apache.
the class TextPaneSkinComponentNodeView method getBaseline.
@Override
public int getBaseline() {
ComponentNode componentNode = (ComponentNode) getNode();
Component component = componentNode.getComponent();
int baseline = -1;
if (component != null) {
baseline = component.getBaseline();
}
return baseline;
}
use of org.apache.pivot.wtk.Component in project pivot by apache.
the class TextPaneSkinComponentNodeView method attach.
@Override
protected void attach() {
super.attach();
ComponentNode componentNode = (ComponentNode) getNode();
componentNode.getComponentNodeListeners().add(this);
Component component = componentNode.getComponent();
if (component != null) {
component.getComponentListeners().add(myComponentListener);
}
}
use of org.apache.pivot.wtk.Component in project pivot by apache.
the class TextPaneSkinComponentNodeView method componentChanged.
@Override
public void componentChanged(ComponentNode componentNode, Component previousComponent) {
invalidateUpTree();
Component component = componentNode.getComponent();
if (component != null) {
component.getComponentListeners().add(myComponentListener);
}
if (previousComponent != null) {
previousComponent.getComponentListeners().remove(myComponentListener);
}
}
use of org.apache.pivot.wtk.Component in project pivot by apache.
the class GridPaneSkin method getPreferredHeight.
@Override
public int getPreferredHeight(int width) {
GridPane gridPane = (GridPane) getComponent();
GridPane.RowSequence rows = gridPane.getRows();
int columnCount = gridPane.getColumnCount();
int rowCount = rows.getLength();
Metadata metadata = new Metadata();
int cellWidthLocal = getCellWidth(width, metadata);
int preferredCellHeight = 0;
for (int i = 0; i < rowCount; i++) {
GridPane.Row row = rows.get(i);
for (int j = 0, n = row.getLength(); j < n && j < columnCount; j++) {
Component component = row.get(j);
if (component != null && component.isVisible()) {
preferredCellHeight = Math.max(preferredCellHeight, component.getPreferredHeight(cellWidthLocal));
}
}
}
// The preferred height of the grid pane is the sum of the row
// heights, plus padding and spacing
int preferredHeight = (metadata.visibleRowCount * preferredCellHeight) + padding.getHeight();
if (metadata.visibleRowCount > 1) {
preferredHeight += (metadata.visibleRowCount - 1) * verticalSpacing;
}
return preferredHeight;
}
Aggregations