Java Code Examples for org.jfree.chart.ChartPanel#repaint()
The following examples show how to use
org.jfree.chart.ChartPanel#repaint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegionSelectionHandler.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Handles a mouse dragged event. * * @param e the event. */ public void mouseDragged(MouseEvent e) { if (this.lastPoint == null) { return; // we never started a selection } ChartPanel panel = (ChartPanel) e.getSource(); Point pt = e.getPoint(); Point2D pt2 = ShapeUtilities.getPointInRectangle(pt.x, pt.y, panel.getScreenDataArea()); if (pt2.distance(this.lastPoint) > 5) { this.selection.lineTo((float) pt2.getX(), (float) pt2.getY()); this.lastPoint = pt2; } panel.setSelectionShape(selection); panel.setSelectionFillPaint(this.fillPaint); panel.setSelectionOutlinePaint(this.outlinePaint); panel.repaint(); }
Example 2
Source File: RegionSelectionHandler.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Handles a mouse released event. * * @param e the event. */ public void mouseReleased(MouseEvent e) { if (this.lastPoint == null) { return; // we never started a selection } ChartPanel panel = (ChartPanel) e.getSource(); this.selection.closePath(); // do something with the selection shape JFreeChart chart = panel.getChart(); Plot plot = chart.getPlot(); if (!(plot instanceof Selectable)) { return; } Selectable p = (Selectable) plot; if (p.canSelectByRegion()) { p.select(this.selection, panel.getScreenDataArea(), panel); } panel.setSelectionShape(null); this.selection.reset(); this.lastPoint = null; panel.repaint(); //panel.clearLiveMouseHandler(); }
Example 3
Source File: ChartExportUtil.java From mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * takes Only Width in account * * @param chart * @param sett * @throws Exception */ public static void writeChartToImage(ChartPanel chart, GraphicsExportParameters sett) throws Exception { boolean repaint = false; FixedSize fixed = sett.getFixedSize(); double oldW = sett.getWidthPixel(); double oldH = sett.getHeightPixel(); // Size only by width? if (sett.isUseOnlyWidth()) { // fixed size for chart or plot if (fixed.equals(FixedSize.Chart)) { sett.setHeightPixel(ChartLogics.calcHeightToWidth(chart, oldW, false)); } else { // fixed plot width sett.setPixelSize(ChartLogics.calcSizeForPlotWidth(chart, oldW)); } } else if (fixed.equals(FixedSize.Plot)) { // fixed plot size - width and height are given sett.setPixelSize(ChartLogics.calcSizeForPlotSize(chart, oldW, oldH)); } Dimension size = sett.getPixelSize(); // resize chart.setPreferredSize(size); chart.setMaximumSize(size); chart.setMinimumSize(size); // repaint if (repaint) { chart.revalidate(); chart.repaint(); } writeChartToImage(chart.getChart(), sett, chart.getChartRenderingInfo()); // reset size sett.setPixelSize(oldW, oldH); }
Example 4
Source File: ChartExportUtil.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
/** * takes Only Width in account * * @param chart * @param sett * @throws Exception */ public static void writeChartToImage(ChartPanel chart, GraphicsExportParameters sett) throws Exception { boolean repaint = false; FixedSize fixed = sett.getFixedSize(); double oldW = sett.getWidthPixel(); double oldH = sett.getHeightPixel(); // Size only by width? if (sett.isUseOnlyWidth()) { // fixed size for chart or plot if (fixed.equals(FixedSize.Chart)) { sett.setHeightPixel(ChartLogics.calcHeightToWidth(chart, oldW, false)); } else { // fixed plot width sett.setPixelSize(ChartLogics.calcSizeForPlotWidth(chart, oldW)); } } else if (fixed.equals(FixedSize.Plot)) { // fixed plot size - width and height are given sett.setPixelSize(ChartLogics.calcSizeForPlotSize(chart, oldW, oldH)); } Dimension size = sett.getPixelSize(); // resize chart.setPreferredSize(size); chart.setMaximumSize(size); chart.setMinimumSize(size); // repaint if (repaint) { chart.revalidate(); chart.repaint(); } writeChartToImage(chart.getChart(), sett, chart.getChartRenderingInfo()); // reset size sett.setPixelSize(oldW, oldH); }
Example 5
Source File: ChartExportUtil.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
/** * takes Only Width in account * * @param chart * @param sett * @throws Exception */ public static void writeChartToImage(ChartPanel chart, GraphicsExportParameters sett) throws Exception { boolean repaint = false; FixedSize fixed = sett.getFixedSize(); double oldW = sett.getWidthPixel(); double oldH = sett.getHeightPixel(); // Size only by width? if (sett.isUseOnlyWidth()) { // fixed size for chart or plot if (fixed.equals(FixedSize.Chart)) { sett.setHeightPixel(ChartLogics.calcHeightToWidth(chart, oldW, false)); } else { // fixed plot width sett.setPixelSize(ChartLogics.calcSizeForPlotWidth(chart, oldW)); } } else if (fixed.equals(FixedSize.Plot)) { // fixed plot size - width and height are given sett.setPixelSize(ChartLogics.calcSizeForPlotSize(chart, oldW, oldH)); } Dimension size = sett.getPixelSize(); // resize chart.setPreferredSize(size); chart.setMaximumSize(size); chart.setMinimumSize(size); // repaint if (repaint) { chart.revalidate(); chart.repaint(); } writeChartToImage(chart.getChart(), sett, chart.getChartRenderingInfo()); // reset size sett.setPixelSize(oldW, oldH); }
Example 6
Source File: ZoomHandler.java From astor with GNU General Public License v2.0 | 4 votes |
public void mouseReleased(MouseEvent e) { if (this.zoomRectangle == null) { return; } ChartPanel panel = (ChartPanel) e.getSource(); boolean hZoom = false; boolean vZoom = false; if (panel.getOrientation() == PlotOrientation.HORIZONTAL) { hZoom = panel.isRangeZoomable(); vZoom = panel.isDomainZoomable(); } else { hZoom = panel.isDomainZoomable(); vZoom = panel.isRangeZoomable(); } boolean zoomTrigger1 = hZoom && Math.abs(e.getX() - this.zoomPoint.getX()) >= panel.getZoomTriggerDistance(); boolean zoomTrigger2 = vZoom && Math.abs(e.getY() - this.zoomPoint.getY()) >= panel.getZoomTriggerDistance(); if (zoomTrigger1 || zoomTrigger2) { if ((hZoom && (e.getX() < this.zoomPoint.getX())) || (vZoom && (e.getY() < this.zoomPoint.getY()))) { panel.restoreAutoBounds(); } else { double x, y, w, h; Rectangle2D screenDataArea = panel.getScreenDataArea( (int) this.zoomPoint.getX(), (int) this.zoomPoint.getY()); double maxX = screenDataArea.getMaxX(); double maxY = screenDataArea.getMaxY(); // for mouseReleased event, (horizontalZoom || verticalZoom) // will be true, so we can just test for either being false; // otherwise both are true if (!vZoom) { x = this.zoomPoint.getX(); y = screenDataArea.getMinY(); w = Math.min(this.zoomRectangle.getWidth(), maxX - this.zoomPoint.getX()); h = screenDataArea.getHeight(); } else if (!hZoom) { x = screenDataArea.getMinX(); y = this.zoomPoint.getY(); w = screenDataArea.getWidth(); h = Math.min(this.zoomRectangle.getHeight(), maxY - this.zoomPoint.getY()); } else { x = this.zoomPoint.getX(); y = this.zoomPoint.getY(); w = Math.min(this.zoomRectangle.getWidth(), maxX - this.zoomPoint.getX()); h = Math.min(this.zoomRectangle.getHeight(), maxY - this.zoomPoint.getY()); } Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h); panel.zoom(zoomArea); } this.zoomPoint = null; this.zoomRectangle = null; panel.setZoomRectangle(null); panel.clearLiveMouseHandler(); } else { // erase the zoom rectangle Graphics2D g2 = (Graphics2D) panel.getGraphics(); if (panel.getUseBuffer()) { panel.repaint(); } else { drawZoomRectangle(panel, g2, true); } g2.dispose(); this.zoomPoint = null; this.zoomRectangle = null; panel.setZoomRectangle(null); panel.clearLiveMouseHandler(); } }