Java 类javax.swing.SizeRequirements 实例源码

项目:OpenJSharp    文件:BlockView.java   
/**
 * 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;
}
项目:jdk8u-jdk    文件:BlockView.java   
/**
 * 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;
}
项目:openjdk-jdk10    文件:BlockView.java   
/**
 * 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;
}
项目:openjdk9    文件:BlockView.java   
/**
 * 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;
}
项目:Java8CN    文件:BlockView.java   
/**
 * 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;
}
项目:jdk8u_jdk    文件:BlockView.java   
/**
 * 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;
}
项目:lookaside_java-1.8.0-openjdk    文件:BlockView.java   
/**
 * 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;
}
项目:javify    文件:BoxView.java   
/**
 * Creates a new <code>BoxView</code> for the given
 * <code>Element</code> and axis. Valid values for the axis are
 * {@link View#X_AXIS} and {@link View#Y_AXIS}.
 *
 * @param element the element that is rendered by this BoxView
 * @param axis the axis along which the box is laid out
 */
public BoxView(Element element, int axis)
{
  super(element);
  myAxis = axis;
  layoutValid[0] = false;
  layoutValid[1] = false;
  requirementsValid[X_AXIS] = false;
  requirementsValid[Y_AXIS] = false;
  span[0] = 0;
  span[1] = 0;
  requirements[0] = new SizeRequirements();
  requirements[1] = new SizeRequirements();

  // Initialize the cache arrays.
  spans[0] = new int[0];
  spans[1] = new int[0];
  offsets[0] = new int[0];
  offsets[1] = new int[0];
}
项目:javify    文件:TableView.java   
/**
 * Replaces some child views with a new set of child views. This is
 * implemented to call the superclass behaviour and invalidates the row
 * grid so that rows and columns will be recalculated.
 *
 * @param offset the start offset at which to replace views
 * @param length the number of views to remove
 * @param views the new set of views
 */
public void replace(int offset, int length, View[] views)
{
  super.replace(offset, length, views);
  int viewCount = getViewCount();
  if (columnRequirements == null
      || viewCount > columnRequirements.length)
    {
      columnRequirements = new SizeRequirements[viewCount];
      for (int i = 0; i < columnRequirements.length; i++)
        columnRequirements[i] = new SizeRequirements();
    }
  if (columnOffsets == null || columnOffsets.length < viewCount)
    columnOffsets = new int[viewCount];
  if (columnSpans == null || columnSpans.length < viewCount)
    columnSpans = new int[viewCount];
  layoutChanged(X_AXIS);
}
项目:javify    文件:TableView.java   
/**
 * Updates the column requirements.
 */
private void updateColumnRequirements()
{
  int rowCount = getViewCount();
  for (int r = 0; r < rowCount; ++r)
    {
      TableRow row = (TableRow) getView(r);
      int columnCount = row.getViewCount();
      for (int c = 0; c < columnCount; ++c)
        {
          View cell = row.getView(c);
          SizeRequirements cr = columnRequirements[c];
          cr.minimum = Math.max(cr.minimum, (int) cell.getMinimumSpan(X_AXIS));
          cr.preferred = Math.max(cr.preferred,
                                  (int) cell.getPreferredSpan(X_AXIS));
          cr.maximum = Math.max(cr.maximum, (int) cell.getMaximumSpan(X_AXIS));
        }
    }
}
项目:javify    文件:ParagraphView.java   
/**
 * Sets the span on the SizeRequirements object according to the
 * according CSS span value, when it is set.
 *
 * @param r the size requirements
 * @param axis the axis
 *
 * @return <code>true</code> when the CSS span has been set,
 *         <code>false</code> otherwise
 */
private boolean setCSSSpan(SizeRequirements r, int axis)
{
  boolean ret = false;
  if (axis == X_AXIS)
    {
      if (cssWidth != null && ! cssWidth.isPercentage())
        {
          r.minimum = (int) cssWidth.getValue();
          r.preferred = (int) cssWidth.getValue();
          r.maximum = (int) cssWidth.getValue();
          ret = true;
        }
    }
  else
    {
      if (cssHeight != null && ! cssWidth.isPercentage())
        {
          r.minimum = (int) cssHeight.getValue();
          r.preferred = (int) cssHeight.getValue();
          r.maximum = (int) cssHeight.getValue();
          ret = true;
        }
    }
  return ret;
}
项目:javify    文件:BlockView.java   
/**
 * Sets the span on the SizeRequirements object according to the
 * according CSS span value, when it is set.
 *
 * @param r the size requirements
 * @param axis the axis
 *
 * @return <code>true</code> when the CSS span has been set,
 *         <code>false</code> otherwise
 */
