List of usage examples for org.jfree.chart ChartMouseEvent ChartMouseEvent
public ChartMouseEvent(JFreeChart chart, MouseEvent trigger, ChartEntity entity)
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Implementation of the MouseMotionListener's method. * // ww w .j a va2 s . c o m * @param e * the event. */ public void mouseMoved(MouseEvent e) { Graphics2D g2 = (Graphics2D) getGraphics(); if (this.horizontalAxisTrace) { drawHorizontalAxisTrace(g2, e.getX()); } if (this.verticalAxisTrace) { drawVerticalAxisTrace(g2, e.getY()); } g2.dispose(); Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } Insets insets = getInsets(); int x = (int) ((e.getX() - insets.left) / this.scaleX); int y = (int) ((e.getY() - insets.top) / this.scaleY); ChartEntity entity = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } // we can only generate events if the panel's chart is not null // (see bug report 1556951) if (this.chart != null) { ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(event); } } }
From source file:edu.pitt.dbmi.odie.ui.jfreechart.EnhancedChartComposite.java
public void mouseDown(MouseEvent event) { Point2D javaPoint = translateScreenToJava2D(new Point(event.x, event.y)); Rectangle scaledDataArea = getScreenDataArea(event.x, event.y); if (scaledDataArea == null) return;/*from w w w .j a v a 2 s . co m*/ // new entity code ChartEntity entity = getEntityForLocation(javaPoint.getX(), javaPoint.getY()); if (entity != null) logger.debug("Entity Bounds:" + entity.getArea().getBounds()); // logger.debug("----------END------------"); if (event.button == 1) { // Init zoom point only if CTRL key is down. if ((event.stateMask & SWT.CONTROL) != 0) { this.zoomPoint = getPointInRectangle(event.x, event.y, scaledDataArea); } else { clearSelection(false, false); this.selectionPoint = getPointInRectangle(event.x, event.y, scaledDataArea); } } this.anchor = javaPoint; this.chart.setNotify(true); // force a redraw this.canvas.redraw(); Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } // pass mouse down event if some ChartMouseListener are listening java.awt.event.MouseEvent mouseEvent = SWTUtils.toAwtMouseEvent(event); ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), mouseEvent, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent); } }
From source file:org.jfree.experimental.chart.swt.ChartComposite.java
public void mouseMove(MouseEvent event) { // handle axis trace if (this.horizontalAxisTrace || this.verticalAxisTrace) { this.horizontalTraceLineY = event.y; this.verticalTraceLineX = event.x; this.canvas.redraw(); }/*from ww w . ja va 2s . c om*/ // handle tool tips in a simple way if (this.displayToolTips) { String s = getToolTipText(event); if (s == null && this.canvas.getToolTipText() != null || s != null && !s.equals(this.canvas.getToolTipText())) this.canvas.setToolTipText(s); } // handle zoom box boolean hZoom, vZoom; if (this.zoomPoint != null) { Rectangle scaledDataArea = getScreenDataArea(this.zoomPoint.x, this.zoomPoint.y); org.eclipse.swt.graphics.Point movingPoint = getPointInRectangle(event.x, event.y, scaledDataArea); if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } if (hZoom && vZoom) { // selected rectangle shouldn't extend outside the data area... this.zoomRectangle = new Rectangle(this.zoomPoint.x, this.zoomPoint.y, movingPoint.x - this.zoomPoint.x, movingPoint.y - this.zoomPoint.y); } else if (hZoom) { this.zoomRectangle = new Rectangle(this.zoomPoint.x, scaledDataArea.y, movingPoint.x - this.zoomPoint.x, scaledDataArea.height); } else if (vZoom) { int ymax = Math.max(movingPoint.y, scaledDataArea.y); this.zoomRectangle = new Rectangle(scaledDataArea.x, this.zoomPoint.y, scaledDataArea.width, ymax - this.zoomPoint.y); } this.canvas.redraw(); } // new entity code ChartEntity entity = null; int x = (int) ((event.x - getClientArea().x) / this.scaleX); int y = (int) ((event.y - getClientArea().y) / this.scaleY); if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } // pass mouse move event if some ChartMouseListener are listening java.awt.event.MouseEvent mouseEvent = SWTUtils.toAwtMouseEvent(event); ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), mouseEvent, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(chartEvent); } }
From source file:org.rdv.viz.chart.ChartPanel.java
/** * Receives notification of mouse clicks on the panel. These are * translated and passed on to any registered {@link ChartMouseListener}s. * * @param event Information about the mouse event. *///w w w . j a v a 2 s.c o m public void mouseClicked(MouseEvent event) { Insets insets = getInsets(); int x = (int) ((event.getX() - insets.left) / this.scaleX); int y = (int) ((event.getY() - insets.top) / this.scaleY); this.anchor = new Point2D.Double(x, y); if (this.chart == null) { return; } this.chart.setNotify(true); // force a redraw // new entity code... Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } ChartEntity entity = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), event, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent); } }
From source file:com.munch.exchange.parts.neuralnetwork.results.NeuralNetworkResultChartComposite.java
/** * Handles a mouse move event./*from ww w . j a va 2s. com*/ * * @param event the mouse event. */ public void mouseMove(MouseEvent event) { // handle axis trace if (this.horizontalAxisTrace || this.verticalAxisTrace) { this.horizontalTraceLineY = event.y; this.verticalTraceLineX = event.x; this.canvas.redraw(); } // handle tool tips in a simple way if (this.displayToolTips) { String s = getToolTipText(event); if (s == null && this.canvas.getToolTipText() != null || s != null && !s.equals(this.canvas.getToolTipText())) this.canvas.setToolTipText(s); } // handle zoom box boolean hZoom, vZoom; if (this.zoomPoint != null) { Rectangle scaledDataArea = getScreenDataArea(this.zoomPoint.x, this.zoomPoint.y); org.eclipse.swt.graphics.Point movingPoint = getPointInRectangle(event.x, event.y, scaledDataArea); if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } if (hZoom && vZoom) { // selected rectangle shouldn't extend outside the data area... this.zoomRectangle = new Rectangle(this.zoomPoint.x, this.zoomPoint.y, movingPoint.x - this.zoomPoint.x, movingPoint.y - this.zoomPoint.y); } else if (hZoom) { this.zoomRectangle = new Rectangle(this.zoomPoint.x, scaledDataArea.y, movingPoint.x - this.zoomPoint.x, scaledDataArea.height); } else if (vZoom) { int ymax = Math.max(movingPoint.y, scaledDataArea.y); this.zoomRectangle = new Rectangle(scaledDataArea.x, this.zoomPoint.y, scaledDataArea.width, ymax - this.zoomPoint.y); } this.canvas.redraw(); } // new entity code ChartEntity entity = null; //int x = (int) ((event.x - getClientArea().x) / this.scaleX); //int y = (int) ((event.y - getClientArea().y) / this.scaleY); int x = (int) ((event.x - getClientArea().x)); int y = (int) ((event.y - getClientArea().y)); //System.out.println("scaleX: "+this.scaleX); //System.out.println("this.scaleY: "+this.scaleY); //TODO if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } // pass mouse move event if some ChartMouseListener are listening java.awt.event.MouseEvent mouseEvent = SWTUtils.toAwtMouseEvent(event); ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), mouseEvent, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(chartEvent); } }
From source file:com.munch.exchange.ExchangeChartComposite.java
/** * Handles a mouse move event./*from w ww .ja va2s. c o m*/ * * @param event the mouse event. */ public void mouseMove(MouseEvent event) { // handle axis trace if (this.horizontalAxisTrace || this.verticalAxisTrace) { this.horizontalTraceLineY = event.y; this.verticalTraceLineX = event.x; this.canvas.redraw(); } // handle tool tips in a simple way if (this.displayToolTips) { String s = getToolTipText(event); if (s == null && this.canvas.getToolTipText() != null || s != null && !s.equals(this.canvas.getToolTipText())) this.canvas.setToolTipText(s); } // handle zoom box boolean hZoom, vZoom; if (this.zoomPoint != null) { Rectangle scaledDataArea = getScreenDataArea(this.zoomPoint.x, this.zoomPoint.y); org.eclipse.swt.graphics.Point movingPoint = getPointInRectangle(event.x, event.y, scaledDataArea); if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } if (hZoom && vZoom) { // selected rectangle shouldn't extend outside the data area... this.zoomRectangle = new Rectangle(this.zoomPoint.x, this.zoomPoint.y, movingPoint.x - this.zoomPoint.x, movingPoint.y - this.zoomPoint.y); } else if (hZoom) { this.zoomRectangle = new Rectangle(this.zoomPoint.x, scaledDataArea.y, movingPoint.x - this.zoomPoint.x, scaledDataArea.height); } else if (vZoom) { int ymax = Math.max(movingPoint.y, scaledDataArea.y); this.zoomRectangle = new Rectangle(scaledDataArea.x, this.zoomPoint.y, scaledDataArea.width, ymax - this.zoomPoint.y); } this.canvas.redraw(); } // new entity code ChartEntity entity = null; int x = (int) ((event.x - getClientArea().x) / this.scaleX); int y = (int) ((event.y - getClientArea().y) / this.scaleY); System.out.println("scaleX: " + this.scaleX); System.out.println("scaleY: " + this.scaleY); //TODO if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } // pass mouse move event if some ChartMouseListener are listening java.awt.event.MouseEvent mouseEvent = SWTUtils.toAwtMouseEvent(event); ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), mouseEvent, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(chartEvent); } }
From source file:org.mwc.cmap.grideditor.chart.FixedChartComposite.java
/** * Handles a mouse move event.// w w w . j a va 2s . c om * * @param event * the mouse event. */ public void mouseMove(final MouseEvent event) { // handle axis trace if (this.horizontalAxisTrace || this.verticalAxisTrace) { this.horizontalTraceLineY = event.y; this.verticalTraceLineX = event.x; this.canvas.redraw(); } // handle tool tips in a simple way if (this.displayToolTips) { final String s = getToolTipText(event); if (s == null && this.canvas.getToolTipText() != null || s != null && !s.equals(this.canvas.getToolTipText())) this.canvas.setToolTipText(s); } // handle zoom box boolean hZoom, vZoom; if (this.zoomPoint != null) { final Rectangle scaledDataArea = getScreenDataArea(this.zoomPoint.x, this.zoomPoint.y); final org.eclipse.swt.graphics.Point movingPoint = getPointInRectangle(event.x, event.y, scaledDataArea); if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } if (hZoom && vZoom) { // selected rectangle shouldn't extend outside the data area... this.zoomRectangle = new Rectangle(this.zoomPoint.x, this.zoomPoint.y, movingPoint.x - this.zoomPoint.x, movingPoint.y - this.zoomPoint.y); } else if (hZoom) { this.zoomRectangle = new Rectangle(this.zoomPoint.x, scaledDataArea.y, movingPoint.x - this.zoomPoint.x, scaledDataArea.height); } else if (vZoom) { final int ymax = Math.max(movingPoint.y, scaledDataArea.y); this.zoomRectangle = new Rectangle(scaledDataArea.x, this.zoomPoint.y, scaledDataArea.width, ymax - this.zoomPoint.y); } this.canvas.redraw(); } // new entity code ChartEntity entity = null; // [MG] the code below is not used now, see [MG] comment below // int x = (int) ((event.x - getClientArea().x) / this.scaleX); // int y = (int) ((event.y - getClientArea().y) / this.scaleY); if (this.info != null) { final EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { // [MG] -- the code below from original // org.jfree.experimental.chart.swt.ChartComposite // doewn't work -- because entities already placed with respect to the // scale factor. // // entity = entities.getEntity(x, y); // entity = entities.getEntity(event.x - getClientArea().x, event.y - getClientArea().y); } } final Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } // pass mouse move event if some ChartMouseListener are listening final java.awt.event.MouseEvent mouseEvent = SWTUtils.toAwtMouseEvent(event); final ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), mouseEvent, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(chartEvent); } }
From source file:com.rcp.wbw.demo.ChartComposite.java
/** * Handles a mouse move event.//from w w w . j a va 2s. com * * @param event * the mouse event. */ public void mouseMove(MouseEvent event) { // handle axis trace if (this.horizontalAxisTrace || this.verticalAxisTrace) { this.horizontalTraceLineY = event.y; this.verticalTraceLineX = event.x; this.canvas.redraw(); } // handle tool tips in a simple way if (this.displayToolTips) { String s = getToolTipText(event); if (s == null && this.canvas.getToolTipText() != null || s != null && !s.equals(this.canvas.getToolTipText())) this.canvas.setToolTipText(s); } // handle zoom box boolean hZoom, vZoom; if (this.zoomPoint != null) { Rectangle scaledDataArea = getScreenDataArea(this.zoomPoint.x, this.zoomPoint.y); org.eclipse.swt.graphics.Point movingPoint = getPointInRectangle(event.x, event.y, scaledDataArea); if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } if (hZoom && vZoom) { // selected rectangle shouldn't extend outside the data area... this.zoomRectangle = new Rectangle(this.zoomPoint.x, this.zoomPoint.y, movingPoint.x - this.zoomPoint.x, movingPoint.y - this.zoomPoint.y); } else if (hZoom) { this.zoomRectangle = new Rectangle(this.zoomPoint.x, scaledDataArea.y, movingPoint.x - this.zoomPoint.x, scaledDataArea.height); } else if (vZoom) { int ymax = Math.max(movingPoint.y, scaledDataArea.y); this.zoomRectangle = new Rectangle(scaledDataArea.x, this.zoomPoint.y, scaledDataArea.width, ymax - this.zoomPoint.y); } this.canvas.redraw(); } // new entity code ChartEntity entity = null; int x = (int) ((event.x - getClientArea().x) / this.scaleX); int y = (int) ((event.y - getClientArea().y) / this.scaleY); if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } // pass mouse move event if some ChartMouseListener are listening java.awt.event.MouseEvent mouseEvent = SWTUtils.toAwtMouseEvent(event); ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), mouseEvent, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(chartEvent); } }
From source file:edu.pitt.dbmi.odie.ui.jfreechart.EnhancedChartComposite.java
public void mouseUp(MouseEvent event) { boolean hZoom, vZoom; if (zoomRectangle != null) { hZoom = false;/* w ww. ja v a 2 s. co m*/ vZoom = false; if (this.orientation == PlotOrientation.HORIZONTAL) { hZoom = this.rangeZoomable; vZoom = this.domainZoomable; } else { hZoom = this.domainZoomable; vZoom = this.rangeZoomable; } boolean zoomTrigger1 = hZoom && Math.abs(this.zoomRectangle.width) >= this.zoomTriggerDistance; boolean zoomTrigger2 = vZoom && Math.abs(this.zoomRectangle.height) >= this.zoomTriggerDistance; if (zoomTrigger1 || zoomTrigger2) { // if the box has been drawn backwards, restore the auto bounds if ((hZoom && (this.zoomRectangle.x + this.zoomRectangle.width < this.zoomPoint.x)) || (vZoom && (this.zoomRectangle.y + this.zoomRectangle.height < this.zoomPoint.y))) restoreAutoBounds(); else { zoom(this.zoomRectangle); } this.canvas.redraw(); } } else { Rectangle screenDataArea = getScreenDataArea(event.x, event.y); if (screenDataArea != null) { this.zoomPoint = getPointInRectangle(event.x, event.y, screenDataArea); } if (this.popup != null && event.button == 3) { org.eclipse.swt.graphics.Point pt = this.canvas.toDisplay(event.x, event.y); displayPopupMenu(pt.x, pt.y); } } if (selectionRectangle != null) { selectedEntities = getEnclosedEntities(selectionRectangle); boundSelectionRectangle(); this.canvas.redraw(); } fireSelectionChanged(new SelectionChangedEvent(this, getSelection())); this.zoomPoint = null; this.zoomRectangle = null; this.selectionPoint = null; Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } java.awt.event.MouseEvent mouseEvent = SWTUtils.toAwtMouseEvent(event); ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), mouseEvent, null); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(chartEvent); } }
From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java
/** * Receives notification of mouse clicks on the panel. These are translated and passed on to any * registered {@link ChartMouseListener}s. * //from w w w .ja va 2 s . c o m * @param event * Information about the mouse event. */ @Override public void mouseClicked(MouseEvent event) { Insets insets = getInsets(); int x = (int) ((event.getX() - insets.left) / this.scaleX); int y = (int) ((event.getY() - insets.top) / this.scaleY); this.anchor = new Point2D.Double(x, y); if (this.chart == null) { return; } this.chart.setNotify(true); // force a redraw // new entity code... Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } ChartEntity entity = null; if (this.info != null) { EntityCollection entities = this.info.getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); } } ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), event, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent); } }