List of usage examples for org.jfree.chart.plot XYPlot setRenderer
public void setRenderer(int index, XYItemRenderer renderer)
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.dec.TwoCoefsDecorator.java
/** * Creates a new dataset for visualizing the fitted function. * <p>//from w w w . ja v a 2 s . c o m * The new dataset is added to the end of the dataset list of the given plot. * </p> * * @param aPlot Plot to which the new dataset must be added. * @return Index of the newly created dataset in the dataset list of <code>aPlot</code>. */ protected static int createDataset(XYPlot aPlot) { int i = aPlot.getDatasetCount(); aPlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); XYLineAndShapeRenderer rend = new XYLineAndShapeRenderer(); rend.setSeriesLinesVisible(0, true); rend.setSeriesShapesVisible(0, false); aPlot.setRenderer(i, rend); return i; }
From source file:ta4jexamples.analysis.CashFlowToChart.java
/** * Adds the cash flow axis to the plot./*from ww w .j ava2s. com*/ * @param plot the plot * @param dataset the cash flow dataset */ private static void addCashFlowAxis(XYPlot plot, TimeSeriesCollection dataset) { final NumberAxis cashAxis = new NumberAxis("Cash Flow Ratio"); cashAxis.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, cashAxis); plot.setDataset(1, dataset); plot.mapDatasetToRangeAxis(1, 1); final StandardXYItemRenderer cashFlowRenderer = new StandardXYItemRenderer(); cashFlowRenderer.setSeriesPaint(0, Color.blue); plot.setRenderer(1, cashFlowRenderer); }
From source file:com.leonarduk.finance.analysis.CashFlowToChart.java
/** * Adds the cash flow axis to the plot.// w ww .jav a 2s . c o m * * @param plot * the plot * @param dataset * the cash flow dataset */ private static void addCashFlowAxis(final XYPlot plot, final TimeSeriesCollection dataset) { final NumberAxis cashAxis = new NumberAxis("Cash Flow Ratio"); cashAxis.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, cashAxis); plot.setDataset(1, dataset); plot.mapDatasetToRangeAxis(1, 1); final StandardXYItemRenderer cashFlowRenderer = new StandardXYItemRenderer(); cashFlowRenderer.setSeriesPaint(0, Color.blue); plot.setRenderer(1, cashFlowRenderer); }
From source file:Methods.CalculusSecant.java
public static ChartPanel createChartSecant(XYDataset datasetFunction) {// Method that populates and returns a Chart Pannel object, uses an entering paramether for the equation dataset and a global variable for the iteration points data set datasetPointsSecant();// ww w .j a v a 2 s.c om JFreeChart chart = ChartFactory.createXYLineChart("Equation Chart", "X Axys", "Y Axys", datasetFunction, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();//declaring a renderer used to plot more than one datatset on the table plot.setDataset(1, datasetPoints); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); plot.setRenderer(1, renderer); return new ChartPanel(chart); }
From source file:Methods.CalculusBisection.java
public static ChartPanel createChartBisection(XYDataset datasetFunction) {// Method that populates and returns a Chart Pannel object, uses an entering paramether for the equation dataset and a global variable for the iteration points data set datasetPointsBisection();//from w w w .jav a2 s . c om JFreeChart chart = ChartFactory.createXYLineChart("Equation Chart", "X Axys", "Y Axys", datasetFunction, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();//declaring a renderer used to plot more than one datatset on the table plot.setDataset(1, datasetPoints); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); plot.setRenderer(1, renderer); return new ChartPanel(chart); }
From source file:ch.zhaw.parallelComputing.view.Plotter.java
/** * Generates a plot for comparing to datasets * @param title the name of the plot//from www . j ava2 s.c o m * @param dataset1 the first data set for plotting * @param dataset2 the second data set for plotting * @return a chart object for displaying or saving as picture */ public static JFreeChart plot(String title, XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title "Date", // x-axis label "Input Value", // y-axis label dataset1, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); XYPlot plot = chart.getXYPlot(); Axis axis1 = plot.getRangeAxis(0); axis1.setLabelPaint(Color.red); NumberAxis axis2 = new NumberAxis("Twitter"); axis2.setLabelPaint(Color.blue); plot.setRangeAxis(1, axis2); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setBaseShapesVisible(false); plot.setRenderer(1, renderer); return chart; }
From source file:ec.nbdemetra.benchmarking.calendarization.CalendarizationChartView.java
private static JFreeChart createChart(String title) { JFreeChart result = ChartFactory.createXYLineChart("", "", "", Charts.emptyXYDataset(), PlotOrientation.VERTICAL, false, false, false); result.setPadding(TsCharts.CHART_PADDING); result.setTitle(new TextTitle(title, new Font("SansSerif", Font.PLAIN, 12))); XYPlot plot = result.getXYPlot(); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); LinesThickness linesThickness = LinesThickness.Thin; XYLineAndShapeRenderer daily = new XYLineAndShapeRenderer(true, false); daily.setAutoPopulateSeriesPaint(false); daily.setAutoPopulateSeriesStroke(false); daily.setBaseStroke(TsCharts.getStrongStroke(linesThickness)); plot.setRenderer(DAILY_INDEX, daily); XYDifferenceRenderer difference = new XYDifferenceRenderer(); difference.setAutoPopulateSeriesPaint(false); difference.setAutoPopulateSeriesStroke(false); difference.setBaseStroke(TsCharts.getNormalStroke(linesThickness)); plot.setRenderer(DIFF_INDEX, difference); XYLineAndShapeRenderer smooth = new XYLineAndShapeRenderer(true, false); smooth.setAutoPopulateSeriesPaint(false); smooth.setAutoPopulateSeriesStroke(false); smooth.setBaseStroke(TsCharts.getStrongStroke(linesThickness)); plot.setRenderer(SMOOTH_INDEX, smooth); DateAxis domainAxis = new DateAxis(); domainAxis.setTickMarkPosition(DateTickMarkPosition.START); domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR); plot.setDomainAxis(domainAxis);// ww w. j a v a 2s .co m NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR); plot.setRangeAxis(rangeAxis); return result; }
From source file:Methods.CalculusNewtonRaphson.java
public static ChartPanel createChartNewtonRapson(XYDataset datasetFunction) {// Method that populates and returns a Chart Pannel object, uses an entering paramether for the equation dataset and a global variable for the iteration points data set datasetPointsNewtonRapson();/*from ww w . j a va2 s .co m*/ JFreeChart chart = ChartFactory.createXYLineChart("Equation Chart", "X Axys", "Y Axys", datasetFunction, PlotOrientation.VERTICAL, true, true, false);//creating a object table wich takes the methods arguments as a dataset XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();//declaring a renderer used to plot more than one datatset on the table plot.setDataset(1, datasetPoints); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); plot.setRenderer(1, renderer); return new ChartPanel(chart); }
From source file:org.jfree.chart.demo.SymbolicYPlotDemo.java
/** * Create and display an overlaid chart. * //from ww w .j a va 2 s. c om * @param frameTitle * the frame title. * @param data1 * dataset1. * @param data2 * dataset2. */ private static void displayYSymbolicOverlaid(final String frameTitle, final XYDataset data1, final XYDataset data2) { final String title = "Animals Overlaid"; final String xAxisLabel = "Miles"; final String yAxisLabel = "Animal"; // combine the y symbolic values of the two data sets... final String[] combinedYSymbolicValues = SampleYSymbolicDataset.combineYSymbolicDataset((YisSymbolic) data1, (YisSymbolic) data2); // make master dataset... final CombinedDataset data = new CombinedDataset(); data.add(data1); data.add(data2); // decompose data... final XYDataset series0 = new SubSeriesDataset(data, 0); final XYDataset series1 = new SubSeriesDataset(data, 1); final XYDataset series2 = new SubSeriesDataset(data, 2); final XYDataset series3 = new SubSeriesDataset(data, 3); final XYDataset series4 = new SubSeriesDataset(data, 4); final XYDataset series5 = new SubSeriesDataset(data, 5); final XYDataset series6 = new SubSeriesDataset(data, 6); final XYDataset series7 = new SubSeriesDataset(data, 7); // create main plot... final ValueAxis valueAxis = new NumberAxis(xAxisLabel); final SymbolicAxis symbolicAxis = new SymbolicAxis(yAxisLabel, combinedYSymbolicValues); final XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot plot = new XYPlot(series0, valueAxis, symbolicAxis, renderer); plot.setDataset(1, series1); final XYItemRenderer renderer1 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); plot.setRenderer(1, renderer1); plot.setDataset(2, series2); final XYItemRenderer renderer2 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); plot.setRenderer(2, renderer2); plot.setDataset(3, series3); final XYItemRenderer renderer3 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); plot.setRenderer(3, renderer3); plot.setDataset(4, series4); final XYItemRenderer renderer4 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); plot.setRenderer(4, renderer4); plot.setDataset(5, series5); final XYItemRenderer renderer5 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); plot.setRenderer(5, renderer5); plot.setDataset(6, series6); final XYItemRenderer renderer6 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); plot.setRenderer(6, renderer6); plot.setDataset(7, series7); final XYItemRenderer renderer7 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); plot.setRenderer(7, renderer7); // make the chart... final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); // and present it in a frame... final JFrame frame = new ChartFrame(frameTitle, chart); frame.pack(); RefineryUtilities.positionFrameRandomly(frame); frame.show(); }
From source file:org.jfree.chart.demo.SymbolicXYPlotDemo.java
/** * Displays an overlaid XYPlot with X and Y symbolic data. * //from w w w . j a va 2s . c o m * @param frameTitle * the frame title. * @param data1 * the dataset 1. * @param data2 * the dataset 2. */ private static void displayXYSymbolicOverlaid(final String frameTitle, final XYDataset data1, final XYDataset data2) { final String title = "Pollutant Overlaid"; final String xAxisLabel = "Contamination and Type"; final String yAxisLabel = "Pollutant"; // combine the x symbolic values of the two data sets final String[] combinedXSymbolicValues = SampleXYSymbolicDataset .combineXSymbolicDataset((XisSymbolic) data1, (XisSymbolic) data2); // combine the y symbolic values of the two data sets final String[] combinedYSymbolicValues = SampleXYSymbolicDataset .combineYSymbolicDataset((YisSymbolic) data1, (YisSymbolic) data2); // make master dataset... final CombinedDataset data = new CombinedDataset(); data.add(data1); data.add(data2); // decompose data... final XYDataset series0 = new SubSeriesDataset(data, 0); final XYDataset series1 = new SubSeriesDataset(data, 1); // create overlaid plot... final SymbolicAxis hsymbolicAxis = new SymbolicAxis(xAxisLabel, combinedXSymbolicValues); final SymbolicAxis vsymbolicAxis = new SymbolicAxis(yAxisLabel, combinedYSymbolicValues); final XYItemRenderer renderer1 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); final XYPlot plot = new XYPlot(series0, hsymbolicAxis, vsymbolicAxis, renderer1); final XYItemRenderer renderer2 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null); plot.setDataset(1, series1); plot.setRenderer(1, renderer2); // make the chart... final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); // and present it in a frame... final JFrame frame = new ChartFrame(frameTitle, chart); frame.pack(); RefineryUtilities.positionFrameRandomly(frame); frame.show(); }