use of javax.swing.SizeRequirements in project jdk8u_jdk by JetBrains.
the class BlockView method calculateMajorAxisRequirements.
/**
* Calculate the requirements of the block along the major
* axis (i.e. the axis along with it tiles). This is implemented
* to provide the superclass behavior and then adjust it if the
* CSS width or height attribute is specified and applicable to
* the axis.
*/
protected SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements r) {
if (r == null) {
r = new SizeRequirements();
}
if (!spanSetFromAttributes(axis, r, cssWidth, cssHeight)) {
r = super.calculateMajorAxisRequirements(axis, r);
} else {
// Offset by the margins so that pref/min/max return the
// right value.
SizeRequirements parentR = super.calculateMajorAxisRequirements(axis, null);
int margin = (axis == X_AXIS) ? getLeftInset() + getRightInset() : getTopInset() + getBottomInset();
r.minimum -= margin;
r.preferred -= margin;
r.maximum -= margin;
constrainSize(axis, r, parentR);
}
return r;
}
use of javax.swing.SizeRequirements in project jdk8u_jdk by JetBrains.
the class CSS method calculateTiledRequirements.
/**
* Calculate the requirements needed to tile the requirements
* given by the iterator that would be tiled. The calculation
* takes into consideration margin and border spacing.
*/
static SizeRequirements calculateTiledRequirements(LayoutIterator iter, SizeRequirements r) {
long minimum = 0;
long maximum = 0;
long preferred = 0;
int lastMargin = 0;
int totalSpacing = 0;
int n = iter.getCount();
for (int i = 0; i < n; i++) {
iter.setIndex(i);
int margin0 = lastMargin;
int margin1 = (int) iter.getLeadingCollapseSpan();
totalSpacing += Math.max(margin0, margin1);
preferred += (int) iter.getPreferredSpan(0);
minimum += iter.getMinimumSpan(0);
maximum += iter.getMaximumSpan(0);
lastMargin = (int) iter.getTrailingCollapseSpan();
}
totalSpacing += lastMargin;
totalSpacing += 2 * iter.getBorderWidth();
// adjust for the spacing area
minimum += totalSpacing;
preferred += totalSpacing;
maximum += totalSpacing;
// set return value
if (r == null) {
r = new SizeRequirements();
}
r.minimum = (minimum > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) minimum;
r.preferred = (preferred > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) preferred;
r.maximum = (maximum > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) maximum;
return r;
}
use of javax.swing.SizeRequirements in project jdk8u_jdk by JetBrains.
the class TableView method checkSingleColumnCell.
/**
* check the requirements of a table cell that spans a single column.
*/
void checkSingleColumnCell(int axis, int col, View v) {
SizeRequirements req = columnRequirements[col];
req.minimum = Math.max((int) v.getMinimumSpan(axis), req.minimum);
req.preferred = Math.max((int) v.getPreferredSpan(axis), req.preferred);
}
use of javax.swing.SizeRequirements in project jdk8u_jdk by JetBrains.
the class TableView method checkMultiColumnCell.
/**
* check the requirements of a table cell that spans multiple
* columns.
*/
void checkMultiColumnCell(int axis, int col, int ncols, View v) {
// calculate the totals
long min = 0;
long pref = 0;
long max = 0;
for (int i = 0; i < ncols; i++) {
SizeRequirements req = columnRequirements[col + i];
min += req.minimum;
pref += req.preferred;
max += req.maximum;
}
// check if the minimum size needs adjustment.
int cmin = (int) v.getMinimumSpan(axis);
if (cmin > min) {
/*
* the columns that this cell spans need adjustment to fit
* this table cell.... calculate the adjustments. The
* maximum for each cell is the maximum of the existing
* maximum or the amount needed by the cell.
*/
SizeRequirements[] reqs = new SizeRequirements[ncols];
for (int i = 0; i < ncols; i++) {
SizeRequirements r = reqs[i] = columnRequirements[col + i];
r.maximum = Math.max(r.maximum, (int) v.getMaximumSpan(axis));
}
int[] spans = new int[ncols];
int[] offsets = new int[ncols];
SizeRequirements.calculateTiledPositions(cmin, null, reqs, offsets, spans);
// apply the adjustments
for (int i = 0; i < ncols; i++) {
SizeRequirements req = reqs[i];
req.minimum = Math.max(spans[i], req.minimum);
req.preferred = Math.max(req.minimum, req.preferred);
req.maximum = Math.max(req.preferred, req.maximum);
}
}
// check if the preferred size needs adjustment.
int cpref = (int) v.getPreferredSpan(axis);
if (cpref > pref) {
/*
* the columns that this cell spans need adjustment to fit
* this table cell.... calculate the adjustments. The
* maximum for each cell is the maximum of the existing
* maximum or the amount needed by the cell.
*/
SizeRequirements[] reqs = new SizeRequirements[ncols];
for (int i = 0; i < ncols; i++) {
SizeRequirements r = reqs[i] = columnRequirements[col + i];
}
int[] spans = new int[ncols];
int[] offsets = new int[ncols];
SizeRequirements.calculateTiledPositions(cpref, null, reqs, offsets, spans);
// apply the adjustments
for (int i = 0; i < ncols; i++) {
SizeRequirements req = reqs[i];
req.preferred = Math.max(spans[i], req.preferred);
req.maximum = Math.max(req.preferred, req.maximum);
}
}
}
use of javax.swing.SizeRequirements in project jdk8u_jdk by JetBrains.
the class TableView method calculateMinorAxisRequirements.
/**
* Calculate the requirements for the minor axis. This is called by
* the superclass whenever the requirements need to be updated (i.e.
* a preferenceChanged was messaged through this view).
* <p>
* This is implemented to calculate the requirements as the sum of the
* requirements of the columns.
*/
protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r) {
updateGrid();
// calculate column requirements for each column
calculateColumnRequirements(axis);
// the requirements are the sum of the columns.
if (r == null) {
r = new SizeRequirements();
}
long min = 0;
long pref = 0;
long max = 0;
for (SizeRequirements req : columnRequirements) {
min += req.minimum;
pref += req.preferred;
max += req.maximum;
}
r.minimum = (int) min;
r.preferred = (int) pref;
r.maximum = (int) max;
r.alignment = 0;
return r;
}
Aggregations