📄 jfreechart.java
字号:
} /** * Registers an object for notification of changes to the chart. * * @param listener the listener (<code>null</code> not permitted). */ 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) */ 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. */ 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. */ 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 chart legend has changed, and passes this * on to registered listeners. * * @param event information about the chart legend change. */ public void legendChanged(LegendChangeEvent 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 (!ObjectUtilities.equal(this.title, that.title)) { return false; } if (!ObjectUtilities.equal(this.subtitles, that.subtitles)) { return false; } if (!ObjectUtilities.equal(this.oldLegend, that.oldLegend)) { return false; } if (!ObjectUtilities.equal(this.plot, that.plot)) { return false; } if (!ObjectUtilities.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); } if (this.oldLegend != null) { this.oldLegend.addChangeListener(this); } //if (this.plot != null) { // the plot can never be null. 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.oldLegend != null) { chart.oldLegend = (OldLegend) this.oldLegend.clone(); chart.oldLegend.registerChart(chart); chart.oldLegend.addChangeListener(chart); } if (this.plot != null) { chart.plot = (Plot) this.plot.clone(); chart.plot.addChangeListener(chart); } //private boolean antialias; //private transient Paint backgroundPaint; //private transient Image backgroundImage; // todo: not serialized yet //private int backgroundImageAlignment = Align.FIT; //private float backgroundImageAlpha = 0.5f; chart.progressListeners = new EventListenerList(); chart.changeListeners = new EventListenerList(); //private boolean notify; 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("Anthony Boulestreau", "-"), new Contributor("Jeremy Bowman", "-"), new Contributor("Nicolas Brodu", "-"), new Contributor("David Browning", "-"), new Contributor("S???ren Caspersen", "-"), new Contributor("Chuanhao Chiu", "-"), new Contributor("Brian Cole", "-"), new Contributor("Pascal Collet", "-"), new Contributor("Martin Cordova", "-"), new Contributor("Paolo Cova", "-"), new Contributor("Mike Duffy", "-"), new Contributor("Don Elliott", "-"), 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("Jon Iles", "-"), new Contributor("Wolfgang Irler", "-"), new Contributor("Xun Kang", "-"), new Contributor("Bill Kelemen", "-"), new Contributor("Norbert Kiesel", "-"), new Contributor("Gideon Krause", "-"), new Contributor("Arnaud Lelievre", "-"), new Contributor("Wolfgang Lenhard", "-"), new Contributor("David Li", "-"), 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 Contributor("Barak Naveh", "-"), new Contributor("David M. O'Donnell", "-"), new Contributor("Krzysztof Paz", "-"), new Contributor("Tomer Peretz", "-"), new Contributor("Andrzej Porebski", "-"), new Contributor("Xavier Poinsard", "-"), new Contributor("Viktor Rajewski", "-"), new Contributor("Eduardo Ramalho", "-"), new Contributor("Michael Rauch", "-"), new Contributor("Cameron Riley", "-"), new Contributor("Dan Rivett", "d.rivett@ukonline.co.uk"), new Contributor("Scott Sams", "-"), new Contributor("Michel Santos", "-"), new Contributor("Thierry Saura", "-"), new Contributor("Andreas Schneider", "-"), new Contributor("Jean-Luc SCHWAB", "-"), new Contributor("Bryan Scott", "-"), new Contributor("Tobias Selb", "-"), new Contributor("Mofeed Shahin", "-"), new Contributor("Greg Steckman", "-"), new Contributor("Roger Studner", "-"), new Contributor("Irv Thomae", "-"), new Contributor("Eric Thomas", "-"), new Contributor("Rich Unger", "-"), new Contributor("Daniel van Enckevort", "-"), new Contributor("Laurence Vanhelsuwe", "-"), new Contributor("Sylvain Vieujot", "-"), new Contributor("Mark Watson", "www.markwatson.com"), new Contributor("Alex Weber", "-"), new Contributor("Matthew Wright", "-"), new Contributor("Benoit Xhenseval", "-"), new Contributor( "Christian W. Zuckschwerdt", "Christian.Zuckschwerdt@Informatik.Uni-Oldenburg.de" ), new Contributor("Hari", "-"), new Contributor("Sam (oldman)", "-"), } )); addLibrary(JCommon.INFO); } /** * Returns the JFreeChart logo (a picture of a gorilla). * * @return The JFreeChart logo. */ public Image getLogo() { Image logo = super.getLogo(); if (logo == null) { URL imageURL = ClassLoader.getSystemResource( "org/jfree/chart/gorilla.jpg" ); if (imageURL != null) { ImageIcon temp = new ImageIcon(imageURL); // use ImageIcon because it waits for the image to load... logo = temp.getImage(); setLogo(logo); } } return logo; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -