List of usage examples for org.jfree.chart.plot XYPlot getRenderer
public XYItemRenderer getRenderer()
From source file:com.compomics.pepshell.view.statistics.JFreeChartPanel.java
/** * Enable shadow of renderer? JFreeChart 1.0.11 changed the <b>default</b> * look by painting shadows for bars. To revert back to the old look, you * can disable the shadows with this method. * * @param chart JFreeChart./* w w w.jav a 2 s . co m*/ * @param state False, to disable shadow- * @since 4.1.0 */ private static void setShadowVisible(final JFreeChart chart, final boolean state) { if (chart != null) { final Plot p = chart.getPlot(); if (p instanceof XYPlot) { final XYPlot xyplot = (XYPlot) p; final XYItemRenderer xyItemRenderer = xyplot.getRenderer(); if (xyItemRenderer instanceof XYBarRenderer) { final XYBarRenderer br = (XYBarRenderer) xyItemRenderer; br.setBarPainter(new StandardXYBarPainter()); br.setShadowVisible(state); } } else if (p instanceof CategoryPlot) { final CategoryPlot categoryPlot = (CategoryPlot) p; final CategoryItemRenderer categoryItemRenderer = categoryPlot.getRenderer(); if (categoryItemRenderer instanceof BarRenderer) { final BarRenderer br = (BarRenderer) categoryItemRenderer; br.setBarPainter(new StandardBarPainter()); br.setShadowVisible(state); } } } }
From source file:jprobix.ui.SPlotFinal.java
public static JPanel creteDemoPanel() { JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter plot demo", "X", "Y", samplexydataset2(), PlotOrientation.VERTICAL, true, true, false); Shape cross = ShapeUtilities.createDiagonalCross(3, 2); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesShape(5, cross);/*from ww w . j a va2 s . c o m*/ renderer.setSeriesPaint(0, Color.YELLOW); XYDotRenderer xydotrenderer = new XYDotRenderer(); xyPlot.setRenderer(xydotrenderer); xydotrenderer.setSeriesShape(0, cross); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); return new ChartPanel(jfreechart); }
From source file:net.imglib2.script.analysis.Histogram.java
static private final void setTheme(final JFreeChart chart) { XYPlot plot = (XYPlot) chart.getPlot(); XYBarRenderer r = (XYBarRenderer) plot.getRenderer(); StandardXYBarPainter bp = new StandardXYBarPainter(); r.setBarPainter(bp);/*from w w w . ja v a 2 s . co m*/ r.setSeriesOutlinePaint(0, Color.lightGray); r.setShadowVisible(false); r.setDrawBarOutline(false); setBackgroundDefault(chart); }
From source file:piilSource.Histogram.java
private static JFreeChart createChart(String s, IntervalXYDataset intervalxydataset, String metaLabel) { JFreeChart jfreechart = ChartFactory.createHistogram( "Histogram of the " + metaLabel + " values for all samples - " + s, null, null, intervalxydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setForegroundAlpha(0.85F);//from w w w . ja v a 2 s. c o m XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setDrawBarOutline(false); return jfreechart; }
From source file:org.samjoey.graphing.GraphUtility.java
/** * * @param games the games to graph/*from w ww. j a va 2s. co m*/ * @param key the variable to create the graph with * @param start if index, the index at which to start, else the percent in * the game at which to start * @param stop if index, the index at which to end, else the percent in the * game at which to end * @param index * @return */ public static ChartPanel getCustomGraph(Game[] games, String key, double start, double stop, boolean index) { XYSeriesCollection dataset = new XYSeriesCollection(); for (Game game : games) { ArrayList<Double> data = game.getVar(key); int begin; int end; if (index) { begin = (int) start; end = (int) stop; } else { begin = (int) (data.size() / start); end = (int) (data.size() / stop); } XYSeries series = GraphUtility.createSeries(data.subList(begin, end), "" + game.getId()); dataset.addSeries(series); } JFreeChart chart = ChartFactory.createXYLineChart(key, // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); XYItemRenderer rend = plot.getRenderer(); for (int i = 0; i < games.length; i++) { Game g = games[i]; if (g.getWinner() == 1) { rend.setSeriesPaint(i, Color.RED); } if (g.getWinner() == 2) { rend.setSeriesPaint(i, Color.BLACK); } if (g.getWinner() == 0) { rend.setSeriesPaint(i, Color.PINK); } } ChartPanel chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:org.jfree.chart.demo.ScatterPlotDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter Plot Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, false, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setNoDataMessage("NO DATA"); xyplot.setDomainZeroBaselineVisible(true); xyplot.setRangeZeroBaselineVisible(true); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setSeriesOutlinePaint(0, Color.black); xylineandshaperenderer.setUseOutlinePaint(true); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setTickMarkInsideLength(2.0F); numberaxis.setTickMarkOutsideLength(0.0F); NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis(); numberaxis1.setTickMarkInsideLength(2.0F); numberaxis1.setTickMarkOutsideLength(0.0F); return jfreechart; }
From source file:org.samjoey.graphing.GraphUtility.java
public static void createGraphs(LinkedList<Game> games) { HashMap<String, XYSeriesCollection> datasets = new HashMap<>(); for (Game game : games) { for (String key : game.getVarData().keySet()) { if (datasets.containsKey(key)) { try { datasets.get(key).addSeries(createSeries(game.getVar(key), "" + game.getId())); } catch (Exception e) { }/*from w w w . j a v a 2 s. c o m*/ } else { datasets.put(key, new XYSeriesCollection()); datasets.get(key).addSeries(createSeries(game.getVar(key), "" + game.getId())); } } } for (String key : datasets.keySet()) { JFrame f = new JFrame(); JFreeChart chart = ChartFactory.createXYLineChart(key, // chart title "X", // x axis label "Y", // y axis label datasets.get(key), // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); XYItemRenderer rend = plot.getRenderer(); for (int i = 0; i < games.size(); i++) { Game g = games.get(i); if (g.getWinner() == 1) { rend.setSeriesPaint(i, Color.RED); } if (g.getWinner() == 2) { rend.setSeriesPaint(i, Color.BLACK); } if (g.getWinner() == 0) { rend.setSeriesPaint(i, Color.PINK); } } ChartPanel chartPanel = new ChartPanel(chart); f.setContentPane(chartPanel); f.pack(); RefineryUtilities.centerFrameOnScreen(f); f.setVisible(true); } }
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);/*from w w w. j av a2 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:org.samjoey.graphing.GraphUtility.java
public static HashMap<String, ChartPanel> getGraphs(LinkedList<Game> games) { HashMap<String, XYSeriesCollection> datasets = new HashMap<>(); for (int j = 0; j < games.size(); j++) { Game game = games.get(j);/* w w w . j a v a 2 s. co m*/ if (game == null) { continue; } for (String key : game.getVarData().keySet()) { if (datasets.containsKey(key)) { try { datasets.get(key).addSeries(createSeries(game.getVar(key), "" + game.getId())); } catch (Exception e) { } } else { datasets.put(key, new XYSeriesCollection()); datasets.get(key).addSeries(createSeries(game.getVar(key), "" + game.getId())); } } } HashMap<String, ChartPanel> chartPanels = new HashMap<>(); for (String key : datasets.keySet()) { JFreeChart chart = ChartFactory.createXYLineChart(key, // chart title "X", // x axis label "Y", // y axis label datasets.get(key), // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); XYItemRenderer rend = plot.getRenderer(); for (int i = 0; i < games.size(); i++) { Game g = games.get(i); if (g.getWinner() == 1) { rend.setSeriesPaint(i, Color.RED); } if (g.getWinner() == 2) { rend.setSeriesPaint(i, Color.BLACK); } if (g.getWinner() == 0) { rend.setSeriesPaint(i, Color.PINK); } } ChartPanel chartPanel = new ChartPanel(chart); chartPanels.put(key, chartPanel); } return chartPanels; }
From source file:Operacional.Janela2.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart("Dados Parquimetro", "Mes", true, "Dados", intervalxydataset, PlotOrientation.VERTICAL, true, false, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = jfreechart.getXYPlot(); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); StandardXYToolTipGenerator standardxytooltipgenerator = new StandardXYToolTipGenerator("{1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0")); //xyitemrenderer.setToolTipGenerator(standardxytooltipgenerator); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setRangeGridlinePaint(Color.white); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateaxis.setLowerMargin(0.01D);// w w w. j a v a 2 s. co m dateaxis.setUpperMargin(0.01D); return jfreechart; }