/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Extends the FlowLayout class to support both vertical and horizontal
* layout of components. Orientation can be changed dynamically after
* creation by calling either of the methods @method orientHorizontally or
* @method orientVertically. Separate values for alignment, vertical gap,
* and horizontal gap can be specified for horizontal and vertical
* orientation.
*
* @author Terry Cline
*/
/**
* The horizontal orientation constant.
*/
/**
* The vertical orientation constant.
*/
/**
* The top vertical alignment constant.
*/
/**
* The bottom vertical alignment constant.
*/
int orientation;
int vAlign;
int vHGap;
int vVGap;
/**
* Constructs a new flow layout with a horizontal orientation and
* centered alignment.
*/
public OrientableFlowLayout() {
}
/**
* Constructs a new flow layout with the specified orientation and
* a centered alignment.
*
* @param orientation the orientation, one of HORIZONTAL or VERTICAL.
*/
}
/**
* Constructs a new flow layout with the specified orientation and
* alignment.
*
* @param orientation the orientation, one of HORIZONTAL or VERTICAL.
* @param hAlign the horizontal alignment, one of LEFT, CENTER, or RIGHT.
* @param vAlign the vertical alignment, one of TOP, CENTER, or BOTTOM.
*/
}
/**
* Constructs a new flow layout with the specified orientation,
* alignment, and gap values.
*
* @param orientation the orientation, one of HORIZONTAL or VERTICAL.
* @param hAlign the horizontal alignment, one of LEFT, CENTER, or RIGHT.
* @param vAlign the vertical alignment, one of TOP, CENTER, or BOTTOM.
* @param hHGap the horizontal gap between components in HORIZONTAL.
* @param hVGap the vertical gap between components in HORIZONTAL.
* @param vHGap the horizontal gap between components in VERTICAL.
* @param vVGap the vertical gap between components in VERTICAL.
*/
public OrientableFlowLayout(int orientation, int hAlign, int vAlign, int hHGap, int hVGap, int vHGap, int vVGap) {
this.orientation = orientation;
}
/**
* Set the layout's current orientation to horizontal.
*/
public synchronized void orientHorizontally() {
}
/**
* Set the layout's current orientation to vertical.
*/
public synchronized void orientVertically() {
}
/**
* 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 FlowLayout
* @see #minimumLayoutSize
*/
if (orientation == HORIZONTAL) {
return super.preferredLayoutSize(target);
}
else {
int n = target.countComponents();
for (int i = 0; i < n; i++) {
if (c.isVisible()) {
if (i > 0) {
}
}
}
return dim;
}
}
/**
* 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.
*/
if (orientation == HORIZONTAL) {
return super.minimumLayoutSize(target);
}
else {
int n = target.countComponents();
for (int i = 0; i < n; i++) {
if (c.isVisible()) {
if (i > 0) {
}
}
}
return dim;
}
}
/**
* Lays out the container. This method will reshape the
* components in the target to satisfy the constraints of the
* layout.
*
* @param target the specified component being laid out.
* @see Container.
*/
if (orientation == HORIZONTAL) {
super.layoutContainer(target);
}
else {
int y = 0;
int colWidth = 0;
int start = 0;
int n = target.countComponents();
for (int i = 0; i < n; i++) {
if (c.isVisible()) {
if (y > 0) {
y += vVGap;
}
}
else {
x,
maxHeight - y,
i);
start = i;
}
}
}
x,
maxHeight - y,
n);
}
}
/**
* Aligns the components vertically if there is any slack.
*
* @param target the container whose components need to be moved.
* @param x the x coordinate.
* @param y the y coordinate.
* @param width the width available.
* @param height the height available.
* @param colStart the beginning of the column.
* @param colEnd the end of the column.
*/
private void moveComponents(Container target, int x, int y, int width, int height, int colStart, int colEnd) {
switch (vAlign) {
case TOP:
break;
case CENTER:
y += height/2;
break;
case BOTTOM:
y += height;
}
if (c.isVisible()) {
}
}
}
/**
* Returns the String representation of this layout's values.
*/
switch (orientation) {
case HORIZONTAL:
str = "orientation=horizontal, ";
break;
case VERTICAL:
str = "orientation=vertical, ";
break;
}
}
}