Module Design - Line Segment Object

 

This object was designed by Tom Walcott.
It was last updated April 29th, 1998.

 

Private Data:
boolean setAxis: A line is either horizontal or vertical. We don't save space by using this particular method, but we do manage to decrease search times.
int start, end: Store the start and end co-ordinates for a given line. These will be pixel locations. The axis this is relevant to will change, depending on whether the line is horizontal or vertical, in accordance to the data in Axis.
int lineCount: The number of times that this particular line segment exists; because a line can be drawn multiple times (i.e., merged lines), we need to have a means to keep track of when a given line should be deleted.
int fixedAxis: Because we have the axis set with a boolean type, and have the start and finish points of the line, we only need to determine a single unspecified co-ordinate; the horizontal location, for a vertical line, or the height, for a horizontal line. That pixel offset is stored here.
int lineType: If the object is such that it could possibly have merged line segments, this variable indicates whether a given line segment has merged. It is not a boolean, because possibilities are next, prev, or merged.
int numLeft: The number of prevs in this line segment, to help determine whether the line segment has merged -- or if the deletion of an old link has made this line segment now non-merged.

Methods
:
Overview: The constructor for this object is the only way to set most data values. Should any particular item need to be changed, the appropriate thing to do is scrap the given line object and construct a new one. The only exception is when another occurance of the line is drawn, and we just add a little something to LineCount. The purpose of this object is to describe a single line segment. These segments will then be grouped together to describe a link between two nodes.
public Constructor;
Overview: Create a new line object.
Parameters: Several; int start, end; boolean setAxis; int fixedAxis.
Pre-conditions: None.
Post-conditions: None.
Algorithm: Don't be silly.
Interaction with other objects: The Master Line Object will call this method to create a new line object. All values set by the constructor are unalterable, save by the destruction of the line object.
Error conditions: None.
Return value: Void.
public int GetStart();
Overview: Return the start co-ordinate of the line.
Parameters: None.
Pre-conditions: None.
Post-conditions: None.
Algorithm: Don't be silly.
Interaction with other objects: The Master Line Object will call this method to help determine collisions.
Error conditions: None.
Return value: The value associated with Start.
public int GetEnd();
Overview: Return the end co-ordinate of the line.
Parameters: None.
Pre-conditions: None.
Post-conditions: None.
Algorithm: Don't be silly.
Interaction with other objects: The Master Line Object will call this method to help determine collisions.
Error conditions: None.
Return value: The value associated with End.
public boolean GetAxis();
Overview: Return the fixed axis of the line's orientation.
Parameters: None.
Pre-conditions: None.
Post-conditions: None.
Algorithm: Don't be silly.
Interaction with other objects: The Master Line Object will call this method to help determine collisions, and this method will determine which array of the Master Line Object will reference this line.
Error conditions: None.
Return value: The boolean value 0 for a horizontal line, and 1 for a vertical line.
public int GetFixedAxis();
Overview: Return the fixed axis co-ordinate of the line.
Parameters: None.
Pre-conditions: None.
Post-conditions: None.
Algorithm: Don't be silly.
Interaction with other objects: None.
Error conditions: None.
Return value: The value associated with FixedAxis.
public int GetLineCount();
Overview: Return the number of links that the line is associated with.
Parameters: None.
Pre-conditions: None.
Post-conditions: None.
Algorithm: Don't be silly.
Interaction with other objects: The Master Line Object will call this method to help determine when a line is to be deleted.
Error conditions: None.
Return value: The value associated with LineCount.
public void SetLineCount(boolean, boolean);
Overview: Increment or decrement the number of links that this line segment is a part of.
Parameters: A boolean, indicating 1 for LineCount++, 0 for LineCount--, and a second boolean to indicate whether the line segment is representing a next or prev line segment.
Pre-conditions: None.
Post-conditions: None.
Algorithm: Don't be silly.
Interaction with other objects: The Master Line Object will call this method when a line object is being added to a new link, or when a line is deleted.
Error conditions: None.
Return value: Returns void.
public void CheckMerge(int LineType);
Overview: Determine if this line segment is now a part of two different types of links, in which case the color must be updated.
Parameters: An integer representing line type.
Pre-conditions: None.
Post-conditions: None.
Algorithm: Compare the value passed in to that of the current LineType. If the line is being used for both a right and a left, then make the value reflect a merged line..
Interaction with other objects: The Master Line Object will call this method to help lines determine what color they should draw themselves.
Error conditions: If the input is not of type right (next) or left (prev) then we have a significant problem.
Return value: Void.
public  void Paint();
Overview: Paint the line object.
Parameters: None.
Pre-conditions: None.
Post-conditions: The line segment should be displayed on the screen, or, in the case of off screen drawing, should be displayed off screen and eventually put onto the screen.
Algorithm: Paint a line. If SetAxis is X, use X, start to X, end. Otherwise, SetAxis is Y, and use start, Y to end, Y.
Interaction with other objects: No.
Error conditions: None.
Return value: None.

Search engine sitemap created by AutoSitemap.com