java.awt.Container#getInsets ( )源码实例Demo

下面列出了java.awt.Container#getInsets ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: SnapshotsWindowUI.java
private Dimension maximumLayoutSize(Container parent) {
    int maxw = 0;
    int maxh = 0;
    for (Component c : parent.getComponents()) {
        Dimension pref = c.getPreferredSize();
        maxw += pref.height * MAX_WIDTH_FACTOR;
        maxh = Math.max(maxh, pref.height);
    }
    maxw += HGAP * (parent.getComponentCount() - 1);
    
    Insets i = parent.getInsets();
    maxw += i.left + i.right;
    maxh += i.top + i.bottom;
    
    return new Dimension(maxw, maxh);
}
 
源代码2 项目: Method_Trace_Tool   文件: VerticalFlowLayout.java
/**
 * Returns the preferred dimensions given the components in the target
 * container.
 *
 * @param target
 *            the component to lay out
 */
public Dimension preferredLayoutSize(Container target) {
	Dimension tarsiz = new Dimension(0, 0);

	for (int i = 0; i < target.getComponentCount(); i++) {
		Component m = target.getComponent(i);
		if (m.isVisible()) {
			Dimension d = m.getPreferredSize();
			tarsiz.width = Math.max(tarsiz.width, d.width);
			if (i > 0) {
				tarsiz.height += hgap;
			}
			tarsiz.height += d.height;
		}
	}
	Insets insets = target.getInsets();
	tarsiz.width += insets.left + insets.right + hgap * 2;
	tarsiz.height += insets.top + insets.bottom + vgap * 2;
	return tarsiz;
}
 
源代码3 项目: Method_Trace_Tool   文件: VerticalFlowLayout.java
/**
 * Returns the minimum size needed to layout the target container.
 *
 * @param target
 *            the component to lay out.
 * @return the minimum layout dimension.
 */
public Dimension minimumLayoutSize(Container target) {
	Dimension tarsiz = new Dimension(0, 0);

	for (int i = 0; i < target.getComponentCount(); i++) {
		Component m = target.getComponent(i);
		if (m.isVisible()) {
			Dimension d = m.getMinimumSize();
			tarsiz.width = Math.max(tarsiz.width, d.width);
			if (i > 0) {
				tarsiz.height += vgap;
			}
			tarsiz.height += d.height;
		}
	}
	Insets insets = target.getInsets();
	tarsiz.width += insets.left + insets.right + hgap * 2;
	tarsiz.height += insets.top + insets.bottom + vgap * 2;
	return tarsiz;
}
 
源代码4 项目: gcs   文件: CharacterSheetLayout.java
@Override
public void layoutContainer(Container target) {
    Component[] children = target.getComponents();
    if (children.length > 0) {
        Dimension size   = children[0].getPreferredSize();
        Dimension avail  = target.getSize();
        Insets    insets = target.getInsets();
        int       x      = insets.left;
        int       y      = insets.top;
        int       margin = mSheet.getScale().scale(MARGIN);
        for (Component child : children) {
            child.setBounds(x, y, size.width, size.height);
            x += size.width + margin;
            if (x + size.width + insets.right > avail.width) {
                x = insets.left;
                y += size.height + margin;
            }
        }
    }
}
 
源代码5 项目: openjdk-jdk8u   文件: MetalworksPrefs.java
public Dimension minimumLayoutSize(Container c) {
    Insets insets = c.getInsets();
    int height = yInset + insets.top;
    int width = 0 + insets.left + insets.right;

    Component[] children = c.getComponents();
    Dimension compSize = null;
    for (Component child : children) {
        compSize = child.getPreferredSize();
        height += compSize.height + yGap;
        width = Math.max(width, compSize.width + insets.left + insets.right + xInset
                * 2);
    }
    height += insets.bottom;
    return new Dimension(width, height);
}
 
源代码6 项目: jdk8u-jdk   文件: MetalworksPrefs.java
public Dimension minimumLayoutSize(Container c) {
    Insets insets = c.getInsets();
    int height = yInset + insets.top;
    int width = 0 + insets.left + insets.right;

    Component[] children = c.getComponents();
    Dimension compSize = null;
    for (Component child : children) {
        compSize = child.getPreferredSize();
        height += compSize.height + yGap;
        width = Math.max(width, compSize.width + insets.left + insets.right + xInset
                * 2);
    }
    height += insets.bottom;
    return new Dimension(width, height);
}
 
