List of usage examples for org.jfree.chart.renderer.xy XYItemRenderer setBaseItemLabelsVisible
public void setBaseItemLabelsVisible(Boolean visible);
From source file:org.jfree.chart.demo.BubbleChartDemo2.java
private static JFreeChart createChart(XYZDataset xyzdataset) { JFreeChart jfreechart = ChartFactory.createBubbleChart("Bubble Chart Demo 2", "X", "Y", xyzdataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setRenderer(new XYBubbleRenderer(0)); xyplot.setForegroundAlpha(0.65F);//from w w w. j a v a 2 s . c o m XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(0, Color.blue); xyitemrenderer.setBaseItemLabelGenerator(new BubbleXYItemLabelGenerator()); xyitemrenderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); xyitemrenderer.setBaseItemLabelsVisible(true); xyitemrenderer .setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setRange(0.0D, 10D); NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis(); numberaxis1.setRange(0.0D, 10D); return jfreechart; }
From source file:classpackage.ChartGalaxy.java
private static JFreeChart createChart(final XYDataset dataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("MDS Galaxy", "X", "Y", createDataset(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setBaseItemLabelGenerator(new LabelGenerator()); renderer.setBaseItemLabelPaint(Color.WHITE);//label renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); renderer.setBaseItemLabelFont(renderer.getBaseItemLabelFont().deriveFont(15f)); renderer.setBaseItemLabelsVisible(true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); //set false para linhas no grafico xyPlot.setDomainGridlinesVisible(false); xyPlot.setRangeGridlinesVisible(false); xyPlot.setRangeMinorGridlinesVisible(false); xyPlot.setRangeCrosshairVisible(false); xyPlot.setRangeCrosshairLockedOnData(false); xyPlot.setRangeZeroBaselineVisible(false); xyPlot.setBackgroundPaint(Color.BLACK); double size = 40.0; double delta = size / 2.0; Shape shape = new Rectangle2D.Double(-delta, -delta, size, size); renderer.setSeriesShape(0, shape);/*w ww.j av a 2 s . c o m*/ renderer.setSeriesPaint(0, transparent); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setRange(-0.1, 0.1); domain.setTickUnit(new NumberTickUnit(0.1)); domain.setVerticalTickLabels(true); NumberAxis range = (NumberAxis) xyPlot.getRangeAxis(); range.setRange(-0.1, 0.1); range.setTickUnit(new NumberTickUnit(0.1)); return jfreechart; }
From source file:net.sf.mzmine.modules.visualization.spectra.SpectraPlot.java
void switchItemLabelsVisible() { itemLabelsVisible = !itemLabelsVisible; for (int i = 0; i < plot.getDatasetCount(); i++) { XYItemRenderer renderer = plot.getRenderer(i); renderer.setBaseItemLabelsVisible(itemLabelsVisible); }/*from ww w. j a v a 2 s.c o m*/ }
From source file:com.bt.aloha.sipstone.GenGraph.java
private JFreeChart createSingleChart() { XYDataset xydatasetArray[] = createDataset_CallsPerSecond_AvgResponseTime(); XYDataset xydataset = xydatasetArray[0]; final XYDataset percXydataset = xydatasetArray[1]; JFreeChart jfreechart = ChartFactory.createXYLineChart("SIPStone result", "Calls per second", "Avg response time", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); XYItemRenderer xyrenderer = (XYItemRenderer) xyplot.getRenderer(); xyrenderer.setBaseItemLabelGenerator(new MyXYItemLabelGenerator(percXydataset)); xyrenderer.setBaseItemLabelsVisible(true); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setAutoRange(true);//w ww. j av a 2 s. c o m numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:com.bt.aloha.sipstone.GenGraph.java
private JFreeChart createCombinedChart() { XYDataset xydatasetArray[] = createDataset_TotalCallCreated_CallsPerSecond(); XYDataset xydataset = xydatasetArray[0]; final XYDataset percXydataset = xydatasetArray[1]; JFreeChart jfreechart = ChartFactory.createXYLineChart("SIPStone graph", "Calls", "Call rate", xydataset, PlotOrientation.VERTICAL, false, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); NumberAxis numberaxis = new NumberAxis("Avg. Response Time"); numberaxis.setAutoRangeIncludesZero(false); xyplot.setRangeAxis(1, numberaxis);/* w ww.ja v a 2s . c o m*/ xyplot.setDataset(1, createDataset_TotalCallCreated_AvgResponseTime()); xyplot.mapDatasetToRangeAxis(1, 1); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setShapesFilled(true); } XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer(); xylineandshaperenderer1.setSeriesPaint(0, Color.black); xylineandshaperenderer1.setBaseShapesVisible(true); xylineandshaperenderer1.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); xyplot.setRenderer(1, xylineandshaperenderer1); NumberAxis timeaxis = (NumberAxis) xyplot.getDomainAxis(); timeaxis.setAutoRange(true); timeaxis.setAxisLineVisible(true); LegendTitle legendtitle = new LegendTitle(xyitemrenderer); LegendTitle legendtitle1 = new LegendTitle(xylineandshaperenderer1); BlockContainer blockcontainer = new BlockContainer(new BorderArrangement()); blockcontainer.add(legendtitle, RectangleEdge.LEFT); blockcontainer.add(legendtitle1, RectangleEdge.RIGHT); blockcontainer.add(new EmptyBlock(2000D, 0.0D)); XYItemRenderer xyrenderer = (XYItemRenderer) xyplot.getRenderer(); xyrenderer.setBaseItemLabelGenerator(new MyXYItemLabelGenerator(percXydataset)); xyrenderer.setBaseItemLabelsVisible(true); CompositeTitle compositetitle = new CompositeTitle(blockcontainer); compositetitle.setPosition(RectangleEdge.BOTTOM); jfreechart.addSubtitle(compositetitle); return jfreechart; }
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 w w.j a v a 2s . c o m*/ 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:net.sf.mzmine.modules.visualization.tic.TICPlot.java
public void switchItemLabelsVisible() { // Switch to next mode. Include peaks mode only if peak labels are present. labelsVisible = (labelsVisible + 1) % (havePeakLabels ? 3 : 2); final int dataSetCount = plot.getDatasetCount(); for (int i = 0; i < dataSetCount; i++) { final XYDataset dataSet = plot.getDataset(i); final XYItemRenderer renderer = plot.getRenderer(i); if (dataSet instanceof TICDataSet) { renderer.setBaseItemLabelsVisible(labelsVisible == 1); } else if (dataSet instanceof PeakDataSet) { renderer.setBaseItemLabelsVisible(labelsVisible == 2); } else {//from w w w . j a v a 2 s . c om renderer.setBaseItemLabelsVisible(false); } } }
From source file:net.sf.mzmine.modules.visualization.spectra.SpectraPlot.java
/** * This will set either centroid or continuous renderer to the first data * set, assuming that dataset with index 0 contains the raw data. *///from w w w. ja v a 2 s . co m public void setPlotMode(PlotMode plotMode) { this.plotMode = plotMode; XYDataset dataSet = plot.getDataset(0); if (!(dataSet instanceof ScanDataSet)) return; XYItemRenderer newRenderer; if (plotMode == PlotMode.CENTROID) { newRenderer = new PeakRenderer(SpectraVisualizerWindow.scanColor, false); } else { newRenderer = new ContinuousRenderer(SpectraVisualizerWindow.scanColor, false); ((ContinuousRenderer) newRenderer).setBaseShapesVisible(dataPointsVisible); } // Add label generator for the dataset SpectraItemLabelGenerator labelGenerator = new SpectraItemLabelGenerator(this); newRenderer.setBaseItemLabelGenerator(labelGenerator); newRenderer.setBaseItemLabelsVisible(itemLabelsVisible); newRenderer.setBaseItemLabelPaint(labelsColor); plot.setRenderer(0, newRenderer); }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
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 w w . j av a 2 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.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); // chart properties chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor)); // legend properties LegendTitle legend = chart.getLegend(); // legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); // set the X axis (m/z) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setLabel("m/z"); 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); chartNode.setCursor(Cursor.CROSSHAIR); // Remove the dataset if it is removed from the list datasets.addListener((Change<? extends MsSpectrumDataSet> c) -> { while (c.next()) { if (c.wasRemoved()) { for (MsSpectrumDataSet ds : c.getRemoved()) { int index = plot.indexOf(ds); plot.setDataset(index, null); } } } }); itemLabelsVisible.addListener((prop, oldVal, newVal) -> { for (MsSpectrumDataSet 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:net.sf.mzmine.modules.visualization.spectra.SpectraPlot.java
public synchronized void addDataSet(XYDataset dataSet, Color color, boolean transparency) { XYItemRenderer newRenderer; if (dataSet instanceof ScanDataSet) { ScanDataSet scanDataSet = (ScanDataSet) dataSet; Scan scan = scanDataSet.getScan(); if (scan.isCentroided()) newRenderer = new PeakRenderer(color, transparency); else {/*from w w w . j av a2 s . co m*/ newRenderer = new ContinuousRenderer(color, transparency); ((ContinuousRenderer) newRenderer).setBaseShapesVisible(dataPointsVisible); } // Add label generator for the dataset SpectraItemLabelGenerator labelGenerator = new SpectraItemLabelGenerator(this); newRenderer.setBaseItemLabelGenerator(labelGenerator); newRenderer.setBaseItemLabelsVisible(itemLabelsVisible); newRenderer.setBaseItemLabelPaint(labelsColor); } else { newRenderer = new PeakRenderer(color, transparency); } plot.setDataset(numOfDataSets, dataSet); plot.setRenderer(numOfDataSets, newRenderer); numOfDataSets++; }