Java Code Examples for javax.swing.SizeRequirements

The following examples show how to use javax.swing.SizeRequirements. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: TencentKona-8   Source File: BlockView.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adjust the given requirements to the CSS width or height if
 * it is specified along the applicable axis.  Return true if the
 * size is exactly specified, false if the span is not specified
 * in an attribute or the size specified is a percentage.
 */
static boolean spanSetFromAttributes(int axis, SizeRequirements r,
                                     CSS.LengthValue cssWidth,
                                     CSS.LengthValue cssHeight) {
    if (axis == X_AXIS) {
        if ((cssWidth != null) && (! cssWidth.isPercentage())) {
            r.minimum = r.preferred = r.maximum = (int) cssWidth.getValue();
            return true;
        }
    } else {
        if ((cssHeight != null) && (! cssHeight.isPercentage())) {
            r.minimum = r.preferred = r.maximum = (int) cssHeight.getValue();
            return true;
        }
    }
    return false;
}
 
Example 2
Source Project: jdk1.8-source-analysis   Source File: ParagraphView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Calculate the needs for the paragraph along the minor axis.
 *
 * <p>This uses size requirements of the superclass, modified to take into
 * account the non-breakable areas at the adjacent views edges.  The minimal
 * size requirements for such views should be no less than the sum of all
 * adjacent fragments.</p>
 *
 * <p>If the {@code axis} parameter is neither {@code View.X_AXIS} nor
 * {@code View.Y_AXIS}, {@link IllegalArgumentException} is thrown.  If the
 * {@code r} parameter is {@code null,} a new {@code SizeRequirements}
 * object is created, otherwise the supplied {@code SizeRequirements}
 * object is returned.</p>
 *
 * @param axis  the minor axis
 * @param r     the input {@code SizeRequirements} object
 * @return      the new or adjusted {@code SizeRequirements} object
 * @throws IllegalArgumentException  if the {@code axis} parameter is invalid
 */
@Override
protected SizeRequirements calculateMinorAxisRequirements(int axis,
                                                    SizeRequirements r) {
    r = super.calculateMinorAxisRequirements(axis, r);

    float min = 0;
    float glue = 0;
    int n = getLayoutViewCount();
    for (int i = 0; i < n; i++) {
        View v = getLayoutView(i);
        float span = v.getMinimumSpan(axis);
        if (v.getBreakWeight(axis, 0, v.getMaximumSpan(axis)) > View.BadBreakWeight) {
            // find the longest non-breakable fragments at the view edges
            int p0 = v.getStartOffset();
            int p1 = v.getEndOffset();
            float start = findEdgeSpan(v, axis, p0, p0, p1);
            float end = findEdgeSpan(v, axis, p1, p0, p1);
            glue += start;
            min = Math.max(min, Math.max(span, glue));
            glue = end;
        } else {
            // non-breakable view
            glue += span;
            min = Math.max(min, glue);
        }
    }
    r.minimum = Math.max(r.minimum, (int) min);
    r.preferred = Math.max(r.minimum, r.preferred);
    r.maximum = Math.max(r.preferred, r.maximum);

    return r;
}
 
Example 3
Source Project: jdk1.8-source-analysis   Source File: ParagraphView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected SizeRequirements calculateMajorAxisRequirements(int axis,
        SizeRequirements r) {
    int oldJustficationData[] = justificationData;
    justificationData = null;
    SizeRequirements ret = super.calculateMajorAxisRequirements(axis, r);
    if (isJustifyEnabled()) {
        justificationData = oldJustficationData;
    }
    return ret;
}
 
Example 4
Source Project: jdk1.8-source-analysis   Source File: TableView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    req.maximum = Math.max((int) v.getMaximumSpan(axis), req.maximum);
}
 
Example 5
Source Project: jdk1.8-source-analysis   Source File: BlockView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constrains <code>want</code> to fit in the minimum size specified
 * by <code>min</code>.
 */
