Example usage for java.text NumberFormat getInstance

List of usage examples for java.text NumberFormat getInstance

Introduction

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

Prototype

public static final NumberFormat getInstance() 

Source Link

Document

Returns a general-purpose number format for the current default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:org.talend.dataprofiler.chart.ChartDecorator.java

/**
 * create bar chart with customized bar render class which can be adapted in JFreeChart class.
 * /*from w  w w .  ja  v a 2 s. c o  m*/
 * @param chart
 * @param barRenderer
 */
public static void decorateBarChart(JFreeChart chart, BarRenderer barRenderer) {
    CategoryPlot plot = chart.getCategoryPlot();
    plot.getRangeAxis().setUpperMargin(0.08);
    plot.setRangeGridlinesVisible(true);

    barRenderer.setBaseItemLabelsVisible(true);
    barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    barRenderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    barRenderer.setBaseNegativeItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    // MOD klliu 2010-09-25 bug15514: The chart of summary statistic indicators not beautiful
    barRenderer.setMaximumBarWidth(0.1);
    // renderer.setItemMargin(0.000000005);
    // renderer.setBase(0.04);
    // ADD yyi 2009-09-24 9243
    barRenderer.setBaseToolTipGenerator(
            new StandardCategoryToolTipGenerator(NEW_TOOL_TIP_FORMAT_STRING, NumberFormat.getInstance()));

    // ADD TDQ-5251 msjian 2012-7-31: do not display the shadow
    barRenderer.setShadowVisible(false);
    // TDQ-5251~

    // CategoryAxis domainAxis = plot.getDomainAxis();
    // domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    plot.setRenderer(barRenderer);
}

From source file:com.androidinspain.deskclock.Utils.java

public static String getNumberFormattedQuantityString(Context context, int id, int quantity) {
    final String localizedQuantity = NumberFormat.getInstance().format(quantity);
    return context.getResources().getQuantityString(id, quantity, localizedQuantity);
}

From source file:javadz.beanutils.converters.NumberConverter.java

/**
 * Return a NumberFormat to use for Conversion.
 *
 * @return The NumberFormat.//  w  ww.  j a  va2s .c om
 */
private NumberFormat getFormat() {
    NumberFormat format = null;
    if (pattern != null) {
        if (locale == null) {
            if (log().isDebugEnabled()) {
                log().debug("    Using pattern '" + pattern + "'");
            }
            format = new DecimalFormat(pattern);
        } else {
            if (log().isDebugEnabled()) {
                log().debug("    Using pattern '" + pattern + "'" + " with Locale[" + locale + "]");
            }
            DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale);
            format = new DecimalFormat(pattern, symbols);
        }
    } else {
        if (locale == null) {
            if (log().isDebugEnabled()) {
                log().debug("    Using default Locale format");
            }
            format = NumberFormat.getInstance();
        } else {
            if (log().isDebugEnabled()) {
                log().debug("    Using Locale[" + locale + "] format");
            }
            format = NumberFormat.getInstance(locale);
        }
    }
    if (!allowDecimals) {
        format.setParseIntegerOnly(true);
    }
    return format;
}

From source file:com.almalence.util.Util.java

public static boolean isNumeric(String str) {
    NumberFormat formatter = NumberFormat.getInstance();
    ParsePosition pos = new ParsePosition(0);
    formatter.parse(str, pos);//from w  w w . ja  va  2s  .c o m
    return str.length() == pos.getIndex();
}

From source file:ch.oakmountain.tpa.solver.TrainPathAllocationProblemStatistics.java

private void compileSummaryTable() throws IOException {
    TablePersistor summaryTable = new TablePersistor("summary", outputDir, "Train Path Allocation Problem",
            getHeader());//ww  w .j  a va 2s.  co  m

    for (TrainPathSlot trainPathSlot : arcNodeUnitCapacityCounts.keySet()) {
        int count = arcNodeUnitCapacityCounts.get(trainPathSlot);
        arcNodeUnitCapacityConstraints += 1;
        arcNodeUnitCapacityConstraintTerms += count;
    }
    for (TrainPathSlot trainPathSlot : pathBasedConflictCounts.keySet()) {
        int count = pathBasedConflictCounts.get(trainPathSlot);
        pathBasedSolutionCandidateConflictConstraints += 1;
        pathBasedSolutionCandidateConflictTerms += count;
    }

    // arc-node
    // - flow constraints: sum of nb verticies of all DAGs (terms per constraint: nb of solution candidates)
    // - unit capacity: nb of slots of all DAGs (terms per constraint: at most one term per application)
    summaryTable.writeRow(Arrays.asList("arc-node/path-based", "feasible requests",
            String.valueOf(feasibleSimpleTrainPathApplications.size())));
    summaryTable.writeRow(Arrays.asList("arc-node/path-based", "infeasible requests",
            String.valueOf(infeasibleSimpleTrainPathApplications.size())));
    summaryTable.writeRow(
            Arrays.asList("arc-node/path-based", "total number of train paths", String.valueOf(totalNbPaths)));
    summaryTable.writeRow(Arrays.asList("arc-node/path-based", "global minimum dwell time",
            PeriodicalTimeFrame.formatDuration(
                    feasibleSimpleTrainPathApplications.get(0).getParams().getHARD_MINIMUM_DWELL_TIME())));
    summaryTable.writeRow(Arrays.asList("arc-node/path-based", "global maximum earlier departure time",
            PeriodicalTimeFrame.formatDuration(feasibleSimpleTrainPathApplications.get(0).getParams()
                    .getHARD_MAXIMUM_EARLIER_DEPARTURE())));
    summaryTable.writeRow(Arrays.asList("arc-node/path-based", "global maximum later arrival time",
            PeriodicalTimeFrame.formatDuration(
                    feasibleSimpleTrainPathApplications.get(0).getParams().getHARD_MAXIMUM_LATER_ARRIVAL())));

    summaryTable.writeRow(
            Arrays.asList("arc-node", "flow constraints", String.valueOf(arcNodeFlowConstraintsCount)));
    summaryTable.writeRow(Arrays.asList("arc-node", "terms in flow constraints",
            String.valueOf(arcNodeFlowConstraintTermsCount)));
    summaryTable.writeRow(Arrays.asList("arc-node", "unit capacity constraints",
            String.valueOf(arcNodeUnitCapacityConstraints)));
    summaryTable.writeRow(Arrays.asList("arc-node", "terms in unit capacity constraints",
            String.valueOf(arcNodeUnitCapacityConstraintTerms)));
    BigInteger arcNodeConstraints = BigInteger
            .valueOf(arcNodeFlowConstraintsCount + arcNodeUnitCapacityConstraints);
    summaryTable.writeRow(Arrays.asList("arc-node", "rows (constraints)", String.valueOf(arcNodeConstraints)));
    summaryTable
            .writeRow(Arrays.asList("arc-node", "columns (variables)", String.valueOf(arcNodeVariablesCount)));
    summaryTable.writeRow(Arrays.asList("arc-node", "train path slots",
            String.valueOf(arcNodeUnitCapacityCounts.keySet().size())));
    BigInteger arcNodeTerms = BigInteger
            .valueOf(arcNodeFlowConstraintTermsCount + arcNodeUnitCapacityConstraintTerms);
    BigInteger arcNodeFlowConstraintMatrixSize = BigInteger.valueOf(arcNodeFlowConstraintTermsCount)
            .multiply(BigInteger.valueOf(arcNodeVariablesCount));
    BigInteger arcNodeUnitCapacityConstraintMatrixSize = BigInteger.valueOf(arcNodeUnitCapacityConstraintTerms)
            .multiply(BigInteger.valueOf(arcNodeVariablesCount));
    BigInteger arcNodeMatrixSize = arcNodeConstraints.multiply(BigInteger.valueOf(arcNodeVariablesCount));
    summaryTable.writeRow(Arrays.asList("arc-node", "sparsity in flow constraints",
            String.valueOf(arcNodeFlowConstraintTermsCount + "/" + arcNodeFlowConstraintMatrixSize + " ("
                    + (new BigDecimal(arcNodeFlowConstraintTermsCount))
                            .divide((new BigDecimal(arcNodeFlowConstraintMatrixSize)), 10, RoundingMode.HALF_UP)
                    + ")")));
    summaryTable.writeRow(Arrays.asList("arc-node", "sparsity in unit capacity constraints",
            String.valueOf(arcNodeUnitCapacityConstraintTerms + "/" + arcNodeUnitCapacityConstraintMatrixSize
                    + " ("
                    + (new BigDecimal(arcNodeUnitCapacityConstraintTerms)).divide(
                            (new BigDecimal(arcNodeUnitCapacityConstraintMatrixSize)), 10, RoundingMode.HALF_UP)
                    + ")")));
    summaryTable
            .writeRow(
                    Arrays.asList("arc-node", "sparsity in all constraints",
                            String.valueOf(arcNodeTerms
                                    + "/" + arcNodeMatrixSize + " (" + (new BigDecimal(arcNodeTerms))
                                            .divide(new BigDecimal(arcNodeMatrixSize), 10, RoundingMode.HALF_UP)
                                    + ")")));

    // path-based
    // - solution candidate choice: nb of applications (terms per constraint: nb of solution canidates)
    // - conflict sets: nb of slots of all DAGs (terms per constraint: possibly many terms per application)
    summaryTable.writeRow(Arrays.asList("path-based", "choice constraints",
            String.valueOf(pathBasedSolutionCandidateChoiceConstraintsCount)));
    summaryTable.writeRow(Arrays.asList("path-based", "terms in choice constraints",
            String.valueOf(pathBasedSolutionCandidateChoiceTermsCount)));
    summaryTable.writeRow(Arrays.asList("path-based", "conflict constraints",
            String.valueOf(pathBasedSolutionCandidateConflictConstraints)));
    summaryTable.writeRow(Arrays.asList("path-based", "terms in conflict constraints",
            String.valueOf(pathBasedSolutionCandidateConflictTerms)));
    summaryTable.writeRow(Arrays.asList("path-based", "enumeration rate ",
            String.valueOf(pathBasedSolutionCandidateChoiceTermsCount + "/" + totalNbPaths + "("
                    + ((double) pathBasedSolutionCandidateChoiceTermsCount / totalNbPaths) + ")")));
    BigInteger pathBasedConstraints = BigInteger.valueOf(pathBasedSolutionCandidateChoiceConstraintsCount)
            .add(BigInteger.valueOf(pathBasedSolutionCandidateConflictConstraints));
    summaryTable
            .writeRow(Arrays.asList("path-based", "rows (constraints)", String.valueOf(pathBasedConstraints)));
    summaryTable.writeRow(
            Arrays.asList("path-based", "columns (variables)", String.valueOf(pathBasedVariablesCount)));
    summaryTable.writeRow(Arrays.asList("path-based", "train path slots",
            String.valueOf(pathBasedConflictCounts.keySet().size())));
    BigInteger pathBasedTerms = BigInteger.valueOf(pathBasedSolutionCandidateConflictTerms)
            .add(BigInteger.valueOf(pathBasedSolutionCandidateChoiceTermsCount));
    BigInteger pathBasedMatrixSize = pathBasedConstraints.multiply(BigInteger.valueOf(pathBasedVariablesCount));
    BigInteger pathBasedSolutionCandidateChoiceMatrixSize = BigInteger
            .valueOf(pathBasedSolutionCandidateChoiceConstraintsCount)
            .multiply(BigInteger.valueOf(pathBasedVariablesCount));
    BigInteger pathBasedSolutionCandidateConflictMatrixSize = BigInteger
            .valueOf(pathBasedSolutionCandidateConflictConstraints)
            .multiply(BigInteger.valueOf(pathBasedVariablesCount));
    summaryTable.writeRow(Arrays.asList("path-based", "sparsity in choice constraints",
            String.valueOf(pathBasedSolutionCandidateChoiceTermsCount + "/"
                    + pathBasedSolutionCandidateChoiceMatrixSize + " ("
                    + (new BigDecimal(pathBasedSolutionCandidateChoiceTermsCount)).divide(
                            new BigDecimal(pathBasedSolutionCandidateChoiceMatrixSize), 10,
                            RoundingMode.HALF_UP)
                    + ")")));
    summaryTable.writeRow(Arrays.asList("path-based", "sparsity in conflict constraints",
            String.valueOf(pathBasedSolutionCandidateConflictTerms + "/"
                    + pathBasedSolutionCandidateConflictMatrixSize + " ("
                    + (new BigDecimal(pathBasedSolutionCandidateConflictTerms)).divide(
                            (new BigDecimal(pathBasedSolutionCandidateConflictMatrixSize)), 10,
                            RoundingMode.HALF_UP)
                    + ")")));
    summaryTable
            .writeRow(
                    Arrays.asList("path-based", "sparsity in all constraints",
                            String.valueOf(pathBasedTerms + "/" + pathBasedMatrixSize + " ("
                                    + (new BigDecimal(pathBasedTerms)).divide(
                                            (new BigDecimal(pathBasedMatrixSize)), 10, RoundingMode.HALF_UP)
                                    + ")")));

    summaryTable.finishTable();

    if (!(arcNodeUnitCapacityCounts.keySet().size() >= pathBasedConflictCounts.keySet().size())) {
        throw new IllegalStateException(
                "nb of train path slots in arc node model has to be larger or equal to the number of train path slots in the path based model (because of partial enumeration)");
    }

    // LaTeX table output
    DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance();
    //DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();

    //symbols.setGroupingSeparator(' ');
    //formatter.setDecimalFormatSymbols(symbols);
    File latexFile = new File(outputDir + File.separator + "computational.tex");
    FileUtils.writeStringToFile(latexFile, "Number of feasible applications:&\\multicolumn{2}{c|}{"
            + formatter.format(feasibleSimpleTrainPathApplications.size()) + "}\\\\\n");
    FileUtils.writeStringToFile(latexFile,
            "Number of variables      &" + formatter.format(arcNodeVariablesCount) + "&"
                    + formatter.format(pathBasedVariablesCount) + "\\\\\n",
            true);
    FileUtils.writeStringToFile(latexFile, "Number of constraints   &" + formatter.format(arcNodeConstraints)
            + "&" + formatter.format(pathBasedConstraints) + "\\\\\n", true);
    FileUtils.writeStringToFile(latexFile, "Number of unit capacity / conflict constraints", true);
    FileUtils.writeStringToFile(latexFile,
            "&" + formatter.format(arcNodeUnitCapacityConstraints)
                    + "                                         &"
                    + formatter.format(pathBasedSolutionCandidateConflictConstraints) + "\\\\\n",
            true);
    FileUtils.writeStringToFile(latexFile, "%    Matrix size                     &"
            + formatter.format(arcNodeMatrixSize) + "&" + formatter.format(pathBasedMatrixSize) + "\\\\\n",
            true);
    FileUtils.writeStringToFile(latexFile, "%Number of terms           &" + formatter.format(arcNodeTerms) + "&"
            + formatter.format(pathBasedTerms) + "\\\\\n", true);
    FileUtils.writeStringToFile(latexFile, "Number of terms in unit capacity/", true);
    FileUtils.writeStringToFile(latexFile,
            "&" + formatter.format(arcNodeUnitCapacityConstraintTerms) + "& \\\\\n", true);
    FileUtils.writeStringToFile(latexFile, "\\hspace{0.5cm}choice constraints", true);
    FileUtils.writeStringToFile(latexFile,
            "&&" + formatter.format(pathBasedSolutionCandidateChoiceTermsCount) + "\\\\\n", true);
    FileUtils.writeStringToFile(latexFile, "Number of terms in flow conservation/", true);
    FileUtils.writeStringToFile(latexFile, "&" + formatter.format(arcNodeFlowConstraintTermsCount) + "& \\\\\n",
            true);
    FileUtils.writeStringToFile(latexFile, "\\hspace{0.5cm}conflict constraints", true);
    FileUtils.writeStringToFile(latexFile,
            "&&" + formatter.format(pathBasedSolutionCandidateConflictTerms) + "\\\\\n", true);
}