private boolean setCSSSpan(SizeRequirements r, int axis)
{
  boolean ret = false;
  Length span = cssSpans[axis];
  // We can't set relative CSS spans here because we don't know
  // yet about the allocated span. Instead we use the view's
  // normal requirements.
  if (span != null && ! span.isPercentage())
    {
      r.minimum = (int) span.getValue();
      r.preferred = (int) span.getValue();
      r.maximum = (int) span.getValue();
      ret = true;
    }
  return ret;
}
项目:jvm-stm    文件:BoxView.java   
/**
 * Creates a new <code>BoxView</code> for the given
 * <code>Element</code> and axis. Valid values for the axis are
 * {@link View#X_AXIS} and {@link View#Y_AXIS}.
 *
 * @param element the element that is rendered by this BoxView
 * @param axis the axis along which the box is laid out
 */
public BoxView(Element element, int axis)
{
  super(element);
  myAxis = axis;
  layoutValid[0] = false;
  layoutValid[1] = false;
  requirementsValid[X_AXIS] = false;
  requirementsValid[Y_AXIS] = false;
  span[0] = 0;
  span[1] = 0;
  requirements[0] = new SizeRequirements();
  requirements[1] = new SizeRequirements();

  // Initialize the cache arrays.
  spans[0] = new int[0];
  spans[1] = new int[0];
  offsets[0] = new int[0];
  offsets[1] = new int[0];
}
项目:jvm-stm    文件:TableView.java   
/**
 * Replaces some child views with a new set of child views. This is
 * implemented to call the superclass behaviour and invalidates the row
 * grid so that rows and columns will be recalculated.
 *
 * @param offset the start offset at which to replace views
 * @param length the number of views to remove
 * @param views the new set of views
 */
public void replace(int offset, int length, View[] views)
{
  super.replace(offset, length, views);
  int viewCount = getViewCount();
  if (columnRequirements == null
      || viewCount > columnRequirements.length)
    {
      columnRequirements = new SizeRequirements[viewCount];
      for (int i = 0; i < columnRequirements.length; i++)
        columnRequirements[i] = new SizeRequirements();
    }
  if (columnOffsets == null || columnOffsets.length < viewCount)
    columnOffsets = new int[viewCount];
  if (columnSpans == null || columnSpans.length < viewCount)
    columnSpans = new int[viewCount];
  layoutChanged(X_AXIS);
}
项目:jvm-stm    文件:TableView.java   
/**
 * Updates the column requirements.
 */
private void updateColumnRequirements()
{
  int rowCount = getViewCount();
  for (int r = 0; r < rowCount; ++r)
    {
      TableRow row = (TableRow) getView(r);
      int columnCount = row.getViewCount();
      for (int c = 0; c < columnCount; ++c)
        {
          View cell = row.getView(c);
          SizeRequirements cr = columnRequirements[c];
          cr.minimum = Math.max(cr.minimum, (int) cell.getMinimumSpan(X_AXIS));
          cr.preferred = Math.max(cr.preferred,
                                  (int) cell.getPreferredSpan(X_AXIS));
          cr.maximum = Math.max(cr.maximum, (int) cell.getMaximumSpan(X_AXIS));
        }
    }
}
项目:jvm-stm    文件:ParagraphView.java   
/**
 * Sets the span on the SizeRequirements object according to the
 * according CSS span value, when it is set.
 * 
 * @param r the size requirements
 * @param axis the axis
 *
 * @return <code>true</code> when the CSS span has been set,
 *         <code>false</code> otherwise
 */
