List of usage examples for org.jfree.chart.plot XYPlot setDatasetRenderingOrder
public void setDatasetRenderingOrder(DatasetRenderingOrder order)
From source file:io.github.mzmine.modules.plots.chromatogram.ChromatogramPlotWindowController.java
@FXML public void initialize() { final JFreeChart chart = chartNode.getChart(); final XYPlot plot = chart.getXYPlot(); // Do not set colors and strokes dynamically. They are instead provided // by the dataset and configured in configureRenderer() plot.setDrawingSupplier(null);//from w ww .j a va2 s . c om plot.setDomainGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor)); plot.setRangeGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor)); plot.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor)); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setDomainCrosshairPaint(JavaFXUtil.convertColorToAWT(crossHairColor)); plot.setRangeCrosshairPaint(JavaFXUtil.convertColorToAWT(crossHairColor)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); // chart properties chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor)); // legend properties LegendTitle legend = chart.getLegend(); // legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setLabel("Retention time (min)"); xAxis.setUpperMargin(0.03); xAxis.setLowerMargin(0.03); xAxis.setRangeType(RangeType.POSITIVE); xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20)); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setLabel("Intensity"); yAxis.setRangeType(RangeType.POSITIVE); yAxis.setAutoRangeIncludesZero(true); // set the fixed number formats, because otherwise JFreeChart sometimes // shows exponent, sometimes it doesn't DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); xAxis.setNumberFormatOverride(mzFormat); DecimalFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); yAxis.setNumberFormatOverride(intensityFormat); chartTitle = chartNode.getChart().getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartTitle.setText("Chromatogram"); chartNode.setCursor(Cursor.CROSSHAIR); // Remove the dataset if it is removed from the list datasets.addListener((Change<? extends ChromatogramPlotDataSet> c) -> { while (c.next()) { if (c.wasRemoved()) { for (ChromatogramPlotDataSet ds : c.getRemoved()) { int index = plot.indexOf(ds); plot.setDataset(index, null); } } } }); itemLabelsVisible.addListener((prop, oldVal, newVal) -> { for (ChromatogramPlotDataSet dataset : datasets) { int datasetIndex = plot.indexOf(dataset); XYItemRenderer renderer = plot.getRenderer(datasetIndex); renderer.setBaseItemLabelsVisible(newVal); } }); legendVisible.addListener((prop, oldVal, newVal) -> { legend.setVisible(newVal); }); }
From source file:MSUmpire.DIA.MixtureModelKDESemiParametric.java
public void GeneratePlot(String pngfile) throws IOException { String modelfile = FilenameUtils.getFullPath(pngfile) + "/" + FilenameUtils.getBaseName(pngfile) + "_ModelPoints.txt"; FileWriter writer = new FileWriter(modelfile); double[] IDObs = new double[IDEmpiricalDist.getN()]; double[] DecoyObs = new double[DecoyEmpiricalDist.getN()]; for (int i = 0; i < IDEmpiricalDist.getN(); i++) { IDObs[i] = IDEmpiricalDist.getObs(i); }/*from w w w .j a v a 2s .co m*/ for (int i = 0; i < DecoyEmpiricalDist.getN(); i++) { DecoyObs[i] = DecoyEmpiricalDist.getObs(i); } XYSeries model1 = new XYSeries("Incorrect matches"); XYSeries model2 = new XYSeries("Correct matches"); XYSeries model3 = new XYSeries("All target hits"); writer.write("UScore\tModel\tCorrect\tDecoy\n"); for (int i = 0; i < NoBinPoints; i++) { model1.add(model_kde_x[i], decoy_kde_y[i]); model2.add(model_kde_x[i], correct_kde_y[i]); model3.add(model_kde_x[i], model_kde_y[i]); writer.write(model_kde_x[i] + "\t" + model_kde_y[i] + "\t" + correct_kde_y[i] + "\t" + decoy_kde_y[i] + "\n"); } writer.close(); MixtureModelProb = new float[NoBinPoints + 1][3]; float positiveaccu = 0f; float negativeaccu = 0f; MixtureModelProb[0][0] = (float) model2.getMaxX() + Float.MIN_VALUE; MixtureModelProb[0][1] = 1f; MixtureModelProb[0][2] = 1f; for (int i = 1; i < NoBinPoints + 1; i++) { double positiveNumber = correct_kde_y[NoBinPoints - i]; double negativeNumber = decoy_kde_y[NoBinPoints - i]; MixtureModelProb[i][0] = (float) model_kde_x[NoBinPoints - i]; positiveaccu += positiveNumber; negativeaccu += negativeNumber; MixtureModelProb[i][2] = 0.999999f * (float) (positiveNumber / (negativeNumber + positiveNumber)); MixtureModelProb[i][1] = 0.999999f * (float) (positiveaccu / (negativeaccu + positiveaccu)); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(model1); dataset.addSeries(model2); dataset.addSeries(model3); HistogramDataset histogramDataset = new HistogramDataset(); histogramDataset.setType(HistogramType.SCALE_AREA_TO_1); histogramDataset.addSeries("ID hits", IDObs, 100); histogramDataset.addSeries("Decoy hits", DecoyObs, 100); //histogramDataset.addSeries("Model hits", ModelObs, 100); JFreeChart chart = ChartFactory.createHistogram(FilenameUtils.getBaseName(pngfile), "Score", "Hits", histogramDataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = chart.getXYPlot(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setRange(min, max); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setForegroundAlpha(0.8f); chart.setBackgroundPaint(Color.white); XYLineAndShapeRenderer render = new XYLineAndShapeRenderer(); plot.setDataset(1, dataset); plot.setRenderer(1, render); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); try { ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600); } catch (IOException e) { } }
From source file:org.jfree.chart.demo.OverlaidXYPlotDemo.java
/** * Creates an overlaid chart.//from ww w . j av a 2s . c om * * @return The chart. */ private JFreeChart createOverlaidChart() { // create plot ... final IntervalXYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new XYBarRenderer(0.20); renderer1.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); final DateAxis domainAxis = new DateAxis("Date"); domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); final ValueAxis rangeAxis = new NumberAxis("Value"); final XYPlot plot = new XYPlot(data1, domainAxis, rangeAxis, renderer1); final double x = new Day(9, SerialDate.MARCH, 2002).getMiddleMillisecond(); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", x, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); plot.addAnnotation(annotation); // add a second dataset and renderer... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); plot.setDataset(1, data2); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // return a new chart containing the overlaid plot... return new JFreeChart("Overlaid Plot Example", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.jfree.eastwood.ChartEngine.java
/** * The 'ewtr' tag is an Eastwood extension that draws a trend line over a * chart, using data that has been added to a secondary dataset using the * 'ewd2' tag./* w w w .j a v a 2s.c om*/ * * @param params the chart parameters; * @param chart the chart under construction (will be updated by this * method if necessary). */ public static void processEWTR(Map params, JFreeChart chart) { // the 'ewtr' arguments are: // - <seriesIndex> : the index of the series in the secondary dataset; // - <colour> : the colour; // - <lineThickness> : the line thickness; String[] ewtrStr = (String[]) params.get("ewtr"); if (ewtrStr != null) { String[] atts = ewtrStr[0].split(","); int series = Integer.parseInt(atts[0]); Color color = parseColor(atts[1]); float lineWidth = Float.parseFloat(atts[2]); Plot plot = chart.getPlot(); if (plot instanceof CategoryPlot) { CategoryPlot cp = (CategoryPlot) plot; if (cp.getDataset(1) != null) { LineAndShapeRenderer r = new LineAndShapeRenderer(true, false); r.setBaseSeriesVisible(false); r.setSeriesVisible(series, Boolean.TRUE); r.setSeriesPaint(series, color); r.setSeriesStroke(series, new BasicStroke(lineWidth)); cp.setRenderer(1, r); cp.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); } } else if (plot instanceof XYPlot) { XYPlot xp = (XYPlot) plot; if (xp.getDataset(1) != null) { XYLineAndShapeRenderer r = new XYLineAndShapeRenderer(true, false); r.setBaseSeriesVisible(false); r.setSeriesVisible(series, Boolean.TRUE); r.setSeriesPaint(series, color); r.setSeriesStroke(series, new BasicStroke(lineWidth)); xp.setRenderer(1, r); xp.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); } } } }
From source file:ec.ui.view.StabilityView.java
private JFreeChart createChart() { XYPlot plot = new XYPlot(); plot.setDataset(SMOOTH_INDEX, Charts.emptyXYDataset()); plot.setRenderer(SMOOTH_INDEX, smoothRenderer); plot.mapDatasetToDomainAxis(SMOOTH_INDEX, 0); plot.mapDatasetToRangeAxis(SMOOTH_INDEX, 0); plot.setDataset(MEAN_INDEX, Charts.emptyXYDataset()); plot.setRenderer(MEAN_INDEX, meanRenderer); plot.mapDatasetToDomainAxis(MEAN_INDEX, 0); plot.mapDatasetToRangeAxis(MEAN_INDEX, 0); plot.setDataset(POINTS_INDEX, Charts.emptyXYDataset()); plot.setRenderer(POINTS_INDEX, pointsRenderer); plot.mapDatasetToDomainAxis(POINTS_INDEX, 0); plot.mapDatasetToRangeAxis(POINTS_INDEX, 0); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, false); result.setPadding(TsCharts.CHART_PADDING); return result; }
From source file:com.android.ddmuilib.net.NetworkPanel.java
/** * Create chart of recent network activity. *//*from ww w .j av a 2 s. co m*/ private void createChart() { mChart = ChartFactory.createTimeSeriesChart(null, null, null, null, false, false, false); // create backing datasets and series mRxTotalSeries = new TimeSeries("RX total"); mTxTotalSeries = new TimeSeries("TX total"); mRxTotalSeries.setMaximumItemAge(HISTORY_MILLIS); mTxTotalSeries.setMaximumItemAge(HISTORY_MILLIS); mTotalCollection = new TimeSeriesCollection(); mTotalCollection.addSeries(mRxTotalSeries); mTotalCollection.addSeries(mTxTotalSeries); mRxDetailDataset = new LiveTimeTableXYDataset(); mTxDetailDataset = new LiveTimeTableXYDataset(); mTotalRenderer = new XYAreaRenderer(XYAreaRenderer.AREA); mRenderer = new StackedXYAreaRenderer2(); final XYPlot xyPlot = mChart.getXYPlot(); xyPlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); xyPlot.setDataset(0, mTotalCollection); xyPlot.setDataset(1, mRxDetailDataset); xyPlot.setDataset(2, mTxDetailDataset); xyPlot.setRenderer(0, mTotalRenderer); xyPlot.setRenderer(1, mRenderer); xyPlot.setRenderer(2, mRenderer); // we control domain axis manually when taking samples mDomainAxis = xyPlot.getDomainAxis(); mDomainAxis.setAutoRange(false); final NumberAxis axis = new NumberAxis(); axis.setNumberFormatOverride(new BytesFormat(true)); axis.setAutoRangeMinimumSize(50); xyPlot.setRangeAxis(axis); xyPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); // draw thick line to separate RX versus TX traffic xyPlot.addRangeMarker(new ValueMarker(0, java.awt.Color.BLACK, new java.awt.BasicStroke(2))); // label to indicate that positive axis is RX traffic final ValueMarker rxMarker = new ValueMarker(0); rxMarker.setStroke(new java.awt.BasicStroke(0)); rxMarker.setLabel("RX"); rxMarker.setLabelFont(rxMarker.getLabelFont().deriveFont(30f)); rxMarker.setLabelPaint(java.awt.Color.LIGHT_GRAY); rxMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); rxMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); xyPlot.addRangeMarker(rxMarker); // label to indicate that negative axis is TX traffic final ValueMarker txMarker = new ValueMarker(0); txMarker.setStroke(new java.awt.BasicStroke(0)); txMarker.setLabel("TX"); txMarker.setLabelFont(txMarker.getLabelFont().deriveFont(30f)); txMarker.setLabelPaint(java.awt.Color.LIGHT_GRAY); txMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); txMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); xyPlot.addRangeMarker(txMarker); mChartComposite = new ChartComposite(mPanel, SWT.BORDER, mChart, ChartComposite.DEFAULT_WIDTH, ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH, ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, 4096, 4096, true, true, true, true, false, true); final FormData data = new FormData(); data.top = new FormAttachment(mHeader); data.left = new FormAttachment(0); data.bottom = new FormAttachment(70); data.right = new FormAttachment(100); mChartComposite.setLayoutData(data); }
From source file:com.hazelcast.monitor.server.MChartGenerator.java
@Override protected void afterPlot(List<? super InstanceStatistics> list, JFreeChart chart, XYPlot plot) { NumberAxis sizeAxis = (NumberAxis) plot.getRangeAxis(0); Font labelFont = sizeAxis.getLabelFont(); Paint labelPaint = sizeAxis.getLabelPaint(); TimeSeries tm = new TimeSeries("memory"); for (int i = 0; i < list.size(); i++) { double memory = 0; MapStatistics mapStatistics = (MapStatistics) list.get(i); for (MapStatistics.LocalMapStatistics localMapStatistics : mapStatistics.getListOfLocalStats()) { memory = memory + localMapStatistics.ownedEntryMemoryCost + localMapStatistics.backupEntryMemoryCost + localMapStatistics.markedAsRemovedMemoryCost; }/* w w w . j ava 2 s. com*/ double mem = new Double(memory / (double) (1024 * 1024)); tm.addOrUpdate(new Second(((MapStatistics) list.get(i)).getCreatedDate()), mem); } NumberAxis memoryAxis = new NumberAxis("memory (MB)"); memoryAxis.setAutoRange(true); memoryAxis.setAutoRangeIncludesZero(false); plot.setDataset(1, new TimeSeriesCollection(tm)); plot.setRangeAxis(1, memoryAxis); plot.mapDatasetToRangeAxis(1, 1); plot.setRenderer(1, new StandardXYItemRenderer()); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); increaseRange(memoryAxis); memoryAxis.setLabelFont(labelFont); memoryAxis.setLabelPaint(labelPaint); }
From source file:OverlaidXYPlotDemo2.java
/** * Creates an overlaid chart.//from ww w . j ava2 s . c o m * * @return The chart. */ private JFreeChart createOverlaidChart() { final DateAxis domainAxis = new DateAxis("Date"); domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); final ValueAxis rangeAxis = new NumberAxis("Value"); // create plot... final IntervalXYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new XYBarRenderer(0.20); renderer1.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); final XYPlot plot = new XYPlot(data1, domainAxis, rangeAxis, renderer1); final double x = new Day(9, SerialDate.MARCH, 2002).getMiddleMillisecond(); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", x, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); plot.addAnnotation(annotation); final ValueAxis rangeAxis2 = new NumberAxis("Value 2"); plot.setRangeAxis(1, rangeAxis2); // create subplot 2... final XYDataset data2A = createDataset2A(); final XYItemRenderer renderer2A = new StandardXYItemRenderer(); renderer2A.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); plot.setDataset(1, data2A); plot.setRenderer(1, renderer2A); final XYDataset data2B = createDataset2B(); plot.setDataset(2, data2B); plot.setRenderer(2, new StandardXYItemRenderer()); plot.mapDatasetToRangeAxis(2, 1); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("Overlaid Plot Example", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:be.nbb.demetra.dfm.output.simulation.RealTimePerspGraphView.java
private JFreeChart createChart() { XYPlot plot = new XYPlot(); plot.setDataset(TRUE_DATA_INDEX, Charts.emptyXYDataset()); plot.setRenderer(TRUE_DATA_INDEX, trueDataRenderer); plot.mapDatasetToDomainAxis(TRUE_DATA_INDEX, 0); plot.mapDatasetToRangeAxis(TRUE_DATA_INDEX, 0); plot.setDataset(FCTS_INDEX, Charts.emptyXYDataset()); plot.setRenderer(FCTS_INDEX, forecastsRenderer); plot.mapDatasetToDomainAxis(FCTS_INDEX, 0); plot.mapDatasetToRangeAxis(FCTS_INDEX, 0); plot.setDataset(ARIMA_DATA_INDEX, Charts.emptyXYDataset()); plot.setRenderer(ARIMA_DATA_INDEX, arimaRenderer); plot.mapDatasetToDomainAxis(ARIMA_DATA_INDEX, 0); plot.mapDatasetToRangeAxis(ARIMA_DATA_INDEX, 0); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); JFreeChart result = new JFreeChart("", TsCharts.CHART_TITLE_FONT, plot, false); result.setPadding(TsCharts.CHART_PADDING); return result; }
From source file:com.ivli.roim.controls.VOILUTPanel.java
public VOILUTPanel(LUTControl aP) { iCurveName = java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("VOILUTPANEL.VOI_LUT"); iLUT = LUTControl.create(aP);/*from w ww . j a v a2 s . com*/ aP.addWindowChangeListener(this); initComponents(); XYPlot plot = new XYPlot(); plot.setDataset(0, makeLUTCurve()); plot.setRenderer(0, new XYSplineRenderer()); ((XYSplineRenderer) plot.getRenderer()).setShapesVisible(false); plot.setRangeAxis(0, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle") .getString("VOILUTPANEL.AXIS_LABEL_VOI_CURVE"))); XYSeriesCollection col2 = new XYSeriesCollection(); col2.addSeries(makeHistogram()); plot.setDataset(1, col2); plot.setRenderer(1, new XYBarRenderer()); plot.setRangeAxis(1, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle") .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_SPACE"))); plot.mapDatasetToRangeAxis(1, 1); plot.setDomainAxis(new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle") .getString("VOILUTPANEL.AXIS_LABEL_IMAGE_HISTOGRAM"))); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); // change the rendering order so the primary dataset appears "behind" the // other datasets... plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); JFreeChart jfc = new JFreeChart(plot); jfc.setBorderVisible(true); jfc.removeLegend(); iPanel = new ChartPanel(jfc); iPanel.setSize(jPanel1.getPreferredSize()); jPanel1.add(iPanel);//, java.awt.BorderLayout.CENTER); iLUT.setSize(jPanel2.getPreferredSize()); jPanel2.add(iLUT); iLabelMin.setText(String.format("%.0f", iLUT.getView().getMin())); iLabelMax.setText(String.format("%.0f", iLUT.getView().getMax())); validate(); }