源代码7 项目: jdk8u_jdk   文件: GroupLayout.java
/**
 * Lays out the specified container.
 *
 * @param parent the container to be laid out
 * @throws IllegalStateException if any of the components added to
 *         this layout are not in both a horizontal and vertical group
 */
public void layoutContainer(Container parent) {
    // Step 1: Prepare for layout.
    prepare(SPECIFIC_SIZE);
    Insets insets = parent.getInsets();
    int width = parent.getWidth() - insets.left - insets.right;
    int height = parent.getHeight() - insets.top - insets.bottom;
    boolean ltr = isLeftToRight();
    if (getAutoCreateGaps() || getAutoCreateContainerGaps() ||
            hasPreferredPaddingSprings) {
        // Step 2: Calculate autopadding springs
        calculateAutopadding(horizontalGroup, HORIZONTAL, SPECIFIC_SIZE, 0,
                width);
        calculateAutopadding(verticalGroup, VERTICAL, SPECIFIC_SIZE, 0,
                height);
    }
    // Step 3: set the size of the groups.
    horizontalGroup.setSize(HORIZONTAL, 0, width);
    verticalGroup.setSize(VERTICAL, 0, height);
    // Step 4: apply the size to the components.
    for (ComponentInfo info : componentInfos.values()) {
        info.setBounds(insets, width, ltr);
    }
}
 
源代码8 项目: Logisim   文件: HorizontalSplitPane.java
@Override
public Dimension preferredLayoutSize(Container parent) {
	if (fraction <= 0.0)
		return comp1.getPreferredSize();
	if (fraction >= 1.0)
		return comp0.getPreferredSize();
	Insets in = parent.getInsets();
	Dimension d0 = comp0.getPreferredSize();
	Dimension d1 = comp1.getPreferredSize();
	return new Dimension(in.left + Math.max(d0.width, d1.width) + in.right,
			in.top + d0.height + d1.height + in.bottom);
}
 
源代码9 项目: jdk8u-dev-jdk   文件: MetalworksPrefs.java
public void layoutContainer(Container c) {
    Insets insets = c.getInsets();
    int height = yInset + insets.top;

    Component[] children = c.getComponents();
    Dimension compSize = null;
    for (Component child : children) {
        compSize = child.getPreferredSize();
        child.setSize(compSize.width, compSize.height);
        child.setLocation(xInset + insets.left, height);
        height += compSize.height + yGap;
    }

}
 
源代码10 项目: TencentKona-8   文件: SpringLayout.java
public void layoutContainer(Container parent) {
    setParent(parent);

    int n = parent.getComponentCount();
    getConstraints(parent).reset();
    for (int i = 0 ; i < n ; i++) {
        getConstraints(parent.getComponent(i)).reset();
    }

    Insets insets = parent.getInsets();
    Constraints pc = getConstraints(parent);
    abandonCycles(pc.getX()).setValue(0);
    abandonCycles(pc.getY()).setValue(0);
    abandonCycles(pc.getWidth()).setValue(parent.getWidth() -
                                          insets.left - insets.right);
    abandonCycles(pc.getHeight()).setValue(parent.getHeight() -
                                           insets.top - insets.bottom);

    for (int i = 0 ; i < n ; i++) {
        Component c = parent.getComponent(i);
        Constraints cc = getConstraints(c);
        int x = abandonCycles(cc.getX()).getValue();
        int y = abandonCycles(cc.getY()).getValue();
        int width = abandonCycles(cc.getWidth()).getValue();
        int height = abandonCycles(cc.getHeight()).getValue();
        c.setBounds(insets.left + x, insets.top + y, width, height);
    }
}
 
源代码11 项目: littleluck   文件: LuckTitlePanelLayout.java
public Dimension preferredLayoutSize(Container parent)
{
    LuckTitlePanel root = (LuckTitlePanel) parent;

    Insets i = parent.getInsets();

    // 高度由父面板决定
    // Height is determined by the parent panel
    return new Dimension(0 + i.left + i.right, root.getHeight() + i.top + i.bottom);
}
 
源代码12 项目: openjdk-8   文件: MetalworksPrefs.java
public void layoutContainer(Container c) {
    Insets insets = c.getInsets();
    int height = yInset + insets.top;

    Component[] children = c.getComponents();
    Dimension compSize = null;
    for (Component child : children) {
        compSize = child.getPreferredSize();
        child.setSize(compSize.width, compSize.height);
        child.setLocation(xInset + insets.left, height);
        height += compSize.height + yGap;
    }

}
 
