Examples of NumberFormat


Examples of java.text.NumberFormat

    final int colCount = sheetLayout.getColumnCount();
    final int fullWidth = (int) StrictGeomUtility.toExternalValue(sheetLayout.getMaxWidth());
    final String[] colWidths = new String[colCount];
    final boolean proportionalColumnWidths = isProportionalColumnWidths();
    final NumberFormat pointConverter = styleBuilder.getPointConverter();
    final String unit;

    if (proportionalColumnWidths)
    {
      unit = "%";

      double totalWidth = 0;
      for (int col = 0; col < colCount; col++)
      {
        final int width = (int) StrictGeomUtility.toExternalValue(sheetLayout.getCellWidth(col, col + 1));
        final double colWidth = fixLengthForSafari(Math.max(1, width * 100.0d / fullWidth));
        if (col == colCount - 1)
        {
          colWidths[col] = pointConverter.format(100 - totalWidth);
        }
        else
        {
          totalWidth += colWidth;
          colWidths[col] = pointConverter.format(colWidth);
        }
      }
    }
    else
    {
      unit = "pt";

      double totalWidth = 0;
      for (int col = 0; col < colCount; col++)
      {
        final int width = (int) StrictGeomUtility.toExternalValue(sheetLayout.getCellWidth(col, col + 1));
        final double colWidth = fixLengthForSafari(Math.max(1, width));
        if (col == colCount - 1)
        {
          colWidths[col] = pointConverter.format(fullWidth - totalWidth);
        }
        else
        {
          totalWidth += colWidth;
          colWidths[col] = pointConverter.format(colWidth);
        }
      }
    }

    for (int col = 0; col < colCount; col++)
View Full Code Here

Examples of java.text.NumberFormat

    }
    else if (Number.class.isAssignableFrom(type))
    {
      if (Boolean.TRUE.equals(currency))
      {
        final NumberFormat format = NumberFormat.getCurrencyInstance(context.getLocale());
        if (format instanceof DecimalFormat)
        {
          final DecimalFormat decimalFormat = (DecimalFormat) format;
          return decimalFormat.toPattern();
        }
      }

      final DecimalFormat format = new DecimalFormat();
      if (scale != null && precision != null)
      {
        format.setMaximumFractionDigits(scale.intValue());
        format.setMinimumFractionDigits(scale.intValue());
        format.setMaximumIntegerDigits(precision.intValue() - scale.intValue());
        format.setMinimumIntegerDigits(1);
      }
      return format.toPattern();
    }
    return null;
  }
View Full Code Here

