VJFlowLayout.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* @(#)FlowLayout.java 1.18 95/12/14 Arthur van Hoff
*
* Copyright (c) 1994, 2001 by Sun Microsystems, Inc.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL purposes and without
* fee is hereby granted provided that this copyright notice
* appears in all copies. Please refer to the file "copyright.html"
* for further important copyright and licensing information.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*/
/**
* Flow layout is used to layout buttons in a panel. It will arrange
* buttons left to right until no more buttons fit on the same line.
* Each line is centered.
*
* @version 1.18, 14 Dec 1995
* @author Arthur van Hoff
* @author Sami Shaio
*/
public class VJFlowLayout implements LayoutManager {
/**
* The left alignment variable.
*/
public static final int LEFT = 0;
/**
* The right alignment variable.
*/
public static final int CENTER = 1;
/**
* The right alignment variable.
*/
public static final int RIGHT = 2;
// Private variables
private static final int PREFERREDSIZE = 0;
private static final int MINIMUMSIZE = 1;
private int align;
private int hgap;
private int vgap;
private int minimumWidth;
/**
* Constructs a new Flow Layout with a centered alignment.
*/
public VJFlowLayout() {
this.hgap = 5;
this.vgap = 5;
this.minimumWidth = 0;
}
public void setAlignment(int align) {
}
public int getAlignment() {
return align;
}
}
public int getHGap() {
return hgap;
}
}
public int getVGap() {
return vgap;
}
public void setMinimumWidth(int width) {
this.minimumWidth = width;
}
public int getMinimumWidth() {
return minimumWidth;
}
/**
* Adds the specified component to the layout.
* Not used by this class.
* @param name the name of the component
* @param comp the the component to be added
*/
}
/**
* Removes the specified component from the layout. Not used by
* this class.
* @param comp the component to remove
*/
}
/**
* Returns the preferred dimensions for
* this layout given the components
* in the specified target container.
* @param target the component which needs to be laid out
* @see Container
* @see #minimumLayoutSize
*/
}
/**
* Returns the minimum dimensions needed to layout the components
* contained in the specified target container.
* @param target the component which needs to be laid out
* @see #preferredLayoutSize
*/
}
int rowCount = 0;
int rowHeight = 0;
for (int i = 0; i < nmembers; i++) {
if (m.isVisible()) {
Dimension d;
if (which == PREFERREDSIZE)
d = m.preferredSize();
else
d = m.minimumSize();
rowCount = 0;
rowHeight = 0;
}
rowCount++;
}
}
if (rowCount > 0) {
}
return r;
}
/**
* Centers the elements in the specified row, if there is any slack.
* @param target the component which needs to be moved
* @param x the x coordinate
* @param y the y coordinate
* @param width the width dimensions
* @param height the height dimensions
* @param rowStart the beginning of the row
* @param rowEnd the the ending of the row
*/
switch (align) {
case LEFT:
break;
case CENTER:
x += width / 2;
break;
case RIGHT:
x += width;
break;
}
if (m.isVisible()) {
}
}
}
/**
* Lays out the container. This method will actually reshape the
* components in the target in order to satisfy the constraints of
* the BorderLayout object.
* @param target the specified component being laid out.
* @see Container
*/
hgap*2);
for (int i = 0; i < nmembers; i++) {
if (m.isVisible()) {
Dimension d = m.preferredSize();
if (x > 0) {
x += hgap;
}
x += d.width;
} else {
x = d.width;
start = i;
}
}
}
}
/**
* Returns the String representation of this FlowLayout's values.
*/
switch (align) {
}
}
}