private void constrainSize(int axis, SizeRequirements want,
                           SizeRequirements min) {
    if (min.minimum > want.minimum) {
        want.minimum = want.preferred = min.minimum;
        want.maximum = Math.max(want.maximum, min.maximum);
    }
}
 
Example 6
Source Project: jdk1.8-source-analysis   Source File: TableView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a TableView for the given element.
 *
 * @param elem the element that this view is responsible for
 */
public TableView(Element elem) {
    super(elem, View.Y_AXIS);
    rows = new Vector<RowView>();
    gridValid = false;
    captionIndex = -1;
    totalColumnRequirements = new SizeRequirements();
}
 
Example 7
Source Project: jdk1.8-source-analysis   Source File: TableView.java    License: Apache License 2.0 5 votes vote down vote up
protected SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements r) {
    SizeRequirements req = new SizeRequirements();
    req.minimum = totalColumnRequirements.minimum;
    req.maximum = totalColumnRequirements.maximum;
    req.preferred = totalColumnRequirements.preferred;
    req.alignment = 0f;
    return req;
}
 
Example 8
Source Project: jdk1.8-source-analysis   Source File: TableView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r) {
    SizeRequirements rv = super.calculateMinorAxisRequirements(axis, r);
    //for the cell the minimum should be derived from the child views
    //the parent behaviour is to use CSS for that
    int n = getViewCount();
    int min = 0;
    for (int i = 0; i < n; i++) {
        View v = getView(i);
        min = Math.max((int) v.getMinimumSpan(axis), min);
    }
    rv.minimum = Math.min(rv.minimum, min);
    return rv;
}
 
Example 9
/**
 * Calculate the needs for the paragraph along the minor axis.
 *
 * <p>This uses size requirements of the superclass, modified to take into
 * account the non-breakable areas at the adjacent views edges.  The minimal
 * size requirements for such views should be no less than the sum of all
 * adjacent fragments.</p>
 *
 * <p>If the {@code axis} parameter is neither {@code View.X_AXIS} nor
 * {@code View.Y_AXIS}, {@link IllegalArgumentException} is thrown.  If the
 * {@code r} parameter is {@code null,} a new {@code SizeRequirements}
 * object is created, otherwise the supplied {@code SizeRequirements}
 * object is returned.</p>
 *
 * @param axis  the minor axis
 * @param r     the input {@code SizeRequirements} object
 * @return      the new or adjusted {@code SizeRequirements} object
 * @throws IllegalArgumentException  if the {@code axis} parameter is invalid
 */
@Override
protected SizeRequirements calculateMinorAxisRequirements(int axis,
                                                    SizeRequirements r) {
    r = super.calculateMinorAxisRequirements(axis, r);

    float min = 0;
    float glue = 0;
    int n = getLayoutViewCount();
    for (int i = 0; i < n; i++) {
        View v = getLayoutView(i);
        float span = v.getMinimumSpan(axis);
        if (v.getBreakWeight(axis, 0, v.getMaximumSpan(axis)) > View.BadBreakWeight) {
            // find the longest non-breakable fragments at the view edges
            int p0 = v.getStartOffset();
            int p1 = v.getEndOffset();
            float start = findEdgeSpan(v, axis, p0, p0, p1);
            float end = findEdgeSpan(v, axis, p1, p0, p1);
            glue += start;
            min = Math.max(min, Math.max(span, glue));
            glue = end;
        } else {
            // non-breakable view
            glue += span;
            min = Math.max(min, glue);
        }
    }
    r.minimum = Math.max(r.minimum, (int) min);
    r.preferred = Math.max(r.minimum, r.preferred);
    r.maximum = Math.max(r.preferred, r.maximum);

    return r;
}
 
Example 10
Source Project: jdk8u-dev-jdk   Source File: TableView.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements r) {
    SizeRequirements req = new SizeRequirements();
    req.minimum = totalColumnRequirements.minimum;
    req.maximum = totalColumnRequirements.maximum;
    req.preferred = totalColumnRequirements.preferred;
    req.alignment = 0f;
    return req;
}
 