private boolean setCSSSpan(SizeRequirements r, int axis)
{
  boolean ret = false;
  if (axis == X_AXIS)
    {
      if (cssWidth != null && ! cssWidth.isPercentage())
        {
          r.minimum = (int) cssWidth.getValue();
          r.preferred = (int) cssWidth.getValue();
          r.maximum = (int) cssWidth.getValue();
          ret = true;
        }
    }
  else
    {
      if (cssHeight != null && ! cssWidth.isPercentage())
        {
          r.minimum = (int) cssHeight.getValue();
          r.preferred = (int) cssHeight.getValue();
          r.maximum = (int) cssHeight.getValue();
          ret = true;
        }
    }
  return ret;
}
项目:jvm-stm    文件:BlockView.java   
/**
 * Sets the span on the SizeRequirements object according to the
 * according CSS span value, when it is set.
 * 
 * @param r the size requirements
 * @param axis the axis
 *
 * @return <code>true</code> when the CSS span has been set,
 *         <code>false</code> otherwise
 */
private boolean setCSSSpan(SizeRequirements r, int axis)
{
  boolean ret = false;
  Length span = cssSpans[axis];
  // We can't set relative CSS spans here because we don't know
  // yet about the allocated span. Instead we use the view's
  // normal requirements.
  if (span != null && ! span.isPercentage())
    {
      r.minimum = (int) span.getValue();
      r.preferred = (int) span.getValue();
      r.maximum = (int) span.getValue();
      ret = true;
    }
  return ret;
}
项目:infobip-open-jdk-8    文件:BlockView.java   
/**
 * 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;
}
项目:jdk8u-dev-jdk    文件:BlockView.java   
/**
 * 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;
}
项目:jdk7-jdk    文件:BlockView.java   
/**
 * 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;
}
项目:openjdk-source-code-learn    文件:BlockView.java   
/**
 * 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;
}
项目:JamVM-PH    文件:TableView.java   
/**
 * Updates the column requirements.
 */
private void updateColumnRequirements()
{
  int rowCount = getViewCount();
  for (int r = 0; r < rowCount; ++r)
    {
      TableRow row = (TableRow) getView(r);
      int columnCount = row.getViewCount();
      for (int c = 0; c < columnCount; ++c)
        {
          View cell = row.getView(c);
          SizeRequirements cr = columnRequirements[c];
          cr.minimum = Math.max(cr.minimum, (int) cell.getMinimumSpan(X_AXIS));
          cr.preferred = Math.max(cr.preferred,
                                  (int) cell.getPreferredSpan(X_AXIS));
          cr.maximum = Math.max(cr.maximum, (int) cell.getMaximumSpan(X_AXIS));
        }
    }
}
项目:cn1    文件:SizeRequirementsHelper.java   
/**
 * @see javax.swing.SizeRequirements#getTiledSizeRequirements(SizeRequirements[])
 *
 * @param sr SizeRequirements where results to be copied. If sr is null, new object is created
 *
 * @return SizeRequirements sr or newly created object
 */
public static SizeRequirements
    getTiledSizeRequirements(final SizeRequirements[] children,
                             final SizeRequirements sr) {

    SizeRequirements result = (sr != null) ? sr : new SizeRequirements();
    result.minimum   = 0;
    result.preferred = 0;
    result.maximum   = 0;
    result.alignment = 0.5f;

    for (int iChild = 0; iChild < children.length; iChild++) {
        result.minimum = Utilities.safeIntSum(children[iChild].minimum, result.minimum);
        result.preferred = Utilities.safeIntSum(children[iChild].preferred, result.preferred);
        result.maximum = Utilities.safeIntSum(children[iChild].maximum, result.maximum);
    }

    return result;
}
项目:cn1    文件:BoxView.java   
protected SizeRequirements calculateMinorAxisRequirements(final int axis,
        final SizeRequirements r)  {
    final SizeRequirements result = r != null ? r : new SizeRequirements();
    final SizeRequirements[] children = getRequirements(axis);

    int min  = 0;
    int pref = 0;

    final int count = getViewCount();
    for (int i = 0; i < count; i++) {
        min  = Math.max(min, children[i].minimum);
        pref = Math.max(pref, children[i].preferred);
    }

    result.minimum   = min;
    result.preferred = pref;
    result.maximum   = Integer.MAX_VALUE;
    result.alignment = ALIGN_CENTER;

    return result;
}
项目:cn1    文件:BoxView.java   
/**
 * Resizes an array of size requirements.
 * <small>(Probably may be optimized to not copy old array contents)</small>
 *
 * @param array the array to resize
 * @param index index where remove and add operations occur
 * @param toRemove the number of items to remove
 * @param toAdd the number of items to add
 * @return array with the new size
 */
