📄 formatlayout.java
字号:
this.rowHeights[rowIndex] = Math.max(d0.height, d1.height);
this.totalHeight = this.totalHeight + this.rowHeights[rowIndex];
this.columnWidths[0] = Math.max(this.columnWidths[0], d0.width);
this.columns1to5Width = Math.max(this.columns1to5Width, d1.width);
}
/**
* Processes a row in 'LCB' format.
*
* @param rowIndex the row index.
* @param d0 dimension 0.
* @param d1 dimension 1.
* @param d2 dimension 2.
*/
protected void updateLCB(final int rowIndex,
final Dimension d0, final Dimension d1,
final Dimension d2) {
this.rowHeights[rowIndex]
= Math.max(d0.height, Math.max(d1.height, d2.height));
this.totalHeight = this.totalHeight + this.rowHeights[rowIndex];
this.columnWidths[0] = Math.max(this.columnWidths[0], d0.width);
this.columns1to4Width = Math.max(this.columns1to4Width, d1.width);
this.columnWidths[5] = Math.max(this.columnWidths[5], d2.width);
}
/**
* Processes a row in 'LCLC' format.
*
* @param rowIndex the row index.
* @param d0 dimension 0.
* @param d1 dimension 1.
* @param d2 dimension 2.
* @param d3 dimension 3.
*/
protected void updateLCLC(final int rowIndex, final Dimension d0,
final Dimension d1, final Dimension d2,
final Dimension d3) {
this.rowHeights[rowIndex] = Math.max(Math.max(d0.height, d1.height),
Math.max(d2.height, d3.height));
this.totalHeight = this.totalHeight + this.rowHeights[rowIndex];
this.columnWidths[0] = Math.max(this.columnWidths[0], d0.width);
this.columns1and2Width = Math.max(this.columns1and2Width, d1.width);
this.columnWidths[3] = Math.max(this.columnWidths[3], d2.width);
this.columns4and5Width = Math.max(this.columns4and5Width, d3.width);
}
/**
* Processes a row in 'LCBLC' format.
*
* @param rowIndex the row index.
* @param d0 dimension 0.
* @param d1 dimension 1.
* @param d2 dimension 2.
* @param d3 dimension 3.
* @param d4 dimension 4.
*/
protected void updateLCBLC(final int rowIndex, final Dimension d0,
final Dimension d1, final Dimension d2,
final Dimension d3, final Dimension d4) {
this.rowHeights[rowIndex] = (Math.max(
d0.height,
Math.max(Math.max(d1.height, d2.height),
Math.max(d3.height, d4.height)))
);
this.totalHeight = this.totalHeight + this.rowHeights[rowIndex];
this.columnWidths[0] = Math.max(this.columnWidths[0], d0.width);
this.columnWidths[1] = Math.max(this.columnWidths[1], d1.width);
this.columnWidths[2] = Math.max(this.columnWidths[2], d2.width);
this.columnWidths[3] = Math.max(this.columnWidths[3], d3.width);
this.columns4and5Width = Math.max(this.columns4and5Width, d4.width);
}
/**
* Processes a row in 'LCLCB' format.
*
* @param rowIndex the row index.
* @param d0 dimension 0.
* @param d1 dimension 1.
* @param d2 dimension 2.
* @param d3 dimension 3.
* @param d4 dimension 4.
*/
protected void updateLCLCB(final int rowIndex, final Dimension d0,
final Dimension d1, final Dimension d2,
final Dimension d3, final Dimension d4) {
this.rowHeights[rowIndex] = (Math.max(d0.height,
Math.max(Math.max(d1.height, d2.height),
Math.max(d3.height, d4.height))));
this.totalHeight = this.totalHeight + this.rowHeights[rowIndex];
this.columnWidths[0] = Math.max(this.columnWidths[0], d0.width);
this.columns1and2Width = Math.max(this.columns1and2Width, d1.width);
this.columnWidths[3] = Math.max(this.columnWidths[3], d2.width);
this.columnWidths[4] = Math.max(this.columnWidths[4], d3.width);
this.columnWidths[5] = Math.max(this.columnWidths[5], d4.width);
}
/**
* Processes a row in 'LCBLCB' format.
*
* @param rowIndex the row index.
* @param d0 dimension 0.
* @param d1 dimension 1.
* @param d2 dimension 2.
* @param d3 dimension 3.
* @param d4 dimension 4.
* @param d5 dimension 5.
*/
protected void updateLCBLCB(final int rowIndex,
final Dimension d0, final Dimension d1,
final Dimension d2,
final Dimension d3, final Dimension d4,
final Dimension d5) {
this.rowHeights[rowIndex] = Math.max(
Math.max(d0.height, d1.height),
Math.max(Math.max(d2.height, d3.height),
Math.max(d4.height, d5.height))
);
this.totalHeight = this.totalHeight + this.rowHeights[rowIndex];
this.columnWidths[0] = Math.max(this.columnWidths[0], d0.width);
this.columnWidths[1] = Math.max(this.columnWidths[1], d1.width);
this.columnWidths[2] = Math.max(this.columnWidths[2], d2.width);
this.columnWidths[3] = Math.max(this.columnWidths[3], d3.width);
this.columnWidths[4] = Math.max(this.columnWidths[4], d4.width);
this.columnWidths[5] = Math.max(this.columnWidths[5], d5.width);
}
/**
* Finishes of the processing.
*/
public void complete() {
this.columnWidths[1] = Math.max(
this.columnWidths[1],
this.columns1and2Width - this.columnGaps[1] - this.columnWidths[2]
);
this.columnWidths[4] = Math.max(
this.columnWidths[4],
Math.max(
this.columns4and5Width - this.columnGaps[4]
- this.columnWidths[5],
Math.max(
this.columns1to4Width - this.columnGaps[1]
- this.columnGaps[2] - this.columnGaps[3]
- this.columnWidths[1] - this.columnWidths[2]
- this.columnWidths[3],
this.columns1to5Width - this.columnGaps[1]
- this.columnGaps[2] - this.columnGaps[3]
- this.columnWidths[1] - this.columnWidths[2]
- this.columnWidths[3] - this.columnGaps[4]
)
)
);
int leftWidth = this.columnWidths[0] + this.columnGaps[0]
+ this.columnWidths[1] + this.columnGaps[1]
+ this.columnWidths[2];
int rightWidth = this.columnWidths[3] + this.columnGaps[3]
+ this.columnWidths[4] + this.columnGaps[4]
+ this.columnWidths[5];
if (splitLayout()) {
if (leftWidth > rightWidth) {
final int mismatch = leftWidth - rightWidth;
this.columnWidths[4] = this.columnWidths[4] + mismatch;
rightWidth = rightWidth + mismatch;
}
else {
final int mismatch = rightWidth - leftWidth;
this.columnWidths[1] = this.columnWidths[1] + mismatch;
leftWidth = leftWidth + mismatch;
}
}
this.totalWidth = leftWidth + this.columnGaps[2] + rightWidth;
if (this.columns0to5Width > this.totalWidth) {
final int spaceToAdd = (this.columns0to5Width - this.totalWidth);
if (splitLayout()) {
final int halfSpaceToAdd = spaceToAdd / 2;
this.columnWidths[1] = this.columnWidths[1] + halfSpaceToAdd;
this.columnWidths[4] = this.columnWidths[4] + spaceToAdd
- halfSpaceToAdd;
this.totalWidth = this.totalWidth + spaceToAdd;
}
else {
this.columnWidths[1] = this.columnWidths[1] + spaceToAdd;
this.totalWidth = this.totalWidth + spaceToAdd;
}
}
}
/**
* Returns true if this layout involves a split into two sections.
*
* @return <code>true</code> if this layout involves a split into two
* sections.
*/
private boolean splitLayout() {
for (int i = 0; i < this.rowFormats.length; i++) {
if (this.rowFormats[i] > FormatLayout.LCB) {
return true;
}
}
return false;
}
/**
* Not used.
*
* @param comp the component.
*/
public void addLayoutComponent(final Component comp) {
// not used
}
/**
* Not used.
*
* @param comp the component.
*/
public void removeLayoutComponent(final Component comp) {
// not used
}
/**
* Not used.
*
* @param name the component name.
* @param comp the component.
*/
public void addLayoutComponent(final String name, final Component comp) {
// not used
}
/**
* Not used.
*
* @param name the component name.
* @param comp the component.
*/
public void removeLayoutComponent(final String name, final Component comp) {
// not used
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -