Example usage for java.text NumberFormat getNumberInstance

List of usage examples for java.text NumberFormat getNumberInstance

Introduction

In this page you can find the example usage for java.text NumberFormat getNumberInstance.

Prototype

public static NumberFormat getNumberInstance(Locale inLocale) 

Source Link

Document

Returns a general-purpose number format for the specified locale.

Usage

From source file:dr.app.bss.Utils.java

public static String annotatedTreeModelToString(TreeModel treeModel, LinkedHashMap<NodeRef, int[]> sequencesMap,
        DataType dataType) {/*from w w w .  j  a va 2s . c  o m*/

    StringBuffer buffer = new StringBuffer();
    NumberFormat format = NumberFormat.getNumberInstance(Locale.ENGLISH);
    boolean useTipLabels = true;

    AncestralSequenceTrait ancestralSequence = new AncestralSequenceTrait(sequencesMap, dataType);
    TreeTraitProvider[] treeTraitProviders = new TreeTraitProvider[] { ancestralSequence };

    TreeUtils.newick(treeModel, //
            treeModel.getRoot(), //
            useTipLabels, //
            TreeUtils.BranchLengthType.LENGTHS_AS_TIME, //
            format, //
            null, //
            treeTraitProviders, //
            null, buffer);

    return buffer.toString();
}

From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java

/**
 *
 *///from ww w .  j a  va  2  s  .  co  m
protected JFreeChart createPie3DChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart3D(
            evaluateTextExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(),
            true, false);

    configureChart(jfreeChart, getPlot());

    PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPie3DPlot jrPie3DPlot = (JRPie3DPlot) getPlot();
    double depthFactor = jrPie3DPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT
            : jrPie3DPlot.getDepthFactorDouble();
    boolean isCircular = jrPie3DPlot.getCircular() == null ? false : jrPie3DPlot.getCircular();
    piePlot3D.setDepthFactor(depthFactor);
    piePlot3D.setCircular(isCircular);

    boolean isShowLabels = jrPie3DPlot.getShowLabels() == null ? true : jrPie3DPlot.getShowLabels();

    if (isShowLabels) {
        PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
        JRItemLabel itemLabel = jrPie3DPlot.getItemLabel();
        if (labelGenerator != null) {
            piePlot3D.setLabelGenerator(labelGenerator);
        } else if (jrPie3DPlot.getLabelFormat() != null) {
            piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPie3DPlot.getLabelFormat(),
                    NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
        }
        //      else if (itemLabel != null && itemLabel.getMask() != null)
        //      {
        //         piePlot3D.setLabelGenerator(
        //            new StandardPieSectionLabelGenerator(itemLabel.getMask())
        //            );
        //      }
        else {
            piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator());
        }

        Integer baseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap,
                ChartThemesConstants.BASEFONT_SIZE);
        JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null;
        piePlot3D.setLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize));

        if (itemLabel != null && itemLabel.getColor() != null) {
            piePlot3D.setLabelPaint(itemLabel.getColor());
        } else {
            piePlot3D.setLabelPaint(getChart().getForecolor());
        }

        if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
            piePlot3D.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
        } else {
            piePlot3D.setLabelBackgroundPaint(getChart().getBackcolor());
        }
    } else {
        piePlot3D.setLabelGenerator(null);
    }

    if (jrPie3DPlot.getLegendLabelFormat() != null) {
        piePlot3D.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(
                jrPie3DPlot.getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()),
                NumberFormat.getPercentInstance(getLocale())));
    }

    return jfreeChart;
}

From source file:com.eveningoutpost.dexdrip.Home.java

private void handleWordPair() {
    boolean preserve = false;
    if ((thisnumber == -1) || (thisword == ""))
        return;/*from  w ww .j a  va 2  s.c o m*/

    Log.d(TAG, "GOT WORD PAIR: " + thisnumber + " = " + thisword);

    switch (thisword) {

    case "rapid":
        if ((insulinset == false) && (thisnumber > 0)) {
            thisinsulinnumber = thisnumber;
            textInsulinDose.setText(Double.toString(thisnumber) + " units");
            Log.d(TAG, "Rapid dose: " + Double.toString(thisnumber));
            insulinset = true;
            btnInsulinDose.setVisibility(View.VISIBLE);
            textInsulinDose.setVisibility(View.VISIBLE);
        } else {
            Log.d(TAG, "Rapid dose already set");
            preserve = true;
        }
        break;

    case "carbs":
        if ((carbsset == false) && (thisnumber > 0)) {
            thiscarbsnumber = thisnumber;
            textCarbohydrates.setText(Integer.toString((int) thisnumber) + " carbs");
            carbsset = true;
            Log.d(TAG, "Carbs eaten: " + Double.toString(thisnumber));
            btnCarbohydrates.setVisibility(View.VISIBLE);
            textCarbohydrates.setVisibility(View.VISIBLE);
        } else {
            Log.d(TAG, "Carbs already set");
            preserve = true;
        }
        break;

    case "blood":
        if ((glucoseset == false) && (thisnumber > 0)) {
            thisglucosenumber = thisnumber;
            if (prefs.getString("units", "mgdl").equals("mgdl")) {
                if (textBloodGlucose != null)
                    textBloodGlucose.setText(Double.toString(thisnumber) + " mg/dl");
            } else {
                if (textBloodGlucose != null)
                    textBloodGlucose.setText(Double.toString(thisnumber) + " mmol/l");
            }

            Log.d(TAG, "Blood test: " + Double.toString(thisnumber));
            glucoseset = true;
            if (textBloodGlucose != null) {
                btnBloodGlucose.setVisibility(View.VISIBLE);
                textBloodGlucose.setVisibility(View.VISIBLE);
            }

        } else {
            Log.d(TAG, "Blood glucose already set");
            preserve = true;
        }
        break;

    case "time":
        Log.d(TAG, "processing time keyword");
        if ((timeset == false) && (thisnumber >= 0)) {

            final NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
            final DecimalFormat df = (DecimalFormat) nf;
            //DecimalFormat df = new DecimalFormat("#");
            df.setMinimumIntegerDigits(2);
            df.setMinimumFractionDigits(2);
            df.setMaximumFractionDigits(2);
            df.setMaximumIntegerDigits(2);

            final Calendar c = Calendar.getInstance();

            final SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("dd/M/yyyy ", Locale.US);
            final SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("dd/M/yyyy HH.mm", Locale.US); // TODO double check 24 hour 12.00 etc
            final String datenew = simpleDateFormat1.format(c.getTime()) + df.format(thisnumber);

            Log.d(TAG, "Time Timing data datenew: " + datenew);

            final Date datethen;
            final Date datenow = new Date();

            try {
                datethen = simpleDateFormat2.parse(datenew);
                double difference = datenow.getTime() - datethen.getTime();
                // is it more than 1 hour in the future? If so it must be yesterday
                if (difference < -(1000 * 60 * 60)) {
                    difference = difference + (86400 * 1000);
                } else {
                    // - midnight feast pre-bolus nom nom
                    if (difference > (60 * 60 * 23 * 1000))
                        difference = difference - (86400 * 1000);
                }

                Log.d(TAG, "Time Timing data: " + df.format(thisnumber) + " = difference ms: "
                        + JoH.qs(difference));
                textTime.setText(df.format(thisnumber));
                timeset = true;
                thistimeoffset = difference;
                btnTime.setVisibility(View.VISIBLE);
                textTime.setVisibility(View.VISIBLE);
            } catch (ParseException e) {
                // toast to explain?
                Log.d(TAG, "Got exception parsing date time");
            }
        } else {
            Log.d(TAG, "Time data already set");
            preserve = true;
        }
        break;
    } // end switch

    if (preserve == false) {
        Log.d(TAG, "Clearing speech values");
        thisnumber = -1;
        thisword = "";
    } else {
        Log.d(TAG, "Preserving speech values");
    }

    // don't show approve/cancel if we only have time
    if (insulinset || glucoseset || carbsset) {
        btnApprove.setVisibility(View.VISIBLE);
        btnCancel.setVisibility(View.VISIBLE);

        if (small_screen) {
            final float button_scale_factor = 0.60f;
            ((ViewGroup.MarginLayoutParams) btnApprove.getLayoutParams()).leftMargin = 0;
            ((ViewGroup.MarginLayoutParams) btnBloodGlucose.getLayoutParams()).leftMargin = 0;
            ((ViewGroup.MarginLayoutParams) btnBloodGlucose.getLayoutParams()).setMarginStart(0);
            ((ViewGroup.MarginLayoutParams) btnCancel.getLayoutParams()).setMarginStart(0);
            ((ViewGroup.MarginLayoutParams) btnApprove.getLayoutParams()).rightMargin = 0;
            ((ViewGroup.MarginLayoutParams) btnCancel.getLayoutParams()).rightMargin = 0;
            btnApprove.setScaleX(button_scale_factor);
            btnApprove.setScaleY(button_scale_factor);
            btnCancel.setScaleX(button_scale_factor);
            btnCancel.setScaleY(button_scale_factor);
            btnInsulinDose.setScaleX(button_scale_factor);
            btnCarbohydrates.setScaleX(button_scale_factor);
            btnCarbohydrates.setScaleY(button_scale_factor);
            btnBloodGlucose.setScaleX(button_scale_factor);
            btnBloodGlucose.setScaleY(button_scale_factor);
            btnInsulinDose.setScaleY(button_scale_factor);
            btnTime.setScaleX(button_scale_factor);
            btnTime.setScaleY(button_scale_factor);

            final int small_text_size = 12;

            textCarbohydrates.setTextSize(small_text_size);
            textInsulinDose.setTextSize(small_text_size);
            textBloodGlucose.setTextSize(small_text_size);
            textTime.setTextSize(small_text_size);

        }

    }

    if (insulinset || glucoseset || carbsset || timeset) {
        if (chart != null) {
            chart.setAlpha((float) 0.10);
        }
        WatchUpdaterService.sendTreatment(thiscarbsnumber, thisinsulinnumber, thisglucosenumber, thistimeoffset,
                textTime.getText().toString());
    }

}