From source file:org.sakaiproject.gradebookng.tool.panels.SettingsGradingSchemaPanel.java

/**
 * Build the data for the chart/*from  ww w.j  a  va  2 s . co m*/
 * 
 * @return
 */
private JFreeChart getChartData() {

    // just need the list
    final List<CourseGrade> courseGrades = this.courseGradeMap.values().stream().collect(Collectors.toList());

    // get current grading schema (from model so that it reflects current state)
    final List<GbGradingSchemaEntry> gradingSchemaEntries = this.model.getObject().getGradingSchemaEntries();

    final DefaultCategoryDataset data = new DefaultCategoryDataset();
    final Map<String, Integer> counts = new LinkedHashMap<>(); // must retain order so graph can be printed correctly

    // add all schema entries (these will be sorted according to {@link LetterGradeComparator})
    gradingSchemaEntries.forEach(e -> {
        counts.put(e.getGrade(), 0);
    });

    // now add the count of each course grade for those schema entries
    this.total = 0;
    for (final CourseGrade g : courseGrades) {

        // course grade may not be released so we have to skip it
        if (StringUtils.isBlank(g.getMappedGrade())) {
            continue;
        }

        counts.put(g.getMappedGrade(), counts.get(g.getMappedGrade()) + 1);
        this.total++;
    }

    // build the data
    final ListIterator<String> iter = new ArrayList<>(counts.keySet()).listIterator(0);
    while (iter.hasNext()) {
        final String c = iter.next();
        data.addValue(counts.get(c), "count", c);
    }

    final JFreeChart chart = ChartFactory.createBarChart(null, // the chart title
            getString("settingspage.gradingschema.chart.xaxis"), // the label for the category (x) axis
            getString("label.statistics.chart.yaxis"), // the label for the value (y) axis
            data, // the dataset for the chart
            PlotOrientation.HORIZONTAL, // the plot orientation
            false, // show legend
            true, // show tooltips
            false); // show urls

    chart.getCategoryPlot().setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    chart.setBorderVisible(false);
    chart.setAntiAlias(false);

    final CategoryPlot plot = chart.getCategoryPlot();
    final BarRenderer br = (BarRenderer) plot.getRenderer();

    br.setItemMargin(0);
    br.setMinimumBarLength(0.05);
    br.setMaximumBarWidth(0.1);
    br.setSeriesPaint(0, new Color(51, 122, 183));
    br.setBarPainter(new StandardBarPainter());
    br.setShadowPaint(new Color(220, 220, 220));
    BarRenderer.setDefaultShadowsVisible(true);

    br.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator(getString("label.statistics.chart.tooltip"),
            NumberFormat.getInstance()));

    plot.setRenderer(br);

    // show only integers in the count axis
    plot.getRangeAxis().setStandardTickUnits(new NumberTickUnitSource(true));

    // make x-axis wide enough so we don't get ... suffix
    plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(2.0f);

    plot.setBackgroundPaint(Color.white);

    chart.setTitle(getString("settingspage.gradingschema.chart.heading"));

    return chart;
}