private SizeRequirements[] resizeArray(final SizeRequirements[] array,
                                       final int index,
                                       final int toRemove,
                                       final int toAdd) {
     if (toRemove == toAdd) {
         return array;
     }

     int size = array.length - toRemove + toAdd;
     if (size == 0) {
         return EMPTY_REQUIREMENTS_ARRAY;
     }

     SizeRequirements[] newArray = new SizeRequirements[size];
     System.arraycopy(array, 0, newArray, 0, index);
     System.arraycopy(array, index + toRemove, newArray, index + toAdd,
                      array.length - (index + toRemove));
     return newArray;
 }
项目:JamVM-PH    文件:BoxView.java   
/**
 * Creates a new <code>BoxView</code> for the given
 * <code>Element</code> and axis. Valid values for the axis are
 * {@link View#X_AXIS} and {@link View#Y_AXIS}.
 *
 * @param element the element that is rendered by this BoxView
 * @param axis the axis along which the box is laid out
 */
public BoxView(Element element, int axis)
{
  super(element);
  myAxis = axis;
  layoutValid[0] = false;
  layoutValid[1] = false;
  requirementsValid[X_AXIS] = false;
  requirementsValid[Y_AXIS] = false;
  span[0] = 0;
  span[1] = 0;
  requirements[0] = new SizeRequirements();
  requirements[1] = new SizeRequirements();

  // Initialize the cache arrays.
  spans[0] = new int[0];
  spans[1] = new int[0];
  offsets[0] = new int[0];
  offsets[1] = new int[0];
}
项目:JamVM-PH    文件:TableView.java   
/**
 * Replaces some child views with a new set of child views. This is
 * implemented to call the superclass behaviour and invalidates the row
 * grid so that rows and columns will be recalculated.
 *
 * @param offset the start offset at which to replace views
 * @param length the number of views to remove
 * @param views the new set of views
 */
public void replace(int offset, int length, View[] views)
{
  super.replace(offset, length, views);
  int viewCount = getViewCount();
  if (columnRequirements == null
      || viewCount > columnRequirements.length)
    {
      columnRequirements = new SizeRequirements[viewCount];
      for (int i = 0; i < columnRequirements.length; i++)
        columnRequirements[i] = new SizeRequirements();
    }
  if (columnOffsets == null || columnOffsets.length < viewCount)
    columnOffsets = new int[viewCount];
  if (columnSpans == null || columnSpans.length < viewCount)
    columnSpans = new int[viewCount];
  layoutChanged(X_AXIS);
}
项目:cn1    文件:BoxView_WithChildrenTest.java   
/**
 * Tests <code>baselineRequirements</code> with ordinary children along
 * major axis - Y.
 */
public void testBaselineRequirements01() {
    SizeRequirements sr;
    final int axis = Y_AXIS;
    sr = view.baselineRequirements(axis, null);
    // The sizes to the left and to the right from the alignment point
    int left = getLeft(PREFERRED, axis);
    int right = getRight(PREFERRED, axis);
    int size = left + right;
    assertEquals(size, sr.minimum);
    assertEquals(size, sr.preferred);
    assertEquals(size, sr.maximum);
    assertEquals((float) left / (float) size, sr.alignment, 0.00001f);
    SizeRequirements another = view.baselineRequirements(axis, sr);
    assertSame(sr, another);
}
项目:cn1    文件:BoxView_WithChildrenTest.java   
/**
 * Tests <code>baselineRequirements</code> with flexible children along
 * major axis - Y.
 */
