Changeset 3138


Ignore:
Timestamp:
Feb 20, 2007, 8:34:13 AM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #497: Floating point numbers with leading zeroes in the decimal part are not correctly displayed

Also added an option in the File/Preferences?... dialog to allow a user to specify the number
of decimals to display. This solves the 0.004 issue. Another (better) solution would be to make
it possible to specify a default number of decimals to display for each annotation type. But it
requires a lot more work and should be a tast of it's own.

Location:
branches/2.2.2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.2/src/clients/web/net/sf/basedb/clients/web/formatter/FormatterSettings.java

    r2981 r3138  
    8080  {
    8181    sc.setUserClientSetting("formatter.number.decimals", Integer.toString(numDecimals));
    82     sc.setSessionSetting("formatter.number", null);
     82    sc.setSessionSetting("formatter.double", null);
     83    sc.setSessionSetting("formatter.float", null);
    8384  }
    8485 
  • branches/2.2.2/src/core/net/sf/basedb/util/Values.java

    r2981 r3138  
    628628      result.append(lNumber).append(".");
    629629      String theDecimals = Long.toString(Math.round(fNumber*exp-lNumber*exp));
    630       result.append(theDecimals);
    631630      if (theDecimals.length() < decimals)
    632631      {
     
    636635        }
    637636      }
     637      result.append(theDecimals);
    638638    }
    639639    if (unit != null) result.append(unit);
  • branches/2.2.2/www/my_base/user/preferences.jsp

    r2978 r3138  
    390390      </td>
    391391    </tr>
     392    <%
     393    int numDecimals = FormatterSettings.getNumDecimals(sc);
     394    %>
     395    <tr>
     396      <td class="prompt">Decimals</td>
     397      <td>
     398        <select name="decimals">
     399        <%
     400        for (int i = 0; i < 8; i++)
     401        {
     402          %>
     403          <option value="<%=i%>" <%=numDecimals == i ? "selected" : ""%>><%=i%>
     404          <%
     405        }
     406        %>
     407        <option value="-1" <%=numDecimals < 0 ? "selected" : ""%>>all
     408        </select>
     409      </td>
     410    </tr>
    392411   
    393412    </table>
  • branches/2.2.2/www/my_base/user/submit_user.jsp

    r2978 r3138  
    126126    cc.setRecent("dateFormats", dateFormat, maxRecent);
    127127    cc.setRecent("dateTimeFormats", dateTimeFormat, maxRecent);
     128
     129    int numDecimals = Values.getInt(request.getParameter("decimals"), 2);
     130    FormatterSettings.setNumDecimals(sc, numDecimals);
    128131   
    129132    sc.setUserClientSetting("plugins.sendmessage", Values.getString(request.getParameter("sendmessage"), "0"));
Note: See TracChangeset for help on using the changeset viewer.