Changeset 1841


Ignore:
Timestamp:
2001-01-16T18:04:02+13:00 (23 years ago)
Author:
paynter
Message:

Added ability to control result order, and paramers so you can set this and
border visibility from the HTML page.

Location:
trunk/gsdl/src/phind/client
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/phind/client/Phind.java

    r1832 r1841  
    2929/*********************************************************************
    3030
    31 To use the applet, you'll need to embed it in a web page as follows:
     31To use the applet, you'll need to embed it in a web page like this:
    3232
    3333<APPLET CODE="Phind.class" WIDTH=500 HEIGHT=500>
    3434
     35  <PARAM NAME=collection  VALUE="fao.org">
    3536  <PARAM NAME=phindcgi    VALUE="http://kowhai/cgi-bin/phindcgi">
    3637  <PARAM NAME=library     VALUE="http://kowhai/cgi-bin/library">
    37 
    3838  <PARAM NAME=backdrop    VALUE="http://kowhai/~paynter/transfer/phindtest/green1.jpg">
    39 
    40   <PARAM NAME=collection  VALUE="fao.org">
    41 
    42   <PARAM NAME=orientation VALUE="vertical">
    43   <PARAM NAME=depth       VALUE="2">
    44   <PARAM NAME=blocksize   VALUE="10">
    45 
    46   <PARAM NAME=fontsize    VALUE="12">
    4739  The Phind java applet.
    4840</APPLET>
     41
     42There are a bunch of other parameters; these are described in the
     43getParameters method below.  It is all done for you in Greenstone
     44in the document.dm macro file (the _phindapplet_ macro).
    4945
    5046You may have problems with Java applet security.  Java applet's can only
     
    126122    public String backdrop_address;
    127123    public Image backgroundImage;
     124    public boolean showBorder;
    128125
    129126    // Colours
     
    582579    }
    583580
     581    // Should we draw a border?
     582    showBorder = parameterValue("border", "on").equals("off");
     583
    584584    // Are the windows arranged vertically or horizontally
    585585    if (parameterValue("orientation", "vertical").toLowerCase().startsWith("hori")) {
     
    588588        vertical = true;
    589589    }
    590 
     590   
    591591    // How many phind windows are there?
    592592    depth = parameterValue("depth", 3);
     593
     594    // Result sort order
     595    // Standard is "LlEeDd", expansion-first is "EeLlDd"
     596    String order = parameterValue("resultorder", "standard");
     597    if (!order.equals("standard")) {
     598        int next = 20;
     599        ResultItem.sortMessage = next;
     600        for (int x = 0; x < order.length(); x++) {
     601        if (order.charAt(x) == ',') {
     602            next--;
     603        } else if (order.charAt(x) == 'L') {
     604            ResultItem.sortLinkItem = next;
     605        } else if (order.charAt(x) == 'l') {
     606            ResultItem.sortMoreLinks = next;
     607        } else if (order.charAt(x) == 'E') {
     608            ResultItem.sortPhraseItem = next;
     609        } else if (order.charAt(x) == 'e') {
     610            ResultItem.sortMorePhrases = next;
     611        } else if (order.charAt(x) == 'D') {
     612            ResultItem.sortDocumentItem = next;
     613        } else if (order.charAt(x) == 'd') {
     614            ResultItem.sortMoreDocuments = next;
     615        }
     616        }
     617        System.out.println("link: " + ResultItem.sortLinkItem);
     618        System.out.println("exps: " + ResultItem.sortPhraseItem);
     619        System.out.println("docs: " + ResultItem.sortDocumentItem);
     620
     621    }
    593622
    594623    // How many phrases should we fetch at any given time?
  • trunk/gsdl/src/phind/client/ResultBox.java

    r1830 r1841  
    232232    buffer = buffer.concat(input);
    233233
    234     // if buffer ends with "</phinddata>" then we are finished reading
    235     finished = buffer.endsWith("</phinddata>\n");
    236 
    237234    // Parse each line until there are no more lines to parse
    238235    while(parseLine());
     
    240237    if (finished) {
    241238        c.updateMarkers();
     239        buffer = "";
    242240    } else {
    243241        // We haven't finished, give some feedback about progress
     
    256254    boolean parseLine() {
    257255
    258         // System.out.println("parseLine " + finished + "(" + expansionsRetrieved + ")");
     256        // System.out.print("parseLine " + "(length " + buffer.length() + ")");
    259257    String item;
    260258    int eol = buffer.indexOf((int) '\n');
     
    265263    }
    266264
     265    // The </phinddata> tag concludes the dataset
     266    else if (buffer.startsWith("</phinddata>")) {
     267        mode = finishedMode;
     268        finished = true;
     269        return false;
     270    }
     271   
    267272    // The <expansion> tag
    268273    else if (buffer.startsWith("<expansion ")) {
     
    297302    }
    298303
    299     // The </phinddata> tag concludes the dataset
    300     else if (buffer.startsWith("</phinddata>")) {
    301         mode = finishedMode;
    302         return false;
    303     }
    304    
    305304    // The <phinderror> tag contains an error message
    306305    else if (buffer.startsWith("<phinderror")) {
  • trunk/gsdl/src/phind/client/ResultCanvas.java

    r1832 r1841  
    118118    int index = 0;
    119119    while ((index < numberOfItems) &&
    120            ((item.kind > ((ResultItem) items.elementAt(index)).kind) ||
    121         ((item.kind == ((ResultItem) items.elementAt(index)).kind) &&
     120           ((item.sort < ((ResultItem) items.elementAt(index)).sort) ||
     121        ((item.sort == ((ResultItem) items.elementAt(index)).sort) &&
    122122         (item.frequency <= ((ResultItem) items.elementAt(index)).frequency)))) {
    123123        index++;
     
    461461
    462462   
    463     g.setColor(phind.panel_fg);
    464     g.drawRect(0,0, canvasSize.width - 1, canvasSize.height - 1);
    465     }
    466 
     463    // draw the border
     464    if (phind.showBorder) {
     465        g.setColor(phind.panel_fg);
     466        g.drawRect(0,0, canvasSize.width - 1, canvasSize.height - 1);
     467    }
     468    }
    467469
    468470    // User interaction
  • trunk/gsdl/src/phind/client/ResultItem.java

    r1833 r1841  
    4040public class ResultItem {
    4141
    42     // There are several kinds of ResultItem
    43     //   1. a phrase (expansion)
    44     //   2. a "get more phrases" marker
    45     //   3. a document (or URL)
    46     //   4. a "get more documents" marker
    47     //   5. a thesaurus link
    48     //   6. a "get more thesaurus links" marker
    49 
    50     final static int linkItem = 1;
    51     final static int moreLinks = 2;
    52     final static int phraseItem = 3;
    53     final static int morePhrases = 4;
    54     final static int documentItem = 5;
    55     final static int moreDocuments = 6;
    56     final static int unknownResultItem = 9;
    57 
    5842    // A text string describing the item
    5943    String text = "Generic ResultItem";
     44
     45    // There are several kinds of ResultItem, identified by their
     46    // "kind" field, which has an integer value from the list below.
     47    final static int message = 8;
     48    final static int linkItem = 7;
     49    final static int moreLinks = 6;
     50    final static int phraseItem = 5;
     51    final static int morePhrases = 4;
     52    final static int documentItem = 3;
     53    final static int moreDocuments = 2;
     54    final static int unknownResultItem = 1;
    6055
    6156    // The kind of the item
    6257    int kind = unknownResultItem;
    6358
    64     // The frequency of the item
     59    // When results are displayed, they are loosely sorted by their
     60    // kind.  The user can change the sort order numbers with the
     61    // ResultOrder parameter in Phind.java.
     62    static int sortMessage = 8;
     63    static int sortLinkItem = 7;
     64    static int sortMoreLinks = 6;
     65    static int sortPhraseItem = 5;
     66    static int sortMorePhrases = 4;
     67    static int sortDocumentItem = 3;
     68    static int sortMoreDocuments = 2;
     69    static int sortUnknownResultItem = 1;
     70
     71    // the primary sort key
     72    int sort = 0;
     73   
     74    // The frequency of the item (secondary sort key)
    6575    int frequency = 0;
    6676
     
    8090    if (kind == moreLinks) {
    8191        text = "get more thesaurus links";
     92        sort = sortMoreLinks;
    8293    } else if (kind == morePhrases) {
    8394        text = "get more phrases";
     95        sort = sortMorePhrases;
    8496    } else if (kind == moreDocuments) {
    8597        text = "get more documents";
     98        sort = sortMoreDocuments;
    8699    } else {
    87100        text = "Unknown result type";
     101        sort = sortUnknownResultItem;
    88102    }
    89103    }
  • trunk/gsdl/src/phind/client/ResultItemDocument.java

    r1827 r1841  
    4949    kind = documentItem;
    5050    text = newTitle;
     51
     52    sort = sortDocumentItem;
    5153    frequency = Integer.valueOf(newFrequency).intValue();
    5254    hash = newHash;
  • trunk/gsdl/src/phind/client/ResultItemLink.java

    r1832 r1841  
    5959    symbol = Integer.valueOf(newId).intValue();
    6060    text = newText.trim();
     61    sort = sortLinkItem;
    6162    linkType = newLinkType;
    6263    frequency = Integer.valueOf(tf).intValue();
  • trunk/gsdl/src/phind/client/ResultItemPhrase.java

    r1833 r1841  
    6060    symbol = Integer.valueOf(newId).intValue();
    6161
     62    sort = sortPhraseItem;
    6263    frequency = Integer.valueOf(tf).intValue();
    6364    documentFrequency = Integer.valueOf(df).intValue();
     
    6768    suffix = s;
    6869    text = (prefix + " " + body + " " + suffix);
     70
    6971    }
    7072
Note: See TracChangeset for help on using the changeset viewer.