public void testBaselineRequirements02() {
    if (!isHarmony()) {
        return;
    }
    makeFlexible();
    SizeRequirements sr;
    final int axis = Y_AXIS;
    sr = view.baselineRequirements(axis, null);
    // The sizes to the left and to the right from the alignment point
    int minL = getLeft(MINIMUM, axis);
    int minR = getRight(MINIMUM, axis);
    int prefL = getLeft(PREFERRED, axis);
    int prefR = getRight(PREFERRED, axis);
    int maxL = getLeft(MAXIMUM, axis);
    int maxR = getRight(MAXIMUM, axis);
    int min = minL + minR;
    int pref = prefL + prefR;
    int max = maxL + maxR;
    assertEquals(min, sr.minimum);
    assertEquals(pref, sr.preferred);
    assertEquals(max, sr.maximum);
    assertEquals((float) prefL / (float) pref, sr.alignment, 0.00001f);
}
项目:JamVM-PH    文件:BlockView.java   
/**
 * Sets the span on the SizeRequirements object according to the
 * according CSS span value, when it is set.
 * 
 * @param r the size requirements
 * @param axis the axis
 *
 * @return <code>true</code> when the CSS span has been set,
 *         <code>false</code> otherwise
 */
private boolean setCSSSpan(SizeRequirements r, int axis)
{
  boolean ret = false;
  Length span = cssSpans[axis];
  // We can't set relative CSS spans here because we don't know
  // yet about the allocated span. Instead we use the view's
  // normal requirements.
  if (span != null && ! span.isPercentage())
    {
      r.minimum = (int) span.getValue();
      r.preferred = (int) span.getValue();
      r.maximum = (int) span.getValue();
      ret = true;
    }
  return ret;
}
项目:cn1    文件:BoxView_WithChildrenTest.java   
/**
 * Tests layout of minor axis with <em>resizable</em> children in the case
 * where <code>targetSpan</code> <em>is less than the minimum span</em>
 * of at least one of the children.
 */