Example 11
Source Project: dragonwell8_jdk   Source File: BlockView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrains <code>want</code> to fit in the minimum size specified
 * by <code>min</code>.
 */
private void constrainSize(int axis, SizeRequirements want,
                           SizeRequirements min) {
    if (min.minimum > want.minimum) {
        want.minimum = want.preferred = min.minimum;
        want.maximum = Math.max(want.maximum, min.maximum);
    }
}
 
Example 12
Source Project: dragonwell8_jdk   Source File: TableView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a TableView for the given element.
 *
 * @param elem the element that this view is responsible for
 */
public TableView(Element elem) {
    super(elem, View.Y_AXIS);
    rows = new Vector<RowView>();
    gridValid = false;
    captionIndex = -1;
    totalColumnRequirements = new SizeRequirements();
}
 
Example 13
Source Project: Bytecoder   Source File: TableView.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a TableView for the given element.
 *
 * @param elem the element that this view is responsible for
 */
public TableView(Element elem) {
    super(elem, View.Y_AXIS);
    rows = new Vector<RowView>();
    gridValid = false;
    captionIndex = -1;
    totalColumnRequirements = new SizeRequirements();
}
 
Example 14
/**
 * 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);
    req.maximum = Math.max((int) v.getMaximumSpan(axis), req.maximum);
}
 
Example 15
Source Project: TencentKona-8   Source File: ParagraphView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculate the needs for the paragraph along the minor axis.
 *
 * <p>This uses size requirements of the superclass, modified to take into
 * account the non-breakable areas at the adjacent views edges.  The minimal
 * size requirements for such views should be no less than the sum of all
 * adjacent fragments.</p>
 *
 * <p>If the {@code axis} parameter is neither {@code View.X_AXIS} nor
 * {@code View.Y_AXIS}, {@link IllegalArgumentException} is thrown.  If the
 * {@code r} parameter is {@code null,} a new {@code SizeRequirements}
 * object is created, otherwise the supplied {@code SizeRequirements}
 * object is returned.</p>
 *
 * @param axis  the minor axis
 * @param r     the input {@code SizeRequirements} object
 * @return      the new or adjusted {@code SizeRequirements} object
 * @throws IllegalArgumentException  if the {@code axis} parameter is invalid
 */
@Override
protected SizeRequirements calculateMinorAxisRequirements(int axis,
                                                    SizeRequirements r) {
    r = super.calculateMinorAxisRequirements(axis, r);

    float min = 0;
    float glue = 0;
    int n = getLayoutViewCount();
    for (int i = 0; i < n; i++) {
        View v = getLayoutView(i);
        float span = v.getMinimumSpan(axis);
        if (v.getBreakWeight(axis, 0, v.getMaximumSpan(axis)) > View.BadBreakWeight) {
            // find the longest non-breakable fragments at the view edges
            int p0 = v.getStartOffset();
            int p1 = v.getEndOffset();
            float start = findEdgeSpan(v, axis, p0, p0, p1);
            float end = findEdgeSpan(v, axis, p1, p0, p1);
            glue += start;
            min = Math.max(min, Math.max(span, glue));
            glue = end;
        } else {
            // non-breakable view
            glue += span;
            min = Math.max(min, glue);
        }
    }
    r.minimum = Math.max(r.minimum, (int) min);
    r.preferred = Math.max(r.minimum, r.preferred);
    r.maximum = Math.max(r.preferred, r.maximum);

    return r;
}
 
Example 16
Source Project: Java8CN   Source File: TableView.java    License: Apache License 2.0 5 votes vote down vote up
protected SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements r) {
    SizeRequirements req = new SizeRequirements();
    req.minimum = totalColumnRequirements.minimum;
    req.maximum = totalColumnRequirements.maximum;
    req.preferred = totalColumnRequirements.preferred;
    req.alignment = 0f;
    return req;
}
 
Example 17
Source Project: jdk8u-jdk   Source File: TableView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a TableView for the given element.
 *
 * @param elem the element that this view is responsible for
 */
