Package java.text

Examples of java.text.DecimalFormat$DigitArrays


        long duration = end.getTime() - start.getTime();
        DateFormat df = new SimpleDateFormat( dFormat );
        BigDecimal resultF = BigDecimal.valueOf( (duration * 1.00) / (loops * 1.00) )
                .setScale( 2, BigDecimal.ROUND_HALF_UP );
        DecimalFormat dcf = new DecimalFormat( "###.##" );

        try
        {
            System.out.println( "Writing report to file " + outFile );
            boolean append = new File( outFile ).exists();
            BufferedWriter out = new BufferedWriter( new FileWriter( outFile, append ) );
            if ( !append ) out.write( header );
            out.write( "\r\n" );
            out.write( loops + ";" + df.format( start ) + ';' + df.format( end ) + ';' + duration + ";"
                    + dcf.format( resultF ) );
            out.close();
        }
        catch ( IOException e )
        {
            e.printStackTrace();
View Full Code Here


   */
  public AbstractGraphicsDocument(int defaultMaxDigits) {
    Locale locale = new Locale("en", "US");
    DecimalFormatSymbols decimalSymbols = new DecimalFormatSymbols(locale);
    decimalSymbols.setDecimalSeparator('.');
    formatter = new DecimalFormat();
    formatter.setDecimalFormatSymbols(decimalSymbols);

    // do not group
    formatter.setGroupingSize(0);

View Full Code Here

    }

    public ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache) {
        // Some locales (e.g. "fr") produce non-breaking spaces sent back as space by the browser
        value = value.replace(' ', (char)160);
        DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);

        Number decimalValue;
        try {
            decimalValue = decimalFormat.parse(value);
        } catch (ParseException e) {
            return ConversionResult.create("decimal");
        }

        if (decimalValue instanceof BigDecimal) {
View Full Code Here

        }
        return new ConversionResult(decimalValue);
    }

    public String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache) {
        DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
        return decimalFormat.format(value);
    }
