home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / Source.bin / VerticalLine.java < prev    next >
Text File  |  1998-03-18  |  2KB  |  71 lines

  1. package symantec.itools.awt.shape;
  2.  
  3. import java.beans.PropertyVetoException;
  4. import java.awt.Rectangle;
  5.  
  6. //  07/30/97    LAB    Updated version to 1.1.  Line can now be 1 pixel thick if it is
  7. //                    in BEVEL_LINE or BEVEL_NONE mode.
  8. //  08/13/97    LAB    Overrode setBevelStyle to reshape the component to have a thickness
  9. //                    of two pixels if the bevel style was rasied or lowered.  Addresses Mac
  10. //                    Bug #3571
  11.  
  12. /**
  13.  * This is a vertical line component.
  14.  * @version 1.1, July 30, 1997
  15.  * @author Symantec
  16.  */
  17. public class VerticalLine extends Rect
  18. {
  19.     /**
  20.      * Constructs a default VerticalLine.  The line width is 2.
  21.      */
  22.     public VerticalLine()
  23.     {
  24.         width = 2;
  25.     }
  26.  
  27.     /**
  28.      * Sets the border style of the shape.
  29.      * @see symantec.itools.awt.shape.Shape#getBevelStyle
  30.      *
  31.      * @exception PropertyVetoException
  32.      * if the specified property value is unacceptable
  33.      */
  34.     public void setBevelStyle(int s) throws PropertyVetoException
  35.     {
  36.         if(style != s)
  37.         {
  38.             super.setBevelStyle(s);
  39.             Rectangle r = getBounds();
  40.  
  41.             reshape(r.x, r.y, r.width == 1 ? 1 : 2, r.height);
  42.             validate();
  43.         }
  44.     }
  45.  
  46.     /**
  47.      * Moves and/or resizes this component.
  48.      * This is a standard Java AWT method which gets called to move and/or
  49.      * resize this component. Components that are in containers with layout
  50.      * managers should not call this method, but rely on the layout manager
  51.      * instead.
  52.      *
  53.      * @param x horizontal position in the parent's coordinate space
  54.      * @param y vertical position in the parent's coordinate space
  55.      * @param width the new width
  56.      * @param height the new height
  57.      */
  58.     public void reshape(int x, int y, int width, int height)
  59.     {
  60.         this.height = height;
  61.  
  62.         //Allow a 1 pixel width if the bevel style is line or none.
  63.         if (width == 1 && (style == BEVEL_LINE || style == BEVEL_NONE))
  64.             this.width = 1;
  65.         else
  66.             this.width = 2;
  67.  
  68.         super.reshape(x, y, this.width, height);
  69.     }
  70. }
  71.