public TableView(Element elem) {
    super(elem, View.Y_AXIS);
    rows = new Vector<RowView>();
    gridValid = false;
    captionIndex = -1;
    totalColumnRequirements = new SizeRequirements();
}
 
Example 18
Source Project: openjdk-jdk9   Source File: TableView.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements r) {
    SizeRequirements req = new SizeRequirements();
    req.minimum = totalColumnRequirements.minimum;
    req.maximum = totalColumnRequirements.maximum;
    req.preferred = totalColumnRequirements.preferred;
    req.alignment = 0f;
    return req;
}
 
Example 19
Source Project: TencentKona-8   Source File: TableView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    req.maximum = Math.max((int) v.getMaximumSpan(axis), req.maximum);
}
 
Example 20
Source Project: openjdk-8-source   Source File: TableView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    req.maximum = Math.max((int) v.getMaximumSpan(axis), req.maximum);
}
 
Example 21
Source Project: TencentKona-8   Source File: BlockView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrains <code>want</code> to fit in the minimum size specified
 * by <code>min</code>.
 */
private void constrainSize(int axis, SizeRequirements want,
                           SizeRequirements min) {
    if (min.minimum > want.minimum) {
        want.minimum = want.preferred = min.minimum;
        want.maximum = Math.max(want.maximum, min.maximum);
    }
}
 
Example 22
Source Project: TencentKona-8   Source File: TableView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a TableView for the given element.
 *
 * @param elem the element that this view is responsible for
 */
public TableView(Element elem) {
    super(elem, View.Y_AXIS);
    rows = new Vector<RowView>();
    gridValid = false;
    captionIndex = -1;
    totalColumnRequirements = new SizeRequirements();
}
 
Example 23
Source Project: TencentKona-8   Source File: TableView.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected SizeRequirements calculateMajorAxisRequirements(int axis, SizeRequirements r) {
    SizeRequirements req = new SizeRequirements();
    req.minimum = totalColumnRequirements.minimum;
    req.maximum = totalColumnRequirements.maximum;
    req.preferred = totalColumnRequirements.preferred;
    req.alignment = 0f;
    return req;
}
 
Example 24
Source Project: jdk8u60   Source File: ParagraphView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculate the needs for the paragraph along the minor axis.
 *
 * <p>This uses size requirements of the superclass, modified to take into
 * account the non-breakable areas at the adjacent views edges.  The minimal
 * size requirements for such views should be no less than the sum of all
 * adjacent fragments.</p>
 *
 * <p>If the {@code axis} parameter is neither {@code View.X_AXIS} nor
 * {@code View.Y_AXIS}, {@link IllegalArgumentException} is thrown.  If the
 * {@code r} parameter is {@code null,} a new {@code SizeRequirements}
 * object is created, otherwise the supplied {@code SizeRequirements}
 * object is returned.</p>
 *
 * @param axis  the minor axis
 * @param r     the input {@code SizeRequirements} object
 * @return      the new or adjusted {@code SizeRequirements} object
 * @throws IllegalArgumentException  if the {@code axis} parameter is invalid
 */
@Override
protected SizeRequirements calculateMinorAxisRequirements(int axis,
                                                    SizeRequirements r) {
    r = super.calculateMinorAxisRequirements(axis, r);

    float min = 0;
    float glue = 0;
    int n = getLayoutViewCount();
    for (int i = 0; i < n; i++) {
        View v = getLayoutView(i);
        float span = v.getMinimumSpan(axis);
        if (v.getBreakWeight(axis, 0, v.getMaximumSpan(axis)) > View.BadBreakWeight) {
            // find the longest non-breakable fragments at the view edges
            int p0 = v.getStartOffset();
            int p1 = v.getEndOffset();
            float start = findEdgeSpan(v, axis, p0, p0, p1);
            float end = findEdgeSpan(v, axis, p1, p0, p1);
            glue += start;
            min = Math.max(min, Math.max(span, glue));
            glue = end;
        } else {
            // non-breakable view
            glue += span;
            min = Math.max(min, glue);
        }
    }
    r.minimum = Math.max(r.minimum, (int) min);
    r.preferred = Math.max(r.minimum, r.preferred);
    r.maximum = Math.max(r.preferred, r.maximum);

    return r;
}
 
