List of usage examples for org.jfree.chart.event PlotChangeEvent PlotChangeEvent
public PlotChangeEvent(Plot plot)
From source file:ucar.unidata.idv.control.chart.MyScatterPlot.java
/** * Set the data. Redraw the plot./*w w w. ja v a2s . c o m*/ * * @param newData The data */ public void addSeries(double[][] newData) { series.add(newData); configureDomainAxes(); configureRangeAxes(); if (newData != null) { notifyListeners(new PlotChangeEvent(this)); } }
From source file:net.bioclipse.model.ScatterPlotMouseHandler.java
@Override public void mouseDragged(MouseEvent e) { super.mouseDragged(e); ChartPanel chartPanel = getChartPanel(e); JFreeChart selectedChart = chartPanel.getChart(); ChartDescriptor cd = ChartUtils.getChartDescriptor(selectedChart); int[] indices = cd.getSourceIndices(); XYPlot plot = (XYPlot) chartPanel.getChart().getPlot(); //Create double buffer Image buffer = chartPanel.createImage(chartPanel.getWidth(), chartPanel.getHeight()); Graphics bufferGraphics = buffer.getGraphics(); chartPanel.paint(bufferGraphics);/*w w w .j a va2s. c om*/ if (lastX == 0 && lastY == 0) { lastX = e.getX(); lastY = e.getY(); } drawRect = new Rectangle(); int x1 = Math.min(Math.min(e.getX(), lastX), startX); int y1 = Math.min(Math.min(e.getY(), lastY), startY); int x2 = Math.max(Math.max(e.getX(), lastX), startX); int y2 = Math.max(Math.max(e.getY(), lastY), startY); drawRect.x = x1; drawRect.y = y1; drawRect.width = x2 - drawRect.x; drawRect.height = y2 - drawRect.y; //Create a clipping rectangle Rectangle clipRect = new Rectangle(drawRect.x - 100, drawRect.y - 100, drawRect.width + 200, drawRect.height + 200); //Check for selected points for (int j = 0; j < plot.getDataset().getItemCount(plot.getDataset().getSeriesCount() - 1); j++) { for (int i = 0; i < plot.getDataset().getSeriesCount(); i++) { Number xK = plot.getDataset().getX(i, j); Number yK = plot.getDataset().getY(i, j); Point2D datasetPoint2D = new Point2D.Double(domainValueTo2D(chartPanel, plot, xK.doubleValue()), rangeValueTo2D(chartPanel, plot, yK.doubleValue())); if (drawRect.contains(datasetPoint2D)) { PlotPointData cp = new PlotPointData(indices[j], cd.getXLabel(), cd.getYLabel()); boolean pointAdded = mouseDragSelection.addPoint(cp); if (pointAdded) { ((ScatterPlotRenderer) plot.getRenderer()).addMarkedPoint(j, i); selectedChart.plotChanged(new PlotChangeEvent(plot)); } } else if (!mouseDragSelection.isEmpty()) { PlotPointData cp = new PlotPointData(indices[j], cd.getXLabel(), cd.getYLabel()); boolean pointRemoved = mouseDragSelection.removePoint(cp); if (pointRemoved) { ((ScatterPlotRenderer) plot.getRenderer()).removeMarkedPoint(new Point(j, i)); selectedChart.plotChanged(new PlotChangeEvent(plot)); } } } } Iterator<PlotPointData> iterator = currentSelection.iterator(); while (iterator.hasNext()) { PlotPointData next = iterator.next(); Point dataPoint = next.getDataPoint(); ((ScatterPlotRenderer) plot.getRenderer()).addMarkedPoint(dataPoint); } lastX = e.getX(); lastY = e.getY(); Graphics graphics = chartPanel.getGraphics(); graphics.setClip(clipRect); //Draw selection rectangle bufferGraphics.drawRect(drawRect.x, drawRect.y, drawRect.width, drawRect.height); graphics.drawImage(buffer, 0, 0, chartPanel.getWidth(), chartPanel.getHeight(), null); }
From source file:net.bioclipse.chart.ChartUtils.java
/** * Marks a plotted point/* ww w. j av a 2 s . com*/ * @param series * @param index * @deprecated */ public static void markPoints(CellSelection cs) { if (chart != null && ChartUtils.currentPlotType == ChartConstants.SCATTER_PLOT) { ScatterPlotRenderer renderer = (ScatterPlotRenderer) chart.getXYPlot().getRenderer(); Iterator<CellData> iter = cs.iterator(); renderer.clearMarkedPoints(); while (iter.hasNext()) { CellData cd = iter.next(); if (cd.getColName().equals(ChartUtils.xColumn) || cd.getColName().equals(ChartUtils.yColumn)) { renderer.addMarkedPoint(0, cd.getRowIndex()); chart.plotChanged(new PlotChangeEvent(chart.getPlot())); } } } }
From source file:net.sf.maltcms.chromaui.charts.tools.ChartTools.java
/** * * @param p/* w w w . j a va 2s . co m*/ * @param sps */ public static void changePaintScale(final XYPlot p, final PaintScale sps) { if (p.getRenderer() instanceof XYBlockRenderer) { Runnable r = new Runnable() { @Override public void run() { XYBlockRenderer renderer = (XYBlockRenderer) p.getRenderer(); Logger.getLogger(ChartTools.class.getName()).info("Setting paintscale"); renderer.setPaintScale(sps); if (p instanceof FastHeatMapPlot) { Logger.getLogger(ChartTools.class.getName()).info("Resetting data image"); FastHeatMapPlot fhp = (FastHeatMapPlot) p; fhp.resetDataImage(); } p.notifyListeners(new PlotChangeEvent(p)); } }; SwingUtilities.invokeLater(r); } }
From source file:org.jfree.experimental.chart.plot.dial.DialPlot.java
/** * Sets the background layer./*from w w w . j av a 2 s.c o m*/ * * @param background the background layer (<code>null</code> permitted). * * @see #getBackground() */ public void setBackground(DialLayer background) { this.background = background; notifyListeners(new PlotChangeEvent(this)); }
From source file:org.jfree.experimental.chart.plot.dial.DialPlot.java
/** * Sets the cap./*ww w. j a va 2s . c om*/ * * @param cap the cap (<code>null</code> permitted). * * @see #getCap() */ public void setCap(DialLayer cap) { this.cap = cap; notifyListeners(new PlotChangeEvent(this)); }
From source file:net.bioclipse.model.ScatterPlotMouseHandler.java
@Override public void mousePressed(MouseEvent e) { super.mousePressed(e); ChartPanel chartPanel = getChartPanel(e); startX = e.getX();//w w w. j a v a 2s. c om startY = e.getY(); if (!e.isShiftDown()) { ((ScatterPlotRenderer) ((XYPlot) chartPanel.getChart().getPlot()).getRenderer()).clearMarkedPoints(); currentSelection = new ChartSelection(); chartPanel.getChart().plotChanged(new PlotChangeEvent(chartPanel.getChart().getPlot())); } else { ((ScatterPlotRenderer) ((XYPlot) chartPanel.getChart().getPlot()).getRenderer()) .removeMarkedPoint(null); } if (currentSelection == null) { currentSelection = new ChartSelection(); } mouseDragSelection = new ChartSelection(); currentSelection.setDescriptor(ChartUtils.getChartDescriptor(chartPanel.getChart())); }
From source file:org.jfree.experimental.chart.plot.dial.DialPlot.java
/** * Sets the dial's frame.//from ww w .ja v a 2 s. c o m * * @param frame the frame (<code>null</code> not permitted). * * @see #getDialFrame() */ public void setDialFrame(DialFrame frame) { if (frame == null) { throw new IllegalArgumentException("Null 'frame' argument."); } this.dialFrame = frame; notifyListeners(new PlotChangeEvent(this)); }
From source file:net.sourceforge.processdash.ui.lib.chart.DiscPlot.java
/** * @param discDistributor The discDistributor to set. *//* w w w.j ava 2 s . com*/ public void setDiscDistributor(AbstractDiscItemDistributor discDistributor) { if (discDistributor == null) throw new IllegalArgumentException("Disc distributor cannot be null"); this.discDistributor = discDistributor; this.discDistributor.setDataset(this.dataset); notifyListeners(new PlotChangeEvent(this)); }
From source file:net.sourceforge.processdash.ui.lib.chart.DiscPlot.java
/** * @param discRenderer The discRenderer to set. *///from w ww .ja v a 2 s . c o m public void setDiscRenderer(DiscItemRenderer discRenderer) { if (discRenderer == null) throw new IllegalArgumentException("Disc renderer cannot be null"); this.discRenderer = discRenderer; notifyListeners(new PlotChangeEvent(this)); }