List of usage examples for org.jfree.data.xy XYSeriesCollection getSeriesCount
@Override public int getSeriesCount()
From source file:org.gwaspi.reports.GenericReportGenerator.java
private static void appendToCombinedRangeManhattanPlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection currChrSC, boolean showlables, double threshold, Color background, Color backgroundAlternative, Color main) { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); // Set dot shape of the currently appended Series renderer.setSeriesPaint(currChrSC.getSeriesCount() - 1, main); renderer.setSeriesVisibleInLegend(currChrSC.getSeriesCount() - 1, showlables); renderer.setSeriesShape(currChrSC.getSeriesCount() - 1, new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0)); // Set range axis if (combinedPlot.getSubplots().isEmpty()) { LogAxis rangeAxis = new LogAxis("P value"); rangeAxis.setBase(10);//from w ww . j a va 2s . c om rangeAxis.setInverted(true); rangeAxis.setNumberFormatOverride(FORMAT_P_VALUE); rangeAxis.setTickMarkOutsideLength(2.0f); rangeAxis.setMinorTickCount(2); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setAxisLineVisible(true); rangeAxis.setUpperMargin(0); TickUnitSource units = NumberAxis.createIntegerTickUnits(); rangeAxis.setStandardTickUnits(units); combinedPlot.setRangeAxis(0, rangeAxis); } // Build subchart JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", currChrSC, PlotOrientation.VERTICAL, false, false, false); // Get subplot from subchart XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); // CHART BACKGROUD COLOR if (combinedPlot.getSubplots().size() % 2 == 0) { subplot.setBackgroundPaint(background); // Hue, saturation, brightness } else { subplot.setBackgroundPaint(backgroundAlternative); // Hue, saturation, brightness } // Add significance Threshold to subplot final Marker thresholdLine = new ValueMarker(threshold); thresholdLine.setPaint(Color.red); // Add legend to hetzyThreshold if (showlables) { thresholdLine.setLabel("P = " + FORMAT_P_VALUE.format(threshold)); } thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT); thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); subplot.addRangeMarker(thresholdLine); // Chromosome Axis Labels NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setLabelAngle(1.0); chrAxis.setAutoRangeIncludesZero(false); chrAxis.setAxisLineVisible(true); chrAxis.setTickLabelsVisible(false); chrAxis.setTickMarksVisible(false); // chrAxis.setNumberFormatOverride(Report_Analysis.FORMAT_SCIENTIFIC); // TickUnitSource units = NumberAxis.createIntegerTickUnits(); // chrAxis.setStandardTickUnits(units); //combinedPlot.setGap(0); combinedPlot.add(subplot, 1); }
From source file:com.itemanalysis.jmetrik.graph.scatterplot.ScatterplotPanel.java
public void updateDataset(XYSeriesCollection dataset) { if (dataset.getSeriesCount() == 1 || !showLegend) { chart.removeLegend();//from w w w . j a v a 2s. c om } XYPlot plot = (XYPlot) chart.getPlot(); plot.setDataset(dataset); setXYPlotRenderer(plot); }
From source file:edu.gmu.cs.sim.util.media.chart.TimeSeriesChartGenerator.java
/** Adds a series, plus a (possibly null) SeriesChangeListener which will receive a <i>single</i> event if/when the series is deleted from the chart by the user. The series should have a key in the form of a String. Returns the series attributes. */ public SeriesAttributes addSeries(final XYSeries series, final SeriesChangeListener stopper) { XYSeriesCollection xysc = (XYSeriesCollection) getSeriesDataset(); int i = xysc.getSeriesCount(); series.setKey(new ChartGenerator.UniqueString(series.getKey())); xysc.addSeries(series);/*from w ww .ja va 2s .co m*/ TimeSeriesAttributes csa = new TimeSeriesAttributes(this, series, i, stopper); seriesAttributes.add(csa); revalidate(); return csa; }
From source file:org.pentaho.platform.uifoundation.chart.XYSeriesCollectionChartComponent.java
@Override public Document getXmlContent() { // Create a document that describes the result Document result = DocumentHelper.createDocument(); IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext(); String contextPath = requestContext.getContextPath(); setXslProperty("baseUrl", contextPath + "/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String mapName = "chart" + AbstractChartComponent.chartCount++; //$NON-NLS-1$ Document chartDefinition = jcrHelper.getSolutionDocument(definitionPath, RepositoryFilePermission.READ); if (chartDefinition == null) { Element errorElement = result.addElement("error"); //$NON-NLS-1$ errorElement.addElement("title").setText( //$NON-NLS-1$ Messages.getInstance().getString("ABSTRACTCHARTEXPRESSION.ERROR_0001_ERROR_GENERATING_CHART")); //$NON-NLS-1$ String message = Messages.getInstance().getString("CHARTS.ERROR_0001_CHART_DEFINIION_MISSING", //$NON-NLS-1$ definitionPath);//from w ww . jav a2 s. c o m errorElement.addElement("message").setText(message); //$NON-NLS-1$ error(message); return result; } // create a pie definition from the XML definition dataDefinition = createChart(chartDefinition); if (dataDefinition == null) { Element errorElement = result.addElement("error"); //$NON-NLS-1$ errorElement.addElement("title").setText( //$NON-NLS-1$ Messages.getInstance().getString("ABSTRACTCHARTEXPRESSION.ERROR_0001_ERROR_GENERATING_CHART")); //$NON-NLS-1$ String message = Messages.getInstance().getString("CHARTS.ERROR_0002_CHART_DATA_MISSING", actionPath); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ errorElement.addElement("message").setText(message); //$NON-NLS-1$ // System .out.println( result.asXML() ); return result; } // create an image for the dial using the JFreeChart engine PrintWriter printWriter = new PrintWriter(new StringWriter()); // we'll dispay the title in HTML so that the dial image does not have // to // accommodate it String chartTitle = ""; //$NON-NLS-1$ try { if (width == -1) { width = Integer.parseInt(chartDefinition.selectSingleNode("/chart/width").getText()); //$NON-NLS-1$ } if (height == -1) { height = Integer.parseInt(chartDefinition.selectSingleNode("/chart/height").getText()); //$NON-NLS-1$ } } catch (Exception e) { // go with the default } if (chartDefinition.selectSingleNode("/chart/" + AbstractChartComponent.URLTEMPLATE_NODE_NAME) != null) { //$NON-NLS-1$ urlTemplate = chartDefinition.selectSingleNode("/chart/" + AbstractChartComponent.URLTEMPLATE_NODE_NAME) //$NON-NLS-1$ .getText(); } if (chartDefinition.selectSingleNode("/chart/paramName") != null) { //$NON-NLS-1$ paramName = chartDefinition.selectSingleNode("/chart/paramName").getText(); //$NON-NLS-1$ } Element root = result.addElement("charts"); //$NON-NLS-1$ XYSeriesCollection chartDataDefinition = (XYSeriesCollection) dataDefinition; if (chartDataDefinition.getSeriesCount() > 0) { // create temporary file names String[] tempFileInfo = createTempFile(); String fileName = tempFileInfo[AbstractChartComponent.FILENAME_INDEX]; String filePathWithoutExtension = tempFileInfo[AbstractChartComponent.FILENAME_WITHOUT_EXTENSION_INDEX]; ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); JFreeChartEngine.saveChart(chartDataDefinition, chartTitle, "", filePathWithoutExtension, width, height, //$NON-NLS-1$ JFreeChartEngine.OUTPUT_PNG, printWriter, info, this); applyOuterURLTemplateParam(); populateInfo(info); Element chartElement = root.addElement("chart"); //$NON-NLS-1$ chartElement.addElement("mapName").setText(mapName); //$NON-NLS-1$ chartElement.addElement("width").setText(Integer.toString(width)); //$NON-NLS-1$ chartElement.addElement("height").setText(Integer.toString(height)); //$NON-NLS-1$ for (int row = 0; row < chartDataDefinition.getSeriesCount(); row++) { for (int column = 0; column < chartDataDefinition.getItemCount(row); column++) { Number value = chartDataDefinition.getY(row, column); Comparable rowKey = chartDataDefinition.getSeriesKey(row); Number columnKey = chartDataDefinition.getX(row, column); Element valueElement = chartElement.addElement("value2D"); //$NON-NLS-1$ valueElement.addElement("value").setText(value.toString()); //$NON-NLS-1$ valueElement.addElement("row-key").setText(rowKey.toString()); //$NON-NLS-1$ valueElement.addElement("column-key").setText(columnKey.toString()); //$NON-NLS-1$ } } String mapString = ImageMapUtilities.getImageMap(mapName, info); chartElement.addElement("imageMap").setText(mapString); //$NON-NLS-1$ chartElement.addElement("image").setText(fileName); //$NON-NLS-1$ } return result; }
From source file:no.ntnu.mmfplanner.ui.graph.NpvChart.java
/** * Helper method for updateModel(). Adds the legend elements for self * funding and break even./*from ww w. j a v a 2s . co m*/ */ private void addLegendElements(XYSeriesCollection dataset, XYLineAndShapeRenderer renderer) { // self funding legend XYSeries selfFundingLegend = new XYSeries("Self Funding"); int series = dataset.getSeriesCount(); dataset.addSeries(selfFundingLegend); renderer.setSeriesPaint(series, Color.black); renderer.setSeriesShape(series, ShapeUtilities.createUpTriangle(3.5f)); // break even legend XYSeries breakEvenLegend = new XYSeries("Break Even"); series = dataset.getSeriesCount(); dataset.addSeries(breakEvenLegend); renderer.setSeriesPaint(series, Color.black); renderer.setSeriesShape(series, ShapeUtilities.createDiamond(3.5f)); }
From source file:no.ntnu.mmfplanner.ui.graph.NpvChart.java
/** * Helper method for updateModel(). Adds the gray line at x=0. *//*from www . ja v a 2 s . c o m*/ private void addLineX(XYSeriesCollection dataset, XYLineAndShapeRenderer renderer) { XYSeries line = new XYSeries(""); line.add(0.5, 0.0); line.add(project.getPeriods() + 0.5, 0.0); int series = dataset.getSeriesCount(); dataset.addSeries(line); renderer.setSeriesPaint(series, Color.GRAY); renderer.setSeriesShapesVisible(series, false); renderer.setSeriesLinesVisible(series, true); renderer.setSeriesVisibleInLegend(series, false); }
From source file:umontreal.iro.lecuyer.charts.EmpiricalChart.java
private void fixZeroPoint() { // reset the first point (x0, 0) with x0 at the beginning of x-axis double xmin = Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition()); XYSeriesCollection col = (XYSeriesCollection) dataset.getSeriesCollection(); for (int i = 0; i < col.getSeriesCount(); i++) { XYSeries ser = col.getSeries(i); ser.remove(0); // remove temporary 0-point ser.add(xmin, 0); // replace }/* ww w .j av a 2 s .c o m*/ }
From source file:org.matsim.contrib.drt.analysis.DensityScatterPlots.java
public static JFreeChart createPlot(String title, String xAxisLabel, String yAxisLabel, XYSeries series, Pair<Double, Double> lineCoeffs) { XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series);/* w w w . j a v a2 s . c om*/ double maxValue = Math.max(series.getMaxX(), series.getMaxY()); // y=x XYSeries lineXY = new XYSeries("y = x"); lineXY.add(0, 0); lineXY.add(maxValue, maxValue); dataset.addSeries(lineXY); if (lineCoeffs != null) { // a*y+b=x double a = lineCoeffs.getLeft(); double b = lineCoeffs.getRight(); String namePrefix = a == 0 ? "" : (a + " * y + "); XYSeries lineABXY = new XYSeries(namePrefix + b + " = x"); lineABXY.add(b, 0); if (a == 0) { lineABXY.add(b, maxValue); } else { lineABXY.add(maxValue, (maxValue - b) / a); } dataset.addSeries(lineABXY); } final JFreeChart chart = ChartFactory.createScatterPlot(title, xAxisLabel, yAxisLabel, dataset); XYPlot xyPlot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyPlot.getRenderer(0); renderer.setSeriesPaint(0, new Color(255, 0, 0, 50)); renderer.setSeriesShape(0, CIRCLE); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesVisibleInLegend(0, false); for (int i = 1; i < dataset.getSeriesCount(); i++) { renderer.setSeriesPaint(i, new Color(0, 0, 0)); renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); renderer.setSeriesVisibleInLegend(i, false); } xyPlot.getDomainAxis().setUpperBound(maxValue); xyPlot.getRangeAxis().setUpperBound(maxValue); xyPlot.getDomainAxis().setLowerBound(0); xyPlot.getRangeAxis().setLowerBound(0); return chart; }
From source file:org.jfree.data.xy.junit.XYSeriesCollectionTest.java
/** * Some checks for the constructor.// w w w .j a v a 2s . c om */ public void testConstructor() { XYSeriesCollection xysc = new XYSeriesCollection(); assertEquals(0, xysc.getSeriesCount()); assertEquals(1.0, xysc.getIntervalWidth(), EPSILON); assertEquals(0.5, xysc.getIntervalPositionFactor(), EPSILON); }
From source file:com.anrisoftware.prefdialog.miscswing.multichart.freechart.FreechartXYChart.java
private void updateData(int row0, int row1, int offset) { if (row0 >= model.getViewMaximum() || row0 >= model.getRowCount()) { return;/*from w w w . j a v a 2 s . c om*/ } XYSeriesCollection series = getCategory(); int max = series.getSeriesCount() * (row1 - row0); if (pool != null && max > forkLimitCount) { updateDataThread(row0, row1, offset, max); } else { updateData0(row0, row1, offset); } }