19 package org.sleuthkit.autopsy.uicomponents;
21 import java.awt.Component;
22 import java.awt.Container;
23 import java.awt.Dimension;
24 import java.awt.FlowLayout;
25 import java.awt.Insets;
26 import javax.swing.JScrollPane;
27 import javax.swing.SwingUtilities;
71 super(align, hgap, vgap);
100 minimum.width -= (getHgap() + 1);
113 private Dimension
layoutSize(Container target,
boolean preferred) {
114 synchronized (target.getTreeLock()) {
119 int targetWidth = target.getSize().width;
120 Container container = target;
122 while (container.getSize().width == 0 && container.getParent() != null) {
123 container = container.getParent();
126 targetWidth = container.getSize().width;
128 if (targetWidth == 0) {
129 targetWidth = Integer.MAX_VALUE;
132 int hgap = getHgap();
133 int vgap = getVgap();
134 Insets insets = target.getInsets();
135 int horizontalInsetsAndGap = insets.left + insets.right + (hgap * 2);
136 int maxWidth = targetWidth - horizontalInsetsAndGap;
139 Dimension dim =
new Dimension(0, 0);
143 int nmembers = target.getComponentCount();
145 for (
int i = 0; i < nmembers; i++) {
146 Component m = target.getComponent(i);
149 Dimension d = preferred ? m.getPreferredSize() : m.getMinimumSize();
152 if (rowWidth + d.width > maxWidth) {
153 addRow(dim, rowWidth, rowHeight);
164 rowHeight = Math.max(rowHeight, d.height);
168 addRow(dim, rowWidth, rowHeight);
170 dim.width += horizontalInsetsAndGap;
171 dim.height += insets.top + insets.bottom + vgap * 2;
177 Container scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane.class, target);
179 if (scrollPane != null && target.isValid()) {
180 dim.width -= (hgap + 1);
195 private void addRow(Dimension dim,
int rowWidth,
int rowHeight) {
196 dim.width = Math.max(dim.width, rowWidth);
198 if (dim.height > 0) {
199 dim.height += getVgap();
202 dim.height += rowHeight;
void addRow(Dimension dim, int rowWidth, int rowHeight)
static final long serialVersionUID
WrapLayout(int align, int hgap, int vgap)
Dimension preferredLayoutSize(Container target)
Dimension layoutSize(Container target, boolean preferred)
Dimension minimumLayoutSize(Container target)