源代码13 项目: jdk8u60   文件: SpringLayout.java
public void layoutContainer(Container parent) {
    setParent(parent);

    int n = parent.getComponentCount();
    getConstraints(parent).reset();
    for (int i = 0 ; i < n ; i++) {
        getConstraints(parent.getComponent(i)).reset();
    }

    Insets insets = parent.getInsets();
    Constraints pc = getConstraints(parent);
    abandonCycles(pc.getX()).setValue(0);
    abandonCycles(pc.getY()).setValue(0);
    abandonCycles(pc.getWidth()).setValue(parent.getWidth() -
                                          insets.left - insets.right);
    abandonCycles(pc.getHeight()).setValue(parent.getHeight() -
                                           insets.top - insets.bottom);

    for (int i = 0 ; i < n ; i++) {
        Component c = parent.getComponent(i);
        Constraints cc = getConstraints(c);
        int x = abandonCycles(cc.getX()).getValue();
        int y = abandonCycles(cc.getY()).getValue();
        int width = abandonCycles(cc.getWidth()).getValue();
        int height = abandonCycles(cc.getHeight()).getValue();
        c.setBounds(insets.left + x, insets.top + y, width, height);
    }
}
 
源代码14 项目: openjdk-8   文件: CompactLayout.java
/**
 * Lays out the specified container.
 * @param parent the container to be laid out
 */
public void layoutContainer(Container parent) {
    int n = parent.getComponentCount();
    Insets insets = parent.getInsets();
    Dimension size = parent.getSize();
    int c = horizontal ? insets.left : insets.top;
    int x, y;
    int ebx = size.width - insets.right;
    size.width -= (insets.left + insets.right);
    size.height -= (insets.top + insets.bottom);
    for (int i = 0; i < n; i++) {
        Component comp = parent.getComponent(i);
        Dimension pref = comp.getPreferredSize();
        if (comp instanceof EnableButton) {
            ebx -= 4;
            ebx -= pref.width;
            x = ebx;
            y = (insets.top - pref.height) / 2;
        } else if (horizontal) {
            x = c;
            c += pref.width;
            y = insets.top;
            pref.height = size.height;
        } else {
            x = insets.left;
            pref.width = size.width;
            y = c;
            c += pref.height;
        }
        comp.setBounds(x, y, pref.width, pref.height);
    }
}
 
源代码15 项目: swift-k   文件: SimpleGridLayout.java
public Dimension maximumLayoutSize(Container container) {
	Insets insets = container.getInsets();
	int height = insets.top + insets.bottom;
	int width = insets.left + insets.right;

	int[] widths = new int[nCols];
	int[] heights = new int[nRows];

	Arrays.fill(widths, 0);
	Arrays.fill(heights, 0);

	for (int i = 0; i < nRows; i++) {
		for (int j = 0; j < nCols; j++) {
			if (grid[i][j] == null) {
				continue;
			}

			Dimension cSize = grid[i][j].getMaximumSize();

			if (widths[j] < cSize.width) {
				widths[j] = cSize.width;
			}
			if (heights[i] < cSize.height) {
				heights[i] = cSize.height;
			}
		}
	}
	for (int i = 0; i < nRows; i++) {
		height += heights[i];
	}
	height += vGap * (nRows - 1);

	for (int i = 0; i < nCols; i++) {
		width += widths[i];
	}
	width += hGap * (nCols - 1);
	return new Dimension(width, height);
}
 
源代码16 项目: openjdk-jdk8u   文件: SpringLayout.java
public void layoutContainer(Container parent) {
    setParent(parent);

    int n = parent.getComponentCount();
    getConstraints(parent).reset();
    for (int i = 0 ; i < n ; i++) {
        getConstraints(parent.getComponent(i)).reset();
    }

    Insets insets = parent.getInsets();
    Constraints pc = getConstraints(parent);
    abandonCycles(pc.getX()).setValue(0);
    abandonCycles(pc.getY()).setValue(0);
    abandonCycles(pc.getWidth()).setValue(parent.getWidth() -
                                          insets.left - insets.right);
    abandonCycles(pc.getHeight()).setValue(parent.getHeight() -
                                           insets.top - insets.bottom);

    for (int i = 0 ; i < n ; i++) {
        Component c = parent.getComponent(i);
        Constraints cc = getConstraints(c);
        int x = abandonCycles(cc.getX()).getValue();
        int y = abandonCycles(cc.getY()).getValue();
        int width = abandonCycles(cc.getWidth()).getValue();
        int height = abandonCycles(cc.getHeight()).getValue();
        c.setBounds(insets.left + x, insets.top + y, width, height);
    }
}
 
