Line Class Diagram

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Ancestor class specifications:

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent


Line Class Specification

            Invariant

                        A Line object...

-       is drawn as a line segment.

-       should be added to a container object with one end located x1 pixels from the left and y1 pixels from the top and the opposite end located x2 pixels from the left and y2 pixels from the top. (The upper left corner of the container is (0, 0).)

-       when it is contained within a proper GUI container the line segment appears  in color color.

-       if necessary, the line image is clipped to the boundaries of its GUI container.

 

Below is a black Line added to My Window.

Constructor Methods

public Line( int initX1,  int initY1,  int initX2,  int initY2 )

post: A new Line object is created

         and   color == Color.black

         and   x1  == initX1   and   y1 == initY1

         and   x2  == initX2   and   y2 == initY2

         (Note that Lines don't appear until added.)

            Update Methods

public void setBackground( java.awt.Color c )

post:  color == c

 

public void repaint( )

post:  Causes the Java virtual machine to update the display of this object as soon as possible.

 

            Query Methods

public java.awt.Color  getBackground( )

post:  color == c

 

public java.awt.Container getParent( )

post: this Line is added to a Container

                  implies result == the Container to which this is added

         and  this Line is not added implies result == null