GBConstraints.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"
*
* @(#)GBConstraints.java 1.12 97/09/03 Doug Stein
*
* Copyright (c) 1996, 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.
*/
/**
* GBConstraints is used to specify constraints for components
* laid out using the GBLayout class.
*
* @see java.awt.GBLayout
* @version 1.12, 06/17/97
* @author Doug Stein
*/
public class GBConstraints implements Cloneable {
public static final int RELATIVE = -1;
public static final int REMAINDER = 0;
public static final int NONE = 0;
public static final int BOTH = 1;
public static final int HORIZONTAL = 2;
public static final int VERTICAL = 3;
public static final int CENTER = 10;
public static final int NORTH = 11;
public static final int NORTHEAST = 12;
public static final int EAST = 13;
public static final int SOUTHEAST = 14;
public static final int SOUTH = 15;
public static final int SOUTHWEST = 16;
public static final int WEST = 17;
public static final int NORTHWEST = 18;
// Regular insets and pads will shrink when space gets tight
// Hard insets and pads never shrink
public Insets hardinsets;
// Normally a component will not shrink below it minimum size. Setting
// shrinkx or shrinky to true indicates that the component may shrink
// below its minimum size.
public boolean shrinkx;
public boolean shrinky;
// The following variables are filled in during layout and
// can be accessed, but should not be modified:
int tempWidth, tempHeight;
int tinyWidth, tinyHeight;
/**
* Creates a set of gridbag constraints.
*/
public GBConstraints() {
gridwidth = 1;
gridheight = 1;
weightx = 0;
weighty = 0;
ipadx = 0;
ipady = 0;
hardipadx = 0;
hardipady = 0;
}
/**
* Creates a set of gridbag constraints by parsing the given
* constraints option string. Each option has the form key=value.
* Options are separated by semicolons (;).
*/
this();
}
try {
c = (GBConstraints)super.clone();
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
if (c.hardinsets != null)
return c;
}
try {
while (st.hasMoreTokens()) {
continue;
/* NOI18N */"=", true);
op));
weightx = x.doubleValue();
weighty = x.doubleValue();
getValueToken(op));
shrinkx = x.booleanValue();
shrinky = x.booleanValue();
}
getValueToken(op));
getValueToken(op));
getValueToken(op));
getValueToken(op));
getValueToken(op));
getValueToken(op));
else
throw new NoSuchElementException();
}
}
catch (Exception e) {
/* JSTYLED */
throw new Error(Global.getMsg("sunsoft.jws.visual.rt.awt.GBConstraints.-ba-r-ba-n-ba-tSyntax__error__i.3") +
+ option_string);
}
}
throws NoSuchElementException
{
if (op.hasMoreTokens()) {
if (op.hasMoreTokens())
}
throw new NoSuchElementException();
}
return GBConstraints.RELATIVE;
return GBConstraints.REMAINDER;
return GBConstraints.NONE;
return GBConstraints.BOTH;
return GBConstraints.HORIZONTAL;
return GBConstraints.VERTICAL;
return GBConstraints.CENTER;
return GBConstraints.NORTH;
return GBConstraints.NORTHEAST;
return GBConstraints.EAST;
return GBConstraints.SOUTHEAST;
return GBConstraints.SOUTH;
return GBConstraints.SOUTHWEST;
return GBConstraints.WEST;
return GBConstraints.NORTHWEST;
}
}