Example 25
Source Project: jdk8u60   Source File: ParagraphView.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected SizeRequirements calculateMajorAxisRequirements(int axis,
        SizeRequirements r) {
    int oldJustficationData[] = justificationData;
    justificationData = null;
    SizeRequirements ret = super.calculateMajorAxisRequirements(axis, r);
    if (isJustifyEnabled()) {
        justificationData = oldJustficationData;
    }
    return ret;
}
 
Example 26
Source Project: jdk8u60   Source File: TableView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    req.maximum = Math.max((int) v.getMaximumSpan(axis), req.maximum);
}
 
Example 27
Source Project: jdk8u-jdk   Source File: ParagraphView.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected SizeRequirements calculateMajorAxisRequirements(int axis,
        SizeRequirements r) {
    int oldJustficationData[] = justificationData;
    justificationData = null;
    SizeRequirements ret = super.calculateMajorAxisRequirements(axis, r);
    if (isJustifyEnabled()) {
        justificationData = oldJustficationData;
    }
    return ret;
}
 
Example 28
Source Project: jdk8u60   Source File: TableView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a TableView for the given element.
 *
 * @param elem the element that this view is responsible for
 */
public TableView(Element elem) {
    super(elem, View.Y_AXIS);
    rows = new Vector<RowView>();
    gridValid = false;
    captionIndex = -1;
    totalColumnRequirements = new SizeRequirements();
}
 
Example 29
Source Project: jdk8u-dev-jdk   Source File: ParagraphView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculate the needs for the paragraph along the minor axis.
 *
 * <p>This uses size requirements of the superclass, modified to take into
 * account the non-breakable areas at the adjacent views edges.  The minimal
 * size requirements for such views should be no less than the sum of all
 * adjacent fragments.</p>
 *
 * <p>If the {@code axis} parameter is neither {@code View.X_AXIS} nor
 * {@code View.Y_AXIS}, {@link IllegalArgumentException} is thrown.  If the
 * {@code r} parameter is {@code null,} a new {@code SizeRequirements}
 * object is created, otherwise the supplied {@code SizeRequirements}
 * object is returned.</p>
 *
 * @param axis  the minor axis
 * @param r     the input {@code SizeRequirements} object
 * @return      the new or adjusted {@code SizeRequirements} object
 * @throws IllegalArgumentException  if the {@code axis} parameter is invalid
 */
@Override
protected SizeRequirements calculateMinorAxisRequirements(int axis,
                                                    SizeRequirements r) {
    r = super.calculateMinorAxisRequirements(axis, r);

    float min = 0;
    float glue = 0;
    int n = getLayoutViewCount();
    for (int i = 0; i < n; i++) {
        View v = getLayoutView(i);
        float span = v.getMinimumSpan(axis);
        if (v.getBreakWeight(axis, 0, v.getMaximumSpan(axis)) > View.BadBreakWeight) {
            // find the longest non-breakable fragments at the view edges
            int p0 = v.getStartOffset();
            int p1 = v.getEndOffset();
            float start = findEdgeSpan(v, axis, p0, p0, p1);
            float end = findEdgeSpan(v, axis, p1, p0, p1);
            glue += start;
            min = Math.max(min, Math.max(span, glue));
            glue = end;
        } else {
            // non-breakable view
            glue += span;
            min = Math.max(min, glue);
        }
    }
    r.minimum = Math.max(r.minimum, (int) min);
    r.preferred = Math.max(r.minimum, r.preferred);
    r.maximum = Math.max(r.preferred, r.maximum);

    return r;
}
 
Example 30
Source Project: hottub   Source File: TableView.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    req.maximum = Math.max((int) v.getMaximumSpan(axis), req.maximum);
}