mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Checkstyle.
This commit is contained in:
@@ -12,16 +12,13 @@ import javax.swing.SwingUtilities;
|
||||
/**
|
||||
* FlowLayout subclass that fully supports wrapping of components.
|
||||
*/
|
||||
public class WrapLayout extends FlowLayout
|
||||
{
|
||||
private Dimension preferredLayoutSize;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class WrapLayout extends FlowLayout {
|
||||
/**
|
||||
* Constructs a new <code>WrapLayout</code> with a left
|
||||
* alignment and a default 5-unit horizontal and vertical gap.
|
||||
*/
|
||||
public WrapLayout()
|
||||
{
|
||||
public WrapLayout() {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -33,8 +30,7 @@ public class WrapLayout extends FlowLayout
|
||||
* or <code>WrapLayout</code>.
|
||||
* @param align the alignment value
|
||||
*/
|
||||
public WrapLayout(int align)
|
||||
{
|
||||
public WrapLayout(int align) {
|
||||
super(align);
|
||||
}
|
||||
|
||||
@@ -49,8 +45,7 @@ public class WrapLayout extends FlowLayout
|
||||
* @param hgap the horizontal gap between components
|
||||
* @param vgap the vertical gap between components
|
||||
*/
|
||||
public WrapLayout(int align, int hgap, int vgap)
|
||||
{
|
||||
public WrapLayout(int align, int hgap, int vgap) {
|
||||
super(align, hgap, vgap);
|
||||
}
|
||||
|
||||
@@ -62,8 +57,7 @@ public class WrapLayout extends FlowLayout
|
||||
* subcomponents of the specified container
|
||||
*/
|
||||
@Override
|
||||
public Dimension preferredLayoutSize(Container target)
|
||||
{
|
||||
public Dimension preferredLayoutSize(Container target) {
|
||||
return layoutSize(target, true);
|
||||
}
|
||||
|
||||
@@ -75,8 +69,7 @@ public class WrapLayout extends FlowLayout
|
||||
* subcomponents of the specified container
|
||||
*/
|
||||
@Override
|
||||
public Dimension minimumLayoutSize(Container target)
|
||||
{
|
||||
public Dimension minimumLayoutSize(Container target) {
|
||||
Dimension minimum = layoutSize(target, false);
|
||||
minimum.width -= (getHgap() + 1);
|
||||
return minimum;
|
||||
@@ -90,18 +83,17 @@ public class WrapLayout extends FlowLayout
|
||||
* @param preferred should preferred size be calculated
|
||||
* @return the dimension to layout the target container
|
||||
*/
|
||||
private Dimension layoutSize(Container target, boolean preferred)
|
||||
{
|
||||
synchronized (target.getTreeLock())
|
||||
{
|
||||
private Dimension layoutSize(Container target, boolean preferred) {
|
||||
synchronized (target.getTreeLock()) {
|
||||
// Each row must fit with the width allocated to the containter.
|
||||
// When the container width = 0, the preferred width of the container
|
||||
// has not yet been calculated so lets ask for the maximum.
|
||||
|
||||
int targetWidth = target.getSize().width;
|
||||
|
||||
if (targetWidth == 0)
|
||||
if (targetWidth == 0) {
|
||||
targetWidth = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
int hgap = getHgap();
|
||||
int vgap = getVgap();
|
||||
@@ -117,27 +109,21 @@ public class WrapLayout extends FlowLayout
|
||||
|
||||
int nmembers = target.getComponentCount();
|
||||
|
||||
for (int i = 0; i < nmembers; i++)
|
||||
{
|
||||
for (int i = 0; i < nmembers; i++) {
|
||||
Component m = target.getComponent(i);
|
||||
|
||||
if (m.isVisible())
|
||||
{
|
||||
if (m.isVisible()) {
|
||||
Dimension d = preferred ? m.getPreferredSize() : m.getMinimumSize();
|
||||
|
||||
// Can't add the component to current row. Start a new row.
|
||||
|
||||
if (rowWidth + d.width > maxWidth)
|
||||
{
|
||||
if (rowWidth + d.width > maxWidth) {
|
||||
addRow(dim, rowWidth, rowHeight);
|
||||
rowWidth = 0;
|
||||
rowHeight = 0;
|
||||
}
|
||||
|
||||
// Add a horizontal gap for all components after the first
|
||||
|
||||
if (rowWidth != 0)
|
||||
{
|
||||
if (rowWidth != 0) {
|
||||
rowWidth += hgap;
|
||||
}
|
||||
|
||||
@@ -158,8 +144,7 @@ public class WrapLayout extends FlowLayout
|
||||
|
||||
Container scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane.class, target);
|
||||
|
||||
if (scrollPane != null)
|
||||
{
|
||||
if (scrollPane != null) {
|
||||
dim.width -= (hgap + 1);
|
||||
}
|
||||
|
||||
@@ -175,12 +160,10 @@ public class WrapLayout extends FlowLayout
|
||||
* @param rowWidth the width of the row to add
|
||||
* @param rowHeight the height of the row to add
|
||||
*/
|
||||
private void addRow(Dimension dim, int rowWidth, int rowHeight)
|
||||
{
|
||||
private void addRow(Dimension dim, int rowWidth, int rowHeight) {
|
||||
dim.width = Math.max(dim.width, rowWidth);
|
||||
|
||||
if (dim.height > 0)
|
||||
{
|
||||
if (dim.height > 0) {
|
||||
dim.height += getVgap();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user