Examples of java.text.NumberFormat

      //insert the gridlines (fake data sets)
      double gridline = gridIntervalIncrement;
      final int columns = defaultDataset.getColumnCount();
      final double maxdata = computeMaxValue(defaultDataset);

      final NumberFormat format = NumberFormat.getPercentInstance(getRuntime().getResourceBundleFactory().getLocale());
      while (gridline <= 100)
      {
        final double gridScaled = maxdata * gridline / 100.0;
        final String gridLineText = format.format(gridline / 100.0);
        final GridCategoryItem rowKey = new GridCategoryItem(gridLineText);
        for (int i = 0; i < columns; i++)
        {
          defaultDataset.addValue(gridScaled, rowKey, defaultDataset.getColumnKey(i));
        }
        gridline = gridline + gridIntervalIncrement;
      }
    }
    else if (gridintervall > 0)
    {
      final int columns = defaultDataset.getColumnCount();
      final double maxdata = computeMaxValue(defaultDataset);
      final double gridIntervalIncrement = gridintervall;
      if ((maxdata / gridIntervalIncrement) > 5000)
      {
        return;
      }

      final NumberFormat format = NumberFormat.getNumberInstance(getRuntime().getResourceBundleFactory().getLocale());
      double gridline = 0;
      while (gridline < maxdata)
      {
        gridline = gridline + gridIntervalIncrement;
        final String gridLineText = format.format(gridline);
        final GridCategoryItem rowKey = new GridCategoryItem(gridLineText);
        for (int i = 0; i < columns; i++)
        {
          defaultDataset.addValue
              (gridline, rowKey, defaultDataset.getColumnKey(i));
View Full Code Here

Examples of java.text.NumberFormat

              else
              {    // not "1e#"-type label
                if (i >= 0)
                {   // if positive exponent then
                  // make integer
                  final NumberFormat format
                      = getNumberFormatOverride();
                  if (format != null)
                  {
                    tickLabel = format.format(tickVal);
                  }
                  else
                  {
                    tickLabel = LogCategoryItemLabelGenerator.formatValue(new Double(tickVal));
                    /*tickLabel = Long.toString((long) Math.rint(tickVal));*/
                  }
                }
                else
                {
                  // negative exponent; create fractional value
                  // set exact number of fractional digits to
                  // be shown:
                  this.numberFormatterObj
                      .setMaximumFractionDigits(-i);
                  // create tick label:
                  tickLabel = this.numberFormatterObj.format(
                      tickVal
                  );
                }
              }
            }
          }
          else
          {   // not first tick to be displayed
            tickLabel = "";     // no tick label
          }
        }
        else
        { // not small log values in use; allow for values <= 0
          if (zeroTickFlag)
          {      // if did zero tick last iter then
            --j;
          }               // decrement to do 1.0 tick now
          tickVal = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j)
              : j == 0 ? -Math.pow(10, -i) : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * (9 - j)));
          if (j == 0)
          {  // first tick of group
            if (!zeroTickFlag)
            {     // did not do zero tick last
              // iteration
              if (i > iBegCount && i < iEndCount
                  && Math.abs(tickVal - 1.0) < 0.0001)
              {
                // not first or last tick on graph and value
                // is 1.0
                tickVal = 0.0;        // change value to 0.0
                zeroTickFlag = true// indicate zero tick
                tickLabel = "0";      // create label for tick
              }
              else
              {
                // first or last tick on graph or value is 1.0
                // create label for tick:
                if (this.log10TickLabelsFlag)
                {
                  // create "log10"-type label
                  tickLabel = (((i < 0) ? "-" : "")
                      + "10^" + Math.abs(i));
                }
                else
                {
                  if (this.expTickLabelsFlag)
                  {
                    // create "1e#"-type label
                    tickLabel = (((i < 0) ? "-" : "")
                        + "1e" + Math.abs(i));
                  }
                  else
                  {
                    final NumberFormat format
                        = getNumberFormatOverride();
                    if (format != null)
                    {
                      tickLabel = format.format(tickVal);
                    }
                    else
                    {
                      tickLabel = LogCategoryItemLabelGenerator.formatValue(new Double(tickVal));/*
                      tickLabel =  Long.toString((long) Math.rint(tickVal));*/
 
View Full Code Here

Examples of java.text.NumberFormat

   *
   * @param f The format.
   */
  public void setFormatter(final Format f)
  {
    final NumberFormat fm = (NumberFormat) f;
    super.setFormatter(fm);
  }
View Full Code Here

Examples of java.text.NumberFormat

   *
   * @param f The format.
   */
  public void setFormatter(final Format f)
  {
    final NumberFormat fm = (NumberFormat) f;
    super.setFormatter(fm);
  }
View Full Code Here

Examples of java.text.NumberFormat

     * @param number the number to format
     * @return a currency formatted number string
     */
    public String currency(Number number) {
        if (number != null) {
            NumberFormat format = NumberFormat.getCurrencyInstance(getLocale());

            return format.format(number.doubleValue());

        } else {
            return getEmptyString();
        }
    }
View Full Code Here

Examples of java.text.NumberFormat

     * @param number the number value to format
     * @return a percentage formatted number string
     */
    public String percentage(Number number) {
        if (number != null) {
            NumberFormat format = NumberFormat.getPercentInstance(getLocale());

            return format.format(number.doubleValue());

        } else {
            return getEmptyString();
        }
    }
View Full Code Here

Examples of java.text.NumberFormat

                                              String semisphere) {
        double valueAbs = Math.abs(value);
        int degrees = (int) valueAbs;
        double minutes = (valueAbs - degrees) * 60.0;

        NumberFormat nf = NumberFormat.getInstance();
        nf.setGroupingUsed(false);
        nf.setMinimumIntegerDigits(integerDigits);
        nf.setMaximumIntegerDigits(integerDigits);
        String strDegrees = nf.format(degrees);
        nf.setMinimumIntegerDigits(2);
        nf.setMaximumIntegerDigits(2);
        nf.setMinimumFractionDigits(3);
        nf.setMaximumFractionDigits(3);
        String strMinutes = nf.format(minutes);
        return strDegrees + DEGREE_SIGN + strMinutes + "'" + semisphere;
    }
View Full Code Here

Examples of java.text.NumberFormat

                                                 final Object value, final boolean isSelected,
                                                 final boolean hasFocus, final int row, final int column)
  {

    setFont(null);
    final NumberFormat nf = NumberFormat.getNumberInstance();
    if (value != null)
    {
      setText(nf.format(value));
    }
    else
    {
      setText("");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.