View Full Code Here

        DecimalFormat decimalFormat = getDecimalFormat(locale, formatCache);
        return decimalFormat.format(value);
    }

    protected final DecimalFormat getDecimalFormat(Locale locale, Convertor.FormatCache formatCache) {
        DecimalFormat decimalFormat = null;
        if (formatCache != null)
            decimalFormat = (DecimalFormat)formatCache.get();
        if (decimalFormat == null) {
            decimalFormat = getDecimalFormat(locale);
            if (formatCache != null)
View Full Code Here

          range.getUpperBound() == (int)range.getUpperBound() &&
          tickInterval == (int)tickInterval) ||
          dialUnitScale > 1
          )
      {
        chartPlot.setTickLabelFormat(new DecimalFormat("#,##0"));
      }
      else if(dialUnitScale == 1)
      {
        chartPlot.setTickLabelFormat(new DecimalFormat("#,##0.0"));
      }
      else if(dialUnitScale <= 0)
      {
        chartPlot.setTickLabelFormat(new DecimalFormat("#,##0.00"));
      }
    }
    chartPlot.setTickLabelsVisible(true);

    // Set all the colors we support
    Paint backgroundPaint = jrPlot.getOwnBackcolor() == null ? ChartThemesConstants.TRANSPARENT_PAINT : jrPlot.getOwnBackcolor();
    chartPlot.setBackgroundPaint(backgroundPaint);

    GradientPaint gp =
      new GradientPaint(
        new Point(), Color.LIGHT_GRAY,
        new Point(), Color.BLACK,
        false
        );
   
    if(jrPlot.getMeterBackgroundColor() != null)
    {
      chartPlot.setDialBackgroundPaint(jrPlot.getMeterBackgroundColor());
    }
    else
    {
      chartPlot.setDialBackgroundPaint(gp);
    }
    //chartPlot.setForegroundAlpha(1f);
    Paint needlePaint = jrPlot.getNeedleColor() == null ? new Color(191, 48, 0) : jrPlot.getNeedleColor();
    chartPlot.setNeedlePaint(needlePaint);

    JRValueDisplay display = jrPlot.getValueDisplay();
    if(display != null)
    {
      Color valueColor = display.getColor() == null ? Color.BLACK : display.getColor();
      chartPlot.setValuePaint(valueColor);
      String pattern = display.getMask() != null ? display.getMask() : "#,##0.####";
      if(pattern != null)
        chartPlot.setTickLabelFormat( new DecimalFormat(pattern));
      JRFont displayFont = display.getFont();
      Font themeDisplayFont = getFont((JRFont)getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_DISPLAY_FONT), displayFont, defaultBaseFontSize);
 
      if (themeDisplayFont != null)
      {
View Full Code Here

      {
        chartPlot.setValuePaint(display.getColor());
      }
      if (display.getMask() != null)
      {
        chartPlot.setValueFormat(new DecimalFormat(display.getMask()));
      }
      if (display.getFont() != null)
      {
//        chartPlot.setValueFont(JRFontUtil.getAwtFont(display.getFont()).deriveFont(Font.BOLD));
      }
View Full Code Here

          upperBound == (int)upperBound &&
          scale.getMajorTickIncrement() == (int)scale.getMajorTickIncrement()) ||
          dialUnitScale > 1
          )
      {
        scale.setTickLabelFormatter(new DecimalFormat("#,##0"));
      }
      else if(dialUnitScale == 1)
      {

        scale.setTickLabelFormatter(new DecimalFormat("#,##0.0"));
      }
      else if(dialUnitScale <= 0)
      {
        scale.setTickLabelFormatter(new DecimalFormat("#,##0.00"));
      }
    }
    else
    {
      scale = new ScaledDialScale();
    }
    scale.setTickRadius(0.9);
    scale.setTickLabelOffset(0.16);
    JRFont tickLabelFont = jrPlot.getTickLabelFont();
    Integer defaultBaseFontSize = (Integer)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE);
    Font themeTickLabelFont = getFont((JRFont)getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_TICK_LABEL_FONT), tickLabelFont, defaultBaseFontSize);
    scale.setTickLabelFont(themeTickLabelFont);
    scale.setMajorTickStroke(new BasicStroke(1f));
    scale.setMinorTickStroke(new BasicStroke(0.7f));
    scale.setMajorTickPaint(Color.BLACK);
    scale.setMinorTickPaint(Color.BLACK);
    scale.setTickLabelsVisible(true);
    scale.setFirstTickLabelVisible(true);
    dialPlot.addScale(0, scale);
   
   
    List intervals = jrPlot.getIntervals();
    if (intervals != null && intervals.size() > 0)
    {
      int size = Math.min(3, intervals.size());
     
      int colorStep = 0;
      if(size > 3)
        colorStep = 255 / (size - 3);
     
      for(int i = 0; i < size; i++)
      {
        JRMeterInterval interval = (JRMeterInterval)intervals.get(i);
        Range intervalRange = convertRange(interval.getDataRange());
        double intervalLowerBound = ChartThemesUtilities.getTruncatedValue(intervalRange.getLowerBound(), dialUnitScale);
        double intervalUpperBound = ChartThemesUtilities.getTruncatedValue(intervalRange.getUpperBound(), dialUnitScale);

        Color color = i < 3
          ? (Color)ChartThemesConstants.AEGEAN_INTERVAL_COLORS.get(i)
          : new Color(255 - colorStep * (i - 3), 0 + colorStep * (i - 3), 0);
          ScaledDialRange dialRange =
            new ScaledDialRange(
              intervalLowerBound,
              intervalUpperBound,
              interval.getBackgroundColor() == null
                ? color
                : interval.getBackgroundColor(),
              15f
              );
        dialRange.setInnerRadius(0.5);
        dialRange.setOuterRadius(0.5);
        dialPlot.addLayer(dialRange);
      }
     
    }
    JRValueDisplay display = jrPlot.getValueDisplay();

    String displayVisibility = display != null && getChart().hasProperties() ?
        getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_VALUE_DISPLAY_VISIBLE) : "false";

    if(Boolean.valueOf(displayVisibility).booleanValue())
    {
      ScaledDialValueIndicator dvi = new ScaledDialValueIndicator(0, dialUnitScale);
      dvi.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
//      dvi.setFont(JRFontUtil.getAwtFont(jrFont).deriveFont(10f).deriveFont(Font.BOLD));
      dvi.setOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
      dvi.setPaint(Color.WHITE);

      String pattern = display.getMask() != null ? display.getMask() : "#,##0.####";
      if(pattern != null)
        dvi.setNumberFormat( new DecimalFormat(pattern));
      dvi.setRadius(0.15);
      dvi.setValueAnchor(RectangleAnchor.CENTER);
      dvi.setTextAnchor(TextAnchor.CENTER);
      //dvi.setTemplateValue(Double.valueOf(getDialTickValue(dialPlot.getValue(0),dialUnitScale)));
      dialPlot.addLayer(dvi);
View Full Code Here

   */
  public void setBundlePriority(String bundleName, int priority) {
    Properties metadataProperties = getPropertiesWithoutResolvingRecursively(null, bundleName);
    if (priority > 999) { throw new AssertException(
        "Bundle priorities can not be higher than 999. The smaller the number, the higher the priority."); }
    NumberFormat formatter = new DecimalFormat("000");
    metadataProperties.setProperty(METADATA_BUNDLE_PRIORITY_KEY, formatter.format(priority));
    saveOrUpdateProperties(metadataProperties, null, bundleName);
  }
View Full Code Here

   */
  public void setKeyPriority(String bundleName, String key, int priority) {
    Properties metadataProperties = getPropertiesWithoutResolvingRecursively(null, bundleName);
    if (priority > 999) { throw new AssertException(
        "Bundle priorities can not be higher than 999. The smaller the number, the higher the priority."); }
    NumberFormat formatter = new DecimalFormat("00");
    metadataProperties.setProperty(key + METADATA_KEY_PRIORITY_POSTFIX, formatter.format(priority));
    saveOrUpdateProperties(metadataProperties, null, bundleName);
  }
View Full Code Here

TOP

Related Classes of java.text.DecimalFormat$DigitArrays

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.