From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java

/**
 *
 *//*from   ww  w  .  j a va2  s  . c om*/
protected JFreeChart createPie3DChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart3D(
            evaluateTextExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(),
            true, false);

    configureChart(jfreeChart, getPlot());

    PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPie3DPlot jrPie3DPlot = (JRPie3DPlot) getPlot();
    double depthFactor = jrPie3DPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT
            : jrPie3DPlot.getDepthFactorDouble();
    boolean isCircular = jrPie3DPlot.getCircular() == null ? false : jrPie3DPlot.getCircular();
    piePlot3D.setDepthFactor(depthFactor);
    piePlot3D.setCircular(isCircular);

    boolean isShowLabels = jrPie3DPlot.getShowLabels() == null ? true : jrPie3DPlot.getShowLabels();

    if (isShowLabels) {
        PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
        JRItemLabel itemLabel = jrPie3DPlot.getItemLabel();
        if (labelGenerator != null) {
            piePlot3D.setLabelGenerator(labelGenerator);
        } else if (jrPie3DPlot.getLabelFormat() != null) {
            piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPie3DPlot.getLabelFormat(),
                    NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
        }
        //      else if (itemLabel != null && itemLabel.getMask() != null)
        //      {
        //         piePlot3D.setLabelGenerator(
        //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
        //               );
        //      }

        if (itemLabel != null && itemLabel.getFont() != null) {
            piePlot3D.setLabelFont(getFontUtil().getAwtFont(itemLabel.getFont(), getLocale()));
        } else {
            piePlot3D.setLabelFont(getFontUtil().getAwtFont(new JRBaseFont(getChart(), null), getLocale()));
        }

        if (itemLabel != null && itemLabel.getColor() != null) {
            piePlot3D.setLabelPaint(itemLabel.getColor());
        } else {
            piePlot3D.setLabelPaint(getChart().getForecolor());
        }

        if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
            piePlot3D.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
        } else {
            piePlot3D.setLabelBackgroundPaint(getChart().getBackcolor());
        }
    } else {
        piePlot3D.setLabelGenerator(null);
    }

    if (jrPie3DPlot.getLegendLabelFormat() != null) {
        piePlot3D.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(
                jrPie3DPlot.getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()),
                NumberFormat.getPercentInstance(getLocale())));
    }

    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java

/**
 *
 *///  w ww  . ja va 2s  .  c  o  m
protected JFreeChart createPieChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart(evaluateTextExpression(getChart().getTitleExpression()),
            (PieDataset) getDataset(), isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());
    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPiePlot jrPiePlot = (JRPiePlot) getPlot();
    boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular();
    piePlot.setCircular(isCircular);

    boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels();

    if (isShowLabels) {
        PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
        JRItemLabel itemLabel = jrPiePlot.getItemLabel();

        if (labelGenerator != null) {
            piePlot.setLabelGenerator(labelGenerator);
        } else if (jrPiePlot.getLabelFormat() != null) {
            piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat(),
                    NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
        }
        //      else if (itemLabel != null && itemLabel.getMask() != null)
        //      {
        //         piePlot.setLabelGenerator(
        //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
        //               );
        //
        //      }

        Integer baseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap,
                ChartThemesConstants.BASEFONT_SIZE);
        JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null;

        piePlot.setLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize));

        if (itemLabel != null && itemLabel.getColor() != null) {
            piePlot.setLabelPaint(itemLabel.getColor());
        } else {
            piePlot.setLabelPaint(getChart().getForecolor());
        }

        if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
            piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
        } else {
            piePlot.setLabelBackgroundPaint(getChart().getBackcolor());
        }
    } else {
        piePlot.setLabelGenerator(null);
    }

    if (jrPiePlot.getLegendLabelFormat() != null) {
        piePlot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLegendLabelFormat(),
                NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
    }

    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java