From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java

private void rebuildSigmaProfiles() {
    if (listModel.getSize() == 0) {
        if (err == true) {
            err = false;//  w ww  .  j  a va  2 s .  co m
            return;
        }
        JOptionPane.showMessageDialog(this, "Select compounds.", "Error", JOptionPane.OK_OPTION);
        return;
    }

    int num = listModel.getSize();
    COSMOSACCompound[] c = new COSMOSACCompound[num];
    double[][] area = new double[num][];
    double[][] charge = new double[num][];
    XYSeriesCollection dataset = new XYSeriesCollection();

    for (int i = 0; i < num; i++) {
        try {
            c[i] = db.getComp((String) listModel.getElementAt(i));
        } catch (SQLException e1) {
            e1.printStackTrace();
            return;
        }
    }

    COSMOSAC cosmosac = (COSMOSAC) modelBox.getSelectedItem();
    try {
        cosmosac.setComponents(c);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(2);

    for (int i = 0; i < num; i++) {

        if (c[i] == null)
            return;

        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

        area[i] = c[i].area;
        charge[i] = c[i].charge;

        int n = charge[0].length;
        XYSeries comp = new XYSeries(c[i].name);

        // charges represent the center of the segments
        comp.add(charge[i][0], area[i][0]);
        for (int j = 1; j < n; ++j) {
            comp.add(charge[i][j] - (charge[i][j] - charge[i][j - 1]) / 2, area[i][j]);
        }

        double areaT = 0;
        double absSigmaAvg = 0;
        double sigmaAvg2 = 0;
        for (int j = 1; j < n; ++j) {
            areaT += area[i][j];
            absSigmaAvg += area[i][j] * Math.abs(charge[i][j]);
            sigmaAvg2 += area[i][j] * charge[i][j] * charge[i][j];
        }
        absSigmaAvg /= areaT;
        sigmaAvg2 /= areaT;
        comp.setKey(c[i].name + " (A=" + nf.format(areaT) + ", |sigma|=" + nf.format(absSigmaAvg * 1000)
                + ", |sigma|2=" + nf.format(sigmaAvg2 * 10000) + ")");

        dataset.addSeries(comp);
        sigmaProfilePlot.setRenderer(i, stepRenderer);
        sigmaProfilePlot.getRenderer().setSeriesStroke(i, new BasicStroke(2.5f));
    }
    sigmaProfilePlot.setDataset(dataset);

    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:de.tor.tribes.ui.views.DSWorkbenchStatsFrame.java

private void setupChart(String pInitialId, XYDataset pInitialDataset) {
    chart = ChartFactory.createTimeSeriesChart("Spielerstatistiken", // title
            "Zeiten", // x-axis label
            pInitialId, // y-axis label
            pInitialDataset, // data
            jShowLegend.isSelected(), // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );// w  ww  .java2 s  . c  o  m

    chart.setBackgroundPaint(Constants.DS_BACK);
    XYPlot plot = (XYPlot) chart.getPlot();
    setupPlotDrawing(plot);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    for (int i = 0; i < plot.getSeriesCount(); i++) {
        renderer.setSeriesLinesVisible(i, jShowLines.isSelected());
        renderer.setSeriesShapesVisible(i, jShowDataPoints.isSelected());
        plot.setRenderer(i, renderer);
    }

    renderer.setDefaultItemLabelsVisible(jShowItemValues.isSelected());
    renderer.setDefaultItemLabelGenerator(new org.jfree.chart.labels.StandardXYItemLabelGenerator());
    renderer.setDefaultToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"), NumberFormat.getInstance()));
    int lastDataset = plot.getDatasetCount() - 1;
    if (lastDataset > 0) {
        plot.getRangeAxis().setAxisLinePaint(plot.getLegendItems().get(lastDataset).getLinePaint());
        plot.getRangeAxis().setLabelPaint(plot.getLegendItems().get(lastDataset).getLinePaint());
        plot.getRangeAxis().setTickLabelPaint(plot.getLegendItems().get(lastDataset).getLinePaint());
        plot.getRangeAxis().setTickMarkPaint(plot.getLegendItems().get(lastDataset).getLinePaint());
    }
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMinimumFractionDigits(0);
    nf.setMaximumFractionDigits(0);
    NumberAxis na = ((NumberAxis) plot.getRangeAxis());
    if (na != null) {
        na.setNumberFormatOverride(nf);
    }
}

From source file:org.squale.squaleweb.util.graph.BubbleMaker.java

/**
 * Affichage sous la forme de sous-titres de la rpartition des mthodes - Maintenable et structur, - Maintenable
 * mais mal structur - Difficilement maintenable mais structur - Difficilement maintenable et mal structur
 * /* ww w.j  av  a2s  .c  om*/
 * @param pChart graphe de type Bubble
 */
private void displayRepartitionSubtitles(JFreeChart pChart) {
    double percentTopLeft = 0;
    double percentTopRight = 0;
    double percentBottomLeft = 0;
    double percentBottomRight = 0;
    int totalMethods = (int) (totalTopLeft + totalTopRight + totalBottomLeft + totalBottomRight);
    if (totalMethods > 0) {
        final int oneHundred = 100;
        // haut gauche : difficilement maintenable mais structur
        percentTopLeft = totalTopLeft * oneHundred / totalMethods;
        // haut droit : difficilement maintenable et mal structur
        percentTopRight = totalTopRight * oneHundred / totalMethods;
        // Bas gauche : maintenable et structur
        percentBottomLeft = totalBottomLeft * oneHundred / totalMethods;
        // Bas droit : maintenable mais mal structur
        percentBottomRight = totalBottomRight * oneHundred / totalMethods;
    }
    // Formatage des zones d'affichage
    NumberFormat numberFormat = NumberFormat.getInstance();
    numberFormat.setMaximumFractionDigits(1);
    numberFormat.setMinimumFractionDigits(1);
    // Ajout du sous-titre de rpartition des mthodes avec le pourcentage correspondant : partie suprieure, coin
    // gauche et droit
    StringBuffer stringBufferTop = new StringBuffer();
    stringBufferTop.append(WebMessages.getString(locale, "bubble.project.subtitle.topLeft") + " "
            + numberFormat.format(percentTopLeft) + "%     ");
    stringBufferTop.append(WebMessages.getString(locale, "bubble.project.subtitle.topRight") + " "
            + numberFormat.format(percentTopRight) + "%");
    TextTitle subtitleTop = new TextTitle(stringBufferTop.toString());

    // Ajout du sous-titre de rpartition des mthodes avec le pourcentage correspondant : partie infrieure, coin
    // gauche et droit
    StringBuffer stringBufferBottom = new StringBuffer();
    stringBufferBottom.append(WebMessages.getString(locale, "bubble.project.subtitle.bottomLeft") + " "
            + numberFormat.format(percentBottomLeft) + "%     ");
    stringBufferBottom.append(WebMessages.getString(locale, "bubble.project.subtitle.bottomRight") + " "
            + numberFormat.format(percentBottomRight) + "%");
    TextTitle subtitleBottom = new TextTitle(stringBufferBottom.toString());

    // Les rpartitions sont ajoutes sous la forme de sous-menus
    subtitleBottom.setPosition(RectangleEdge.BOTTOM);
    pChart.addSubtitle(subtitleBottom);
    subtitleTop.setPosition(RectangleEdge.BOTTOM);
    pChart.addSubtitle(subtitleTop);
}

From source file:io.plaidapp.ui.DesignerNewsStory.java

private void bindDescription() {
    final TextView storyComment = (TextView) header.findViewById(R.id.story_comment);
    if (!TextUtils.isEmpty(story.comment)) {
        HtmlUtils.setTextWithNiceLinks(storyComment,
                markdown.markdownToSpannable(story.comment, storyComment, new Bypass.LoadImageCallback() {
                    @Override/*from w  ww  .j a va 2 s  .  co  m*/
                    public void loadImage(String src, ImageLoadingSpan loadingSpan) {
                        Glide.with(DesignerNewsStory.this).load(src).asBitmap()
                                .diskCacheStrategy(DiskCacheStrategy.ALL)
                                .into(new ImageSpanTarget(storyComment, loadingSpan));
                    }
                }));
    } else {
        storyComment.setVisibility(View.GONE);
    }

    upvoteStory = (Button) header.findViewById(R.id.story_vote_action);
    upvoteStory.setText(getResources().getQuantityString(R.plurals.upvotes, story.vote_count,
            NumberFormat.getInstance().format(story.vote_count)));
    upvoteStory.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            upvoteStory();
        }
    });

    Button share = (Button) header.findViewById(R.id.story_share_action);
    share.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(ShareCompat.IntentBuilder.from(DesignerNewsStory.this).setText(story.url)
                    .setType("text/plain").setSubject(story.title).getIntent());
        }
    });

    TextView storyPosterTime = (TextView) header.findViewById(R.id.story_poster_time);
    SpannableString poster = new SpannableString("" + story.user_display_name);
    poster.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance_CommentAuthor), 0, poster.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    CharSequence job = !TextUtils.isEmpty(story.user_job) ? "\n" + story.user_job : "";
    CharSequence timeAgo = DateUtils.getRelativeTimeSpanString(story.created_at.getTime(),
            System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS);
    storyPosterTime.setText(TextUtils.concat(poster, job, "\n", timeAgo));
    ImageView avatar = (ImageView) header.findViewById(R.id.story_poster_avatar);
    if (!TextUtils.isEmpty(story.user_portrait_url)) {
        Glide.with(this).load(story.user_portrait_url).placeholder(R.drawable.avatar_placeholder)
                .transform(circleTransform).into(avatar);
    } else {
        avatar.setVisibility(View.GONE);
    }
}