puzzled.grid
Class Relation

java.lang.Object
  |
  +--puzzled.grid.Relation
All Implemented Interfaces:
java.io.Serializable

public class Relation
extends java.lang.Object
implements java.io.Serializable

This class simply acts as a data structure to regroup the essential elements of a relationship. They include a value, two X-coordinate components, and two Y-coordinate components. All its members are public, therefore modifiable by any class, similar to a class like Point, where point.x and point.y would be available, or Dimension, where dimension.width and dimension.height would also be available. It is here made serializable such that it is possible in the future to save information of this class on a disk.

Version:
1.0 1 Sep 99
Author:
Frédéric Demers
See Also:
Serialized Form

Field Summary
 int cat1
          First category index of the relationship (the smaller of the two.)
 int cat2
          Second category index of the relationship (the larger of the two, cannot be the same as cat1.)
 int item1
          item index associated with the first category.
 int item2
          item index associated with the second category.
 int value
          value associated with the relationship, such as in the Constants interface.
 
Constructor Summary
Relation(int value_arg, int XCat, int XItem, int YCat, int YItem)
          Constructor, takes in the parameter required for a relationship, but the coordinate components can be in any order, since a sorting operation is completed before the affectation.
 
Method Summary
 void sortCoordinates(int XCat_arg, int XItem_arg, int YCat_arg, int YItem_arg)
          Sorting operation called when constructing the relationship.
 java.lang.String toString()
          Method used when displaying a relationship at the screen, in the text format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cat1

public int cat1
First category index of the relationship (the smaller of the two.)

cat2

public int cat2
Second category index of the relationship (the larger of the two, cannot be the same as cat1.)

item1

public int item1
item index associated with the first category.

item2

public int item2
item index associated with the second category.

value

public int value
value associated with the relationship, such as in the Constants interface.
Constructor Detail

Relation

public Relation(int value_arg,
                int XCat,
                int XItem,
                int YCat,
                int YItem)
Constructor, takes in the parameter required for a relationship, but the coordinate components can be in any order, since a sorting operation is completed before the affectation.
Parameters:
value_arg - the value given to this relation
XCat - one of the category index of the relation
XItem - one of the item index of the relation
YCat - the other category index of the relation
YItem - the other item index of the relation
Method Detail

sortCoordinates

public void sortCoordinates(int XCat_arg,
                            int XItem_arg,
                            int YCat_arg,
                            int YItem_arg)
Sorting operation called when constructing the relationship. It ensures the smallest category index is first, this in order to use only the top right triangle of the Grid's square matrix
Parameters:
XCat_arg - first category index
XItem_arg - first item index
YCat_arg - second category index
YItem_arg - second item index

toString

public java.lang.String toString()
Method used when displaying a relationship at the screen, in the text format. It is automatically implied when using a relationship in a println statement.
Overrides:
toString in class java.lang.Object
Returns:
a string representing the relationship