public class SizeRequirements extends Object implements Serializable
- tiled
- The components are placed end-to-end, starting either at coordinate 0 (the leftmost or topmost position) or at the coordinate representing the end of the allocated span (the rightmost or bottommost position).
- aligned
- The components are aligned as specified by each component's X or Y alignment value.
每个SizeRequirements对象都包含有关单个组件或一组组件的宽度(和X对齐)或高度(和Y对齐)的信息:
minimum- The smallest reasonable width/height of the component or component group, in pixels.
preferred- The natural width/height of the component or component group, in pixels.
maximum- The largest reasonable width/height of the component or component group, in pixels.
alignment- The X/Y alignment of the component or component group.
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4开始,所有JavaBeans的长期存储支持已被添加到java.beans软件包中。 请参阅XMLEncoder 。
| Modifier and Type | Field and Description |
|---|---|
float |
alignment
对齐方式,指定为0.0和1.0之间的值,包括0和1.0。
|
int |
maximum
允许的最大大小。
|
int |
minimum
所需最小尺寸
|
int |
preferred
优选(自然)尺寸。
|
| Constructor and Description |
|---|
SizeRequirements()
创建一个SizeRequirements对象,其最小,首选和最大大小设置为零,对齐值为0.5(居中)。
|
SizeRequirements(int min, int pref, int max, float a)
创建一个SizeRequirements对象,具有指定的最小,首选和最大大小以及指定的对齐方式。
|
| Modifier and Type | Method and Description |
|---|---|
static int[] |
adjustSizes(int delta, SizeRequirements[] children)
将指定的大小数组调整一定量。
|
static void |
calculateAlignedPositions(int allocated, SizeRequirements total, SizeRequirements[] children, int[] offsets, int[] spans)
创建一堆偏移/跨度对,指定如何使用指定的对齐方式布置一组组件。
|
static void |
calculateAlignedPositions(int allocated, SizeRequirements total, SizeRequirements[] children, int[] offsets, int[] spans, boolean normal)
创建一组偏移/跨度对,指定如何使用指定的对齐方式布置一组组件。
|
static void |
calculateTiledPositions(int allocated, SizeRequirements total, SizeRequirements[] children, int[] offsets, int[] spans)
创建一组偏移/跨度对,这些偏移/跨度对代表端到端布局一组组件。
|
static void |
calculateTiledPositions(int allocated, SizeRequirements total, SizeRequirements[] children, int[] offsets, int[] spans, boolean forward)
创建一组偏移/跨度对,这些偏移/跨度对代表端到端布局一组组件。
|
static SizeRequirements |
getAlignedSizeRequirements(SizeRequirements[] children)
确定对齐一组组件所需的总空间。
|
static SizeRequirements |
getTiledSizeRequirements(SizeRequirements[] children)
确定端点到端放置一组组件所需的总空间。
|
String |
toString()
返回描述最小,首选和最大大小要求的字符串以及对齐方式。
|
public int minimum
comp ,这应该等于comp.getMinimumSize().width或comp.getMinimumSize().height 。
public int preferred
comp ,这应该等于comp.getPreferredSize().width或comp.getPreferredSize().height 。
public int maximum
comp ,这应该等于comp.getMaximumSize().width或comp.getMaximumSize().height 。
public float alignment
public SizeRequirements()
public SizeRequirements(int min,
int pref,
int max,
float a)
min - 最小大小> = 0
pref - 首选大小> = 0
max - 最大大小> = 0
a - alignment> = 0.0f && <= 1.0f
public static SizeRequirements getTiledSizeRequirements(SizeRequirements[] children)
children - children的空间要求。
向量可能为零长度,这将导致返回的默认SizeRequirements对象实例。
public static SizeRequirements getAlignedSizeRequirements(SizeRequirements[] children)
children - 一组子要求。
如果零长度,则返回结果将是SizeRequirements的默认实例。
public static void calculateTiledPositions(int allocated,
SizeRequirements total,
SizeRequirements[] children,
int[] offsets,
int[] spans)
allocated - 要分配的总跨度> = 0。
total - 儿童请求的总和。
此参数是可选的,可以为null。
children - 每个组件的尺寸要求。
offsets - 分配了跨度的每个小孩的偏移量(从0确定跨度的位置)。
spans - 为每个孩子分配的跨度达到总目标跨度的跨度。
public static void calculateTiledPositions(int allocated,
SizeRequirements total,
SizeRequirements[] children,
int[] offsets,
int[] spans,
boolean forward)
allocated - 要分配的总跨度> = 0。
total - 儿童请求的总和。
此参数是可选的,可以为null。
children - 每个组件的尺寸要求。
offsets - 分配跨距的每个小孩的偏移量(从0决定跨度的位置)。
spans - 为每个小孩分配的跨度达到总目标跨度的跨度。
forward - 如果为true,则偏移量从0增加,如果为false,则从已分配空间的末尾减少偏移量。
public static void calculateAlignedPositions(int allocated,
SizeRequirements total,
SizeRequirements[] children,
int[] offsets,
int[] spans)
allocated - 要分配的总跨度> = 0。
total - 儿童请求的总数。
children - 每个组件的尺寸要求。
offsets - 分配跨距的每个小孩的偏移量(从0决定跨度的位置)。
spans - 为每个孩子分配的跨度达到总目标跨度的跨度。
public static void calculateAlignedPositions(int allocated,
SizeRequirements total,
SizeRequirements[] children,
int[] offsets,
int[] spans,
boolean normal)
allocated - 要分配的总跨度> = 0。
total - 儿童请求的总和。
children - 每个组件的尺寸要求。
offsets - 分配跨度的每个小孩的偏移量(从0决定跨度的位置)。
spans - 为每个孩子分配的跨度达到总目标跨度的跨度。
normal - 当为true时,对齐值0.0f表示左/顶;
当错误时,表示右/底。
public static int[] adjustSizes(int delta,
SizeRequirements[] children)
delta - 指定大小差异的int
children - 一个SizeRequirements对象的数组
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.