private void removeAllDatasetSeries() { int datasetCount = xyPlot.getDatasetCount(); for (int i = 0; i < datasetCount; i++) { xyPlot.setDataset(i, null); } }
XYPlot plot = new XYPlot(this.data1, xAxis, yAxis, renderer1); LineFunction2D line = new LineFunction2D(A, B); XYDataset lineDS = DatasetUtilities.sampleFunction2D(line,start,end,samples,seriesKey ); plot.setDataset(plot.getDatasetCount() + 1, lineDS);
MetadataPlotTableModel(XYPlot plot) { this.plot = plot; columList = new ArrayList<>(); columList.add(plot.getDomainAxis().getLabel()); for(int i = 0; i < plot.getDatasetCount(); i++) { columList.add(String.valueOf(plot.getDataset(i).getSeriesKey(0))); } }
/** * Gets the index of the first dataset containing the specified series. * * @param aPlot Plot to be searched for the dataset of the fitted function. * @param aSeriesName Name of series the dataset should contain. * @return Index of the dataset which contains series named <code>aSeriesName</code>, * <code>-1</code> if such dataset does not exist. */ protected static int getDatasetIndex(XYPlot aPlot, String aSeriesName) { final int datasetCount = aPlot.getDatasetCount(); for (int i = 0; i < datasetCount; ++i) { if (aSeriesName.equals(aPlot.getDataset(i).getSeriesKey(0))) { return i; } } return -1; }
/** * Returns the domain axis for a dataset. * * @param index the dataset index. * * @return The axis. */ public ValueAxis getDomainAxisForDataset(int index) { int upper = Math.max(getDatasetCount(), getRendererCount()); if (index < 0 || index >= upper) { throw new IllegalArgumentException("Index " + index + " out of bounds."); } ValueAxis valueAxis = null; List axisIndices = (List) this.datasetToDomainAxesMap.get( new Integer(index)); if (axisIndices != null) { // the first axis in the list is used for data <--> Java2D Integer axisIndex = (Integer) axisIndices.get(0); valueAxis = getDomainAxis(axisIndex.intValue()); } else { valueAxis = getDomainAxis(0); } return valueAxis; }
/** * Returns the range axis for a dataset. * * @param index the dataset index. * * @return The axis. */ public ValueAxis getRangeAxisForDataset(int index) { int upper = Math.max(getDatasetCount(), getRendererCount()); if (index < 0 || index >= upper) { throw new IllegalArgumentException("Index " + index + " out of bounds."); } ValueAxis valueAxis = null; List axisIndices = (List) this.datasetToRangeAxesMap.get( new Integer(index)); if (axisIndices != null) { // the first axis in the list is used for data <--> Java2D Integer axisIndex = (Integer) axisIndices.get(0); valueAxis = getRangeAxis(axisIndex.intValue()); } else { valueAxis = getRangeAxis(0); } return valueAxis; }
/** * Returns <code>true</code> if all the datasets belonging to the specified * plot are empty or <code>null</code>, and <code>false</code> otherwise. * * @param plot the plot (<code>null</code> permitted). * * @return A boolean. * * @since 1.0.7 */ public static boolean isEmptyOrNull(XYPlot plot) { if (plot != null) { for (int i = 0, n = plot.getDatasetCount(); i < n; i++) { final XYDataset dataset = plot.getDataset(i); if (!DatasetUtilities.isEmptyOrNull(dataset)) { return false; } } } return true; }
public static XYPlot addDatasetRender(XYPlot plot, XYDataset dataset, XYItemRenderer renderer) { int index = plot.getDatasetCount(); // Bug jfreechart. When we create a XYPlot without dataset, one null dataset is added to list. if (index == 1 && plot.getDataset(0) == null) { index--; } plot.setDataset(index, dataset); plot.setRenderer(index, renderer); return plot; }
/** * Draws the range markers (if any) for a renderer and layer. This method * is typically called from within the draw() method. * * @param g2 the graphics device. * @param dataArea the data area. * @param index the renderer index. * @param layer the layer (foreground or background). */ protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, int index, Layer layer) { XYItemRenderer r = getRenderer(index); if (r == null) { return; } // check that the renderer has a corresponding dataset (it doesn't // matter if the dataset is null) if (index >= getDatasetCount()) { return; } Collection markers = getRangeMarkers(index, layer); ValueAxis axis = getRangeAxisForDataset(index); if (markers != null && axis != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker marker = (Marker) iterator.next(); r.drawRangeMarker(g2, this, axis, marker, dataArea); } } }
/** * Draws the domain markers (if any) for an axis and layer. This method is * typically called from within the draw() method. * * @param g2 the graphics device. * @param dataArea the data area. * @param index the dataset/renderer index. * @param layer the layer (foreground or background). */ protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea, int index, Layer layer) { XYItemRenderer r = getRenderer(index); if (r == null) { return; } // check that the renderer has a corresponding dataset (it doesn't // matter if the dataset is null) if (index >= getDatasetCount()) { return; } Collection markers = getDomainMarkers(index, layer); ValueAxis axis = getDomainAxisForDataset(index); if (markers != null && axis != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker marker = (Marker) iterator.next(); r.drawDomainMarker(g2, this, axis, marker, dataArea); } } }
/** * Draws the range markers (if any) for a renderer and layer. This method * is typically called from within the draw() method. * * @param g2 the graphics device. * @param dataArea the data area. * @param index the renderer index. * @param layer the layer (foreground or background). */ protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, int index, Layer layer) { XYItemRenderer r = getRenderer(index); if (r == null) { return; } // check that the renderer has a corresponding dataset (it doesn't // matter if the dataset is null) if (index >= getDatasetCount()) { return; } Collection markers = getRangeMarkers(index, layer); ValueAxis axis = getRangeAxisForDataset(index); if (markers != null && axis != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker marker = (Marker) iterator.next(); r.drawRangeMarker(g2, this, axis, marker, dataArea); } } }
/** * Draws the domain markers (if any) for an axis and layer. This method is * typically called from within the draw() method. * * @param g2 the graphics device. * @param dataArea the data area. * @param index the renderer index. * @param layer the layer (foreground or background). */ protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea, int index, Layer layer) { XYItemRenderer r = getRenderer(index); if (r == null) { return; } // check that the renderer has a corresponding dataset (it doesn't // matter if the dataset is null) if (index >= getDatasetCount()) { return; } Collection markers = getDomainMarkers(index, layer); ValueAxis axis = getDomainAxisForDataset(index); if (markers != null && axis != null) { Iterator iterator = markers.iterator(); while (iterator.hasNext()) { Marker marker = (Marker) iterator.next(); r.drawDomainMarker(g2, this, axis, marker, dataArea); } } }
XYDataset dataSet = // your line dataset CombinedDomainXYPlot plot = (CombinedDomainXYPlot) chart.getPlot(); XYPlot plot = (XYPlot) plot.getSubplots().get(0); int dataSetIndx = plot.getDatasetCount(); plot.setDataset(dataSetIndx, dataSet); XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); plot.setRenderer(dataSetIndx, lineRenderer);
/** * Creates a new dataset for visualizing the fitted function. * <p> * The new dataset is added to the end of the dataset list of the given plot. * </p> * * @param aPlot Plot to which the new dataset must be added. * @return Index of the newly created dataset in the dataset list of <code>aPlot</code>. */ protected static int createDataset(XYPlot aPlot) { int i = aPlot.getDatasetCount(); aPlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); XYLineAndShapeRenderer rend = new XYLineAndShapeRenderer(); rend.setSeriesLinesVisible(0, true); rend.setSeriesShapesVisible(0, false); aPlot.setRenderer(i, rend); return i; }
private void updatePlot(boolean hasData) { for (int i = 0; i < timeSeriesPlot.getDatasetCount(); i++) { timeSeriesPlot.setDataset(i, null);
protected String getTooltipAtPoint(Point point) { XYPlot plot = (XYPlot) getChart().getPlot(); PlotRenderingInfo info = getChartRenderingInfo().getPlotInfo(); double x0 = point.getX(); double x1 = x0 - 2 * getScaleX(); double x2 = x0 + 4 * getScaleX(); ValueAxis domainAxis = plot.getDomainAxis(); Rectangle2D screenArea = scale(info.getDataArea()); double tx1 = domainAxis.java2DToValue(x1, screenArea, BOTTOM); double tx2 = domainAxis.java2DToValue(x2, screenArea, BOTTOM); for (int datasetIndex = 0; datasetIndex < plot.getDatasetCount(); datasetIndex++) { XYDataset dataset = plot.getDataset(datasetIndex); for (int seriesIndex = 0; seriesIndex < dataset.getSeriesCount(); seriesIndex++) { int itemCount = dataset.getItemCount(seriesIndex); for (int itemIndex = 0; itemIndex < itemCount; itemIndex++) { double xValue = dataset.getXValue(seriesIndex, itemIndex); if (tx1 < xValue && xValue < tx2) return toolTipGenerator.generateToolTip(dataset, seriesIndex, itemIndex); } } } return null; } }
table.addValue( xColumnName, xVal ); final int nSets = plot.getDatasetCount(); for ( int i = 0; i < nSets; i++ )
table.addValue( xColumnName, xVal ); final int nSets = plot.getDatasetCount(); for ( int i = 0; i < nSets; i++ )
double my = plot.getRangeAxis().java2DToValue(point.y, dataArea, rangeEdge); int datasetCount = chartPanel.getChart().getXYPlot().getDatasetCount(); double minDist = Double.POSITIVE_INFINITY; for (int datasetIndex = 0; datasetIndex < datasetCount; datasetIndex++) {
double my = plot.getRangeAxis().java2DToValue(point.y, dataArea, rangeEdge); int datasetCount = chartPanel.getChart().getXYPlot().getDatasetCount(); double minDist = Double.POSITIVE_INFINITY; for (int datasetIndex = 0; datasetIndex < datasetCount; datasetIndex++) {