/**
 *
 */// w  w  w  . ja va 2s .  co  m
protected JFreeChart createPieChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart(evaluateTextExpression(getChart().getTitleExpression()),
            (PieDataset) getDataset(), isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());
    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPiePlot jrPiePlot = (JRPiePlot) getPlot();
    boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular();
    piePlot.setCircular(isCircular);

    boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels();

    if (isShowLabels) {
        PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
        JRItemLabel itemLabel = jrPiePlot.getItemLabel();
        if (labelGenerator != null) {
            piePlot.setLabelGenerator(labelGenerator);
        } else if (jrPiePlot.getLabelFormat() != null) {
            piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat(),
                    NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
        }
        //      else if (itemLabel != null && itemLabel.getMask() != null)
        //      {
        //         piePlot.setLabelGenerator(
        //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
        //               );
        //      }

        if (itemLabel != null && itemLabel.getFont() != null) {
            piePlot.setLabelFont(getFontUtil().getAwtFont(itemLabel.getFont(), getLocale()));
        } else {
            piePlot.setLabelFont(getFontUtil().getAwtFont(new JRBaseFont(getChart(), null), getLocale()));
        }

        if (itemLabel != null && itemLabel.getColor() != null) {
            piePlot.setLabelPaint(itemLabel.getColor());
        } else {
            piePlot.setLabelPaint(getChart().getForecolor());
        }

        if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
            piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
        } else {
            piePlot.setLabelBackgroundPaint(getChart().getBackcolor());
        }
    } else {
        piePlot.setLabelGenerator(null);
    }

    if (jrPiePlot.getLegendLabelFormat() != null) {
        piePlot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(
                ((JRPiePlot) getPlot()).getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()),
                NumberFormat.getPercentInstance(getLocale())));
    }

    return jfreeChart;
}

From source file:com.smi.travel.datalayer.bean.master.AJAXBean.java

public String calculatePriceDaytour(List<DaytourBookingPrice> DriverList) {
    String result = "";
    UtilityFunction util = new UtilityFunction();
    int Pricesum = 0;
    for (int i = 0; i < DriverList.size(); i++) {
        DaytourBookingPrice price = DriverList.get(i);
        Pricesum += util.ConvertInt(price.getQty()) * util.ConvertInt(price.getPrice());
    }//  w  w  w  .j av  a2 s. c om

    return String.valueOf(NumberFormat.getNumberInstance(Locale.US).format(Pricesum));
}

From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java

/**
 *
 *//*from w w  w  . j  a  v  a 2  s. c  o m*/
protected JFreeChart createPie3DChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart3D(
            evaluateTextExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(),
            true, false);

    configureChart(jfreeChart);

    PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPie3DPlot jrPie3DPlot = (JRPie3DPlot) getPlot();
    double depthFactor = jrPie3DPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT
            : jrPie3DPlot.getDepthFactorDouble();
    boolean isCircular = jrPie3DPlot.getCircular() == null ? false : jrPie3DPlot.getCircular();
    piePlot3D.setDepthFactor(depthFactor);
    piePlot3D.setCircular(isCircular);

    boolean isShowLabels = jrPie3DPlot.getShowLabels() == null ? true : jrPie3DPlot.getShowLabels();

    if (isShowLabels) {
        PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
        JRItemLabel itemLabel = jrPie3DPlot.getItemLabel();
        if (labelGenerator != null) {
            piePlot3D.setLabelGenerator(labelGenerator);
        } else if (jrPie3DPlot.getLabelFormat() != null) {
            piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPie3DPlot.getLabelFormat(),
                    NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
        } // the default section label is just the key, so there's no need to set localized number formats
        //      else if (itemLabel != null && itemLabel.getMask() != null)
        //      {
        //         piePlot3D.setLabelGenerator(
        //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
        //               );
        //      }

        piePlot3D.setLabelFont(
                fontUtil.getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale()));

        if (itemLabel != null && itemLabel.getColor() != null) {
            piePlot3D.setLabelPaint(itemLabel.getColor());
        } else {
            piePlot3D.setLabelPaint(getChart().getForecolor());
        }

        if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
            piePlot3D.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
        } else {
            piePlot3D.setLabelBackgroundPaint(getChart().getBackcolor());
        }
    } else {
        piePlot3D.setLabelGenerator(null);
    }

    if (jrPie3DPlot.getLegendLabelFormat() != null) {
        piePlot3D.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(
                jrPie3DPlot.getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()),
                NumberFormat.getPercentInstance(getLocale())));
    } // the default legend label is just the key, so there's no need to set localized number formats

    return jfreeChart;
}

