Changeset 3512


Ignore:
Timestamp:
12/28/07 14:13:49 (12 years ago)
Author:
melissa
Message:

Fixed rounding error.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/plugins/browser/CacheIndicator.java

    r3510 r3512  
    7979    if (cacheLength == 0) return; 
    8080 
    81     int pixelsPerIndex = getWidth() / cacheLength; 
    82     if (pixelsPerIndex * cacheLength < getWidth()) pixelsPerIndex++; 
     81    int pixelsPerIndex = (getWidth() - 2) / (cacheLength + 1); 
     82    int remainder = (getWidth() - 2) - (pixelsPerIndex * cacheLength); 
    8383 
    8484    try { 
     
    9393      System.arraycopy(currentPos, 0, pos, 0, pos.length); 
    9494 
     95      int start = 1; 
    9596      for (int i=0; i<cacheLength; i++) { 
    9697        pos[axis] = i; 
     
    120121        else g.setColor(Color.WHITE); 
    121122        int len = pixelsPerIndex; 
    122         if (i == cacheLength - 1) { 
    123           len = getWidth() - i*pixelsPerIndex - 2; 
    124         } 
    125         g.fillRect(i*pixelsPerIndex + 1, 1, len, getHeight() - 2); 
     123        if (i < remainder) len++; 
     124        g.fillRect(start, 1, len, getHeight() - 2); 
     125        start += len; 
    126126      } 
    127127    } 
Note: See TracChangeset for help on using the changeset viewer.