Package java.text

Examples of java.text.DecimalFormat


     */
    public Object clone() {
        OMDistance clone = (OMDistance) super.clone();
        clone.labels = new OMGraphicList();
        clone.points = new OMGraphicList();
        clone.df = new DecimalFormat("0.#");
        return clone;
    }
View Full Code Here


        _leos.writeByte(0); // Byte 31 Reserved Bytes(0) #31
    }

    public void writeRecords(DbfTableModel model) throws IOException {

        DecimalFormat df = new DecimalFormat();
        DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.ENGLISH);
        df.setDecimalFormatSymbols(dfs);
        df.setGroupingUsed(false);
       
        int rowCount = model.getRowCount();
        int columnCount = model.getColumnCount();
        for (int r = 0; r <= rowCount - 1; r++) {
            _leos.writeByte(32);
            for (int c = 0; c <= columnCount - 1; c++) {
                byte type = model.getType(c);
                int columnLength = model.getLength(c);
                int numDecSpaces = model.getDecimalCount(c);
                df.setMaximumFractionDigits(numDecSpaces);
                df.setGroupingUsed(false);
                String value = DbfTableModel.getStringForType(model.getValueAt(r, c),
                        type,
                        df, columnLength);

                int length = model.getLength(c);
View Full Code Here

    public void readData() throws IOException {

        // Thanks to Bart Jourquin for the heads-up that some locales
        // may try to read this data incorrectly. DBF files have to
        // have '.' as decimal markers, not ','
        DecimalFormat df = new DecimalFormat();
        DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.ENGLISH);
        df.setDecimalFormatSymbols(dfs);

        _leis.skipBytes(2);
        _records = new ArrayList(_rowCount);
        for (int r = 0; r <= _rowCount - 1; r++) {
            ArrayList record = new ArrayList(_columnCount);
            for (int c = 0; c <= _columnCount - 1; c++) {
                int length = _lengths[c];
                if (length == -1)
                    length = 255;
                int type = _types[c];
                int numDecSpaces = _decimalCounts[c];
                df.setMaximumFractionDigits(numDecSpaces);
                String cell = _leis.readString(length);
                try {
                    record.add(c,
                            DbfTableModel.getObjectForType(cell, type, df, length));
                } catch (ParseException pe) {
View Full Code Here

        else
        {
          effectiveFormatString = formatString;
        }
        lastLocale = localeUsed;
        decimalFormat = new DecimalFormat(effectiveFormatString);
        activateBigDecimalMode(decimalFormat);
        decimalFormat.setDecimalFormatSymbols(new DecimalFormatSymbols(localeUsed));
      }

      return decimalFormat.parse(String.valueOf(o));
View Full Code Here

   
    file_size_slider.addModifyListener(new ExSliderModifyListener() {

      public void downValueChanged(double downValue) {
        updated_file_size = true;
        DecimalFormat formatter = new DecimalFormat("0.00");
       
        downValue = Math.round(downValue);
        double u = 1024 / 100D;
       
        min_file_size.setText(formatter.format(u * downValue));
       
      }

      public void upValueChanged(double upValue) {
        updated_file_size = true;
        DecimalFormat formatter = new DecimalFormat("0.00");
       
        upValue = Math.round(upValue);
        double u = 1024 / 100D;
       
        max_file_size.setText(formatter.format(u * upValue));
      }
    });
       
    Composite options_composite = new Composite(shell,SWT.NONE);
    layout_data = new GridData();
    layout_data.grabExcessHorizontalSpace = true;
    layout_data.horizontalAlignment = GridData.FILL;
    options_composite.setLayoutData(layout_data);
    options_composite.setLayout(new GridLayout(4,false));
   
    label = new Label(options_composite,SWT.NONE);
    label.setText("File type : ");
    layout_data = new GridData();
    layout_data.horizontalAlignment = SWT.RIGHT;
    label.setLayoutData(layout_data);
   
    file_type = new Combo(options_composite,SWT.READ_ONLY);
    // must be same order as filetypes
    file_type.add(_._("advancedsearchwindow.file_type.any"));
    file_type.add(_._("advancedsearchwindow.file_type.archive"));
    file_type.add(_._("advancedsearchwindow.file_type.audio"));
    file_type.add(_._("advancedsearchwindow.file_type.cd_image"));
    file_type.add(_._("advancedsearchwindow.file_type.document"));
    file_type.add(_._("advancedsearchwindow.file_type.pictures"));
    file_type.add(_._("advancedsearchwindow.file_type.program"));
    file_type.add(_._("advancedsearchwindow.file_type.video"));
   
    file_type.select(0);
    file_type.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout_data = new GridData();
    file_type.setLayoutData(layout_data);
       
    label = new Label(options_composite,SWT.NONE);
    label.setText(_._("advancedsearchwindow.label.extension") + " : ");
    layout_data = new GridData();
    layout_data.horizontalAlignment = SWT.RIGHT;
    label.setLayoutData(layout_data);
   
    file_extension = new Text(options_composite,SWT.BORDER);
   
    label = new Label(options_composite,SWT.NONE);
    label.setText(_._("advancedsearchwindow.label.availability") + " : ");
    layout_data = new GridData();
    layout_data.horizontalAlignment = SWT.RIGHT;
    label.setLayoutData(layout_data);
   
    av_spinner = new Spinner(options_composite,SWT.BORDER);
    av_spinner.setMaximum(1000);
   
    label = new Label(options_composite,SWT.NONE);
    label.setText(_._("advancedsearchwindow.label.complete_sources") + " : ");
    layout_data = new GridData();
    layout_data.horizontalAlignment = SWT.RIGHT;
    label.setLayoutData(layout_data);
    cmp_src_spinner = new Spinner(options_composite,SWT.BORDER);
    cmp_src_spinner.setMaximum(1000);
   
   
    Composite button_composite = new Composite(shell,SWT.BORDER);
    layout_data = new GridData();
    layout_data.verticalAlignment = GridData.END;
    layout_data.horizontalAlignment = GridData.FILL;
    layout_data.grabExcessHorizontalSpace = true;
    layout_data.grabExcessVerticalSpace=true;
    button_composite.setLayoutData(layout_data);
   
    layout = new GridLayout(3,false);
    button_composite.setLayout(layout);
   
    Button button_clear = new Button(button_composite,SWT.NONE);
    button_clear.setText(_._("advancedsearchwindow.button.clear"));
    button_clear.setImage(SWTImageRepository.getImage("remove_all.png"));
    button_clear.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        min_file_size.setText("0.0");
        min_file_size_units.select(0);
       
        max_file_size.setText("1024.00");
        max_file_size_units.select(0);
       
        file_extension.setText("");
        file_type.select(0);
       
        av_spinner.setSelection(0);
        cmp_src_spinner.setSelection(0);
       
        updated_file_size = false;
      }
    });
   
    Button button_ok = new Button(button_composite,SWT.NONE);
    button_ok.setText(_._("advancedsearchwindow.button.ok"));
    button_ok.setImage(skin.getButtonImage(Skin.OK_BUTTON_IMAGE));
   
    layout_data = new GridData();
    layout_data.grabExcessHorizontalSpace=true;
    layout_data.horizontalAlignment = SWT.RIGHT;
    button_ok.setLayoutData(layout_data);
   
    button_ok.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        long min_unit = (Long)min_file_size_units.getData(min_file_size_units.getText());
        long max_unit = (Long)max_file_size_units.getData(max_file_size_units.getText());
        double min = formatSize(file_size_slider.getDownValue(), min_unit);
        double max = formatSize(file_size_slider.getUpValue(), max_unit);
        if (updated_file_size)
          save((long)min, (long)max, file_types[file_type.getSelectionIndex()],file_extension.getText(), av_spinner.getSelection(), cmp_src_spinner.getSelection());
        else
          save((long)0, (long)0, file_types[file_type.getSelectionIndex()],file_extension.getText(), av_spinner.getSelection(), cmp_src_spinner.getSelection());
        shell.close();
      }
    });
   
    Button button_cancel = new Button(button_composite,SWT.NONE);
    button_cancel.setText(_._("advancedsearchwindow.button.cancel"));
    button_cancel.setImage(skin.getButtonImage(Skin.CANCEL_BUTTON_IMAGE));
    button_cancel.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent arg0) {
        shell.close();
      }
    });
   
    Utils.centreWindow(shell);
    shell.open();
   
    // initialization
   
    DecimalFormat formatter = new DecimalFormat("0.00");
   
    min_file_size.setText(formatter.format(min));
    max_file_size.setText(formatter.format(max));
   
    min_file_size_units.select(initial_min_size_units);
    max_file_size_units.select(initial_max_size_units);
   
    file_extension.setText(initial_extension);