From source file:com.moviejukebox.plugin.ImdbPlugin.java

/**
 * Process financial information in the IMDb web page
 *
 * @param movie/*from  w ww.j ava  2 s  .  co m*/
 * @return
 */
private boolean updateBusiness(Movie movie) {
    String imdbId = movie.getId(IMDB_PLUGIN_ID);
    String xml = getImdbData(getImdbUrl(imdbId, IMDB_TITLE, SUFFIX_BUSINESS));

    if (isValidString(xml)) {
        String budget = HTMLTools.extractTag(xml, "<h5>Budget</h5>", HTML_BREAK).replaceAll("\\s.*", "");
        movie.setBudget(budget);
        NumberFormat moneyFormat = NumberFormat.getNumberInstance(new Locale("US"));
        for (int i = 0; i < 2; i++) {
            for (String oWeek : HTMLTools.extractTags(xml,
                    HTML_H5_START + (i == 0 ? "Opening Weekend" : "Gross") + "</h5", HTML_H5_START, "",
                    "<br/")) {
                if (isValidString(oWeek)) {
                    String currency = oWeek.replaceAll("\\d+.*", "");
                    long value = NumberUtils.toLong(
                            oWeek.replaceAll("^\\D*\\s*", "").replaceAll("\\s.*", "").replaceAll(",", ""), -1L);
                    String country = HTMLTools.extractTag(oWeek, "(", ")");
                    if ("Worldwide".equals(country) && !"$".equals(currency)) {
                        continue;
                    }
                    String money = i == 0 ? movie.getOpenWeek(country) : movie.getGross(country);
                    if (isValidString(money)) {
                        long m = NumberUtils.toLong(money.replaceAll("^\\D*\\s*", "").replaceAll(",", ""), -1L);
                        value = i == 0 ? value + m : value > m ? value : m;
                    }
                    if (i == 0) {
                        movie.setOpenWeek(country, currency + moneyFormat.format(value));
                    } else {
                        movie.setGross(country, currency + moneyFormat.format(value));
                    }
                }
            }
        }
        return Boolean.TRUE;
    }
    return Boolean.FALSE;
}

From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java

/**
 *
 *///w w w  .j a v  a  2 s. co m
protected JFreeChart createPieChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart(evaluateTextExpression(getChart().getTitleExpression()),
            (PieDataset) getDataset(), isShowLegend(), true, false);

    configureChart(jfreeChart);
    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPiePlot jrPiePlot = (JRPiePlot) getPlot();
    boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular();
    piePlot.setCircular(isCircular);

    boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels();

    if (isShowLabels) {
        PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
        JRItemLabel itemLabel = jrPiePlot.getItemLabel();
        if (labelGenerator != null) {
            piePlot.setLabelGenerator(labelGenerator);
        } else if (jrPiePlot.getLabelFormat() != null) {
            piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat(),
                    NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
        } // the default section label is just the key, so there's no need to set localized number formats
        //      else if (itemLabel != null && itemLabel.getMask() != null)
        //      {
        //         piePlot.setLabelGenerator(
        //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
        //               );
        //      }

        piePlot.setLabelFont(
                fontUtil.getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale()));

        if (itemLabel != null && itemLabel.getColor() != null) {
            piePlot.setLabelPaint(itemLabel.getColor());
        } else {
            piePlot.setLabelPaint(getChart().getForecolor());
        }

        if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
            piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
        } else {
            piePlot.setLabelBackgroundPaint(getChart().getBackcolor());
        }
    } else {
        piePlot.setLabelGenerator(null);
    }

    if (jrPiePlot.getLegendLabelFormat() != null) {
        piePlot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(jrPiePlot.getLegendLabelFormat(),
                NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
    } // the default legend label is just the key, so there's no need to set localized number formats

    return jfreeChart;
}