|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--puzzled.grid.Grid
The grid class represent the data structure of the problem to be solved. It is not a drawable component itself, but owns a reference to a GridCanvas object, which is the graphical representation of the relationships between the various items. This class also contains an array of category names, as well as a two-dimensional array containing each of the item names.
Field Summary | |
AnswerCanvas |
answerCanvas
|
GridCanvas |
gridCanvas
A canvas to draw the relationship beween the items. |
Fields inherited from interface puzzled.Constants |
ACTION_TOKEN, AND_TOKEN, AND_TOKENS, IS_ACTION, IS_TOKEN, IS_TOKENS, ISNOT_ACTION, JUNCTION_TOKEN, LESS_ACTION, LESS_TOKEN, LESS_TOKENS, MORE_ACTION, MORE_TOKEN, MORE_TOKENS, NEXT_ACTION, NEXT_TOKEN, NEXT_TOKENS, NO_ACTION, NOR_TOKEN, NOT_TOKEN, NOT_TOKENS, NOT_VALID, NOTNEXT_ACTION, NOTNEXT_TOKEN, NUMBER_TOKEN, NUMBER_TOKENS, OR_ACTION, OR_TOKEN, OR_TOKENS, PREVIOUS_CLUE_TOKEN, RESET_TOKEN, THAN_TOKEN, TO_TOKEN, VALUE_NO, VALUE_UNKNOWN, VALUE_YES |
Constructor Summary | |
Grid(ProblemSolver parent_arg)
Constructor |
|
Grid(ProblemSolver parent_arg,
java.io.File file_arg)
Class constructor with filename. |
Method Summary | |
void |
addClue(Clue newClue)
Method used to add a clue in the cluesVector. |
boolean |
addRelation(int value,
int cat1,
int item1,
int cat2,
int item2)
Method used to add a relationship to the squares array, and update the graphical representation by passing the call to the GridCanvas object. |
boolean |
addRelation(Relation rel)
Method used to add a relationship to the squares array, and update the graphical representation by passing the call to the GridCanvas object. |
int |
checkAnswer(java.lang.String testItem,
int specialCategory)
Method used to check if there is a recorded answer between a specific item and a category. |
void |
generateCanvases()
|
AnswerCanvas |
getAnswerCanvas()
|
java.util.Vector |
getAnswersVector()
Method used to obtain a reference to the ayeVector. |
java.lang.String[] |
getCategories()
|
java.lang.String |
getCategory(int index)
Method used to get the name of a category of items, given its index. |
int |
getCatIndex(java.lang.String item)
Method used to obtain the category index of a given item or category name. |
int |
getCatNumber()
Method used to obtain the number of categories |
Clue |
getClue(int clueNumber_arg)
Method used to obtain the vector containing the special relations. |
java.util.Vector |
getCluesVector()
|
java.io.File |
getCurrentFile()
Returns a reference to the current File for this Worksheet. |
GridCanvas |
getGridCanvas()
Method used to return the canvas, which is the graphic representation of the relationships. |
java.lang.String |
getItem(int category,
int index)
Method returning the name of an item given its category number and index. |
int |
getItemIndex(java.lang.String item)
Method returning the item index of a given item. |
int |
getItemNumber()
Method used to obtain the number of items |
java.lang.String[][] |
getItems()
|
ProblemSolver |
getParent()
|
int |
getRelation(int cat1,
int item1,
int cat2,
int item2)
Method used to obtain the relationship between two items, such as set in the square matrix. |
boolean |
isDirty()
|
void |
loadGrid(java.io.File filename)
Loads a worksheet with the specified file name. |
void |
refresh()
|
void |
regenerateVector()
|
void |
reset()
Method used to reset the squares and redraw the new grid. |
void |
saveGrid()
Saves the current Worksheet. |
void |
saveGrid(java.io.File theFile)
Saves the current Grid information in the specified File. |
void |
setCategory(int index,
java.lang.String name)
Method used to set the name of a category given its index. |
void |
setCatNumber(int number)
Method called to set the number of categories in the problem. |
void |
setCurrentFile(java.io.File f)
Assigns the specified File to this grid. |
void |
setDirty(boolean dirty_arg)
|
void |
setItem(int category,
int index,
java.lang.String name)
Method used to set the name of an item, given its category number and index. |
void |
setItemNumber(int number)
Method called to set the number of items per category. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public GridCanvas gridCanvas
public AnswerCanvas answerCanvas
Constructor Detail |
public Grid(ProblemSolver parent_arg)
public Grid(ProblemSolver parent_arg, java.io.File file_arg)
parent_arg
- a reference to the parent which contains this Worksheet.Method Detail |
public void setCatNumber(int number)
number
- the number of categories.public void setItemNumber(int number)
number
- the number of items per category.public void generateCanvases()
public void setCategory(int index, java.lang.String name)
index
- the index of this category.name
- the name of the category.public java.lang.String getCategory(int index)
index
- the index of this category.public java.lang.String[] getCategories()
public void setItem(int category, int index, java.lang.String name)
category
- the category number between 0 and catNumber-1index
- the index of this itemname
- the name of the itempublic java.lang.String getItem(int category, int index)
category
- the category number between 0 and catNumber-1index
- the index of this itempublic java.lang.String[][] getItems()
public int getCatIndex(java.lang.String item)
item
- the item name.public int getItemIndex(java.lang.String item)
public boolean addRelation(Relation rel)
rel
- the relationship to be added.public boolean addRelation(int value, int cat1, int item1, int cat2, int item2)
value
- cat1
- item1
- cat2
- item2
- public int getRelation(int cat1, int item1, int cat2, int item2)
cat1
- One category index associated with one itemitem1
- One item indexcat2
- The other category index associated with the other itemitem1
- The other item indexpublic java.util.Vector getAnswersVector()
public int checkAnswer(java.lang.String testItem, int specialCategory)
public int getCatNumber()
public int getItemNumber()
public Clue getClue(int clueNumber_arg)
public java.util.Vector getCluesVector()
public void addClue(Clue newClue)
clue
- the clue to be added in the cluesVector.public void reset()
public void refresh()
public GridCanvas getGridCanvas()
public AnswerCanvas getAnswerCanvas()
public ProblemSolver getParent()
public boolean isDirty()
public void setDirty(boolean dirty_arg)
public void loadGrid(java.io.File filename) throws java.io.IOException, InvalidGridException
filename
- the name of the filepublic void saveGrid() throws java.io.IOException
public void saveGrid(java.io.File theFile) throws java.io.IOException
theFile
- a File reference obtained through file chooserpublic void setCurrentFile(java.io.File f)
f
- the Filepublic java.io.File getCurrentFile()
public void regenerateVector()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |