Changeset 1832
- Timestamp:
- 2001-01-12T15:20:55+13:00 (23 years ago)
- Location:
- trunk/gsdl/src/phind/client
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/phind/client/Phind.java
r1831 r1832 107 107 public String library_address, phindcgi_address; 108 108 109 // Initial serach term 110 public String initialSearch; 111 109 112 // Number of phrases to retrieve at any one time 110 113 public int phraseBlockSize; … … 113 116 public boolean vertical; 114 117 public int depth; 118 119 // Font 115 120 public int fontSize; 121 public String fontName; 116 122 public Font plainFont, boldFont; 117 123 … … 120 126 public String backdrop_address; 121 127 public Image backgroundImage; 128 129 // Colours 130 public Color panel_fg, panel_bg, 131 column_1_fg, column_1_bg, 132 column_2_fg, column_2_bg, 133 highlight_fg, highlight_bg, 134 thesaurus_fg, thesaurus_bg, thesaurus_bar_fg, thesaurus_bar_bg, 135 expansion_fg, expansion_bg, expansion_bar_fg, expansion_bar_bg, 136 document_fg, document_bg, document_bar_fg, document_bar_bg, 137 message_fg, message_bg; 138 139 // Column dimensions 140 int column_1_width, column_2_width; 141 142 // Where do we open new windows 143 String searchWindowName, documentWindowName; 122 144 123 145 // the mode of operation … … 127 149 final int searchMode = 2; 128 150 129 // elements of the page 151 // Elements of the control panel 152 boolean showControlPanel; 130 153 Label titleLabel; 131 154 TextField wordField; … … 170 193 mode = initMode; 171 194 172 // Default applet parameters173 collection = "";174 phindcgi_address = "";175 library_address = "";176 177 showImage = false;178 backdrop_address = "";179 180 vertical = true;181 depth = 3;182 183 phraseBlockSize = 10;184 fontSize = 12;185 186 195 // Read applet parameters 187 196 getParameters(); 188 197 189 190 198 // Initialise the user interface 191 setBackground( Color.white);199 setBackground(panel_bg); 192 200 lastQueryEndTime = new Date(); 193 201 194 202 // fonts used to output text 195 plainFont = new Font( "Helvetica", Font.PLAIN, fontSize);196 boldFont = new Font( "Helvetica", Font.BOLD, fontSize);203 plainFont = new Font(fontName, Font.PLAIN, fontSize); 204 boldFont = new Font(fontName, Font.BOLD, fontSize); 197 205 198 206 // The phind applet layout manager 199 207 setLayout(new BorderLayout()); 200 208 201 // thePanel containing the displays is in the center of the display209 // Panel containing the displays is in the center of the display 202 210 resultPanel = new Panel(); 203 211 if (vertical) { … … 209 217 add("Center", resultPanel); 210 218 211 // Create ResultDisplays and place in the interface219 // Create ResultDisplays and place into the interface 212 220 ResultDisplay d1, d2 = null; 213 221 firstDisplay = new ResultDisplay(this, null); 214 222 resultPanel.add(firstDisplay); 215 223 216 d1 = firstDisplay; 217 for (int i = 2; i <= depth; i++) { 218 d2 = new ResultDisplay(this, d1); 219 resultPanel.add(d2); 220 d1 = d2; 221 } 222 lastDisplay = d2; 223 224 225 // The "control panel" 226 Panel p1 = new Panel(); 227 add("North", p1); 228 p1.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); 229 230 searchButton = new Button("Search"); 231 searchButton.setFont(boldFont); 232 p1.add(searchButton); 233 234 Label tempLabel = new Label(" for"); 235 tempLabel.setFont(boldFont); 236 p1.add(tempLabel); 237 238 wordField = new TextField(12); 239 wordField.setFont(boldFont); 240 p1.add(wordField); 241 242 Label temp2 = new Label(" "); 243 p1.add(temp2); 244 245 prevButton = new Button("Previous"); 246 prevButton.setFont(boldFont); 247 prevButton.disable(); 248 p1.add(prevButton); 249 250 nextButton = new Button(" Next "); 251 nextButton.setFont(boldFont); 252 nextButton.disable(); 253 p1.add(nextButton); 224 if (depth == 1) { 225 lastDisplay = firstDisplay; 226 } else { 227 d1 = firstDisplay; 228 for (int i = 2; i <= depth; i++) { 229 d2 = new ResultDisplay(this, d1); 230 resultPanel.add(d2); 231 d1 = d2; 232 } 233 lastDisplay = d2; 234 } 235 236 // The control panel 237 initialiseControlPanel(); 254 238 255 239 // lets get started then 256 240 setStatus("Welcome to Phind."); 257 241 mode = idleMode; 258 } 259 260 261 // Get the applet parameters 262 void getParameters() { 263 264 265 // What is this collection called? 266 try { 267 collection = new String(getParameter("collection")); 268 System.out.println("Phind collection: " + collection); 269 } catch (Exception e) { 270 System.err.println("Phind could not read collection name: " + e.toString()); 271 stop(); 272 } 273 274 // Where do we get the phind data 275 try { 276 phindcgi_address = new String(getParameter("phindcgi")); 277 phindcgi_address = tidy_URL(phindcgi_address, true); 278 System.out.println("Phind phindcgi: " + phindcgi_address); 279 } catch (Exception e) { 280 System.err.println("Phind could not process phindcgi URL: " + e.toString()); 281 stop(); 282 } 283 284 // Where is the collection served from 285 try { 286 library_address = new String(getParameter("library")); 287 library_address = tidy_URL(library_address, true); 288 System.out.println("Phind library: " + library_address); 289 } catch (Exception e) { 290 System.err.println("Phind library: not specified"); 291 library_address = ""; 292 } 293 294 // Should we display a background image? 295 try { 296 backdrop_address = new String(getParameter("backdrop")); 297 backdrop_address = tidy_URL(backdrop_address, false); 298 URL backdrop_url = new URL(backdrop_address); 299 backgroundImage = getImage(backdrop_url); 300 showImage = true; 301 System.out.println("Phind backdrop: " + backdrop_address); 302 } catch (Exception e) { 303 System.out.println("Phind backdrop not set: " + e.toString()); 304 } 305 306 // Are the windows arranged vertically or horizontally 307 try { 308 if (getParameter("orientation").toLowerCase().startsWith("h")) { 309 vertical = false; 310 System.out.println("Phind orientation: horizontal"); 311 } 312 } catch (Exception e) { 313 System.out.println("Phind orientation: vertical"); 314 } 315 316 // How many phind windows are there? 317 try { 318 depth = Integer.valueOf(getParameter("depth")).intValue(); 319 } catch (Exception e) { 320 depth = 3; 321 } 322 System.out.println("Phind depth: " + depth); 323 324 // How many phrases should we fetch at any given time? 325 try { 326 phraseBlockSize = Integer.valueOf(getParameter("blocksize")).intValue(); 327 } catch (Exception e) { 328 phraseBlockSize = 10; 329 } 330 System.out.println("Phind retrieval block size: " + phraseBlockSize); 331 332 // How large should the font be? 333 try { 334 fontSize = Integer.valueOf(getParameter("fontsize")).intValue(); 335 } catch (Exception e) { 336 fontSize = 12; 337 } 338 System.out.println("Phind font size: " + fontSize); 339 } 340 242 243 // Perform initial search, if requested 244 if (initialSearch.length() > 0) { 245 searchForWord(initialSearch); 246 } 247 } 248 249 250 // Display a message in the status bar 341 251 void setStatus(String status) { 342 252 showStatus(status); 343 253 } 344 254 255 // The user performs an action in the interface 345 256 public boolean action(Event evt, Object arg) { 346 257 347 258 if (evt.target == searchButton) { 348 searchForWord( );259 searchForWord(getSearchTerm()); 349 260 } else if (evt.target == wordField) { 350 searchForWord( );261 searchForWord(getSearchTerm()); 351 262 } else if (evt.target == prevButton) { 352 263 shiftPrevious(); … … 354 265 shiftNext(); 355 266 } else { 356 System.out.println("unknown action: " + evt.toString() + ", object: " + arg.toString()); 267 System.out.println("unknown action: " + evt.toString() 268 + ", object: " + arg.toString()); 357 269 } 358 270 return true; … … 362 274 // Search for a word 363 275 // 364 // called when the "Search" Button is pressed 365 void searchForWord() { 276 // Clled on two occasions: 277 // when the "Search" Button is pressed, or 278 // to perform an "initial search" 279 void searchForWord(String searchWord) { 366 280 367 281 if (mode == idleMode) { 368 282 369 283 // transform the word to an appropriate search key 370 String searchWord = wordField.getText().trim().toLowerCase();284 searchWord = searchWord.trim().toLowerCase(); 371 285 for (int i = 0; i < searchWord.length(); i++) { 372 286 if ((searchWord.charAt(i) < 'a') || (searchWord.charAt(i) > 'z')) { … … 374 288 } 375 289 } 376 wordField.setText(searchWord);290 setSearchTerm(searchWord); 377 291 378 292 // look up the word … … 410 324 if (mode == idleMode) { 411 325 412 // If we are going to replace the next ResultDisplay, then empty it326 // If we are going to replace the first ResultDisplay, then empty it 413 327 if (queryMode <= 2) { 414 328 if (source.display.next != null) source.display.next.emptyContents(); … … 452 366 boolean keyKnown, String key, String phrase, 453 367 int queryMode) { 454 searchButton.disable();368 disableSearchButton(); 455 369 mode = searchMode; 456 370 ResultBox r = null; … … 468 382 setStatus("Query error: " + e.toString()); 469 383 mode = idleMode; 470 searchButton.enable();384 enableSearchButton(); 471 385 return null; 472 386 } … … 475 389 setStatus(r.c.numberOfItems + " results for \"" + phrase + "\""); 476 390 mode = idleMode; 477 searchButton.enable();391 enableSearchButton(); 478 392 lastQueryEndTime = new Date(); 479 393 … … 566 480 } 567 481 568 569 // Previous and Next button functionality570 571 // enable or disable the "Previous" and "Next" buttons572 void enablePreviousAndNext() {573 574 Component c = firstDisplay.current;575 if (c.getClass().getName().equals("ResultBox")) {576 if (((ResultBox) c).prevBoxExists()) {577 prevButton.enable();578 } else {579 prevButton.disable();580 }581 }582 583 c = lastDisplay.current;584 if (c.getClass().getName().equals("ResultBox")) {585 if (((ResultBox) c).nextBoxExists()) {586 nextButton.enable();587 } else {588 nextButton.disable();589 }590 }591 }592 593 // Shift to previous box594 //595 // If the user clicks "Previous" then scroll up.596 void shiftPrevious() {597 598 Component c = firstDisplay.current;599 if (c.getClass().getName().equals("ResultBox")) {600 601 ResultBox b = (ResultBox) c;602 if (b.prevBoxExists()) {603 b = b.prev;604 605 // empty all the displays606 firstDisplay.emptyContents();607 608 // add as many result boxes as there are displays609 for (int i = 1 ; ((i <= depth) && (b != null)); i++) {610 lastDisplay.display(b);611 b.resize(b.display.size());612 b.paintAll(b.getGraphics());613 b = b.next;614 }615 }616 }617 enablePreviousAndNext();618 }619 620 621 // Shift to next box622 //623 // If the user clicks "Next" then scroll down if possible624 void shiftNext() {625 626 Component c = lastDisplay.current;627 if (c.getClass().getName().equals("ResultBox")) {628 629 ResultBox b = (ResultBox) c;630 if (b.nextBoxExists()) {631 632 // find the new "first" displayed box633 c = firstDisplay.current;634 b = (ResultBox) c;635 b = b.next;636 637 // empty all the displays638 firstDisplay.emptyContents();639 640 // add as many result boxes as there are displays641 for (int i = 1 ; ((i <= depth) && (b != null)); i++) {642 lastDisplay.display(b);643 b.resize(b.display.size());644 b.paintAll(b.getGraphics());645 b = b.next;646 }647 }648 }649 enablePreviousAndNext();650 }651 652 653 482 654 483 // Tidy up URLs … … 710 539 } 711 540 541 542 // Get the applet parameters 543 void getParameters() { 544 545 // What is this collection called? 546 collection = parameterValue("collection"); 547 System.out.println("Phind collection: " + collection); 548 549 // Where is the phind CGI script 550 phindcgi_address = parameterValue("phindcgi"); 551 phindcgi_address = tidy_URL(phindcgi_address, true); 552 System.out.println("Phind phindcgi: " + phindcgi_address); 553 554 // Where is the Greenstone library 555 library_address = parameterValue("library"); 556 library_address = tidy_URL(library_address, true); 557 System.out.println("Phind library: " + library_address); 558 559 // Is there a default search term? 560 initialSearch = parameterValue("initial_search", ""); 561 562 // Should we display the control panel 563 showControlPanel = true; 564 if (parameterValue("control_panel", "show").toLowerCase().equals("hide")) { 565 showControlPanel = false; 566 } 567 568 // Should we show a background image? 569 backdrop_address = parameterValue("backdrop", ""); 570 if (backdrop_address.length() > 0) { 571 backdrop_address = tidy_URL(backdrop_address, false); 572 System.out.println("Phind backdrop URL: " + backdrop_address); 573 574 try { 575 URL backdrop_url = new URL(backdrop_address); 576 backgroundImage = getImage(backdrop_url); 577 showImage = true; 578 } catch (Exception e) { 579 System.out.println("Phind could not load " + backdrop_address); 580 showImage = false; 581 } 582 } 583 584 // Are the windows arranged vertically or horizontally 585 if (parameterValue("orientation", "vertical").toLowerCase().startsWith("hori")) { 586 vertical = false; 587 } else { 588 vertical = true; 589 } 590 591 // How many phind windows are there? 592 depth = parameterValue("depth", 3); 593 594 // How many phrases should we fetch at any given time? 595 phraseBlockSize = parameterValue("blocksize", 10); 596 597 // What font should we use? 598 fontSize = parameterValue("fontsize", 10); 599 fontName = parameterValue("fontname", "Helvetica"); 600 601 // Column dimensions 602 column_1_width = parameterValue("first_column_width", 6); 603 column_2_width = parameterValue("second_column_width", column_1_width); 604 605 // Where do we open new windows 606 searchWindowName = parameterValue("search_window", "phindsearch"); 607 documentWindowName = parameterValue("document_window", "phinddoc"); 608 609 // Colours 610 panel_fg = parameterValue("panel_fg", panel_fg); 611 panel_bg = parameterValue("panel_bg", panel_bg); 612 613 highlight_bg = parameterValue("highlight_bg", new Color(255, 220, 115)); 614 615 expansion_fg = parameterValue("expansion_fg", Color.black); 616 thesaurus_fg = parameterValue("thesaurus_fg", new Color(0, 100, 0)); 617 document_fg = parameterValue("document_fg", Color.blue); 618 619 thesaurus_bar_fg = parameterValue("thesaurus_bar_fg", Color.black); 620 expansion_bar_fg = parameterValue("expansion_bar_fg", Color.black); 621 document_bar_fg = parameterValue("document_bar_fg", Color.black); 622 623 thesaurus_bar_bg = parameterValue("thesaurus_bar_bg", new Color(160, 160, 190)); 624 expansion_bar_bg = parameterValue("expansion_bar_bg", new Color(255, 200, 200)); 625 document_bar_bg = parameterValue("document_bar_bg", new Color(150, 193, 156)); 626 627 column_1_fg = parameterValue("first_column_fg", Color.black); 628 column_1_bg = parameterValue("first_column_bg", new Color(235, 245, 235)); 629 column_2_fg = parameterValue("second_column_fg", Color.black); 630 column_2_bg = parameterValue("second_column_bg", new Color(200, 220, 200)); 631 632 message_fg = parameterValue("message_fg", Color.black); 633 message_bg = parameterValue("message_bg", Color.white); 634 635 // Colours I don't use, yet 636 // thesaurus_bg = parameterValue("thesaurus_bg", Color.white); 637 // expansion_bg = parameterValue("expansion_bg", Color.white); 638 // document_bg = parameterValue("document_bg", Color.white); 639 } 640 641 // Get the value of a parameter given its name. 642 // There are many types of parameters, hence the variety of functions. 643 644 // Get a REQUIRED string. Stop the applet if we cannot. 645 String parameterValue(String name) { 646 try { 647 return getParameter(name); 648 } catch (Exception e) { 649 System.err.println("Phind: you must give a parameter for \"" 650 + name + "\". Stopping."); 651 stop(); 652 } 653 return ""; 654 } 655 656 // Get an optional parameter. Return a default if we cannot. 657 String parameterValue(String name, String defaultValue) { 658 String text = getParameter(name); 659 if (text == null) { 660 return defaultValue; 661 } 662 System.out.println("Phind " + name + ": " + text); 663 return text; 664 } 665 666 int parameterValue(String name, int defaultValue) { 667 int value; 668 try { 669 value = Integer.parseInt(getParameter(name)); 670 } catch (Exception e) { 671 return defaultValue; 672 } 673 System.out.println("Phind " + name + ": " + value); 674 return value; 675 } 676 677 Color parameterValue(String name, Color defaultValue) { 678 679 String text = getParameter(name); 680 if (text == null) { 681 return defaultValue; 682 } 683 text = text.toLowerCase(); 684 685 // a number of the form "#ddffee" 686 if (text.startsWith("#") && (text.length() == 7)) { 687 text = text.substring(1); 688 int r, g, b; 689 try { 690 r = Integer.parseInt(text.substring(0,2), 16); 691 g = Integer.parseInt(text.substring(2,4), 16); 692 b = Integer.parseInt(text.substring(4), 16); 693 return new Color(r, g, b); 694 } catch (Exception e) { 695 return defaultValue; 696 } 697 } 698 699 // a known Java colour string 700 else if (text.equals("black")) { return Color.black; } 701 else if (text.equals("blue")) { return Color.blue; } 702 else if (text.equals("cyan")) { return Color.cyan; } 703 else if (text.equals("darkgray")) { return Color.darkGray; } 704 else if (text.equals("gray")) { return Color.gray; } 705 else if (text.equals("green")) { return Color.green; } 706 else if (text.equals("lightgray")) { return Color.lightGray; } 707 else if (text.equals("magenta")) { return Color.magenta; } 708 else if (text.equals("orange")) { return Color.orange; } 709 else if (text.equals("pink")) { return Color.pink; } 710 else if (text.equals("red")) { return Color.red; } 711 else if (text.equals("white")) { return Color.white; } 712 else if (text.equals("yellow")) { return Color.yellow; } 713 714 return defaultValue; 715 } 716 717 718 // Control panel operations 719 720 // Initialise the control panel 721 void initialiseControlPanel() { 722 723 if (showControlPanel) { 724 Panel p1 = new Panel(); 725 add("North", p1); 726 p1.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); 727 728 searchButton = new Button("Search"); 729 searchButton.setFont(boldFont); 730 p1.add(searchButton); 731 732 Label tempLabel = new Label(" for"); 733 tempLabel.setFont(boldFont); 734 p1.add(tempLabel); 735 736 wordField = new TextField(12); 737 wordField.setFont(boldFont); 738 p1.add(wordField); 739 740 Label temp2 = new Label(" "); 741 p1.add(temp2); 742 743 prevButton = new Button("Previous"); 744 prevButton.setFont(boldFont); 745 prevButton.disable(); 746 747 p1.add(prevButton); 748 749 nextButton = new Button(" Next "); 750 nextButton.setFont(boldFont); 751 nextButton.disable(); 752 p1.add(nextButton); 753 754 } 755 } 756 757 // Button and field functionality 758 759 // Enable and disable the word field 760 void enableSearchButton() { 761 if (showControlPanel) { 762 searchButton.enable(); 763 } 764 } 765 void disableSearchButton() { 766 if (showControlPanel) { 767 searchButton.disable(); 768 } 769 } 770 771 // Get and set the search text in the wordField 772 String getSearchTerm() { 773 if (showControlPanel) { 774 return wordField.getText(); 775 } else { 776 return initialSearch; 777 } 778 } 779 void setSearchTerm(String word) { 780 if (showControlPanel) { 781 wordField.setText(word); 782 } 783 } 784 785 // Enable or disable the "Previous" and "Next" buttons 786 void enablePreviousAndNext() { 787 788 if (showControlPanel) { 789 Component c = firstDisplay.current; 790 if (c.getClass().getName().equals("ResultBox")) { 791 if (((ResultBox) c).prevBoxExists()) { 792 prevButton.enable(); 793 } else { 794 prevButton.disable(); 795 } 796 } 797 798 c = lastDisplay.current; 799 if (c.getClass().getName().equals("ResultBox")) { 800 if (((ResultBox) c).nextBoxExists()) { 801 nextButton.enable(); 802 } else { 803 nextButton.disable(); 804 } 805 } 806 } 807 } 808 809 // Shift to previous box 810 // 811 // If the user clicks "Previous" then scroll up. 812 void shiftPrevious() { 813 814 Component c = firstDisplay.current; 815 if (c.getClass().getName().equals("ResultBox")) { 816 817 ResultBox b = (ResultBox) c; 818 if (b.prevBoxExists()) { 819 b = b.prev; 820 821 // empty all the displays 822 firstDisplay.emptyContents(); 823 824 // add as many result boxes as there are displays 825 for (int i = 1 ; ((i <= depth) && (b != null)); i++) { 826 lastDisplay.display(b); 827 b.resize(b.display.size()); 828 b.paintAll(b.getGraphics()); 829 b = b.next; 830 } 831 } 832 } 833 enablePreviousAndNext(); 834 } 835 836 // Shift to next box 837 // 838 // If the user clicks "Next" then scroll down if possible 839 void shiftNext() { 840 841 Component c = lastDisplay.current; 842 if (c.getClass().getName().equals("ResultBox")) { 843 844 ResultBox b = (ResultBox) c; 845 if (b.nextBoxExists()) { 846 847 // find the new "first" displayed box 848 c = firstDisplay.current; 849 b = (ResultBox) c; 850 b = b.next; 851 852 // empty all the displays 853 firstDisplay.emptyContents(); 854 855 // add as many result boxes as there are displays 856 for (int i = 1 ; ((i <= depth) && (b != null)); i++) { 857 lastDisplay.display(b); 858 b.resize(b.display.size()); 859 b.paintAll(b.getGraphics()); 860 b = b.next; 861 } 862 } 863 } 864 enablePreviousAndNext(); 865 } 866 867 868 869 870 712 871 } -
trunk/gsdl/src/phind/client/ResultCanvas.java
r1831 r1832 205 205 void updateMoreLinksMarker() { 206 206 207 System.out.println("updateMoreLinksMarker() "); 208 System.out.println("retreived: " + parent.thesaurusLinksRetrieved); 209 System.out.println("total: " + parent.numberOfThesaurusLinks); 207 // System.out.println("updateMoreLinksMarker() "); 210 208 211 209 // look for a marker … … 255 253 g.setFont(areaPlain); 256 254 int space = g.getFontMetrics().stringWidth(" "); 257 int margin = g.getFontMetrics().stringWidth(" 8888 "); 258 259 int secondColumn = canvasSize.width - margin; 260 int firstColumn = secondColumn - margin; 261 262 int leftMargin = 0; 263 int rightMargin = firstColumn; 255 int nought = g.getFontMetrics().stringWidth("0"); 256 257 int firstColumnWidth = phind.column_1_width * nought; 258 int secondColumnWidth = phind.column_2_width * nought; 259 int columnWidth = firstColumnWidth + secondColumnWidth; 260 261 int firstColumnLeft = canvasSize.width - columnWidth; 262 int secondColumnLeft = firstColumnLeft + firstColumnWidth; 263 264 int mainLeftMargin = 0; 265 int mainRightMargin = firstColumnLeft; 264 266 265 267 // the number of items that will fit on the canvas … … 276 278 277 279 // Draw the phrase area 280 Color fore = phind.panel_fg; 281 Color back = phind.panel_bg; 282 278 283 279 284 // draw the background … … 281 286 try { 282 287 g.drawImage(backgroundImage, 283 leftMargin, 0, rightMargin, canvasSize.height,284 Color.white, null);288 mainLeftMargin, 0, mainRightMargin, canvasSize.height, 289 back, null); 285 290 } catch (Exception e) { 286 291 phind.showImage = false; 287 292 System.err.println("ResultCanvas paint error: " + e); 288 g.setColor( Color.white);293 g.setColor(back); 289 294 g.fillRect(0, 0, canvasSize.width, canvasSize.height); 290 295 } 291 296 } else { 292 g.setColor( Color.white);297 g.setColor(back); 293 298 g.fillRect(0, 0, canvasSize.width, canvasSize.height); 294 299 } … … 296 301 // If there are no phrases, output a brief explanation. 297 302 if (numberOfItems == 0) { 298 g.drawString("No phrases match this query.", leftMargin + 10, lineSpacing);303 g.drawString("No phrases match this query.", mainLeftMargin + 10, lineSpacing); 299 304 } 300 305 … … 302 307 ResultItem result; 303 308 int tab, i, y = 0; 304 int center = leftMargin305 + (( rightMargin - leftMargin309 int center = mainLeftMargin 310 + ((mainRightMargin - mainLeftMargin 306 311 - g.getFontMetrics().stringWidth(parent.searchPhrase)) / 2); 307 int thesColumn = leftMargin + margin312 int thesColumn = mainLeftMargin + firstColumnWidth 308 313 + g.getFontMetrics().stringWidth("Narrower term"); 309 314 … … 320 325 g.setFont(areaPlain); 321 326 322 // Highlight ifthe selected phrase.327 // Highlight the selected phrase. 323 328 if (i == itemSelected) { 324 g.setColor(new Color(255, 220, 115)); 325 g.fillRect(leftMargin, y-lineSpacing+2, rightMargin, lineSpacing); 326 g.setColor(Color.black); 329 g.setColor(phind.highlight_bg); 330 g.fillRect(mainLeftMargin, y-lineSpacing+2, mainRightMargin, lineSpacing); 327 331 } 328 332 … … 335 339 suffix = result.suffixText(); 336 340 337 g.setColor( Color.black);341 g.setColor(phind.expansion_fg); 338 342 g.setFont(areaPlain); 339 343 tab = center - g.getFontMetrics().stringWidth(prefix) - space; … … 342 346 g.setFont(areaBold); 343 347 g.drawString(body, center, y); 348 344 349 tab = center + space + g.getFontMetrics().stringWidth(body); 345 346 350 g.setFont(areaPlain); 347 351 g.drawString(suffix, tab, y); … … 353 357 body = result.mainText(); 354 358 359 g.setColor(phind.document_fg); 355 360 g.setFont(areaPlain); 356 g.setColor(Color.blue); 357 tab = (rightMargin - g.getFontMetrics().stringWidth(body)) / 2; 361 tab = (mainRightMargin - g.getFontMetrics().stringWidth(body)) / 2; 358 362 g.drawString(body, tab, y); 359 363 … … 366 370 tab = thesColumn - g.getFontMetrics().stringWidth(prefix) - space; 367 371 368 g.setColor( new Color(0, 100, 0));372 g.setColor(phind.thesaurus_fg); 369 373 g.setFont(areaPlain); 370 374 g.drawString(prefix, tab, y); … … 380 384 381 385 if (result.isMorePhrases()) { 382 g.setColor(new Color(255, 200, 200)); 386 g.setColor(phind.expansion_bar_bg); 387 } else if (result.isMoreDocuments()) { 388 g.setColor(phind.document_bar_bg); 383 389 } else { 384 g.setColor( new Color(150, 193, 156));390 g.setColor(phind.thesaurus_bar_bg); 385 391 } 386 g.fillRect(leftMargin, y-lineSpacing+2, rightMargin, lineSpacing); 387 388 g.setColor(Color.black); 392 g.fillRect(mainLeftMargin, y-lineSpacing+2, mainRightMargin, lineSpacing); 393 394 if (result.isMorePhrases()) { 395 g.setColor(phind.expansion_bar_fg); 396 } else if (result.isMoreDocuments()) { 397 g.setColor(phind.document_bar_fg); 398 } else { 399 g.setColor(phind.thesaurus_bar_fg); 400 } 389 401 g.setFont(areaPlain); 390 tab = ( rightMargin - g.getFontMetrics().stringWidth(body)) / 2;402 tab = (mainRightMargin - g.getFontMetrics().stringWidth(body)) / 2; 391 403 g.drawString(body, tab, y); 392 404 } … … 396 408 397 409 // column backgrounds 398 g.setColor( new Color(235, 245, 235));399 g.fillRect(firstColumn , 0, margin, canvasSize.height);400 g.setColor( new Color(200, 220, 200));401 g.fillRect(secondColumn , 0, margin, canvasSize.height);410 g.setColor(phind.column_1_bg); 411 g.fillRect(firstColumnLeft, 0, firstColumnWidth, canvasSize.height); 412 g.setColor(phind.column_2_bg); 413 g.fillRect(secondColumnLeft, 0, secondColumnWidth, canvasSize.height); 402 414 403 415 // fill in the numbers 404 g.setColor( Color.black);416 g.setColor(phind.column_1_fg); 405 417 g.setFont(areaPlain); 406 418 y = 0; … … 420 432 // Write the document frequency 421 433 if (docsText.length() > 0) { 422 tab = secondColumn - space - g.getFontMetrics().stringWidth(docsText);434 tab = secondColumnLeft - space - g.getFontMetrics().stringWidth(docsText); 423 435 g.drawString(docsText, tab, y); 424 436 } … … 426 438 // Write the term frequency 427 439 if (freqText.length() > 0) { 428 tab = secondColumn + margin - space - g.getFontMetrics().stringWidth(freqText); 440 tab = secondColumnLeft + secondColumnWidth 441 - space - g.getFontMetrics().stringWidth(freqText); 429 442 g.drawString(freqText, tab, y); 430 443 } … … 447 460 } 448 461 462 463 g.setColor(phind.panel_fg); 449 464 g.drawRect(0,0, canvasSize.width - 1, canvasSize.height - 1); 450 465 } … … 470 485 // which Item is selected? 471 486 int rowSelected = event.y / lineSpacing; 472 i nt itemSelected = rowSelected + firstItemDisplayed;487 itemSelected = rowSelected + firstItemDisplayed; 473 488 ResultItem item = (ResultItem) items.elementAt(itemSelected); 474 489 … … 486 501 + "a=q&c=" + phind.collection 487 502 + "&q=%22" + item.toString().replace(' ', '+') + "%22"; 488 phind.displayWebPage(address, "phindsearch");503 phind.displayWebPage(address, phind.searchWindowName); 489 504 } 490 505 } … … 501 516 + "a=q&c=" + phind.collection 502 517 + "&q=%22" + item.toString().replace(' ', '+') + "%22"; 503 phind.displayWebPage(address, "phindsearch");518 phind.displayWebPage(address, phind.searchWindowName); 504 519 } 505 520 } … … 514 529 + "&d=" + item.hiddenText() 515 530 + "&q=" + parent.searchPhrase.replace(' ', '+'); 516 phind.displayWebPage(address, "phinddoc");531 phind.displayWebPage(address, phind.documentWindowName); 517 532 } 518 533 -
trunk/gsdl/src/phind/client/ResultItemLink.java
r1830 r1832 58 58 id = newId; 59 59 symbol = Integer.valueOf(newId).intValue(); 60 text = newText ;60 text = newText.trim(); 61 61 linkType = newLinkType; 62 62 frequency = Integer.valueOf(tf).intValue(); -
trunk/gsdl/src/phind/client/ResultItemPhrase.java
r1827 r1832 66 66 body = b; 67 67 suffix = s; 68 text = prefix + " " + body + " " + suffix;68 text = (prefix + " " + body + " " + suffix).trim(); 69 69 } 70 70
Note:
See TracChangeset
for help on using the changeset viewer.