📄 jfreechart.java
字号:
return (Title) this.subtitles.get(index);
}
/**
* Adds a chart subtitle, and notifies registered listeners that the chart
* has been modified.
*
* @param subtitle the subtitle (<code>null</code> not permitted).
*
* @see #getSubtitle(int)
*/
public void addSubtitle(Title subtitle) {
if (subtitle == null) {
throw new IllegalArgumentException("Null 'subtitle' argument.");
}
this.subtitles.add(subtitle);
subtitle.addChangeListener(this);
fireChartChanged();
}
/**
* Adds a subtitle at a particular position in the subtitle list, and sends
* a {@link ChartChangeEvent} to all registered listeners.
*
* @param index the index (in the range 0 to {@link #getSubtitleCount()}).
* @param subtitle the subtitle to add (<code>null</code> not permitted).
*
* @since 1.0.6
*/
public void addSubtitle(int index, Title subtitle) {
if (index < 0 || index > getSubtitleCount()) {
throw new IllegalArgumentException(
"The 'index' argument is out of range.");
}
if (subtitle == null) {
throw new IllegalArgumentException("Null 'subtitle' argument.");
}
this.subtitles.add(index, subtitle);
subtitle.addChangeListener(this);
fireChartChanged();
}
/**
* Clears all subtitles from the chart and sends a {@link ChartChangeEvent}
* to all registered listeners.
*
* @see #addSubtitle(Title)
*/
public void clearSubtitles() {
Iterator iterator = this.subtitles.iterator();
while (iterator.hasNext()) {
Title t = (Title) iterator.next();
t.removeChangeListener(this);
}
this.subtitles.clear();
fireChartChanged();
}
/**
* Removes the specified subtitle and sends a {@link ChartChangeEvent} to
* all registered listeners.
*
* @param title the title.
*
* @see #addSubtitle(Title)
*/
public void removeSubtitle(Title title) {
this.subtitles.remove(title);
fireChartChanged();
}
/**
* Returns the plot for the chart. The plot is a class responsible for
* coordinating the visual representation of the data, including the axes
* (if any).
*
* @return The plot.
*/
public Plot getPlot() {
return this.plot;
}
/**
* Returns the plot cast as a {@link CategoryPlot}.
* <p>
* NOTE: if the plot is not an instance of {@link CategoryPlot}, then a
* <code>ClassCastException</code> is thrown.
*
* @return The plot.
*
* @see #getPlot()
*/
public CategoryPlot getCategoryPlot() {
return (CategoryPlot) this.plot;
}
/**
* Returns the plot cast as an {@link XYPlot}.
* <p>
* NOTE: if the plot is not an instance of {@link XYPlot}, then a
* <code>ClassCastException</code> is thrown.
*
* @return The plot.
*
* @see #getPlot()
*/
public XYPlot getXYPlot() {
return (XYPlot) this.plot;
}
/**
* Returns a flag that indicates whether or not anti-aliasing is used when
* the chart is drawn.
*
* @return The flag.
*
* @see #setAntiAlias(boolean)
*/
public boolean getAntiAlias() {
Object val = this.renderingHints.get(RenderingHints.KEY_ANTIALIASING);
return RenderingHints.VALUE_ANTIALIAS_ON.equals(val);
}
/**
* Sets a flag that indicates whether or not anti-aliasing is used when the
* chart is drawn.
* <P>
* Anti-aliasing usually improves the appearance of charts, but is slower.
*
* @param flag the new value of the flag.
*
* @see #getAntiAlias()
*/
public void setAntiAlias(boolean flag) {
Object val = this.renderingHints.get(RenderingHints.KEY_ANTIALIASING);
if (val == null) {
val = RenderingHints.VALUE_ANTIALIAS_DEFAULT;
}
if (!flag && RenderingHints.VALUE_ANTIALIAS_OFF.equals(val)
|| flag && RenderingHints.VALUE_ANTIALIAS_ON.equals(val)) {
// no change, do nothing
return;
}
if (flag) {
this.renderingHints.put(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
}
else {
this.renderingHints.put(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
}
fireChartChanged();
}
/**
* Returns the current value stored in the rendering hints table for
* {@link RenderingHints#KEY_TEXT_ANTIALIASING}.
*
* @return The hint value (possibly <code>null</code>).
*
* @since 1.0.5
*
* @see #setTextAntiAlias(Object)
*/
public Object getTextAntiAlias() {
return this.renderingHints.get(RenderingHints.KEY_TEXT_ANTIALIASING);
}
/**
* Sets the value in the rendering hints table for
* {@link RenderingHints#KEY_TEXT_ANTIALIASING} to either
* {@link RenderingHints#VALUE_TEXT_ANTIALIAS_ON} or
* {@link RenderingHints#VALUE_TEXT_ANTIALIAS_OFF}, then sends a
* {@link ChartChangeEvent} to all registered listeners.
*
* @param flag
*
* @since 1.0.5
*
* @see #getTextAntiAlias()
* @see #setTextAntiAlias(Object)
*/
public void setTextAntiAlias(boolean flag) {
if (flag) {
setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
else {
setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
}
}
/**
* Sets the value in the rendering hints table for
* {@link RenderingHints#KEY_TEXT_ANTIALIASING} and sends a
* {@link ChartChangeEvent} to all registered listeners.
*
* @param val the new value (<code>null</code> permitted).
*
* @since 1.0.5
*
* @see #getTextAntiAlias()
* @see #setTextAntiAlias(boolean)
*/
public void setTextAntiAlias(Object val) {
this.renderingHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, val);
this.notifyListeners(new ChartChangeEvent(this));
}
/**
* Returns the paint used for the chart background.
*
* @return The paint (possibly <code>null</code>).
*
* @see #setBackgroundPaint(Paint)
*/
public Paint getBackgroundPaint() {
return this.backgroundPaint;
}
/**
* Sets the paint used to fill the chart background and sends a
* {@link ChartChangeEvent} to all registered listeners.
*
* @param paint the paint (<code>null</code> permitted).
*
* @see #getBackgroundPaint()
*/
public void setBackgroundPaint(Paint paint) {
if (this.backgroundPaint != null) {
if (!this.backgroundPaint.equals(paint)) {
this.backgroundPaint = paint;
fireChartChanged();
}
}
else {
if (paint != null) {
this.backgroundPaint = paint;
fireChartChanged();
}
}
}
/**
* Returns the background image for the chart, or <code>null</code> if
* there is no image.
*
* @return The image (possibly <code>null</code>).
*
* @see #setBackgroundImage(Image)
*/
public Image getBackgroundImage() {
return this.backgroundImage;
}
/**
* Sets the background image for the chart and sends a
* {@link ChartChangeEvent} to all registered listeners.
*
* @param image the image (<code>null</code> permitted).
*
* @see #getBackgroundImage()
*/
public void setBackgroundImage(Image image) {
if (this.backgroundImage != null) {
if (!this.backgroundImage.equals(image)) {
this.backgroundImage = image;
fireChartChanged();
}
}
else {
if (image != null) {
this.backgroundImage = image;
fireChartChanged();
}
}
}
/**
* Returns the background image alignment. Alignment constants are defined
* in the <code>org.jfree.ui.Align</code> class in the JCommon class
* library.
*
* @return The alignment.
*
* @see #setBackgroundImageAlignment(int)
*/
public int getBackgroundImageAlignment() {
return this.backgroundImageAlignment;
}
/**
* Sets the background alignment. Alignment options are defined by the
* {@link org.jfree.ui.Align} class.
*
* @param alignment the alignment.
*
* @see #getBackgroundImageAlignment()
*/
public void setBackgroundImageAlignment(int alignment) {
if (this.backgroundImageAlignment != alignment) {
this.backgroundImageAlignment = alignment;
fireChartChanged();
}
}
/**
* Returns the alpha-transparency for the chart's background image.
*
* @return The alpha-transparency.
*
* @see #setBackgroundImageAlpha(float)
*/
public float getBackgroundImageAlpha() {
return this.backgroundImageAlpha;
}
/**
* Sets the alpha-transparency for the chart's background image.
* Registered listeners are notified that the chart has been changed.
*
* @param alpha the alpha value.
*
* @see #getBackgroundImageAlpha()
*/
public void setBackgroundImageAlpha(float alpha) {
if (this.backgroundImageAlpha != alpha) {
this.backgroundImageAlpha = alpha;
fireChartChanged();
}
}
/**
* Returns a flag that controls whether or not change events are sent to
* registered listeners.
*
* @return A boolean.
*
* @see #setNotify(boolean)
*/
public boolean isNotify() {
return this.notify;
}
/**
* Sets a flag that controls whether or not listeners receive
* {@link ChartChangeEvent} notifications.
*
* @param notify a boolean.
*
* @see #isNotify()
*/
public void setNotify(boolean notify) {
this.notify = notify;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -