List of usage examples for org.jfree.chart.plot XYPlot getRenderer
public XYItemRenderer getRenderer()
From source file:org.webcat.grader.graphs.HistogramChart.java
protected JFreeChart generateChart(WCChartTheme chartTheme) { JFreeChart chart = ChartFactory.createHistogram(null, xAxisLabel(), yAxisLabel(), intervalXYDataset(), orientation(), false, false, false); XYPlot plot = chart.getXYPlot(); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setAutoPopulateSeriesOutlinePaint(true); renderer.setDrawBarOutline(true);//from w w w . j ava2 s .co m renderer.setShadowVisible(false); if (markValue != null) { plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairValue(markValue.doubleValue()); plot.setDomainCrosshairPaint(Color.red); plot.setDomainCrosshairStroke(MARKER_STROKE); } NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:playground.artemc.socialCost.SocialCostWriter.java
private ChartUtil getGraphic(String yAxisTitle, double[] meanData, double[] medianData, double[] quantil25Data, double[] quantil75Data) { double[] iterations = new double[iteration + 1]; for (int i = 0; i <= iteration; i++) { iterations[i] = i;/*from www. j a v a 2 s .c om*/ } XYLineChart chart = new XYLineChart("Social Costs", "iteration", yAxisTitle); chart.addSeries("mean", iterations, meanData); chart.addSeries("median", iterations, medianData); chart.addSeries("25% quantil", iterations, quantil25Data); chart.addSeries("75% qunatil", iterations, quantil75Data); XYPlot plot = chart.getChart().getXYPlot(); plot.getRenderer().setSeriesPaint(0, Color.red); plot.getRenderer().setSeriesPaint(1, Color.blue); plot.getRenderer().setSeriesPaint(2, Color.blue); plot.getRenderer().setSeriesPaint(3, Color.blue); plot.getRenderer().setSeriesStroke(2, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 8.0f, 4.0f }, 0.0f)); plot.getRenderer().setSeriesStroke(3, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 4.0f }, 0.0f)); chart.addMatsimLogo(); return chart; }
From source file:net.sf.jasperreports.customizers.shape.LineDotShapeCustomizer.java
@Override public void customize(JFreeChart jfc, JRChart jrc) { Plot plot = jfc.getPlot();//from w w w. j ava 2s . c om ItemsCounter itemsCounter = null; SeriesNameProvider seriesNameProvider = null; Object renderer = null; if (plot instanceof XYPlot) { XYPlot xyPlot = jfc.getXYPlot(); renderer = xyPlot.getRenderer(); itemsCounter = new XYPlotSeriesCounter(xyPlot); seriesNameProvider = new XYPlotSeriesNameProvider(xyPlot); } else if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = jfc.getCategoryPlot(); renderer = categoryPlot.getRenderer(); itemsCounter = new CategoryCounter(categoryPlot); seriesNameProvider = new CategorySeriesNameProvider(categoryPlot); } Integer seriesItemIndex = CustomizerUtil.resolveIndex(this, itemsCounter, seriesNameProvider); if (seriesItemIndex != null && renderer instanceof AbstractRenderer) { ShapeSetter shapeSetter = new AbstractRendererSeriesShapeSetter((AbstractRenderer) renderer); if (seriesItemIndex == -1) { updateItems(itemsCounter, shapeSetter); } else { updateItem(itemsCounter, shapeSetter, seriesItemIndex); } } }
From source file:org.jfree.chart.demo.XYStepChartDemo.java
/** * Displays a sample chart in its own frame. *//*from www .ja v a2s .c o m*/ private void displayChart() { if (this.frame == null) { // create a default chart based on some sample data... final String title = "LCACs in use at given time"; final String xAxisLabel = "Time"; final String yAxisLabel = "Number of Transports"; final XYDataset data = createStepXYDataset(); final JFreeChart chart = ChartFactory.createXYStepChart(title, xAxisLabel, yAxisLabel, data, PlotOrientation.VERTICAL, true, // legend true, // tooltips false // urls ); // then customise it a little... chart.setBackgroundPaint(new Color(216, 216, 216)); final XYPlot plot = chart.getXYPlot(); plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); // and present it in a frame... this.frame = new ChartFrame("Plan Comparison", chart); this.frame.pack(); RefineryUtilities.positionFrameRandomly(this.frame); this.frame.setVisible(true); } else { this.frame.setVisible(true); this.frame.requestFocus(); } }
From source file:task5.Histogram.java
private ChartPanel createChartPanel() { // dataset//w w w . j a va 2 s . c o m dataset = new HistogramDataset(); Raster raster = img.getRaster(); final int w = img.getWidth(); final int h = img.getHeight(); double[] r = new double[w * h + 1]; r = raster.getSamples(0, 0, w, h, 0, r); dataset.addSeries("Red", r, BINS); r = raster.getSamples(0, 0, w, h, 1, r); dataset.addSeries("Green", r, BINS); r = raster.getSamples(0, 0, w, h, 2, r); dataset.addSeries("Blue", r, BINS); // chart JFreeChart chart = ChartFactory.createHistogram("Histogram", "Value", "Count", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); renderer = (XYBarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); // translucent red, green & blue Paint[] paintArray = { new Color(0x80ff0000, true), new Color(0x8000ff00, true), new Color(0x800000ff, true) }; plot.setDrawingSupplier( new DefaultDrawingSupplier(paintArray, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); ChartPanel panel = new ChartPanel(chart); panel.setMouseWheelEnabled(true); return panel; }
From source file:org.jfree.chart.demo.MovingAverageDemo.java
/** * A moving average demo.//from w ww .j a v a2s .c o m * * @param title the frame title. */ public MovingAverageDemo(final String title) { super(title); // create a title... final String chartTitle = "Legal & General Unit Trust Prices"; final XYDataset dataset = createDataset(); final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Date", "Price Per Unit", dataset, true, true, false); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); final XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setPlotShapes(true); rr.setShapesFilled(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:gchisto.gui.panels.gctimeline.ChartPanel.java
/** * It creates a chart for the given dataset and adds the chart to the panel. * * @param dataset The dataset that will provide the values for the chart. *//*from w w w .j av a 2s . c om*/ private void addChart() { JFreeChart chart = ChartFactory.createXYBarChart(getTitle(), "Elapsed Time (sec)", false, "Time" + unitSuffix(), dataset, PlotOrientation.VERTICAL, true, true, false); chart.addProgressListener(locker); XYPlot plot = (XYPlot) chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator(dataset); groupActivatingTable = new GroupActivatingPanel(dataset, locker); org.jfree.chart.ChartPanel chartPanel = new org.jfree.chart.ChartPanel(chart); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, groupActivatingTable, chartPanel); splitPane.setDividerLocation(200); mainPanel().add(BorderLayout.CENTER, splitPane); }
From source file:gchisto.gui.panels.gcdistribution.ChartPanelSingle.java
/** * It creates a chart for the given dataset and adds the chart to the panel. * * @param dataset The dataset that will provide the values for the chart. */// w w w. ja v a 2 s . c o m private void addChart() { JFreeChart chart = ChartFactory.createXYBarChart(getTitle(), "Buckets (sec)", false, "Count", dataset, PlotOrientation.VERTICAL, true, true, false); chart.addProgressListener(locker); XYPlot plot = (XYPlot) chart.getPlot(); XYItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator(dataset); groupActivatingPanel = new GroupActivatingPanel(dataset, locker); org.jfree.chart.ChartPanel chartPanel = new org.jfree.chart.ChartPanel(chart); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, groupActivatingPanel, chartPanel); splitPane.setDividerLocation(200); mainPanel().add(BorderLayout.CENTER, splitPane); }
From source file:org.jfree.chart.demo.XYBoxAndWhiskerDemo.java
/** * Creates a chart./*w w w . j av a 2s . c o m*/ * * @param dataset the dataset. * * @return The dataset. */ private JFreeChart createChart(final BoxAndWhiskerXYDataset dataset) { final JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Box-and-Whisker Demo", "Time", "Value", dataset, true); XYPlot plot = (XYPlot) chart.getPlot(); XYBoxAndWhiskerRenderer renderer = (XYBoxAndWhiskerRenderer) plot.getRenderer(); renderer.setFillBox(false); return chart; }
From source file:pdi.HistogramaRGB.java
public ChartPanel criaHistograma() { dataset = new HistogramDataset(); //pega o RGB/*w ww . j a v a2 s. com*/ r = raster.getSamples(0, 0, w, h, 0, r); dataset.addSeries("Red", r, BINS); r = raster.getSamples(0, 0, w, h, 1, r); dataset.addSeries("Green", r, BINS); r = raster.getSamples(0, 0, w, h, 2, r); dataset.addSeries("Blue", r, BINS); JFreeChart chart = ChartFactory.createHistogram("Histograma", "Pixels", "Y", dataset, PlotOrientation.VERTICAL, true, true, false); //Plota as cores XYPlot plot = (XYPlot) chart.getPlot(); renderer = (XYBarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); //vermelho, verde, azul Paint[] paintArray = { new Color(0x80ff0000, true), new Color(0x8000ff00, true), new Color(0x800000ff, true) }; //desenhando o grfico plot.setDrawingSupplier( new DefaultDrawingSupplier(paintArray, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); ChartPanel panel = new ChartPanel(chart); panel.setMouseWheelEnabled(true); return panel; }