View Full Code Here

      if (isDisposed()) return;
      String text = _._("mainwindow.sharedtab.group.shared_files");
      SharedFile hashing_file = sharing_manager.getCurrentHashingFile();
      if (hashing_file != null) {
        text +=" Hashing [";
        DecimalFormat formatter = new DecimalFormat("0.00");
        String file_name = hashing_file.getSharingName();
        if (file_name.length()>20)
          file_name = file_name.substring(0, 20) + "...";
        text +=file_name+" : " + formatter.format(sharing_manager.getCurrentHashingFilePercent())+"%";
        text +="]";
      }
 
      shared_files_group.setText(text);
   
View Full Code Here

    setRowImage(session, SWTConstants.DOWNLOAD_LIST_FILE_NAME_COLUMN_ID, image);
    setRowText(session,  SWTConstants.DOWNLOAD_LIST_FILE_NAME_COLUMN_ID, file_name);
    setRowText(session,  SWTConstants.DOWNLOAD_LIST_SIZE_COLUMN_ID, FileFormatter.formatFileSize(session.getFileSize()));
    setRowText(session,  SWTConstants.DOWNLOAD_LIST_TRANSFERRED_COLUMN_ID, FileFormatter.formatFileSize(session.getTransferredBytes()));
   
    DecimalFormat formatter = new DecimalFormat("0.00");
    setRowText(session,  SWTConstants.DOWNLOAD_LIST_COMPLETED_COLUMN_ID, formatter.format(session.getPercentCompleted())+"%");
   
    String speed = SpeedFormatter.formatSpeed(session.getSpeed());
    setRowText(session,  SWTConstants.DOWNLOAD_LIST_DOWNLOAD_SPEED_COLUMN_ID,speed);
   
    FileHash file_hash = session.getFileHash();
