- Timestamp:
- 2002-10-04T13:46:20+12:00 (22 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/applet/phind
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/applet/phind/Makefile
r3391 r3444 14 14 15 15 #name/location of java compiler 16 JAVAC=/usr/local/share/j2sdk1.4.0/bin/javac17 JAVAH=/usr/local/share/j2sdk1.4.0/bin/javah18 JAVA=/usr/local/share/j2sdk1.4.0/bin/java19 JAVADOC=/usr/local/share/j2sdk1.4.0/bin/javadoc16 #JAVAC=/usr/local/share/j2sdk1.4.0/bin/javac 17 #JAVAH=/usr/local/share/j2sdk1.4.0/bin/javah 18 #JAVA=/usr/local/share/j2sdk1.4.0/bin/java 19 #JAVADOC=/usr/local/share/j2sdk1.4.0/bin/javadoc 20 20 21 #JAVACOPTIONS= -deprecation -g -O 22 JAVACOPTIONS= -g -O 21 JAVAC=/usr/local/share/jdk1.3.1/bin/javac 22 JAVACOPTIONS= -deprecation -g -O 23 #JAVACOPTIONS= -g -O 23 24 24 JAVACLASSPATH= $(JAVACLASSDIR):$(CLASSPATH)25 JAVACLASSPATH=/usr/local/share/jdk1.3.1/bin:$(JAVACLASSDIR):$(CLASSPATH) 25 26 26 27 all: compile -
trunk/gsdl3/src/java/org/greenstone/applet/phind/Phind.java
r3391 r3444 77 77 import java.awt.Component; 78 78 import java.awt.Dimension; 79 import java.awt. Event;79 import java.awt.event.ActionEvent; 80 80 import java.awt.FlowLayout; 81 81 import java.awt.Font; … … 85 85 import java.awt.Panel; 86 86 import java.awt.TextField; 87 87 import java.awt.event.ActionListener; 88 88 import java.net.URL; 89 89 import java.io.DataInputStream; … … 99 99 import org.w3c.dom.Element; 100 100 import org.w3c.dom.Document; 101 import org.greenstone.gsdl3.util.*;102 import javax.xml.parsers.*;101 //import org.greenstone.gsdl3.util.*; 102 //import javax.xml.parsers.*; 103 103 import org.xml.sax.InputSource; 104 import org.apache.xerces.parsers.DOMParser; 104 105 105 106 //import org.nzdl.gsdl.Phind.URLUTF8Encoder; 106 107 107 public class Phind extends java.applet.Applet { 108 public class Phind extends java.applet.Applet 109 implements ActionListener { 108 110 109 111 // What is the collection called? … … 264 266 265 267 // The user performs an action in the interface 266 public boolean action(Event evt, Object arg) {268 /* public boolean action(Event evt, Object arg) { 267 269 268 270 if (evt.target == searchButton) { 271 System.out.println("evt.target==searchButton"); 269 272 searchForWord(getSearchTerm()); 270 273 } else if (evt.target == wordField) { 274 System.out.println("evt.target==wordField"); 271 275 searchForWord(getSearchTerm()); 272 276 } else if (evt.target == prevButton) { … … 281 285 } 282 286 287 */ 288 289 public void actionPerformed(ActionEvent evt) { 290 291 Component target = (Component)evt.getSource(); 292 if (target==searchButton) { 293 System.out.println("search button pressed"); 294 searchForWord(getSearchTerm()); 295 } else if (target == wordField) { 296 System.out.println("word field entered"); 297 searchForWord(getSearchTerm()); 298 } else if (target == prevButton) { 299 System.out.println("prev button pressed"); 300 shiftPrevious(); 301 }else if (target == nextButton) { 302 System.out.println("prev button pressed"); 303 shiftNext(); 304 } else { 305 System.out.println("unknown action: " + evt.toString() ); 306 307 } 308 } 283 309 284 310 // Search for a word … … 289 315 void searchForWord(String searchWord) { 290 316 317 System.err.println("in searchforword!!"); 291 318 if (mode == idleMode) { 292 319 … … 311 338 // display the result 312 339 result.display = firstDisplay.display(result); 313 result. resize(result.display.size());340 result.setSize(result.display.getSize()); 314 341 result.paintAll(result.getGraphics()); 315 342 } … … 347 374 if (queryMode <= 2) { 348 375 result.display = lastDisplay.display(result); 349 result. resize(result.display.size());376 result.setSize(result.display.getSize()); 350 377 result.paintAll(result.getGraphics()); 351 378 } … … 481 508 } 482 509 */ 483 DocumentBuilderFactory doc_build_fact = DocumentBuilderFactory.newInstance();510 /* DocumentBuilderFactory doc_build_fact = DocumentBuilderFactory.newInstance(); 484 511 DocumentBuilder doc_builder = doc_build_fact.newDocumentBuilder(); 485 Document data_doc = doc_builder.parse(new InputSource(in)); 512 Document data_doc = doc_builder.parse(new InputSource(in));*/ 513 514 DOMParser parser = new DOMParser(); 515 parser.parse(new InputSource(in)); 516 Document data_doc = parser.getDocument(); 486 517 Element data_elem = data_doc.getDocumentElement(); 487 518 … … 573 604 System.out.println("Phind classifier: " + classifier); 574 605 575 // Where is the phind CGI script576 phindcgi_address = parameterValue("phindcgi");577 phindcgi_address = tidy_URL(phindcgi_address, true);578 System.out.println("Phind phindcgi: " + phindcgi_address);579 580 606 // Where is the Greenstone library 581 607 library_address = parameterValue("library"); 582 608 library_address = tidy_URL(library_address, true); 583 609 System.out.println("Phind library: " + library_address); 610 611 // Where is the phind CGI script 612 // we assume this is relative to the greenstone library 613 phindcgi_address = parameterValue("library")+parameterValue("phindcgi"); 614 phindcgi_address = tidy_URL(phindcgi_address, true); 615 System.out.println("Phind phindcgi: " + phindcgi_address); 616 584 617 585 618 // Is there a default search term? … … 786 819 searchButton = new Button("Search"); 787 820 searchButton.setFont(boldFont); 821 //searchButton.setEnabled(true); 822 searchButton.addActionListener(this); 788 823 p1.add(searchButton); 789 824 … … 794 829 wordField = new TextField(12); 795 830 wordField.setFont(boldFont); 831 wordField.addActionListener(this); 796 832 p1.add(wordField); 797 833 … … 801 837 prevButton = new Button("Previous"); 802 838 prevButton.setFont(boldFont); 803 prevButton.disable(); 839 prevButton.addActionListener(this); 840 prevButton.setEnabled(false); 804 841 805 842 p1.add(prevButton); … … 807 844 nextButton = new Button(" Next "); 808 845 nextButton.setFont(boldFont); 809 nextButton.disable(); 846 nextButton.addActionListener(this); 847 nextButton.setEnabled(false); 810 848 p1.add(nextButton); 811 849 … … 818 856 void enableSearchButton() { 819 857 if (showControlPanel) { 820 searchButton. enable();858 searchButton.setEnabled(true); 821 859 } 822 860 } 823 861 void disableSearchButton() { 824 862 if (showControlPanel) { 825 searchButton. disable();863 searchButton.setEnabled(false); 826 864 } 827 865 } … … 847 885 if (c.getClass().getName().endsWith("ResultBox")) { 848 886 if (((ResultBox) c).prevBoxExists()) { 849 prevButton. enable();887 prevButton.setEnabled(true); 850 888 } else { 851 prevButton. disable();889 prevButton.setEnabled(false); 852 890 } 853 891 } … … 856 894 if (c.getClass().getName().endsWith("ResultBox")) { 857 895 if (((ResultBox) c).nextBoxExists()) { 858 nextButton. enable();896 nextButton.setEnabled(true); 859 897 } else { 860 nextButton. disable();898 nextButton.setEnabled(false); 861 899 } 862 900 } … … 882 920 for (int i = 1 ; ((i <= depth) && (b != null)); i++) { 883 921 lastDisplay.display(b); 884 b. resize(b.display.size());922 b.setSize(b.display.getSize()); 885 923 b.paintAll(b.getGraphics()); 886 924 b = b.next; … … 913 951 for (int i = 1 ; ((i <= depth) && (b != null)); i++) { 914 952 lastDisplay.display(b); 915 b. resize(b.display.size());953 b.setSize(b.display.getSize()); 916 954 b.paintAll(b.getGraphics()); 917 955 b = b.next; -
trunk/gsdl3/src/java/org/greenstone/applet/phind/PhindTitle.java
r3391 r3444 57 57 58 58 public void paint(Graphics g) { 59 Dimension canvasSize = size();59 Dimension canvasSize = getSize(); 60 60 61 61 Color fore = phind.panel_fg; -
trunk/gsdl3/src/java/org/greenstone/applet/phind/ResultBox.java
r3391 r3444 45 45 46 46 import java.awt.Label; 47 import java.awt.Event; 48 47 import java.awt.AWTEvent; 48 import java.awt.event.AdjustmentListener; 49 import java.awt.event.AdjustmentEvent; 49 50 import java.net.*; 50 51 import java.applet.*; … … 57 58 import org.greenstone.gsdl3.util.*; 58 59 59 public class ResultBox extends Panel { 60 public class ResultBox extends Panel 61 implements AdjustmentListener { 60 62 61 63 // Objects at a "higher" level than this one … … 137 139 s = new Scrollbar(Scrollbar.VERTICAL); 138 140 disableScrollbar(); 141 s.addAdjustmentListener(this); 139 142 add("East", s); 140 143 … … 183 186 if (s.isEnabled()) { 184 187 s.setValues(0, 1, 0, 1); 185 s.set LineIncrement(1);186 s.set PageIncrement(1);187 s. disable();188 s.setUnitIncrement(1); 189 s.setBlockIncrement(1); 190 s.setEnabled(false); 188 191 } 189 192 } … … 207 210 } 208 211 209 public boolean handleEvent(Event event) {212 /* public void processEvent(AWTEvent event) { 210 213 // System.out.println("event: " + event.toString()); 211 214 if ( (event.target == s) && … … 216 219 (event.id == Event.SCROLL_PAGE_UP) ) ) { 217 220 c.repaint(); 218 return true;221 219 222 } else { 220 return super.handleEvent(event); 221 } 222 } 223 super.processEvent(event); 224 } 225 } */ 226 227 public void adjustmentValueChanged(AdjustmentEvent evt) { 228 c.repaint(); 229 } 223 230 224 231 void parseXML(Element data) { 225 232 226 System.out.println("phinddata:"+data.toString());233 //System.out.println("phinddata:"+data.toString()); 227 234 228 235 //String id="", phrase=""; … … 271 278 e = (Element)e.getNextSibling(); 272 279 } 273 280 // finished parsing, update the getMoreDocs markers 281 c.updateMarkers(); 274 282 } 275 283 -
trunk/gsdl3/src/java/org/greenstone/applet/phind/ResultCanvas.java
r3391 r3444 52 52 import java.util.Vector; 53 53 import java.awt.Image; 54 import java.awt.Event; 55 54 //import java.awt.Event; 55 import java.awt.event.MouseListener; 56 import java.awt.event.MouseEvent; 57 import java.awt.event.MouseAdapter; 56 58 import java.net.URL; 57 59 import java.applet.Applet; … … 59 61 60 62 public class ResultCanvas extends Canvas { 63 61 64 62 65 // Other objects associated with this … … 100 103 backgroundImage = p.phind.backgroundImage; 101 104 } 105 106 // add a mouse listener for the mouse clicks. we only want to override 107 // one method, so we use the adaptor class 108 addMouseListener(new MouseAdapter() { 109 public void mouseClicked(MouseEvent evt) { 110 ResultCanvas.this.mouseClicked(evt); 111 } 112 }); 113 102 114 103 115 } … … 142 154 void updateMorePhrasesMarker() { 143 155 144 //System.out.println("updateMorePhrasesMarker() ");145 156 System.out.println("updateMorePhrasesMarker() "); 157 System.out.println("expansions retrieved = "+parent.expansionsRetrieved +" num expansions = "+parent.numberOfExpansions); 146 158 // look for a marker 147 159 boolean found = false; … … 250 262 251 263 // Note: the size() method is deprecated, but getSize fails in NetScape 4 252 // Dimension canvasSize = getSize(); 253 Dimension canvasSize = size(); 254 264 Dimension canvasSize = getSize(); 265 255 266 g.setFont(areaPlain); 256 267 int space = g.getFontMetrics().stringWidth(" "); … … 454 465 // setBlockIncrement(), but the latter doesn't work on some 455 466 // browsers. Damn. 456 //scrollbar.setBlockIncrement(visible - 1);457 scrollbar.setPageIncrement(visible - 1);467 scrollbar.setBlockIncrement(visible - 1); 468 //scrollbar.setPageIncrement(visible - 1); 458 469 // Deprecated - more nonsense: enable() has been replaced by 459 470 // setEnabled(true), but this doesn't work on some browsers. 460 //scrollbar.setEnabled(true);461 scrollbar.enable();471 scrollbar.setEnabled(true); 472 //scrollbar.enable(); 462 473 } 463 474 … … 469 480 } 470 481 } 482 483 // handle mouse clicks in the new way. just copy gordons thing for now 484 public void mouseClicked(MouseEvent event) { 485 486 // ignore actions that occur within 1 second of the last 487 Date now = new Date(); 488 // System.out.println("Click time: " + now.toString()); 489 if (now.getTime() < (phind.lastQueryEndTime.getTime() + 1000)) { 490 System.out.println("Ignoring click - too close to last query."); 491 return; 492 } 493 494 // which Item is selected? 495 int rowSelected = event.getY() / lineSpacing; 496 itemSelected = rowSelected + firstItemDisplayed; 497 ResultItem item = (ResultItem) items.elementAt(itemSelected); 498 499 if (itemSelected <= numberOfItems) { 500 501 //User clicks on a phrase 502 if (item.isPhrase()) { 503 itemSelected = itemSelected; 504 update(getGraphics()); 505 parent.lookupPhrase(item.hiddenText(), item.toString(), 2); 506 507 // If meta key is held down, send query to search engine 508 /*if (event.metaDown() && !phind.library_address.equals("")) { 509 String address = phind.library_address 510 + "a=q&sa=text&c=" + phind.collection 511 + "&q=%22" + item.toString().replace(' ', '+') + "%22"; 512 phind.displayWebPage(address, phind.searchWindowName); 513 }*/ 514 } 515 516 // Click on a thesaurus link 517 else if (item.isLink()) { 518 itemSelected = itemSelected; 519 update(getGraphics()); 520 parent.lookupPhrase(item.hiddenText(), item.toString(), 2); 521 522 // If meta key is held down, send query to search engine 523 /*if (event.metaDown() && !phind.library_address.equals("")) { 524 String address = phind.library_address 525 + "a=q&sa=text&c=" + phind.collection 526 + "&q=%22" + item.toString().replace(' ', '+') + "%22"; 527 phind.displayWebPage(address, phind.searchWindowName); 528 }*/ 529 } 530 531 // The user clicks on a URL; display it. 532 else if (item.isDocument()) { 533 itemSelected = itemSelected; 534 update(getGraphics()); 535 536 String address = phind.library_address 537 + "a=r&c=" + phind.collection 538 + "&r=" + item.hiddenText() 539 + "&q=" + parent.searchPhrase.replace(' ', '+'); 540 541 phind.displayWebPage(address, phind.documentWindowName); 542 } 543 544 // When the user clicks on "get more phrases" or other marker, 545 // we have to send a new query to the host 546 else if (item.isMorePhrases()){ 547 parent.lookupPhrase(parent.searchKey, parent.searchPhrase, 3); 548 } else if (item.isMoreDocuments()){ 549 parent.lookupPhrase(parent.searchKey, parent.searchPhrase, 4); 550 } else if (item.isMoreLinks()){ 551 parent.lookupPhrase(parent.searchKey, parent.searchPhrase, 5); 552 553 554 } 555 repaint(); 556 } 557 } 558 471 559 472 560 // User interaction … … 475 563 // is handles in this method. Note we ignore clicks that follow 476 564 // another too closely to avoid problems with slow connections. 477 public boolean handleEvent(Event event) {565 /* public boolean processEvent(Event event) { 478 566 479 567 if (event.id == Event.MOUSE_UP) { … … 552 640 } 553 641 return true; 554 }642 } */ 555 643 556 644 } -
trunk/gsdl3/src/java/org/greenstone/applet/phind/ResultTitle.java
r3391 r3444 47 47 48 48 public class ResultTitle extends Canvas { 49 50 // Other objects associated with this 51 Phind phind; 52 ResultBox parent; 53 ResultCanvas canvas; 49 54 50 // Other objects associated with this 51 Phind phind; 52 ResultBox parent; 53 ResultCanvas canvas; 54 55 // fonts and font spacings to use 56 Font plain, bold; 57 Graphics g; 58 59 // Create a ResultTitle from the ResultBox which is its parent. 60 ResultTitle(ResultBox p) { 61 62 parent = p; 63 phind = p.phind; 64 canvas = p.c; 65 g = getGraphics(); 66 67 plain = phind.plainFont; 68 bold = phind.boldFont; 55 // fonts and font spacings to use 56 Font plain, bold; 57 Graphics g; 69 58 70 // Note: the size() and resize() methods are deprecated, but the newer 71 // getSize() and setSize() methods fail in NetScape 4 72 //Dimension d = getSize(); 73 Dimension d = size(); 74 d.height = phind.fontSize + 10; 75 //setSize(d); 76 resize(d); 59 // Create a ResultTitle from the ResultBox which is its parent. 60 ResultTitle(ResultBox p) { 61 62 parent = p; 63 phind = p.phind; 64 canvas = p.c; 65 g = getGraphics(); 66 67 plain = phind.plainFont; 68 bold = phind.boldFont; 69 70 // Note: the size() and resize() methods are deprecated, but the newer 71 // getSize() and setSize() methods fail in NetScape 4 72 Dimension d = getSize(); 73 d.height = phind.fontSize + 10; 74 setSize(d); 75 76 77 } 77 78 78 } 79 80 public void update(Graphics g) { 81 paint(g); 82 } 83 84 public void paint(Graphics g) { 85 86 // calculate the canvas size, margins, and spacing 87 Dimension canvasSize = size(); 79 public void update(Graphics g) { 80 paint(g); 81 } 88 82 89 g.setFont(plain); 90 int margin = g.getFontMetrics().stringWidth(" 8888 "); 91 int y = phind.fontSize + 5; 92 93 int rightMargin = canvas.size().width; 94 int secondColumn = rightMargin - margin; 95 int firstColumn = secondColumn - margin; 96 97 g.setColor(Color.white); 98 g.fillRect(0, 0, canvasSize.width, canvasSize.height); 99 g.setColor(Color.black); 100 101 102 // What is the phrase we are searching for? 103 String phrase = parent.searchPhrase.replace('+', ' '); 104 105 // Construct the description phrase 106 String links = ""; 107 if (parent.numberOfThesaurusLinks <= 0) { 108 links = ""; 109 } else if (parent.numberOfThesaurusLinks == 1) { 110 links = "1 link"; 111 } else if (parent.thesaurusLinksRetrieved == parent.numberOfThesaurusLinks) { 112 links = parent.numberOfThesaurusLinks + " links"; 113 } else { 114 links = parent.thesaurusLinksRetrieved + " of " 115 + parent.numberOfThesaurusLinks + " links"; 83 public void paint(Graphics g) { 84 85 // calculate the canvas size, margins, and spacing 86 Dimension canvasSize = getSize(); 87 88 g.setFont(plain); 89 int margin = g.getFontMetrics().stringWidth(" 8888 "); 90 int y = phind.fontSize + 5; 91 92 int rightMargin = canvas.getSize().width; 93 int secondColumn = rightMargin - margin; 94 int firstColumn = secondColumn - margin; 95 96 g.setColor(Color.white); 97 g.fillRect(0, 0, canvasSize.width, canvasSize.height); 98 g.setColor(Color.black); 99 100 101 // What is the phrase we are searching for? 102 String phrase = parent.searchPhrase.replace('+', ' '); 103 104 // Construct the description phrase 105 String links = ""; 106 if (parent.numberOfThesaurusLinks <= 0) { 107 links = ""; 108 } else if (parent.numberOfThesaurusLinks == 1) { 109 links = "1 link"; 110 } else if (parent.thesaurusLinksRetrieved == parent.numberOfThesaurusLinks) { 111 links = parent.numberOfThesaurusLinks + " links"; 112 } else { 113 links = parent.thesaurusLinksRetrieved + " of " 114 + parent.numberOfThesaurusLinks + " links"; 115 } 116 117 String expansions = ""; 118 if (parent.numberOfExpansions <= 0) { 119 expansions = "no phrases"; 120 } else if (parent.numberOfExpansions == 1) { 121 expansions = "1 phrase"; 122 } else if (parent.expansionsRetrieved == parent.numberOfExpansions) { 123 expansions = parent.numberOfExpansions + " phrases"; 124 } else { 125 expansions = parent.expansionsRetrieved + " of " 126 + parent.numberOfExpansions + " phrases"; 127 } 128 129 String documents = ""; 130 if (parent.numberOfDocuments <= 0) { 131 documents = "no documents"; 132 } else if (parent.documentsRetrieved == 1) { 133 documents = "1 document"; 134 } else if (parent.documentsRetrieved == parent.numberOfDocuments) { 135 documents = parent.numberOfDocuments + " documents"; 136 } else { 137 documents = parent.documentsRetrieved + " of " 138 + parent.numberOfDocuments + " documents"; 139 } 140 141 String status = "("; 142 if (parent.numberOfThesaurusLinks > 0) { 143 status = status + links + ", "; 144 } 145 status = status + expansions + ", " + documents + ")"; 146 147 148 // Draw the text 149 g.setFont(bold); 150 g.drawString(phrase, 0, y); 151 int tab = g.getFontMetrics().stringWidth(phrase + " "); 152 153 g.setFont(plain); 154 g.drawString(status, tab, y); 155 tab = tab + g.getFontMetrics().stringWidth(status); 156 157 if (tab < firstColumn) { 158 g.drawString("docs", firstColumn, y); 159 g.drawString("freq", secondColumn, y); 160 } 116 161 } 117 118 String expansions = "";119 if (parent.numberOfExpansions <= 0) {120 expansions = "no phrases";121 } else if (parent.numberOfExpansions == 1) {122 expansions = "1 phrase";123 } else if (parent.expansionsRetrieved == parent.numberOfExpansions) {124 expansions = parent.numberOfExpansions + " phrases";125 } else {126 expansions = parent.expansionsRetrieved + " of "127 + parent.numberOfExpansions + " phrases";128 }129 130 String documents = "";131 if (parent.numberOfDocuments <= 0) {132 documents = "no documents";133 } else if (parent.documentsRetrieved == 1) {134 documents = "1 document";135 } else if (parent.documentsRetrieved == parent.numberOfDocuments) {136 documents = parent.numberOfDocuments + " documents";137 } else {138 documents = parent.documentsRetrieved + " of "139 + parent.numberOfDocuments + " documents";140 }141 142 String status = "(";143 if (parent.numberOfThesaurusLinks > 0) {144 status = status + links + ", ";145 }146 status = status + expansions + ", " + documents + ")";147 148 149 // Draw the text150 g.setFont(bold);151 g.drawString(phrase, 0, y);152 int tab = g.getFontMetrics().stringWidth(phrase + " ");153 154 g.setFont(plain);155 g.drawString(status, tab, y);156 tab = tab + g.getFontMetrics().stringWidth(status);157 158 if (tab < firstColumn) {159 g.drawString("docs", firstColumn, y);160 g.drawString("freq", secondColumn, y);161 }162 }163 162 }
Note:
See TracChangeset
for help on using the changeset viewer.