List of usage examples for org.jfree.chart.axis NumberAxis setNumberFormatOverride
public void setNumberFormatOverride(NumberFormat formatter)
From source file:org.amanzi.awe.charts.builder.TimeChartBuilder.java
@Override protected NumberAxis configRangeAxis(IRangeAxis axis) { NumberAxis rangeAxis; if (axis.equals(getModel().getMainRangeAxis())) { rangeAxis = (NumberAxis) getPlot().getRangeAxis(); rangeAxis.setNumberFormatOverride(NumberFormat.getInstance()); rangeAxis.getNumberFormatOverride().setMaximumFractionDigits(MAXIMUM_FRACTION_DIGITS); } else {//ww w. j a va 2s . c om rangeAxis = new NumberAxis(getModel().getSecondRangeAxis().getName()); rangeAxis.setNumberFormatOverride(NumberFormat.getInstance()); rangeAxis.getNumberFormatOverride().setMaximumFractionDigits(MAXIMUM_FRACTION_DIGITS); rangeAxis.setAutoRangeIncludesZero(false); } return rangeAxis; }
From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.tasks.ChromatogramViewLoaderWorker.java
private void configurePlot(XYPlot plot, RTUnit rtAxisUnit) { NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setNumberFormatOverride(new RTNumberFormatter(rtAxisUnit)); domainAxis.setLabel("RT[" + rtAxisUnit.name().toLowerCase() + "]"); plot.setRangeZeroBaselineVisible(true); plot.setDomainZeroBaselineVisible(false); domainAxis.setAutoRange(true);//www . j a va 2s .com domainAxis.setAutoRangeIncludesZero(false); ((NumberAxis) plot.getRangeAxis()).setAutoRange(true); ((NumberAxis) plot.getRangeAxis()).setAutoRangeIncludesZero(true); Logger.getLogger(getClass().getName()).info("Adding chart"); plot.setBackgroundPaint(Color.WHITE); }
From source file:org.drools.planner.benchmark.statistic.BestScoreStatistic.java
private CharSequence writeGraphStatistic(File solverStatisticFilesDirectory, String baseName) { XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (Map.Entry<String, BestScoreStatisticListener> listenerEntry : bestScoreStatisticListenerMap .entrySet()) {/*from w w w . j a v a 2s . c om*/ String configName = listenerEntry.getKey(); XYSeries configSeries = new XYSeries(configName); List<BestScoreStatisticPoint> statisticPointList = listenerEntry.getValue() .getBestScoreStatisticPointList(); for (BestScoreStatisticPoint statisticPoint : statisticPointList) { long timeMillisSpend = statisticPoint.getTimeMillisSpend(); Score score = statisticPoint.getScore(); Double scoreGraphValue = scoreDefinition.translateScoreToGraphValue(score); if (scoreGraphValue != null) { configSeries.add(timeMillisSpend, scoreGraphValue); } } seriesCollection.addSeries(configSeries); } NumberAxis xAxis = new NumberAxis("Time millis spend"); xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat()); NumberAxis yAxis = new NumberAxis("Score"); yAxis.setAutoRangeIncludesZero(false); XYItemRenderer renderer = new XYStepRenderer(); XYPlot plot = new XYPlot(seriesCollection, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(baseName + " best score statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); BufferedImage chartImage = chart.createBufferedImage(1024, 768); File graphStatisticFile = new File(solverStatisticFilesDirectory, baseName + "Statistic.png"); OutputStream out = null; try { out = new FileOutputStream(graphStatisticFile); ImageIO.write(chartImage, "png", out); } catch (IOException e) { throw new IllegalArgumentException("Problem writing graphStatisticFile: " + graphStatisticFile, e); } finally { IOUtils.closeQuietly(out); } return " <img src=\"" + graphStatisticFile.getName() + "\"/>\n"; }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.CoberturaTimeChartStrategy.java
public NumberAxis getRangeAxis() { NumberAxis valueaxis = new NumberAxis(); valueaxis.setLowerMargin(0.0D);//from w w w. j av a 2s .c om valueaxis.setUpperMargin(0.099D); valueaxis.setRangeWithMargins(0.0D, 1.0D); valueaxis.setLabel(this.getYAxisLabel()); valueaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); return valueaxis; }
From source file:guineu.modules.filter.Alignment.RANSAC.AlignmentRansacPlot.java
public void printAlignmentChart(String axisTitleX, String axisTitleY) { try {//from w w w .j av a 2s .c o m toolTipGenerator = new AlignmentPreviewTooltipGenerator(axisTitleX, axisTitleY); plot.getRenderer().setBaseToolTipGenerator(toolTipGenerator); NumberAxis xAxis = new NumberAxis(axisTitleX); xAxis.setNumberFormatOverride(rtFormat); xAxis.setAutoRangeIncludesZero(false); plot.setDomainAxis(xAxis); NumberAxis yAxis = new NumberAxis(axisTitleY); yAxis.setNumberFormatOverride(rtFormat); yAxis.setAutoRangeIncludesZero(false); plot.setRangeAxis(yAxis); } catch (Exception e) { } }
From source file:org.drools.planner.benchmark.statistic.bestscore.BestScoreStatistic.java
private CharSequence writeGraphStatistic(File solverStatisticFilesDirectory, String baseName) { NumberAxis xAxis = new NumberAxis("Time millis spend"); xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat()); NumberAxis yAxis = new NumberAxis("Score"); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); int seriesIndex = 0; for (Map.Entry<String, BestScoreStatisticListener> listenerEntry : bestScoreStatisticListenerMap .entrySet()) {/* w w w .j av a 2s . c o m*/ String configName = listenerEntry.getKey(); XYSeries series = new XYSeries(configName); List<BestScoreStatisticPoint> statisticPointList = listenerEntry.getValue().getStatisticPointList(); for (BestScoreStatisticPoint statisticPoint : statisticPointList) { long timeMillisSpend = statisticPoint.getTimeMillisSpend(); Score score = statisticPoint.getScore(); Double scoreGraphValue = scoreDefinition.translateScoreToGraphValue(score); if (scoreGraphValue != null) { series.add(timeMillisSpend, scoreGraphValue); } } XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(series); plot.setDataset(seriesIndex, seriesCollection); XYItemRenderer renderer; // No direct lines between 2 points renderer = new XYStepRenderer(); if (statisticPointList.size() <= 1) { // Workaround for https://sourceforge.net/tracker/?func=detail&aid=3387330&group_id=15494&atid=115494 renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES); } plot.setRenderer(seriesIndex, renderer); seriesIndex++; } plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(baseName + " best score statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); BufferedImage chartImage = chart.createBufferedImage(1024, 768); File graphStatisticFile = new File(solverStatisticFilesDirectory, baseName + "BestScoreStatistic.png"); OutputStream out = null; try { out = new FileOutputStream(graphStatisticFile); ImageIO.write(chartImage, "png", out); } catch (IOException e) { throw new IllegalArgumentException("Problem writing graphStatisticFile: " + graphStatisticFile, e); } finally { IOUtils.closeQuietly(out); } return " <img src=\"" + graphStatisticFile.getName() + "\"/>\n"; }
From source file:ch.epfl.leb.sass.ijplugin.SimulatorStatusFrame.java
/** * Creates a new status frame.// ww w . ja va2s . c om * * @param groundTruthYLabel The y-axis label for the ground truth signal. * @param analyzerYLabel The units output by the analyzer. * @param setpointYLabel The units of the controller setpoint. * @param outputYLabel The units output by the controller. */ public SimulatorStatusFrame(String groundTruthYLabel, String analyzerYLabel, String setpointYLabel, String outputYLabel) { String seriesLabel = ""; String yLabel = ""; CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new NumberAxis("Simulation Outputs")); Font yLabelFont = new Font("Dialog", Font.PLAIN, 10); datasets = new XYSeriesCollection[4]; for (int i = 0; i < SUBPLOT_COUNT; i++) { switch (i) { case 0: seriesLabel = "True density"; yLabel = groundTruthYLabel; break; case 1: seriesLabel = "Analyzer output"; yLabel = analyzerYLabel; break; case 2: seriesLabel = "Setpoint"; yLabel = setpointYLabel; break; case 3: seriesLabel = "Controller output"; yLabel = outputYLabel; break; } XYSeries timeseries = new XYSeries(seriesLabel); datasets[i] = new XYSeriesCollection(timeseries); NumberAxis numberaxis = new NumberAxis(yLabel); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setNumberFormatOverride(new DecimalFormat("###0.00")); XYPlot xyplot = new XYPlot(datasets[i], null, numberaxis, new StandardXYItemRenderer()); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.getRangeAxis().setLabelFont(yLabelFont); combineddomainxyplot.add(xyplot); } JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, combineddomainxyplot, true); jfreechart.setBorderPaint(Color.black); jfreechart.setBorderVisible(true); jfreechart.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); ValueAxis valueaxis = combineddomainxyplot.getDomainAxis(); valueaxis.setAutoRange(true); // Number of frames to display valueaxis.setFixedAutoRange(2000D); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(800, 500)); chartpanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chartpanel.setVisible(true); JPanel jPanel = new JPanel(); jPanel.setLayout(new BorderLayout()); jPanel.add(chartpanel, BorderLayout.NORTH); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); add(jPanel); pack(); setVisible(true); }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.CloverTimeChartStrategy.java
/** * /*from ww w . j a va 2s. co m*/ */ public NumberAxis getRangeAxis() { NumberAxis valueaxis = new NumberAxis(); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.05D); valueaxis.setRangeWithMargins(0.0D, 1.0D); valueaxis.setLabel(this.getYAxisLabel()); valueaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); return valueaxis; }
From source file:com.sixrr.metrics.ui.charts.DiffHistogramDialog.java
private JFreeChart createChart(IntervalXYDataset dataset, boolean isIntegral) { final String title = getTitle(); final NumberAxis xAxis = new NumberAxis(); if (metricType.equals(MetricType.Ratio) || metricType.equals(MetricType.RecursiveRatio)) { xAxis.setNumberFormatOverride(new PercentFormatter()); }/* ww w . ja v a2 s. com*/ if (isIntegral) { xAxis.setTickUnit(new NumberTickUnit(1.0)); } final XYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator(); final XYItemRenderer renderer = new XYBarRenderer(); renderer.setToolTipGenerator(tooltipGenerator); renderer.setURLGenerator(null); final ValueAxis yAxis = new NumberAxis(); final XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); plot.setRenderer(renderer); plot.setOrientation(PlotOrientation.VERTICAL); return new JFreeChart(title, JFreeChartConstants.DEFAULT_TITLE_FONT, plot, true); }
From source file:guineu.modules.filter.Alignment.RANSACGCGC.AlignmentGCGCRansacPlot.java
public void printAlignmentChart(String axisTitleX, String axisTitleY) { try {/* w w w . java2 s. c o m*/ toolTipGenerator = new AlignmentGCGCPreviewTooltipGenerator(axisTitleX, axisTitleY); plot.getRenderer().setBaseToolTipGenerator(toolTipGenerator); NumberAxis xAxis = new NumberAxis(axisTitleX); xAxis.setNumberFormatOverride(rtFormat); xAxis.setAutoRangeIncludesZero(false); plot.setDomainAxis(xAxis); NumberAxis yAxis = new NumberAxis(axisTitleY); yAxis.setNumberFormatOverride(rtFormat); yAxis.setAutoRangeIncludesZero(false); plot.setRangeAxis(yAxis); } catch (Exception e) { } }