home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Main.bin
/
HorizontalLine.java
< prev
next >
Wrap
Text File
|
1998-10-02
|
3KB
|
97 lines
package symantec.itools.awt.shape;
import java.beans.PropertyVetoException;
import java.awt.Dimension;
import java.awt.Rectangle;
// 07/30/97 LAB Updated version to 1.1. Line can now be 1 pixel thick if it is
// in BEVEL_LINE or BEVEL_NONE mode.
// 08/13/97 LAB Overrode setBevelStyle to reshape the component to have a thickness
// of two pixels if the bevel style was rasied or lowered. Addresses Mac
// Bug #3571
// 10/01/98 EB Overrode getMinimumSize and getPreferredSize
/**
* This is a horizontal line component.
* @version 1.2, October 1, 1998
* @author Symantec
*/
public class HorizontalLine extends Rect
{
/**
* Constructs a default HorizontalLine. The line height is 2.
*/
public HorizontalLine()
{
height = 2;
}
/**
* Sets the border style of the shape.
* @see symantec.itools.awt.shape.Shape#getBevelStyle
*
* @exception PropertyVetoException
* if the specified property value is unacceptable
*/
public void setBevelStyle(int s) throws PropertyVetoException
{
if(style != s)
{
super.setBevelStyle(s);
Rectangle r = getBounds();
reshape(r.x, r.y, r.width, r.height == 1 ? 1 : 2);
validate();
}
}
/**
* Moves and/or resizes this component.
* This is a standard Java AWT method which gets called to move and/or
* resize this component. Components that are in containers with layout
* managers should not call this method, but rely on the layout manager
* instead.
*
* @param x horizontal position in the parent's coordinate space
* @param y vertical position in the parent's coordinate space
* @param width the new width
* @param height the new height
*/
public void reshape(int x, int y, int width, int height)
{
this.width = width;
//Allow a 1 pixel height if the bevel style is line or none.
if (height == 1 && (style == BEVEL_LINE || style == BEVEL_NONE))
this.height = 1;
else
this.height = 2;
super.reshape(x, y, width, this.height);
}
/**
* Returns the minimum dimensions to properly display this component.
* This is a standard Java AWT method which gets called to determine
* the minimum size of this component.
* @see #getPreferredSize
*/
public Dimension getMinimumSize()
{
return new Dimension(2, 1);
}
/**
* Returns the recommended dimensions to properly display this component.
* This is a standard Java AWT method which gets called to determine
* the recommended size of this component.
*
* @see java.awt.Component#minimumSize
*/
public Dimension getPreferredSize()
{
Dimension dim = getSize();
Dimension min = getMinimumSize();
return new Dimension(Math.max(dim.width, min.width), Math.max(dim.height, min.height));
}
}