List of usage examples for org.jfree.chart JFreeChart getXYPlot
public XYPlot getXYPlot()
From source file:jmeanshift.ChartProof.java
private void bubblyBubblesScatter(JPanel panel) { JFreeChart chart = ChartFactory.createScatterPlot(TITLE, "X1", "X2", dataset, PlotOrientation.VERTICAL, true, true, false);//from ww w .java 2 s.co m chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.yellow)); plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.BLUE); plot.setRangeGridlinePaint(Color.CYAN); plot.setForegroundAlpha(0.65f); domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setLowerBound(0); domainAxis.setUpperBound(255); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLowerBound(0); rangeAxis.setUpperBound(255); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chartPanel = new ChartPanel(chart); chartPanel.addChartMouseListener(this); panel.setLayout(new GridLayout(0, 1)); panel.add(chartPanel); }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, false, rangeLabel, dataset, PlotOrientation.VERTICAL,// ww w . j av a2s .co m // !legendPanelOn, false, // no legend true, false); // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
From source file:com.romraider.logger.ecu.ui.tab.dyno.DynoChartPanel.java
private void addSeries1(JFreeChart chart, int index, XYSeries series, Color color) { XYDataset dataset = new XYSeriesCollection(series); XYPlot plot = chart.getXYPlot(); plot.setDataset(index, dataset);//ww w . j a v a 2s . co m plot.setRenderer(index, buildTrendLineRendererY1(color)); }
From source file:com.romraider.logger.ecu.ui.tab.dyno.DynoChartPanel.java
private void addSeries2(JFreeChart chart, int index, XYSeries series, Color color) { XYDataset dataset = new XYSeriesCollection(series); XYPlot plot = chart.getXYPlot(); plot.setDataset(index, dataset);/* w w w .j a va2 s . c o m*/ plot.setRenderer(index, buildTrendLineRendererY2(color)); }
From source file:com.romraider.logger.ecu.ui.tab.dyno.DynoChartPanel.java
private void addRef(JFreeChart chart, int index, XYSeries series, Color color) { XYDataset dataset = new XYSeriesCollection(series); XYPlot plot = chart.getXYPlot(); plot.setDataset(index, dataset);//w w w.j ava 2 s.co m plot.setRenderer(index, buildTrendLineRenderer(color)); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.XYAreaLineChartExpression.java
protected void configureChart(final JFreeChart chart) { super.configureChart(chart); final XYPlot plot = chart.getXYPlot(); if (isSharedRangeAxis() == false) { final ValueAxis linesAxis = plot.getRangeAxis(1); if (linesAxis instanceof NumberAxis) { final NumberAxis numberAxis = (NumberAxis) linesAxis; numberAxis.setAutoRangeIncludesZero(isLineAxisIncludesZero()); numberAxis.setAutoRangeStickyZero(isLineAxisStickyZero()); if (getLinePeriodCount() > 0) { if (getLineTicksLabelFormat() != null) { final FastDecimalFormat formatter = new FastDecimalFormat(getLineTicksLabelFormat(), getResourceBundleFactory().getLocale()); numberAxis.setTickUnit(new FastNumberTickUnit(getLinePeriodCount(), formatter)); } else { numberAxis.setTickUnit(new FastNumberTickUnit(getLinePeriodCount())); }//from w ww .ja v a2 s . com } else { if (getLineTicksLabelFormat() != null) { final DecimalFormat formatter = new DecimalFormat(getLineTicksLabelFormat(), new DecimalFormatSymbols(getResourceBundleFactory().getLocale())); numberAxis.setNumberFormatOverride(formatter); } } } else if (linesAxis instanceof DateAxis) { final DateAxis numberAxis = (DateAxis) linesAxis; if (getLinePeriodCount() > 0 && getLineTimePeriod() != null) { if (getLineTicksLabelFormat() != null) { final SimpleDateFormat formatter = new SimpleDateFormat(getLineTicksLabelFormat(), new DateFormatSymbols(getResourceBundleFactory().getLocale())); numberAxis.setTickUnit(new DateTickUnit(getDateUnitAsInt(getLineTimePeriod()), (int) getLinePeriodCount(), formatter)); } else { numberAxis.setTickUnit(new DateTickUnit(getDateUnitAsInt(getLineTimePeriod()), (int) getLinePeriodCount())); } } else if (getRangeTickFormatString() != null) { final SimpleDateFormat formatter = new SimpleDateFormat(getRangeTickFormatString(), new DateFormatSymbols(getResourceBundleFactory().getLocale())); numberAxis.setDateFormatOverride(formatter); } } if (linesAxis != null) { final Font labelFont = Font.decode(getLabelFont()); linesAxis.setLabelFont(labelFont); linesAxis.setTickLabelFont(labelFont); if (getLineTitleFont() != null) { linesAxis.setLabelFont(getLineTitleFont()); } if (getLineTickFont() != null) { linesAxis.setTickLabelFont(getLineTickFont()); } final int level = getRuntime().getProcessingContext().getCompatibilityLevel(); if (ClassicEngineBoot.isEnforceCompatibilityFor(level, 3, 8)) { final double lineRangeMinimumVal = lineRangeMinimum == null ? 0 : lineRangeMinimum; final double lineRangeMaximumVal = lineRangeMaximum == null ? 0 : lineRangeMaximum; if (lineRangeMinimum != null) { linesAxis.setLowerBound(getLineRangeMinimum()); } if (lineRangeMaximum != null) { linesAxis.setUpperBound(getRangeMaximum()); } if (lineRangeMinimumVal == 0 && lineRangeMaximumVal == 1) { linesAxis.setLowerBound(0); linesAxis.setUpperBound(1); linesAxis.setAutoRange(true); } } else { if (lineRangeMinimum != null) { linesAxis.setLowerBound(lineRangeMinimum); } if (lineRangeMaximum != null) { linesAxis.setUpperBound(lineRangeMaximum); } linesAxis.setAutoRange(isLineAxisAutoRange()); } } } final XYLineAndShapeRenderer linesRenderer = (XYLineAndShapeRenderer) plot.getRenderer(1); if (linesRenderer != null) { //set stroke with line width linesRenderer.setStroke(translateLineStyle(getLineWidth(), getLineStyle())); //hide shapes on line linesRenderer.setShapesVisible(isMarkersVisible()); linesRenderer.setBaseShapesFilled(isMarkersVisible()); //set colors for each line for (int i = 0; i < lineSeriesColor.size(); i++) { final String s = (String) lineSeriesColor.get(i); linesRenderer.setSeriesPaint(i, parseColorFromString(s)); } } }
From source file:edu.ucla.stat.SOCR.chart.demo.HistogramChartDemo3.java
protected JFreeChart createChart(IntervalXYDataset dataset) { JFreeChart chart = ChartFactory.createXYBarChart(chartTitle, domainLabel, true, rangeLabel, dataset, PlotOrientation.VERTICAL, false, // !legendPanelOn, true, false);//w w w.j av a 2 s .co m // then customise it a little... // chart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do")); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setRenderer(new ClusteredXYBarRenderer()); XYItemRenderer renderer = plot.getRenderer(); StandardXYToolTipGenerator generator = new StandardXYToolTipGenerator("{1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0")); renderer.setBaseToolTipGenerator(generator); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setLowerMargin(0.01); axis.setUpperMargin(0.01); // setXSummary(dataset); X is time return chart; }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.PlateHeatMapController.java
/** * Plot the z-scores: simple scatterplot *//*from w w w. j a v a2 s .co m*/ private void plotZScores() { XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); Map<Well, Double> map = computeZScoresForMap(); List<PlateCondition> plateConditionList = trackCoordinatesController.getPlateConditionList(); for (int i = 0; i < plateConditionList.size(); i++) { // current condition PlateCondition condition = plateConditionList.get(i); XYSeries series = new XYSeries(i + "-" + condition); for (int j = 0; j < condition.getSingleCellAnalyzedWells().size(); j++) { // current well Well well = condition.getSingleCellAnalyzedWells().get(j); series.add(i + 1, map.get(well)); } xySeriesCollection.addSeries(series); } JFreeChart jfreechart = ChartFactory.createScatterPlot("z*-score", "condition number", "z*-score", xySeriesCollection, PlotOrientation.VERTICAL, false, true, false); JFreeChartUtils.setupXYPlot(jfreechart.getXYPlot()); jfreechart.getXYPlot().getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // line for the median speed ValueMarker marker = new ValueMarker(0); marker.setPaint(Color.GRAY); Stroke dashedStroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 1.0f, 3.0f }, 0.0f); marker.setStroke(dashedStroke); jfreechart.getXYPlot().addRangeMarker(marker); marker = new ValueMarker(3); marker.setPaint(Color.GRAY); marker.setStroke(dashedStroke); jfreechart.getXYPlot().addRangeMarker(marker); marker = new ValueMarker(-3); marker.setPaint(Color.GRAY); marker.setStroke(dashedStroke); jfreechart.getXYPlot().addRangeMarker(marker); XYItemRenderer renderer = jfreechart.getXYPlot().getRenderer(); for (int i = 0; i < xySeriesCollection.getSeriesCount(); i++) { // plot lines according to conditions indexes int colorIndex = i % GuiUtils.getAvailableColors().length; Color color = GuiUtils.getAvailableColors()[colorIndex]; color = new Color(color.getRed(), color.getGreen(), color.getBlue(), 127); renderer.setSeriesPaint(i, color); renderer.setSeriesShape(i, new Ellipse2D.Double(0, 0, 10, 10)); } zScoreChartPanel.setChart(jfreechart); }
From source file:tmn.dev.project.Player.java
/** * Generate a plot of batting average over the span of a season and write * the plot to a PNG file./* w w w.j av a 2 s .c om*/ * * @return The String representation of the name of the PNG file containing * the plot. * @throws IOException */ private String createBAPlot() throws IOException { // Create a scatter plot for batting average over the season // Game number on the x axis, Batting average on the y axis JFreeChart chart = ChartFactory.createScatterPlot("Batting Average Throughout the Season", "Game Number", "Batting Average", new XYSeriesCollection(baGame), PlotOrientation.VERTICAL, false, false, false); XYPlot plot = chart.getXYPlot(); // Set the axis ranges to provide an appropriate zoom NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setRange(baGame.getMinX(), baGame.getMaxX()); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setRange(baGame.getMinY() - .02, baGame.getMaxY() + .02); // Set the tick labels on the y axis to the typical BA format yAxis.setNumberFormatOverride(new DecimalFormat(".000")); // Create the String representation of the /images directory String imgDirStr = System.getProperty("user.dir") + System.getProperty("file.separator") + "images"; // If the directory doesn't already exist, create it File imgDir = new File(imgDirStr); if (!imgDir.exists() && !imgDir.isDirectory()) imgDir.mkdir(); // Create the batting average PNG files String fileName = imgDirStr + System.getProperty("file.separator") + this.getId() + ".png"; File imgFile = new File(fileName); // If the file already exists, append a number in parentheses int index = 0; while (!imgFile.createNewFile()) { // Append (<index>).html after the Player ID fileName = imgDirStr + System.getProperty("file.separator") + this.getId() + "(" + ++index + ")" + ".png"; // Try to create a file with this name imgFile = new File(fileName); } // Write the plot to the PNG file that was created ChartUtilities.saveChartAsPNG(imgFile, chart, 800, 450); return imgFile.getName(); }