@Override public Dimension minimumLayoutSize(Container parent) { synchronized (parent.getTreeLock()) { return calculateSize(parent, Component::getMinimumSize); } }
@Override public Dimension preferredLayoutSize(Container parent) { synchronized (parent.getTreeLock()) { return calculateSize(parent, Component::getPreferredSize); } }
@Override public void layoutContainer(Container parent) { update(); synchronized (parent.getTreeLock()) { for (ComponentSpan span : spanMap.values()) { int x1 = span.topLeftCell.column.boundX; int collisionIndexStart = (span.collisionIndex == FILL_COLLISIONS_FLAG) ? 0 : span.collisionIndex; int y1 = span.topLeftCell.row.boundY + (collisionIndexStart * span.topLeftCell.row.baseHeight); int x2 = span.bottomRightCell.column.boundX + span.bottomRightCell.column.baseWidth; int collisionIndexEnd = (span.collisionIndex == FILL_COLLISIONS_FLAG) ? span.bottomRightCell.row.collisionCount : span.collisionIndex + 1; int y2 = span.bottomRightCell.row.boundY + (collisionIndexEnd * span.bottomRightCell.row.baseHeight); span.component.setBounds(x1, y1, x2 - x1, y2 - y1); } } }
@Override public void layoutContainer(Container parent) synchronized (parent.getTreeLock())
private int getMaximumWidth(Container target) { int maxWidth = 0; synchronized (target.getTreeLock()) { int nmembers = target.getComponentCount(); for (int i = 0; i < nmembers; i++) { Component m = target.getComponent(i); if (m.isVisible()) { Dimension d = m.getPreferredSize(); maxWidth = Math.max(d.width, maxWidth); } } } return maxWidth; }
@Override public Dimension preferredLayoutSize(Container target) { synchronized (target.getTreeLock()) { Dimension dim = new Dimension(0, 0); int count = target.getComponentCount(); for (int i = 0; i < count; i++) { Component m = target.getComponent(i); Dimension d = m.getPreferredSize(); dim.width = Math.max(dim.width, d.width); dim.height += d.height + padding; } Insets insets = target.getInsets(); dim.width += insets.left + insets.right + padding * 2; dim.height += insets.top + insets.bottom + padding * 2; return dim; } }
/** * Determines the minimum size of the container argument using this column layout. <p> The minimum width of a grid * layout is the largest minimum width of each column in the container, plus the horizontal padding times the number * of columns minus one, plus the left and right insets of the target container. <p> The minimum height of a column * layout is the largest minimum height of each row in the container, plus the vertical padding times the number of * rows minus one, plus the top and bottom insets of the target container. * * @param parent the container in which to do the layout * @return the minimum dimensions needed to lay out the subcomponents of the specified container * @see java.awt.RelativeLayout#preferredLayoutSize * @see java.awt.Container#doLayout */ @Override public Dimension minimumLayoutSize(Container parent) { synchronized (parent.getTreeLock()) { return getLayoutSize(parent, MINIMUM); } }
/** * Determines the preferred size of the container argument using this column layout. <p> The preferred width of a * column layout is the largest preferred width of each column in the container, plus the horizontal padding times * the number of columns minus one, plus the left and right insets of the target container. <p> The preferred height * of a column layout is the largest preferred height of each row in the container, plus the vertical padding times * the number of rows minus one, plus the top and bottom insets of the target container. * * @param parent the container in which to do the layout * @return the preferred dimensions to lay out the subcomponents of the specified container * @see java.awt.RelativeLayout#minimumLayoutSize * @see java.awt.Container#getPreferredSize() */ @Override public Dimension preferredLayoutSize(Container parent) { synchronized (parent.getTreeLock()) { return getLayoutSize(parent, PREFERRED); } }
/** * Lays out the specified container using this layout. <p> This method reshapes the components in the specified * target container in order to satisfy the constraints of the * <code>RelativeLayout</code> object. <p> The grid layout manager determines the size of individual components by * dividing the free space in the container into equal-sized portions according to the number of rows and columns in * the layout. The container's free space equals the container's size minus any insets and any specified horizontal * or vertical gap. All components in a grid layout are given the same size. * * @param parent the container in which to do the layout * @see java.awt.Container * @see java.awt.Container#doLayout */ @Override public void layoutContainer(Container parent) { synchronized (parent.getTreeLock()) { if (axis == X_AXIS) { layoutContainerHorizontally(parent); } else { layoutContainerVertically(parent); } } }
synchronized (target.getTreeLock()) { switch (getAlignment()) { case LEFT:
synchronized (target.getTreeLock()) { Dimension dim = new Dimension(0, 0); int nmembers = target.getComponentCount();
int maxWidth = getMaximumWidth(target); synchronized (target.getTreeLock()) { Dimension dim = new Dimension(0, 0); int nmembers = target.getComponentCount();
int maxWidth = getMaximumWidth(target); synchronized (target.getTreeLock()) { Insets insets = target.getInsets(); int maxwidth = target.getSize().width - (insets.left + insets.right + (getHgap() * 2));
private static void fixComponentZOrder(Component component, int index) { if (component != null) { Container parent = component.getParent(); synchronized (parent.getTreeLock()) { if (index < 0) index += parent.getComponentCount(); parent.setComponentZOrder(component, index); } } }
@Override public Dimension minimumLayoutSize(Container parent) { synchronized(parent.getTreeLock()) { return getSizeImpl(parent, LayoutUtil.MIN); } }
@Override public void addLayoutComponent(Component comp, Object constraints) { synchronized(comp.getParent().getTreeLock()) { setComponentConstraintsImpl(comp, constraints, true); } }
/** * Method minimumLayoutSize * * @param parent * @return the minimum dimension of the layout */ @Override public Dimension minimumLayoutSize(Container parent) { synchronized (parent.getTreeLock()) { return getMinWidthHeight(parent); } }
@Override public void removeLayoutComponent(Component comp) { synchronized(comp.getParent().getTreeLock()) { scrConstrMap.remove(comp); ccMap.remove(new SwingComponentWrapper(comp)); grid = null; // To clear references } }
/** Creates lock object used in close and openCloneableTopComponent. */ private Object getLock() { if (container == null) { container = new java.awt.Container(); } return container.getTreeLock(); }
/** * Вычисление предпочитаемого размера. * * @param aTarget * @return */ private Dimension calcPreferredSize(Container aTarget) { synchronized (aTarget.getTreeLock()) { return aTarget.getSize(); } }