public void testLayoutMinorAxis03() {
    int[] offsets = new int[view.getViewCount()];
    int[] spans = new int[view.getViewCount()];
    makeFlexible();
    SizeRequirements[] childReq = new SizeRequirements[view.getViewCount()];
    fillRequirements(childReq, X_AXIS);
    shape.width = 16;
    view.layoutMinorAxis(shape.width, X_AXIS, offsets, spans);
    boolean widthLessMinimum = false;
    for (int i = 0; i < view.getViewCount(); i++) {
        widthLessMinimum |= childReq[i].minimum > shape.width;
        int span = getChildSpan(shape.width, childReq[i]);
        assertEquals("Spans are different @ " + i, span, spans[i]);
        assertEquals("Offsets are different @ " + i, getChildOffset(shape.width, span,
                childReq[i].alignment), offsets[i]);
    }
    assertTrue("Minimum span of at least one child view must "
            + "be greater than targetSpan", widthLessMinimum);
}
项目:openjdk-jdk7u-jdk    文件:BlockView.java   
/**
 * 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;
}
项目:cn1    文件:BlockViewTest.java   
public void testCalculateMajorAxisRequirements() {
    SizeRequirements r = view.calculateMajorAxisRequirements(Y_AXIS, null);
    assertEquals(r.preferred, r.minimum);
    assertEquals(0, r.preferred);
    assertEquals(0, r.maximum);

    doc.getStyleSheet().addRule("p {width: 305pt}");
    view.setPropertiesFromAttributes();
    SizeRequirements sr = view.calculateMajorAxisRequirements(Y_AXIS, r);
    assertSame(r, sr);
    assertEquals(0, r.minimum);
    assertEquals(0, r.preferred);
    assertEquals(0, r.maximum);

    doc.getStyleSheet().addRule("p {height: 40pt}");
    view.setPropertiesFromAttributes();
    view.calculateMajorAxisRequirements(Y_AXIS, r);
    assertEquals(25, r.minimum);
    assertEquals(25, r.preferred);
    assertEquals(25, r.maximum);
}
项目:cn1    文件:BlockViewTest.java   
public void testCalculateMinorAxisRequirements() {
    SizeRequirements r = view.calculateMinorAxisRequirements(X_AXIS, null);
    assertEquals(r.preferred, r.minimum);
    assertEquals((int)getMaxChildSpan(X_AXIS), r.preferred);
    assertEquals(Integer.MAX_VALUE, r.maximum);

    doc.getStyleSheet().addRule("p {height: 40pt}");
    view.setPropertiesFromAttributes();
    SizeRequirements sr = view.calculateMinorAxisRequirements(X_AXIS, r);
    assertSame(r, sr);
    assertEquals(r.preferred, r.minimum);
    assertEquals((int)getMaxChildSpan(X_AXIS), r.preferred);
    assertEquals(Integer.MAX_VALUE, r.maximum);

    doc.getStyleSheet().addRule("p {width: 305pt}");
    view.setPropertiesFromAttributes();
    view.calculateMinorAxisRequirements(X_AXIS, r);
    assertEquals(r.preferred, r.minimum);
    assertEquals(305, r.preferred);
    assertEquals(305, r.maximum);
}
项目:cn1    文件:BlockViewTest.java   
public void testCalculateMinorAxisRequirementsOrthogonal() {
    view = new BlockViewImpl(block, X_AXIS);
    SizeRequirements r = view.calculateMinorAxisRequirements(Y_AXIS, null);
    assertEquals(r.preferred, r.minimum);
    assertEquals(0, r.preferred);
    assertEquals(Integer.MAX_VALUE, r.maximum);

    doc.getStyleSheet().addRule("p {width: 305pt}");
    view.setPropertiesFromAttributes();
    SizeRequirements sr = view.calculateMinorAxisRequirements(Y_AXIS, r);
    assertSame(r, sr);
    assertEquals(r.preferred, r.minimum);
    assertEquals(0, r.preferred);
    assertEquals(Integer.MAX_VALUE, r.maximum);

    doc.getStyleSheet().addRule("p {height: 40pt}");
    view.setPropertiesFromAttributes();
    view.calculateMinorAxisRequirements(Y_AXIS, r);
    assertEquals(r.preferred, r.minimum);
    assertEquals(25, r.preferred); // 40 - 15 (def. top margin) = 25
    assertEquals(25, r.maximum);
}
项目:cn1    文件:BlockViewTest.java   
public void testLayoutMinorAxisFlexible() {
    factory = new ChildrenFactory();
    ((ChildrenFactory)factory).makeFlexible();

    view = new BlockViewImpl(block, Y_AXIS);

    final int[] offsets = new int[view.getViewCount()];
    final int[] spans = new int[view.getViewCount()];
    final int target = 305;
    ((BlockViewImpl)view).layoutMinorAxis(target, X_AXIS, offsets, spans);
    for (int i = 0; i < view.getViewCount(); i++) {
        View child = view.getView(i);
        SizeRequirements sr =
            new SizeRequirements((int)child.getMinimumSpan(X_AXIS),
                                 (int)child.getPreferredSpan(X_AXIS),
                                 (int)child.getMaximumSpan(X_AXIS),
                                 child.getAlignment(X_AXIS));
        assertEquals(getChildSpan(target, sr), spans[i]);
        assertEquals(getChildOffset(target, spans[i], sr), offsets[i]);
    }
}
项目:cn1    文件:BlockViewTest.java   
public void testLayoutMinorAxisFlexibleWide() {
    factory = new ChildrenFactory();
    ((ChildrenFactory)factory).makeFlexible();

    view = new BlockViewImpl(block, Y_AXIS);

    final int[] offsets = new int[view.getViewCount()];
    final int[] spans = new int[view.getViewCount()];
    final int target = 451;
    ((BlockViewImpl)view).layoutMinorAxis(target, X_AXIS, offsets, spans);
    for (int i = 0; i < view.getViewCount(); i++) {
        View child = view.getView(i);
        SizeRequirements sr =
            new SizeRequirements((int)child.getMinimumSpan(X_AXIS),
                                 (int)child.getPreferredSpan(X_AXIS),
                                 (int)child.getMaximumSpan(X_AXIS),
                                 child.getAlignment(X_AXIS));
        assertEquals(getChildSpan(target, sr), spans[i]);
        assertEquals(getChildOffset(target, spans[i], sr), offsets[i]);
    }
}
项目:OpenJSharp    文件:ParagraphView.java   
/**
 * 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;
}
项目:OpenJSharp    文件:ParagraphView.java   
@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;
}
项目:OpenJSharp    文件:TableView.java   
/**
 * 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);
}