Changeset 1830
- Timestamp:
- 2001-01-11T12:28:05+13:00 (23 years ago)
- Location:
- trunk/gsdl/src/phind/client
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/phind/client/Phind.java
r1827 r1830 481 481 482 482 // The query is finished 483 setStatus(r.c.numberOf Phrases + " results containing\"" + phrase + "\"");483 setStatus(r.c.numberOfItems + " results for \"" + phrase + "\""); 484 484 mode = idleMode; 485 485 searchButton.enable(); -
trunk/gsdl/src/phind/client/ResultBox.java
r1827 r1830 242 242 } else { 243 243 // We haven't finished, give some feedback about progress 244 setStatus("Connected to host, " + c.numberOf Phrases + " results read");244 setStatus("Connected to host, " + c.numberOfItems + " results read"); 245 245 } 246 246 } -
trunk/gsdl/src/phind/client/ResultCanvas.java
r1827 r1830 67 67 int lineSpacing; 68 68 69 // The phrases to display on this canvas70 int numberOf Phrases;71 int first PhraseDisplayed;72 int phraseSelected;73 Vector phrases;69 // The items to display on this canvas 70 int numberOfItems; 71 int firstItemDisplayed; 72 int itemSelected; 73 Vector items; 74 74 75 75 // the background image … … 90 90 lineSpacing = phind.fontSize + 2; 91 91 92 phrases = new Vector();93 numberOf Phrases = 0;94 first PhraseDisplayed = 0;95 phraseSelected = -1;92 items = new Vector(); 93 numberOfItems = 0; 94 firstItemDisplayed = 0; 95 itemSelected = -1; 96 96 97 97 if (backgroundImage == null) { … … 102 102 103 103 void resetCanvas( ) { 104 phrases.removeAllElements();105 numberOf Phrases = 0;104 items.removeAllElements(); 105 numberOfItems = 0; 106 106 repaint(); 107 107 } … … 117 117 // This is not efficient, but I don't care right now. 118 118 int index = 0; 119 while ((index < numberOf Phrases) &&120 ((item.kind > ((ResultItem) phrases.elementAt(index)).kind) ||121 ((item.kind == ((ResultItem) phrases.elementAt(index)).kind) &&122 (item.frequency <= ((ResultItem) phrases.elementAt(index)).frequency)))) {119 while ((index < numberOfItems) && 120 ((item.kind > ((ResultItem) items.elementAt(index)).kind) || 121 ((item.kind == ((ResultItem) items.elementAt(index)).kind) && 122 (item.frequency <= ((ResultItem) items.elementAt(index)).frequency)))) { 123 123 index++; 124 124 } 125 phrases.insertElementAt(item,index);126 numberOf Phrases++;125 items.insertElementAt(item,index); 126 numberOfItems++; 127 127 return true; 128 128 } … … 145 145 boolean found = false; 146 146 int index = 0; 147 while (!found && (index < numberOf Phrases)) {148 if (((ResultItem) phrases.elementAt(index)).isMorePhrases()) {147 while (!found && (index < numberOfItems)) { 148 if (((ResultItem) items.elementAt(index)).isMorePhrases()) { 149 149 found = true; 150 150 } else { … … 156 156 // there should be no marker 157 157 if (found) { 158 phrases.removeElementAt(index);159 numberOf Phrases--;158 items.removeElementAt(index); 159 numberOfItems--; 160 160 } 161 161 … … 177 177 boolean found = false; 178 178 int index = 0; 179 while (!found && (index < numberOf Phrases)) {180 if (((ResultItem) phrases.elementAt(index)).isMoreDocuments()) {179 while (!found && (index < numberOfItems)) { 180 if (((ResultItem) items.elementAt(index)).isMoreDocuments()) { 181 181 found = true; 182 182 } else { … … 188 188 // there should be no marker 189 189 if (found) { 190 phrases.removeElementAt(index);191 numberOf Phrases--;190 items.removeElementAt(index); 191 numberOfItems--; 192 192 } 193 193 … … 212 212 boolean found = false; 213 213 int index = 0; 214 while (!found && (index < numberOf Phrases)) {215 if (((ResultItem) phrases.elementAt(index)).isMoreLinks()) {214 while (!found && (index < numberOfItems)) { 215 if (((ResultItem) items.elementAt(index)).isMoreLinks()) { 216 216 found = true; 217 217 } else { … … 223 223 // there should be no marker 224 224 if (found) { 225 phrases.removeElementAt(index);226 numberOf Phrases--;225 items.removeElementAt(index); 226 numberOfItems--; 227 227 } 228 228 … … 257 257 int margin = g.getFontMetrics().stringWidth(" 8888 "); 258 258 259 int leftMargin = 0;260 259 int secondColumn = canvasSize.width - margin; 261 260 int firstColumn = secondColumn - margin; 261 262 int leftMargin = 0; 262 263 int rightMargin = firstColumn; 263 264 264 // calculate the number of values that will fit onscreen265 // the number of items that will fit on the canvas 265 266 int visible = canvasSize.height / lineSpacing; 266 267 267 // get the initial scrollbar setting 268 // and calculate the first result to output 268 // calculate the first item to output 269 269 int scrollValue = scrollbar.getValue(); 270 if (numberOf Phrases <= visible) {270 if (numberOfItems <= visible) { 271 271 scrollValue = 0; 272 } else if (scrollValue > (numberOf Phrases - visible)) {273 scrollValue = numberOf Phrases - visible;272 } else if (scrollValue > (numberOfItems - visible)) { 273 scrollValue = numberOfItems - visible; 274 274 } 275 first PhraseDisplayed = scrollValue;275 firstItemDisplayed = scrollValue; 276 276 277 277 // Draw the phrase area … … 295 295 296 296 // If there are no phrases, output a brief explanation. 297 if (numberOf Phrases == 0) {297 if (numberOfItems == 0) { 298 298 g.drawString("No phrases match this query.", leftMargin + 10, lineSpacing); 299 299 } … … 305 305 + ((rightMargin - leftMargin 306 306 - g.getFontMetrics().stringWidth(parent.searchPhrase)) / 2); 307 int thesColumn = leftMargin + margin 308 + g.getFontMetrics().stringWidth("Narrower term"); 307 309 308 310 String body, prefix, suffix; 309 311 310 312 for (i = scrollValue; 311 (i < numberOf Phrases) && (y + lineSpacing < canvasSize.height); i++) {313 (i < numberOfItems) && (y + lineSpacing < canvasSize.height); i++) { 312 314 313 315 // Get the resultItem to output 314 result = (ResultItem) phrases.elementAt(i);316 result = (ResultItem) items.elementAt(i); 315 317 316 318 // Graphics settings for drawing this line … … 319 321 320 322 // Highlight if the selected phrase. 321 if (i == phraseSelected) {323 if (i == itemSelected) { 322 324 g.setColor(new Color(255, 220, 115)); 323 325 g.fillRect(leftMargin, y-lineSpacing+2, rightMargin, lineSpacing); … … 362 364 prefix = result.prefixText() + ":"; 363 365 body = result.mainText(); 364 366 tab = thesColumn - g.getFontMetrics().stringWidth(prefix) - space; 367 368 g.setColor(new Color(0, 100, 0)); 365 369 g.setFont(areaPlain); 366 g.setColor(new Color(0, 100, 0));367 tab = center - g.getFontMetrics().stringWidth(prefix) - space;368 // tab = margin + margin - g.getFontMetrics().stringWidth(prefix);369 370 g.drawString(prefix, tab, y); 370 371 371 g.setFont(areaBold); 372 g.drawString(body, center, y); 373 372 g.drawString(body, thesColumn, y); 374 373 } 375 374 … … 406 405 g.setFont(areaPlain); 407 406 y = 0; 407 String docsText, freqText; 408 408 409 409 for (i = scrollValue; 410 (i < numberOf Phrases) && (y + lineSpacing < canvasSize.height); i++) {410 (i < numberOfItems) && (y + lineSpacing < canvasSize.height); i++) { 411 411 412 412 // Get the resultItem to output 413 result = (ResultItem) phrases.elementAt(i); 413 result = (ResultItem) items.elementAt(i); 414 docsText = result.docsText(); 415 freqText = result.freqText(); 414 416 415 417 // Graphics settings for drawing this line … … 417 419 418 420 // Write the document frequency 419 if (result.docsText().length() > 0) { 420 g.drawString(" " + result.docsText(), firstColumn, y); 421 if (docsText.length() > 0) { 422 tab = secondColumn - space - g.getFontMetrics().stringWidth(docsText); 423 g.drawString(docsText, tab, y); 421 424 } 422 425 423 426 // Write the term frequency 424 if (result.freqText().length() > 0) { 425 g.drawString(" " + result.freqText(), secondColumn, y); 427 if (freqText.length() > 0) { 428 tab = secondColumn + margin - space - g.getFontMetrics().stringWidth(freqText); 429 g.drawString(freqText, tab, y); 426 430 } 427 431 } 428 432 429 433 // Adjust the scrollbar 430 if (visible >= numberOf Phrases) {434 if (visible >= numberOfItems) { 431 435 parent.disableScrollbar(); 432 436 } else { 433 scrollbar.setValues(scrollValue, visible, 0, numberOf Phrases);437 scrollbar.setValues(scrollValue, visible, 0, numberOfItems); 434 438 // Deprecated - setPageIncrement() has been replaced by 435 439 // setBlockIncrement(), but the latter doesn't work on some … … 466 470 // which Item is selected? 467 471 int rowSelected = event.y / lineSpacing; 468 int itemSelected = rowSelected + first PhraseDisplayed;469 ResultItem item = (ResultItem) phrases.elementAt(itemSelected);470 471 if (itemSelected <= numberOf Phrases) {472 int itemSelected = rowSelected + firstItemDisplayed; 473 ResultItem item = (ResultItem) items.elementAt(itemSelected); 474 475 if (itemSelected <= numberOfItems) { 472 476 473 477 //User clicks on a phrase 474 478 if (item.isPhrase()) { 475 479 476 phraseSelected = itemSelected;480 itemSelected = itemSelected; 477 481 update(getGraphics()); 478 482 … … 499 503 // Click on a thesaurus link 500 504 else if (item.isLink()) { 501 phraseSelected = itemSelected;505 itemSelected = itemSelected; 502 506 update(getGraphics()); 503 507 parent.lookupPhrase(item.hiddenText(), item.toString(), 2); … … 506 510 // The user clicks on a URL; display it. 507 511 else if (item.isDocument()) { 508 phraseSelected = itemSelected;512 itemSelected = itemSelected; 509 513 update(getGraphics()); 510 514 -
trunk/gsdl/src/phind/client/ResultItem.java
r1827 r1830 102 102 // Return the text of the item components 103 103 public String mainText() { return text; } 104 public String freqText() { return Integer.toString(frequency); } 104 public String freqText() { 105 if (frequency > 0) { return Integer.toString(frequency); } 106 else { return ""; } 107 } 105 108 public String docsText() { return ""; } 106 109 public String prefixText() { return ""; } -
trunk/gsdl/src/phind/client/ResultItemLink.java
r1827 r1830 68 68 69 69 // Return the text of the item components 70 public String docsText() { return Integer.toString(documentFrequency); }71 70 public String hiddenText() { return id; } 72 71 public String docsText() { 72 if (documentFrequency <= 0) { return ""; } 73 else { return Integer.toString(documentFrequency); } 74 } 73 75 public String prefixText() { 74 76 if (linkType.equals("RT")) { return "Related term"; } -
trunk/gsdl/src/phind/client/ResultTitle.java
r1827 r1830 143 143 status = status + links + ", "; 144 144 } 145 status = status + links +expansions + ", " + documents + ")";145 status = status + expansions + ", " + documents + ")"; 146 146 147 147
Note:
See TracChangeset
for help on using the changeset viewer.