package vishnu.testvis.visual; /** This class is maps the display array of keywords onto the stored. * array * @author Matthew Carey */ public class MapKeyWords { /** array map for display to stored */ protected int nodesToWord[] = null; /** array map for stored to display */ protected int wordsToNodes[] = null; /** * map for display to stored * @param display index * @return stored index */ public int mapNodesToWords(int index) { return nodesToWord[index]; } /** * map for stored to display * @param stored index * @return the display index */ public int mapWordsToNodes(int index) { return wordsToNodes[index]; } /** * constructor * @param keywordarray instance containing list of key words and states */ public MapKeyWords(KeyWordArray keyWordArray) { int c, n=0; nodesToWord = null; wordsToNodes = null; nodesToWord = new int [keyWordArray.getNumEnabled()]; wordsToNodes = new int [keyWordArray.getNumWords()]; int totalKeyWord=keyWordArray.getNumWords(); for (c=0;c < totalKeyWord; c++) { if (keyWordArray.getState(c)) { wordsToNodes[c]=n; nodesToWord[n]=c; n++; } else wordsToNodes[c]=-1; } } /** * re-Map the KeyWords with a new vector * @param array the new vector * @param keywordarray instance containing list of key words and states */ public void reMapKeyWords(int array[],KeyWordArray keyWordArray) { if (array.length != keyWordArray.getNumEnabled()) return; int c; for (c=0;c