List of usage examples for org.jfree.chart.plot XYPlot getDataset
public XYDataset getDataset()
From source file:org.gaixie.micrite.jfreechart.style.LineStyle.java
public static void styleOne(JFreeChart chart) { XYPlot xyplot = (XYPlot) chart.getPlot(); XYDataset xyd = xyplot.getDataset(); //?// w ww.jav a 2 s. c o m LineStyle.setBackground(chart); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); if (xyd != null) { //? xylineandshaperenderer.setBaseShapesVisible(true); // xylineandshaperenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); xylineandshaperenderer.setBaseItemLabelsVisible(true); xyplot.setRenderer(xylineandshaperenderer); //tooltip // xyplot.getRenderer().setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"),new DecimalFormat())); //? for (int i = 0; i < xyd.getSeriesCount(); i++) { int colorIdx = i % colors.length; xylineandshaperenderer.setSeriesPaint(i, colors[colorIdx]); } } else { xyplot.setNoDataMessage("NO DATA"); } }
From source file:net.sf.maltcms.chromaui.charts.tools.ChartTools.java
/** * * @param plot// w ww. jav a 2 s . c o m * @return */ public static XYPlot getPlot3(XYPlot plot) { XYPlot p = new XYPlot(plot.getDataset(), new NumberAxis(plot.getRangeAxis().getLabel()), new NumberAxis(plot.getDomainAxis().getLabel()), plot.getRenderer()); p.setOrientation(PlotOrientation.HORIZONTAL); p.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); Logger.getLogger(ChartTools.class.getName()).log(Level.INFO, "fixed auto range: {0}", plot.getRangeAxis().getRange().getUpperBound()); p.getDomainAxis().setFixedAutoRange(500); return p; }
From source file:uk.ac.leeds.ccg.andyt.projects.moses.process.RegressionReport.java
public static JFreeChart[] createRegressionCharts(JFreeChart[] t_ScatterPlots, Object[] t_RegressionParametersAndXYLineCharts) throws IOException { JFreeChart[] result = new JFreeChart[t_ScatterPlots.length]; Object[] t_RegressionParameters = (Object[]) t_RegressionParametersAndXYLineCharts[0]; JFreeChart[] t_regressionXYLineCharts = (JFreeChart[]) t_RegressionParametersAndXYLineCharts[1]; JFreeChart[] t_yequalsxXYLineCharts = (JFreeChart[]) t_RegressionParametersAndXYLineCharts[2]; for (int i = 0; i < result.length; i++) { double[] a_RegressionParameters = (double[]) t_RegressionParameters[i]; int maxLengthOfIntString = 6; String b = String.valueOf(a_RegressionParameters[0]); String a = String.valueOf(a_RegressionParameters[1]); String rsquare = String.valueOf(a_RegressionParameters[2]); String title = "Y=" + a.substring(0, Math.min(a.length(), maxLengthOfIntString)) + "X"; if (a_RegressionParameters[0] < 0) { title += b.substring(0, Math.min(b.length(), maxLengthOfIntString)); } else {/* w w w . j av a 2 s .co m*/ title += "+" + b.substring(0, Math.min(b.length(), maxLengthOfIntString)); } if (a_RegressionParameters.length > 2) { title += " RSquare " + rsquare.substring(0, Math.min(rsquare.length(), maxLengthOfIntString)); } XYLineAndShapeRenderer points_XYLineAndShapeRenderer = new XYLineAndShapeRenderer(false, true); XYPlot a_ScatterPlotXYPlot = (XYPlot) t_ScatterPlots[i].getPlot(); a_ScatterPlotXYPlot.setDataset(0, a_ScatterPlotXYPlot.getDataset()); points_XYLineAndShapeRenderer.setSeriesPaint(0, Color.blue); //Shape[] _Shapes = DefaultDrawingSupplier.createStandardSeriesShapes(); // System.out.println("There are " + _Shapes.length + // " number of Shapes to try..."); // 0 are square // 1 are circles // 2 are up-pointing triangle // 3 are diamond // 4 are horizontal rectangle // 5 are down-pointing triangle // 6 are horizontal ellipse // 7 are right-pointing triangle // 8 are vertical rectangle // 9 are left-pointing triangle int a_SpikeLength = 3; int[] xpoints = new int[9]; int[] ypoints = new int[9]; xpoints[0] = 0; ypoints[0] = 0; xpoints[1] = 0; ypoints[1] = a_SpikeLength; xpoints[2] = 0; ypoints[2] = 0; xpoints[3] = a_SpikeLength; ypoints[3] = 0; xpoints[4] = 0; ypoints[4] = 0; xpoints[5] = 0; ypoints[5] = -a_SpikeLength; xpoints[6] = 0; ypoints[6] = 0; xpoints[7] = -a_SpikeLength; ypoints[7] = 0; xpoints[8] = 0; ypoints[8] = 0; Shape a_Shape = new Polygon(xpoints, ypoints, xpoints.length); // points_XYLineAndShapeRenderer.setSeriesShape( 0, _Shapes[2] ); points_XYLineAndShapeRenderer.setSeriesShape(0, a_Shape); a_ScatterPlotXYPlot.setRenderer(0, points_XYLineAndShapeRenderer); XYDataset a_regressionXYLineChartXYDataset = ((XYPlot) t_regressionXYLineCharts[i].getPlot()) .getDataset(); XYLineAndShapeRenderer line_XYLineAndShapeRenderer = new XYLineAndShapeRenderer(true, false); a_ScatterPlotXYPlot.setDataset(1, a_regressionXYLineChartXYDataset); line_XYLineAndShapeRenderer.setPaint(Color.red); a_ScatterPlotXYPlot.setRenderer(1, line_XYLineAndShapeRenderer); XYDataset a_yequalsxXYLineChartXYDataset = ((XYPlot) t_yequalsxXYLineCharts[i].getPlot()).getDataset(); XYLineAndShapeRenderer yequalsxline_XYLineAndShapeRenderer = new XYLineAndShapeRenderer(true, false); a_ScatterPlotXYPlot.setDataset(2, a_yequalsxXYLineChartXYDataset); yequalsxline_XYLineAndShapeRenderer.setPaint(Color.green); a_ScatterPlotXYPlot.setRenderer(2, yequalsxline_XYLineAndShapeRenderer); result[i] = new JFreeChart(title, a_ScatterPlotXYPlot); } return result; }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java
/** * Updates the axis-related properties of a chart. * //from ww w . j a v a2 s .c o m * @param aControl * Chart control to be updated. * @param aAxes * Axis-related visual settings to be applied. * @param aGrid * Grid-related visual settings to be applied. */ public static void updateAxes(JFreeChart aControl, AxesSettings aAxes, GridSettings aGrid) { XYPlot plot = aControl.getXYPlot(); Range domainDataRange = aAxes.getLogarithmicDomainAxis() ? new Range(logLowerBound(plot.getDataset(), true), plot.getDataRange(plot.getDomainAxis()).getUpperBound()) : plot.getDataRange(plot.getDomainAxis()); Range rangeDataRange = aAxes.getLogarithmicRangeAxis() ? new Range(logLowerBound(plot.getDataset(), false), plot.getDataRange(plot.getRangeAxis()).getUpperBound()) : plot.getDataRange(plot.getRangeAxis()); updateAxes(plot, aAxes, aGrid, domainDataRange, rangeDataRange); }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java
/** * Creates a scatter plot that visualizes the given data collection. * //from w w w. j a v a 2s. co m * @param aCollection * Data to be visualized. * @param aGeneral * General visual settings to be applied. * @param aAxes * Axis-related visual settings to be applied. * @param aGrid * Grid-related visual settings to be applied. * @param aScatter * Point-related visual settings to be applied. * @return Newly created chart control. */ private static JFreeChart createScatter(XYSeriesCollection aCollection, GeneralVisSettings aGeneral, AxesSettings aAxes, GridSettings aGrid, ScatterSettings aScatter) { JFreeChart chart = ChartFactory.createScatterPlot(null, // title convertLabel(aAxes.getDomainAxisLabel()), // label of X axis convertLabel(aAxes.getRangeAxisLabel()), // label of Y axis aCollection, // dataset PlotOrientation.VERTICAL, // orientation false, // create legend true, // display tooltips false); // generate urls XYPlot plot = chart.getXYPlot(); Range domainDataRange = aAxes.getLogarithmicDomainAxis() ? new Range(logLowerBound(plot.getDataset(), true), plot.getDataRange(plot.getDomainAxis()).getUpperBound()) : plot.getDataRange(plot.getDomainAxis()); Range rangeDataRange = aAxes.getLogarithmicRangeAxis() ? new Range(logLowerBound(plot.getDataset(), false), plot.getDataRange(plot.getRangeAxis()).getUpperBound()) : plot.getDataRange(plot.getRangeAxis()); updateGeneral(plot, aGeneral); updateAxes(plot, aAxes, aGrid, domainDataRange, rangeDataRange); updateScatter(plot, aScatter); chart.setBackgroundPaint(null); return chart; }
From source file:org.jfree.chart.demo.MouseListenerDemo3.java
public void chartMouseClicked(ChartMouseEvent chartmouseevent) { org.jfree.chart.entity.ChartEntity chartentity = chartmouseevent.getEntity(); if (chartentity != null && (chartentity instanceof LegendItemEntity)) { LegendItemEntity legenditementity = (LegendItemEntity) chartentity; @SuppressWarnings("rawtypes") Comparable comparable = legenditementity.getSeriesKey(); XYPlot xyplot = (XYPlot) chart.getPlot(); XYDataset xydataset = xyplot.getDataset(); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); for (int i = 0; i < xydataset.getSeriesCount(); i++) { xyitemrenderer.setSeriesStroke(i, new BasicStroke(1.0F)); if (xydataset.getSeriesKey(i).equals(comparable)) xyitemrenderer.setSeriesStroke(i, new BasicStroke(2.0F)); }// w w w . j ava 2 s . co m } }
From source file:org.jfree.chart.demo.CloneTest1.java
public CloneTest1(String s) { super(s);/*from w ww . j av a 2s.c o m*/ lastValue = 100D; series = new TimeSeries("Random Data"); TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(series); JFreeChart jfreechart = createChart(timeseriescollection); JFreeChart jfreechart1 = null; try { jfreechart1 = (JFreeChart) jfreechart.clone(); } catch (Exception exception) { exception.printStackTrace(); } XYPlot xyplot = (XYPlot) jfreechart1.getPlot(); TimeSeriesCollection timeseriescollection1 = (TimeSeriesCollection) xyplot.getDataset(); series = timeseriescollection1.getSeries(0); ChartPanel chartpanel = new ChartPanel(jfreechart1); JButton jbutton = new JButton("Add New Data Item"); jbutton.setActionCommand("ADD_DATA"); jbutton.addActionListener(this); JPanel jpanel = new JPanel(new BorderLayout()); jpanel.add(chartpanel); jpanel.add(jbutton, "South"); chartpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(jpanel); }
From source file:GUI.PlotHere.java
public void PutPoint(int key, double x, double y) { Component[] a = GraphHerePanel.getComponents(); ChartPanel chartpanel = (ChartPanel) a[0]; JFreeChart chart = chartpanel.getChart(); XYPlot plot = (XYPlot) chart.getPlot(); XYSeriesCollection data = (XYSeriesCollection) plot.getDataset(); XYSeries XYseries = data.getSeries(key); XYseries.add(x, y);/* ww w. j ava 2 s . c o m*/ this.revalidate(); this.repaint(); }
From source file:ec.nbdemetra.chainlinking.outlineview.ChainLinkingChart.java
@Override protected void onColorSchemeChange() { XYPlot plot = chartPanel.getChart().getXYPlot(); if (plot.getDataset() != null) { for (int i = 0; i < plot.getDataset().getSeriesCount(); i++) { plot.getRenderer().setSeriesPaint(i, themeSupport.getLineColor(i)); }/* w ww .j a va 2 s . c om*/ } plot.setBackgroundPaint(themeSupport.getPlotColor()); plot.setDomainGridlinePaint(themeSupport.getGridColor()); plot.setRangeGridlinePaint(themeSupport.getGridColor()); chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor()); }
From source file:cgpanalyser.gui.chart.XYChartPanel.java
public void setNextCrosshairValue(JFreeChart jfreechart) { XYPlot plot = (XYPlot) jfreechart.getPlot(); XYDataset dataset = plot.getDataset(); //set crosshair to next value if not on last already for (int i = 0; i < dataSampler.getLastToDisplay().size() - 1; i++) { //find generation in datasampler.todisplay if ((int) plot.getDomainCrosshairValue() == dataSampler.getLastToDisplay().get(i).getGenNumber()) { plot.setDomainCrosshairValue(dataset.getXValue(0, i + 1)); plot.setRangeCrosshairValue(dataset.getYValue(0, i + 1)); break; }/* www.j a va 2 s. com*/ } }