net.miginfocom.layout.LC.getPackWidthAlign()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(83)

本文整理了Java中net.miginfocom.layout.LC.getPackWidthAlign()方法的一些代码示例,展示了LC.getPackWidthAlign()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LC.getPackWidthAlign()方法的具体详情如下:
包路径:net.miginfocom.layout.LC
类名称:LC
方法名:getPackWidthAlign

LC.getPackWidthAlign介绍

[英]If there is a resize of the window due to packing (see #setPackHeight(BoundSize) this value, which is between 0f and 1f, decides where the extra/superfluous size is placed. 0f means that the window will resize so that the left part moves left and the right side stays in the same place. 0.5f will expand/reduce the window equally to the right and lefts. 1f will do the opposite of 0f of course.
[中]如果由于打包(请参见#setPackHeight(BoundSize))而调整了窗口的大小,该值介于0f和1f之间,决定了额外/多余大小的放置位置。0f表示窗口将调整大小,以便左侧部分向左移动,右侧保持在同一位置。0.5f将从右侧和左侧均匀地展开/缩小窗口。1f当然与0f相反。

代码示例

代码示例来源:origin: com.miglayout/miglayout-ideutil

if (lc.getPackWidthAlign() != 0.5f || lc.getPackHeightAlign() != 1f) {
  if (asAPI) {
    sb.append(".packAlign(").append(floatToString(lc.getPackWidthAlign(), asAPI)).append(", ").append(floatToString(lc.getPackHeightAlign(), asAPI)).append(')');
  } else {
    sb.append(",packalign ").append(floatToString(lc.getPackWidthAlign(), asAPI)).append(' ').append(floatToString(lc.getPackHeightAlign(), asAPI));

代码示例来源:origin: com.miglayout/miglayout-swing

int x = Math.round(p.x - ((targW - packable.getWidth()) * (1 - lc.getPackWidthAlign())));
int y = Math.round(p.y - ((targH - packable.getHeight()) * (1 - lc.getPackHeightAlign())));

代码示例来源:origin: com.miglayout/miglayout-javafx

/** Checks the parent window/popup if its size is within parameters as set by the LC.
 */
private void adjustWindowSize()
{
  BoundSize wBounds = layoutConstraints.getPackWidth();
  BoundSize hBounds = layoutConstraints.getPackHeight();
  Scene scene = getScene();
  Window window = scene != null ? scene.getWindow() : null;
  if (window == null || wBounds == BoundSize.NULL_SIZE && hBounds == BoundSize.NULL_SIZE)
    return;
  Parent root = scene.getRoot();
  double winWidth = window.getWidth();
  double winHeight = window.getHeight();
  double prefWidth = root.prefWidth(-1);
  double prefHeight = root.prefHeight(-1);
  FXContainerWrapper container = new FXContainerWrapper(root);
  double horIns = winWidth - scene.getWidth();
  double verIns = winHeight - scene.getHeight();
  double targetW = constrain(container, winWidth, prefWidth, wBounds) + horIns;
  double targetH = constrain(container, winHeight, prefHeight, hBounds) + verIns;
  double x = window.getX() - ((targetW - winWidth) * (1 - layoutConstraints.getPackWidthAlign()));
  double y = window.getY() - ((targetH - winHeight) * (1 - layoutConstraints.getPackHeightAlign()));
  window.setX(x);
  window.setY(y);
  window.setWidth(targetW);
  window.setHeight(targetH);
}

相关文章