Changeset 1637 for trunk/gsdl


Ignore:
Timestamp:
2000-10-31T15:22:17+13:00 (24 years ago)
Author:
paynter
Message:

Rearranged paint function so that frequencys do not get written over by
long titles and phrases.

File:
1 edited

Legend:

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

    r1627 r1637  
    227227    int visible = canvasSize.height / lineSpacing;
    228228
    229     //System.out.println("h " + canvasSize.height + ", l "
    230     //         + lineSpacing + ", v " + visible);
    231 
    232229    // get the initial scrollbar setting
    233230    // and calculate the first result to output
     
    239236    }
    240237    firstPhraseDisplayed = scrollValue;
     238
     239    // Draw the phrase area
    241240
    242241    // draw the background
     
    257256    }
    258257   
    259     // First column
    260     g.setColor(new Color(235, 245, 235));
    261     g.fillRect(firstColumn, 0, margin, canvasSize.height);
    262 
    263     // Second column
    264     g.setColor(new Color(200, 220, 200));
    265     g.fillRect(secondColumn, 0, margin, canvasSize.height);
    266     g.setColor(Color.black);
    267 
    268     // if there are no phrases, output a brief explanation.
     258    // If there are no phrases, output a brief explanation.
    269259    if (numberOfPhrases == 0) {
    270260        g.drawString("No phrases match this query.", leftMargin + 10, lineSpacing);
     
    272262
    273263    // Output each of the visible ResultItems
     264    ResultItem result;
    274265    int tab, i, y = 0;
    275     int center = leftMargin + ((rightMargin - leftMargin - g.getFontMetrics().stringWidth(parent.searchPhrase)) / 2);
    276     ResultItem result;
    277 
    278     for (i = scrollValue; (i < numberOfPhrases) && (y + lineSpacing < canvasSize.height); i++) {
     266    int center = leftMargin
     267        + ((rightMargin - leftMargin
     268        - g.getFontMetrics().stringWidth(parent.searchPhrase)) / 2);
     269   
     270    for (i = scrollValue;
     271         (i < numberOfPhrases) && (y + lineSpacing < canvasSize.height); i++) {
    279272
    280273        // Get the resultItem to output
    281274        result = (ResultItem) phrases.elementAt(i);
    282 
     275       
    283276        // Graphics settings for drawing this line
    284277        y += lineSpacing;
     
    292285        }
    293286
    294         // Draw the item - it could be phrase or a URL
    295 
    296         // Write the document frequency
    297         if ((result.documents > 1) || result.isPhrase()) {
    298         g.drawString(" " + Integer.toString(result.documents), firstColumn, y);
    299         }
    300 
    301         // Write the term frequency
    302         if (result.freq > 0) {
    303         g.drawString(" " + Integer.toString(result.freq), secondColumn, y);
    304         }
     287        // Draw the item
    305288
    306289        if (result.isPhrase()) {
     
    346329    }
    347330
    348     // adjust the scrollbar
     331    // Draw the frequecy columns
     332
     333    // column backgrounds
     334    g.setColor(new Color(235, 245, 235));
     335    g.fillRect(firstColumn, 0, margin, canvasSize.height);
     336    g.setColor(new Color(200, 220, 200));
     337    g.fillRect(secondColumn, 0, margin, canvasSize.height);
     338
     339    // fill in the numbers
     340    g.setColor(Color.black);
     341    g.setFont(areaPlain);
     342    y = 0;
     343
     344    for (i = scrollValue;
     345         (i < numberOfPhrases) && (y + lineSpacing < canvasSize.height); i++) {
     346       
     347        // Get the resultItem to output
     348        result = (ResultItem) phrases.elementAt(i);
     349       
     350        // Graphics settings for drawing this line
     351        y += lineSpacing;
     352
     353        // Write the document frequency
     354        if ((result.documents > 1) || result.isPhrase()) {
     355        g.drawString(" " + Integer.toString(result.documents), firstColumn, y);
     356        }
     357
     358        // Write the term frequency
     359        if (result.freq > 0) {
     360        g.drawString(" " + Integer.toString(result.freq), secondColumn, y);
     361        }
     362    }
     363
     364    // Adjust the scrollbar
    349365    if (visible >= numberOfPhrases) {
    350366        parent.disableScrollbar();
Note: See TracChangeset for help on using the changeset viewer.