Package java.text

Examples of java.text.NumberFormat$NumberFormatGetter


      totalActual += actualAmount.floatValue();

      chartData.setValue(forecastAmount, stageName, month);
    }

    NumberFormat numFormatter = NumberFormat.getCurrencyInstance();
    String totalForecastString = numFormatter.format(totalForecast);
    String totalActualString = numFormatter.format(totalActual);

    // create the chart
    JFreeChart barChart = ChartFactory.createStackedBarChart("Opportunities by Month", "Month", "Opportunity Value ($)",
                                                             chartData, org.jfree.chart.plot.PlotOrientation.VERTICAL,
                                                             true, true, false);
View Full Code Here


        }
        else
        {
          mTemplate.setBlock("authenticated_content", "busy_content");
          mTemplate.setValue("percentage", percentage);
          NumberFormat format = NumberFormat.getInstance();
          format.setMinimumIntegerDigits(2);
          long eta_ms = sIndexingThread.getEta();
          if (eta_ms >= 0)
          {
            long eta_min = eta_ms/60000;
            long eta_s = (eta_ms-(eta_min*60000))/1000;
            mTemplate.setValue("eta_min", eta_min);
            mTemplate.setValue("eta_s", format.format(eta_s));
            mTemplate.setBlock("eta", "eta");
          }
          mTemplate.setValue("processedCount", sIndexingThread.getProcessedCount());
          mTemplate.setValue("totalCount", sIndexingThread.getTotalCount());
        }
View Full Code Here

    return zoomModel;
  }

  protected final String formatZoomText(final double zoom)
  {
    final NumberFormat numberFormat =
        NumberFormat.getPercentInstance(swingGuiContext.getLocale());
    return (numberFormat.format(zoom));
  }
View Full Code Here

  {
    styleBuilder.clear(); // cuts down on object creation

    final long nodeWidth = rc.getWidth();
    final long nodeHeight = rc.getHeight();
    final NumberFormat pointConverter = styleBuilder.getPointConverter();
    styleBuilder.append("overflow", "hidden"); //NON-NLS
    styleBuilder.append(WIDTH_STYLE, pointConverter.format//NON-NLS
        (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(nodeWidth), safariLengthFix)), PT_UNIT);
    styleBuilder.append(HEIGHT_STYLE, pointConverter.format//NON-NLS
        (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(nodeHeight), safariLengthFix)), PT_UNIT);
    return styleBuilder;
  }
View Full Code Here

   */
  private StyleBuilder produceImageStyle(final RenderableReplacedContentBox rc)
  {
    styleBuilder.clear(); // cuts down on object creation

    final NumberFormat pointConverter = styleBuilder.getPointConverter();
    final RenderableReplacedContent content = rc.getContent();
    final long contentWidth = content.getContentWidth();
    final long nodeWidth = rc.getWidth();
    final long contentHeight = content.getContentHeight();
    final long nodeHeight = rc.getHeight();

    final StyleSheet styleSheet = rc.getStyleSheet();
    if (styleSheet.getBooleanStyleProperty(ElementStyleKeys.SCALE))
    {
      if (styleSheet.getBooleanStyleProperty(ElementStyleKeys.KEEP_ASPECT_RATIO) &&
          (contentWidth > 0 && contentHeight > 0))
      {
        final double scaleFactor = Math.min(nodeWidth / (double) contentWidth, nodeHeight / (double) contentHeight);

        styleBuilder.append(WIDTH_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue((long) (contentWidth * scaleFactor)),
                safariLengthFix)), PT_UNIT);
        styleBuilder.append(HEIGHT_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue((long) (contentHeight * scaleFactor)),
                safariLengthFix)), PT_UNIT);
      }
      else
      {
        styleBuilder.append(WIDTH_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(nodeWidth), safariLengthFix)), PT_UNIT);
        styleBuilder.append(HEIGHT_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(nodeHeight), safariLengthFix)), PT_UNIT);
      }
    }
    else
    {
      // for plain drawable content, there is no intrinsic-width or height, so we have to use the computed
      // width and height instead.
      if (contentWidth > nodeWidth || contentHeight > nodeHeight)
      {
        // There is clipping involved. The img-element does *not* receive a width or height property.
        // the width and height is applied to an external DIV element instead.
        return null;
      }

      if (contentWidth == 0 && contentHeight == 0)
      {
        // Drawable content has no intrinsic height or width, therefore we must not use the content size at all.
        styleBuilder.append(WIDTH_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(nodeWidth), safariLengthFix)), PT_UNIT);
        styleBuilder.append(HEIGHT_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(nodeHeight), safariLengthFix)), PT_UNIT);
      }
      else
      {
        final long width = Math.min(nodeWidth, contentWidth);
        final long height = Math.min(nodeHeight, contentHeight);
        styleBuilder.append(WIDTH_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(width), safariLengthFix)), PT_UNIT);
        styleBuilder.append(HEIGHT_STYLE, pointConverter.format
            (HtmlPrinter.fixLengthForSafari(StrictGeomUtility.toExternalValue(height), safariLengthFix)), PT_UNIT);
      }
    }
    return styleBuilder;
  }
View Full Code Here

    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

    }
    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

      //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

              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

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

TOP

Related Classes of java.text.NumberFormat$NumberFormatGetter

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.