org.jfree.chart.ChartMouseListener Java Examples

The following examples show how to use org.jfree.chart.ChartMouseListener. 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: AbstractChartPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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.
 */

@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);
	}

}
 
Example #2
Source File: AbstractChartPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Implementation of the MouseMotionListener's method.
 * 
 * @param e
 *            the event.
 */

@Override
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);
		}
	}

}
 
Example #3
Source File: AbstractChartPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Adds a listener to the list of objects listening for chart mouse events.
 * 
 * @param listener
 *            the listener (<code>null</code> not permitted).
 */

@Override
public void addChartMouseListener(ChartMouseListener listener) {
	if (listener == null) {
		throw new IllegalArgumentException("Null 'listener' argument.");
	}
	this.chartMouseListeners.add(ChartMouseListener.class, listener);
}
 
Example #4
Source File: AbstractChartPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Removes a listener from the list of objects listening for chart mouse events.
 * 
 * @param listener
 *            the listener.
 */

@Override
public void removeChartMouseListener(ChartMouseListener listener) {
	this.chartMouseListeners.remove(ChartMouseListener.class, listener);
}
 
Example #5
Source File: ChartComposite.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Removes a listener from the list of objects listening for chart mouse
 * events.
 *
 * @param listener  the listener.
 */
public void removeChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.remove(ChartMouseListener.class, listener);
}
 
Example #6
Source File: ChartComposite.java    From buffer_bci with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Adds a listener to the list of objects listening for chart mouse events.
 *
 * @param listener  the listener (<code>null</code> not permitted).
 */
public void addChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.add(ChartMouseListener.class, listener);
}
 
Example #7
Source File: ChartComposite.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Removes a listener from the list of objects listening for chart mouse 
 * events.
 *
 * @param listener  the listener.
 */
public void removeChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.remove(ChartMouseListener.class, listener);
}
 
Example #8
Source File: ChartComposite.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Adds a listener to the list of objects listening for chart mouse events.
 *
 * @param listener  the listener (<code>null</code> not permitted).
 */
public void addChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.add(ChartMouseListener.class, listener);
}
 
Example #9
Source File: ChartComposite.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Removes a listener from the list of objects listening for chart mouse
 * events.
 *
 * @param listener  the listener.
 */
public void removeChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.remove(ChartMouseListener.class, listener);
}
 
Example #10
Source File: ChartComposite.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Adds a listener to the list of objects listening for chart mouse events.
 *
 * @param listener  the listener (<code>null</code> not permitted).
 */
public void addChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.add(ChartMouseListener.class, listener);
}
 
Example #11
Source File: ChartComposite.java    From ECG-Viewer with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Removes a listener from the list of objects listening for chart mouse
 * events.
 *
 * @param listener  the listener.
 */
public void removeChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.remove(ChartMouseListener.class, listener);
}
 
Example #12
Source File: ChartComposite.java    From ECG-Viewer with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Adds a listener to the list of objects listening for chart mouse events.
 *
 * @param listener  the listener (<code>null</code> not permitted).
 */
public void addChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.add(ChartMouseListener.class, listener);
}
 
Example #13
Source File: ChartComposite.java    From openstock with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Adds a listener to the list of objects listening for chart mouse events.
 *
 * @param listener  the listener (<code>null</code> not permitted).
 */
public void addChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.add(ChartMouseListener.class, listener);
}
 
Example #14
Source File: ChartComposite.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Removes a listener from the list of objects listening for chart mouse
 * events.
 *
 * @param listener  the listener.
 */
public void removeChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.remove(ChartMouseListener.class, listener);
}
 
Example #15
Source File: ChartComposite.java    From SIMVA-SoS with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a listener to the list of objects listening for chart mouse events.
 *
 * @param listener  the listener (<code>null</code> not permitted).
 */
public void addChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.add(ChartMouseListener.class, listener);
}
 
Example #16
Source File: ChartComposite.java    From ccu-historian with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Removes a listener from the list of objects listening for chart mouse
 * events.
 *
 * @param listener  the listener.
 */
public void removeChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.remove(ChartMouseListener.class, listener);
}
 
Example #17
Source File: ChartComposite.java    From ccu-historian with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Adds a listener to the list of objects listening for chart mouse events.
 *
 * @param listener  the listener (<code>null</code> not permitted).
 */
public void addChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.add(ChartMouseListener.class, listener);
}
 
Example #18
Source File: ChartComposite.java    From openstock with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Removes a listener from the list of objects listening for chart mouse
 * events.
 *
 * @param listener  the listener.
 */
public void removeChartMouseListener(ChartMouseListener listener) {
    this.chartMouseListeners.remove(ChartMouseListener.class, listener);
}