源代码17 项目: jdk8u-jdk   文件: CompactLayout.java
public Dimension getSize(Container parent, boolean minimum) {
    int n = parent.getComponentCount();
    Insets insets = parent.getInsets();
    Dimension d = new Dimension();
    for (int i = 0; i < n; i++) {
        Component comp = parent.getComponent(i);
        if (comp instanceof EnableButton) {
            continue;
        }
        Dimension p = (minimum
                       ? comp.getMinimumSize()
                       : comp.getPreferredSize());
        if (horizontal) {
            d.width += p.width;
            if (d.height < p.height) {
                d.height = p.height;
            }
        } else {
            if (d.width < p.width) {
                d.width = p.width;
            }
            d.height += p.height;
        }
    }
    d.width += (insets.left + insets.right);
    d.height += (insets.top + insets.bottom);
    return d;
}
 
源代码18 项目: TencentKona-8   文件: MetalworksDocumentFrame.java
public void layoutContainer(Container c) {
    Insets insets = c.getInsets();

    int labelWidth = 0;
    for (Component comp : labels) {
        labelWidth = Math.max(labelWidth, comp.getPreferredSize().width);
    }

    int yPos = insets.top;

    Iterator<Component> fieldIter = fields.listIterator();
    Iterator<Component> labelIter = labels.listIterator();
    while (labelIter.hasNext() && fieldIter.hasNext()) {
        JComponent label = (JComponent) labelIter.next();
        JComponent field = (JComponent) fieldIter.next();
        int height = Math.max(label.getPreferredSize().height, field.
                getPreferredSize().height);
        label.setBounds(insets.left, yPos, labelWidth, height);
        field.setBounds(insets.left + labelWidth + xGap,
                yPos,
                c.getSize().width - (labelWidth + xGap + insets.left
                + insets.right),
                height);
        yPos += (height + yGap);
    }

}
 
源代码19 项目: pcgen   文件: FilterBar.java
@Override
public Dimension minimumLayoutSize(Container target)
{
	synchronized (target.getTreeLock())
	{
		Dimension dim = new Dimension(0, 0);
		int nmembers = target.getComponentCount();

		Insets insets = target.getInsets();
		int maxwidth = target.getWidth() - (insets.left + insets.right + getHgap() * 2);
		int width = 0;
		int height = 0;
		int component = 0;
		for (int i = 0; i < nmembers; i++, component++)
		{
			Component m = target.getComponent(i);
			if (m.isVisible())
			{
				Dimension d = m.getMinimumSize();
				if (component > 0)
				{
					if (width + d.width > maxwidth)
					{
						dim.width = Math.max(dim.width, width);
						dim.height += height + getVgap();
						width = 0;
						height = 0;
						component = 0;
					}
					width += getHgap();
				}
				height = Math.max(height, d.height);
				width += d.width;
			}
		}
		dim.width = Math.max(dim.width, width);
		dim.height += height;

		dim.width += insets.left + insets.right + getHgap() * 2;
		dim.height += insets.top + insets.bottom + getVgap() * 2;
		return dim;
	}
}
 
源代码20 项目: ramus   文件: ToolBarLayout.java
/**
 * Sets the sizes and locations of the specified container's subcomponents
 * (docked toolbars and content).
 */
public void layoutContainer(final Container target) {
    ourTargetContainer = target;

    synchronized (target.getTreeLock()) {
        int width = target.getWidth();
        int height = target.getHeight();

        final Insets insets = target.getInsets();
        int top = insets.top;
        final int bottom = height - insets.bottom;
        int left = insets.left;
        final int right = width - insets.right;

        ourNorthBoundary.setPosition(left, top, width);
        ourSouthBoundary.setPosition(left, bottom, width);

        int northHeight = ourNorthBoundary.getDepth();
        int southHeight = ourSouthBoundary.getDepth();
        if (northHeight > 0)
            northHeight += ourVerticalSpacing;
        if (southHeight > 0)
            southHeight += ourVerticalSpacing;
        height = bottom - top - northHeight - southHeight;
        top += northHeight;

        ourWestBoundary.setPosition(left, top, height);
        ourEastBoundary.setPosition(right, top, height);

        int eastWidth = ourEastBoundary.getDepth();
        int westWidth = ourWestBoundary.getDepth();
        if (eastWidth > 0)
            eastWidth += ourHorizontalSpacing;
        if (westWidth > 0)
            westWidth += ourHorizontalSpacing;
        width = right - left - eastWidth - westWidth;
        left += westWidth;

        if (ourContent != null) {
            ourContent.setBounds(left, top, width, height);
        }
    }
}