View Full Code Here

   private Timeout timeout;
   private DecimalFormat format;
   private String formatTxt = "000000";
  
   public ReplicationDumper() {
      format = new DecimalFormat(formatTxt);
   }
View Full Code Here

    facetHandlers.add(new RangeFacetHandler("timeinmillis", new PredefinedTermListFactory(Long.class, DynamicTimeRangeFacetHandler.NUMBER_FORMAT),null));
    Directory idxDir = new RAMDirectory();
    IndexWriter writer = new IndexWriter(idxDir,new StandardAnalyzer(Version.LUCENE_29),MaxFieldLength.UNLIMITED);
   
    long now = System.currentTimeMillis();
    DecimalFormat df = new DecimalFormat(DynamicTimeRangeFacetHandler.NUMBER_FORMAT);
    for(long l=0; l<53; l++)
    {
      Document d = new Document();
      d.add(buildMetaField("timeinmillis", df.format(now - l*3500000)));
      writer.addDocument(d);
      writer.optimize();
      writer.commit();
    }
    IndexReader idxReader = IndexReader.open(idxDir,true);
View Full Code Here

    BigDecimal oDec = getDecimal(sKey);

    if (oDec==null)
      return null;
    else {
      return new DecimalFormat(sPattern).format(oDec.doubleValue());
    }
  } // getDecimalFormated
View Full Code Here

TOP

Related Classes of java.text.DecimalFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.