List of usage examples for org.jfree.chart JFreeChart getXYPlot
public XYPlot getXYPlot()
From source file:net.sf.dynamicreports.design.transformation.chartcustomizer.XyBlockRendererCustomizer.java
@Override public void customize(JFreeChart chart, ReportParameters reportParameters) { chart.getXYPlot().getDomainAxis().setUpperMargin(0); chart.getXYPlot().getRangeAxis().setUpperMargin(0); XYBlockRenderer renderer = new XYBlockRenderer(); if (xyBlockPlot.getBlockWidth() != null) { renderer.setBlockWidth(xyBlockPlot.getBlockWidth()); }// w w w .j av a2 s . c om if (xyBlockPlot.getBlockHeight() != null) { renderer.setBlockHeight(xyBlockPlot.getBlockHeight()); } if (xyBlockPlot.getBlockAnchor() != null) { renderer.setBlockAnchor(ConstantTransform.rectangleAnchor(xyBlockPlot.getBlockAnchor())); } LookupPaintScale paintScale = new LookupPaintScale(xyBlockPlot.getDefaultLowerBound(), xyBlockPlot.getDefaultUpperBound(), xyBlockPlot.getDefaultPaint()); for (DRIPaintScale scale : xyBlockPlot.getPaintScales()) { paintScale.add(scale.getValue(), scale.getPaint()); } renderer.setPaintScale(paintScale); chart.getXYPlot().setRenderer(renderer); LegendItemCollection legendItems = new LegendItemCollection(); for (DRIPaintScale scale : xyBlockPlot.getPaintScales()) { legendItems.add(new LegendItem(scale.getLabel(), scale.getPaint())); } chart.getXYPlot().setFixedLegendItems(legendItems); }
From source file:net.sf.jasperreports.customizers.axis.DomainAxisCustomizer.java
@Override public void customize(JFreeChart jfc, JRChart jrc) { if (jfc.getPlot() instanceof XYPlot) { ValueAxis valueAxis = jfc.getXYPlot().getDomainAxis(); configValueAxis(valueAxis, PROPERTY_MIN_VALUE, PROPERTY_MAX_VALUE); if (valueAxis instanceof NumberAxis) { configNumberAxis((NumberAxis) valueAxis, PROPERTY_TICK_UNIT); }//from ww w. j a va 2 s. com } }
From source file:org.apache.qpid.disttest.charting.chartbuilder.XYDataSetBasedChartBuilder.java
@Override protected SeriesStrokeAndPaintApplier newStrokeAndPaintApplier() { return new SeriesStrokeAndPaintApplier() { @Override//from w w w . j a v a2 s. c om public void setSeriesStroke(int seriesIndex, Stroke stroke, JFreeChart targetChart) { targetChart.getXYPlot().getRenderer().setSeriesStroke(seriesIndex, stroke); } @Override public void setSeriesPaint(int seriesIndex, Color colour, JFreeChart targetChart) { targetChart.getXYPlot().getRenderer().setSeriesPaint(seriesIndex, colour); } @Override public void setSeriesShape(final int seriesIndex, final Shape shape, final JFreeChart targetChart) { XYItemRenderer renderer = targetChart.getXYPlot().getRenderer(); if (renderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer lineAndShapeRenderer = (XYLineAndShapeRenderer) renderer; lineAndShapeRenderer.setSeriesShapesVisible(seriesIndex, true); lineAndShapeRenderer.setSeriesShape(seriesIndex, shape); } } }; }
From source file:Business.Chart.Temperature.java
public Temperature(final String applicationTitle, String chartTitle, HospitalWorkRequest workRequest) { super(applicationTitle); series3 = new TimeSeries("Temperature"); this.workRequest = workRequest; this.chartTitle = chartTitle; final XYDataset dataset3 = createDatasetTemperature(workRequest); final JFreeChart chart3 = createChart(dataset3); final XYPlot plot = chart3.getXYPlot(); HospitalWorkRequest hos1 = (HospitalWorkRequest) workRequest; int age = hos1.getPerson().getAge(); int a = hos1.getPerson().getAboveTemperatureRateMarker(age); int b = hos1.getPerson().getBelowTemperatureRateMarker(age); ValueMarker valueMarker = new ValueMarker(a); valueMarker.setLabel("ALERT"); valueMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); valueMarker.setPaint(Color.blue); ValueMarker valueMarker1 = new ValueMarker(b); valueMarker1.setLabel("ALERT"); valueMarker1.setLabelTextAnchor(TextAnchor.TOP_CENTER); valueMarker1.setPaint(Color.BLUE); plot.addRangeMarker(valueMarker);/*from w w w . ja v a 2 s.c om*/ plot.addRangeMarker(valueMarker1); final ChartPanel chartPanel = new ChartPanel(chart3); chartPanel.setPreferredSize(new java.awt.Dimension(560, 370)); chartPanel.setMouseZoomable(true, false); setContentPane(chartPanel); getContentPane().repaint(); }
From source file:slash.navigation.converter.gui.elevationview.ElevationView.java
private XYPlot createPlot(JFreeChart chart) { XYPlot plot = chart.getXYPlot(); plot.setForegroundAlpha(0.65F);//from w ww . j av a 2s .c om NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); Font font = new JLabel().getFont(); rangeAxis.setLabelFont(font); NumberAxis valueAxis = (NumberAxis) plot.getDomainAxis(); valueAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); valueAxis.setLowerMargin(0.0); valueAxis.setUpperMargin(0.0); valueAxis.setLabelFont(font); XYItemRenderer renderer = plot.getRenderer(); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{2}m @ {1} Km", NumberFormat.getIntegerInstance(), NumberFormat.getIntegerInstance())); return plot; }
From source file:net.sourceforge.processdash.ev.ui.chart.AbstractEVXYChart.java
@Override protected JFreeChart createChart(XYDataset data) { JFreeChart chart = null; chart = getXYChartObject(data);/*from w ww . j av a 2 s . c o m*/ chart.getXYPlot().setRenderer(createRenderer(chart)); return chart; }
From source file:Business.Chart.ChartRespiratory.java
public ChartRespiratory(final String applicationTitle, String chartTitle, HospitalWorkRequest workRequest) { super(applicationTitle); repaint();//from ww w .ja v a 2 s. c om series2 = new TimeSeries("Respiratory Rate"); this.workRequest = workRequest; this.chartTitle = chartTitle; final XYDataset dataset2 = createDatasetRespiratoryRate(workRequest); final JFreeChart chart2 = createChart(dataset2); final XYPlot plot = chart2.getXYPlot(); HospitalWorkRequest hos1 = (HospitalWorkRequest) workRequest; int age = hos1.getPerson().getAge(); int a = hos1.getPerson().getAboveRespirationRateMarker(age); int b = hos1.getPerson().getBelowRespirationRateMarker(age); ValueMarker valueMarker = new ValueMarker(a); valueMarker.setLabel("ALERT"); valueMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); valueMarker.setPaint(Color.blue); ValueMarker valueMarker1 = new ValueMarker(b); valueMarker1.setLabel("ALERT"); valueMarker1.setLabelTextAnchor(TextAnchor.TOP_CENTER); valueMarker1.setPaint(Color.BLUE); plot.addRangeMarker(valueMarker); plot.addRangeMarker(valueMarker1); final ChartPanel chartPanel = new ChartPanel(chart2); chartPanel.setPreferredSize(new java.awt.Dimension(560, 370)); chartPanel.setMouseZoomable(true, false); setContentPane(chartPanel); getContentPane().repaint(); }
From source file:net.sourceforge.processdash.ui.web.reports.XYChart.java
private void addTrendLine(JFreeChart chart, XYDataset dataset) { XYPlot plot = chart.getXYPlot(); plot.setDataset(1, dataset);// w w w . j a v a 2s . c om plot.setRenderer(1, new StandardXYItemRenderer(StandardXYItemRenderer.LINES)); }
From source file:org.matsim.contrib.parking.parkingchoice.lib.GeneralLib.java
public static void generateXYScatterPlot(String fileName, double[] x, double[] y, String title, String xLabel, String yLabel) {//from w w w . j av a 2s . c o m if (x.length != y.length) { DebugLib.stopSystemAndReportInconsistency("dimensions of arrays do not match"); } final XYSeries series1 = new XYSeries(title); for (int i = 0; i < x.length; i++) { series1.add(x[i], y[i]); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); final JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); int width = 500; int height = 300; try { ChartUtilities.saveChartAsPNG(new File(fileName), chart, width, height); } catch (IOException e) { } }
From source file:com.romraider.logger.ecu.ui.tab.LoggerChartPanel.java
private void configurePlot(JFreeChart chart) { XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(BLACK);//from w w w. ja va 2 s. com plot.getDomainAxis().setLabelPaint(WHITE); plot.getRangeAxis().setLabelPaint(WHITE); plot.getDomainAxis().setTickLabelPaint(LIGHT_GREY); plot.getRangeAxis().setTickLabelPaint(LIGHT_GREY); plot.setDomainGridlinePaint(DARK_GREY); plot.setRangeGridlinePaint(DARK_GREY); plot.setOutlinePaint(DARK_GREY); plot.setRenderer(buildScatterRenderer(2, RED)); }