📄 jfreechart.java
字号:
* @param info contains chart dimension and entity information
* (<code>null</code> not permitted).
*/
public void handleClick(int x, int y, ChartRenderingInfo info) {
// pass the click on to the plot...
// rely on the plot to post a plot change event and redraw the chart...
this.plot.handleClick(x, y, info.getPlotInfo());
}
/**
* Registers an object for notification of changes to the chart.
*
* @param listener the listener (<code>null</code> not permitted).
*
* @see #removeChangeListener(ChartChangeListener)
*/
public void addChangeListener(ChartChangeListener listener) {
if (listener == null) {
throw new IllegalArgumentException("Null 'listener' argument.");
}
this.changeListeners.add(ChartChangeListener.class, listener);
}
/**
* Deregisters an object for notification of changes to the chart.
*
* @param listener the listener (<code>null</code> not permitted)
*
* @see #addChangeListener(ChartChangeListener)
*/
public void removeChangeListener(ChartChangeListener listener) {
if (listener == null) {
throw new IllegalArgumentException("Null 'listener' argument.");
}
this.changeListeners.remove(ChartChangeListener.class, listener);
}
/**
* Sends a default {@link ChartChangeEvent} to all registered listeners.
* <P>
* This method is for convenience only.
*/
public void fireChartChanged() {
ChartChangeEvent event = new ChartChangeEvent(this);
notifyListeners(event);
}
/**
* Sends a {@link ChartChangeEvent} to all registered listeners.
*
* @param event information about the event that triggered the
* notification.
*/
protected void notifyListeners(ChartChangeEvent event) {
if (this.notify) {
Object[] listeners = this.changeListeners.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChartChangeListener.class) {
((ChartChangeListener) listeners[i + 1]).chartChanged(
event);
}
}
}
}
/**
* Registers an object for notification of progress events relating to the
* chart.
*
* @param listener the object being registered.
*
* @see #removeProgressListener(ChartProgressListener)
*/
public void addProgressListener(ChartProgressListener listener) {
this.progressListeners.add(ChartProgressListener.class, listener);
}
/**
* Deregisters an object for notification of changes to the chart.
*
* @param listener the object being deregistered.
*
* @see #addProgressListener(ChartProgressListener)
*/
public void removeProgressListener(ChartProgressListener listener) {
this.progressListeners.remove(ChartProgressListener.class, listener);
}
/**
* Sends a {@link ChartProgressEvent} to all registered listeners.
*
* @param event information about the event that triggered the
* notification.
*/
protected void notifyListeners(ChartProgressEvent event) {
Object[] listeners = this.progressListeners.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChartProgressListener.class) {
((ChartProgressListener) listeners[i + 1]).chartProgress(event);
}
}
}
/**
* Receives notification that a chart title has changed, and passes this
* on to registered listeners.
*
* @param event information about the chart title change.
*/
public void titleChanged(TitleChangeEvent event) {
event.setChart(this);
notifyListeners(event);
}
/**
* Receives notification that the plot has changed, and passes this on to
* registered listeners.
*
* @param event information about the plot change.
*/
public void plotChanged(PlotChangeEvent event) {
event.setChart(this);
notifyListeners(event);
}
/**
* Tests this chart for equality with another object.
*
* @param obj the object (<code>null</code> permitted).
*
* @return A boolean.
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof JFreeChart)) {
return false;
}
JFreeChart that = (JFreeChart) obj;
if (!this.renderingHints.equals(that.renderingHints)) {
return false;
}
if (this.borderVisible != that.borderVisible) {
return false;
}
if (!ObjectUtilities.equal(this.borderStroke, that.borderStroke)) {
return false;
}
if (!PaintUtilities.equal(this.borderPaint, that.borderPaint)) {
return false;
}
if (!this.padding.equals(that.padding)) {
return false;
}
if (!ObjectUtilities.equal(this.title, that.title)) {
return false;
}
if (!ObjectUtilities.equal(this.subtitles, that.subtitles)) {
return false;
}
if (!ObjectUtilities.equal(this.plot, that.plot)) {
return false;
}
if (!PaintUtilities.equal(
this.backgroundPaint, that.backgroundPaint
)) {
return false;
}
if (!ObjectUtilities.equal(this.backgroundImage,
that.backgroundImage)) {
return false;
}
if (this.backgroundImageAlignment != that.backgroundImageAlignment) {
return false;
}
if (this.backgroundImageAlpha != that.backgroundImageAlpha) {
return false;
}
if (this.notify != that.notify) {
return false;
}
return true;
}
/**
* Provides serialization support.
*
* @param stream the output stream.
*
* @throws IOException if there is an I/O error.
*/
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
SerialUtilities.writeStroke(this.borderStroke, stream);
SerialUtilities.writePaint(this.borderPaint, stream);
SerialUtilities.writePaint(this.backgroundPaint, stream);
}
/**
* Provides serialization support.
*
* @param stream the input stream.
*
* @throws IOException if there is an I/O error.
* @throws ClassNotFoundException if there is a classpath problem.
*/
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
this.borderStroke = SerialUtilities.readStroke(stream);
this.borderPaint = SerialUtilities.readPaint(stream);
this.backgroundPaint = SerialUtilities.readPaint(stream);
this.progressListeners = new EventListenerList();
this.changeListeners = new EventListenerList();
this.renderingHints = new RenderingHints(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
// register as a listener with sub-components...
if (this.title != null) {
this.title.addChangeListener(this);
}
for (int i = 0; i < getSubtitleCount(); i++) {
getSubtitle(i).addChangeListener(this);
}
this.plot.addChangeListener(this);
}
/**
* Prints information about JFreeChart to standard output.
*
* @param args no arguments are honored.
*/
public static void main(String[] args) {
System.out.println(JFreeChart.INFO.toString());
}
/**
* Clones the object, and takes care of listeners.
* Note: caller shall register its own listeners on cloned graph.
*
* @return A clone.
*
* @throws CloneNotSupportedException if the chart is not cloneable.
*/
public Object clone() throws CloneNotSupportedException {
JFreeChart chart = (JFreeChart) super.clone();
chart.renderingHints = (RenderingHints) this.renderingHints.clone();
// private boolean borderVisible;
// private transient Stroke borderStroke;
// private transient Paint borderPaint;
if (this.title != null) {
chart.title = (TextTitle) this.title.clone();
chart.title.addChangeListener(chart);
}
chart.subtitles = new ArrayList();
for (int i = 0; i < getSubtitleCount(); i++) {
Title subtitle = (Title) getSubtitle(i).clone();
chart.subtitles.add(subtitle);
subtitle.addChangeListener(chart);
}
if (this.plot != null) {
chart.plot = (Plot) this.plot.clone();
chart.plot.addChangeListener(chart);
}
chart.progressListeners = new EventListenerList();
chart.changeListeners = new EventListenerList();
return chart;
}
}
/**
* Information about the JFreeChart project. One instance of this class is
* assigned to <code>JFreeChart.INFO<code>.
*/
class JFreeChartInfo extends ProjectInfo {
/**
* Default constructor.
*/
public JFreeChartInfo() {
// get a locale-specific resource bundle...
String baseResourceClass
= "org.jfree.chart.resources.JFreeChartResources";
ResourceBundle resources = ResourceBundle.getBundle(baseResourceClass);
setName(resources.getString("project.name"));
setVersion(resources.getString("project.version"));
setInfo(resources.getString("project.info"));
setCopyright(resources.getString("project.copyright"));
setLogo(null); // load only when required
setLicenceName("LGPL");
setLicenceText(Licences.getInstance().getLGPL());
setContributors(Arrays.asList(
new Contributor[]{
new Contributor("Eric Alexander", "-"),
new Contributor("Richard Atkinson",
"richard_c_atkinson@ntlworld.com"),
new Contributor("David Basten", "-"),
new Contributor("David Berry", "-"),
new Contributor("Chris Boek", "-"),
new Contributor("Zoheb Borbora", "-"),
new Contributor("Anthony Boulestreau", "-"),
new Contributor("Jeremy Bowman", "-"),
new Contributor("Nicolas Brodu", "-"),
new Contributor("Jody Brownell", "-"),
new Contributor("David Browning", "-"),
new Contributor("Soren Caspersen", "-"),
new Contributor("Chuanhao Chiu", "-"),
new Contributor("Brian Cole", "-"),
new Contributor("Pascal Collet", "-"),
new Contributor("Martin Cordova", "-"),
new Contributor("Paolo Cova", "-"),
new Contributor("Greg Darke", "-"),
new Contributor("Mike Duffy", "-"),
new Contributor("Don Elliott", "-"),
new Contributor("David Forslund", "-"),
new Contributor("Jonathan Gabbai", "-"),
new Contributor("David Gilbert",
"david.gilbert@object-refinery.com"),
new Contributor("Serge V. Grachov", "-"),
new Contributor("Daniel Gredler", "-"),
new Contributor("Hans-Jurgen Greiner", "-"),
new Contributor("Joao Guilherme Del Valle", "-"),
new Contributor("Aiman Han", "-"),
new Contributor("Cameron Hayne", "-"),
new Contributor("Martin Hoeller", "-"),
new Contributor("Jon Iles", "-"),
new Contributor("Wolfgang Irler", "-"),
new Contributor("Sergei Ivanov", "-"),
new Contributor("Adriaan Joubert", "-"),
new Contributor("Darren Jung", "-"),
new Contributor("Xun Kang", "-"),
new Contributor("Bill Kelemen", "-"),
new Contributor("Norbert Kiesel", "-"),
new Contributor("Gideon Krause", "-"),
new Contributor("Pierre-Marie Le Biot", "-"),
new Contributor("Arnaud Lelievre", "-"),
new Contributor("Wolfgang Lenhard", "-"),
new Contributor("David Li", "-"),
new Contributor("Yan Liu", "-"),
new Contributor("Tin Luu", "-"),
new Contributor("Craig MacFarlane", "-"),
new Contributor("Achilleus Mantzios", "-"),
new Contributor("Thomas Meier", "-"),
new Contributor("Jim Moore", "-"),
new Contributor("Jonathan Nash", "-"),
new Con
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -