| Method from org.jfree.chart.plot.Plot Detail: |
public void addChangeListener(PlotChangeListener listener) {
this.listenerList.add(PlotChangeListener.class, listener);
}
Registers an object for notification of changes to the plot. |
public void axisChanged(AxisChangeEvent event) {
fireChangeEvent();
}
Receives notification of a change to one of the plot's axes. |
public Object clone() throws CloneNotSupportedException {
Plot clone = (Plot) super.clone();
// private Plot parent < -- don't clone the parent plot, but take care
// childs in combined plots instead
if (this.datasetGroup != null) {
clone.datasetGroup
= (DatasetGroup) ObjectUtilities.clone(this.datasetGroup);
}
clone.drawingSupplier
= (DrawingSupplier) ObjectUtilities.clone(this.drawingSupplier);
clone.listenerList = new EventListenerList();
return clone;
}
Creates a clone of the plot. |
public void datasetChanged(DatasetChangeEvent event) {
PlotChangeEvent newEvent = new PlotChangeEvent(this);
newEvent.setType(ChartChangeEventType.DATASET_UPDATED);
notifyListeners(newEvent);
}
|
abstract public void draw(Graphics2D g2,
Rectangle2D area,
Point2D anchor,
PlotState parentState,
PlotRenderingInfo info)
Draws the plot within the specified area. The anchor is a point on the
chart that is specified externally (for instance, it may be the last
point of the last mouse click performed by the user) - plots can use or
ignore this value as they see fit.
Subclasses need to provide an implementation of this method, obviously. |
public void drawBackground(Graphics2D g2,
Rectangle2D area) {
// some subclasses override this method completely, so don't put
// anything here that *must* be done
fillBackground(g2, area);
drawBackgroundImage(g2, area);
}
Draws the plot background (the background color and/or image).
This method will be called during the chart drawing process and is
declared public so that it can be accessed by the renderers used by
certain subclasses. You shouldn't need to call this method directly. |
public void drawBackgroundImage(Graphics2D g2,
Rectangle2D area) {
if (this.backgroundImage != null) {
Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
this.backgroundImageAlpha));
Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0,
this.backgroundImage.getWidth(null),
this.backgroundImage.getHeight(null));
Align.align(dest, area, this.backgroundImageAlignment);
g2.drawImage(this.backgroundImage, (int) dest.getX(),
(int) dest.getY(), (int) dest.getWidth() + 1,
(int) dest.getHeight() + 1, null);
g2.setComposite(originalComposite);
}
}
Draws the background image (if there is one) aligned within the
specified area. |
protected void drawNoDataMessage(Graphics2D g2,
Rectangle2D area) {
Shape savedClip = g2.getClip();
g2.clip(area);
String message = this.noDataMessage;
if (message != null) {
g2.setFont(this.noDataMessageFont);
g2.setPaint(this.noDataMessagePaint);
TextBlock block = TextUtilities.createTextBlock(
this.noDataMessage, this.noDataMessageFont,
this.noDataMessagePaint, 0.9f * (float) area.getWidth(),
new G2TextMeasurer(g2));
block.draw(g2, (float) area.getCenterX(),
(float) area.getCenterY(), TextBlockAnchor.CENTER);
}
g2.setClip(savedClip);
}
Draws a message to state that there is no data to plot. |
public void drawOutline(Graphics2D g2,
Rectangle2D area) {
if (!this.outlineVisible) {
return;
}
if ((this.outlineStroke != null) && (this.outlinePaint != null)) {
g2.setStroke(this.outlineStroke);
g2.setPaint(this.outlinePaint);
g2.draw(area);
}
}
Draws the plot outline. This method will be called during the chart
drawing process and is declared public so that it can be accessed by the
renderers used by certain subclasses. You shouldn't need to call this
method directly. |
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Plot)) {
return false;
}
Plot that = (Plot) obj;
if (!ObjectUtilities.equal(this.noDataMessage, that.noDataMessage)) {
return false;
}
if (!ObjectUtilities.equal(
this.noDataMessageFont, that.noDataMessageFont
)) {
return false;
}
if (!PaintUtilities.equal(this.noDataMessagePaint,
that.noDataMessagePaint)) {
return false;
}
if (!ObjectUtilities.equal(this.insets, that.insets)) {
return false;
}
if (this.outlineVisible != that.outlineVisible) {
return false;
}
if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) {
return false;
}
if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) {
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.foregroundAlpha != that.foregroundAlpha) {
return false;
}
if (this.backgroundAlpha != that.backgroundAlpha) {
return false;
}
if (!this.drawingSupplier.equals(that.drawingSupplier)) {
return false;
}
return true;
}
Tests this plot for equality with another object. |
protected void fillBackground(Graphics2D g2,
Rectangle2D area) {
fillBackground(g2, area, PlotOrientation.VERTICAL);
}
Fills the specified area with the background paint. |
protected void fillBackground(Graphics2D g2,
Rectangle2D area,
PlotOrientation orientation) {
if (orientation == null) {
throw new IllegalArgumentException("Null 'orientation' argument.");
}
if (this.backgroundPaint == null) {
return;
}
Paint p = this.backgroundPaint;
if (p instanceof GradientPaint) {
GradientPaint gp = (GradientPaint) p;
if (orientation == PlotOrientation.VERTICAL) {
p = new GradientPaint((float) area.getCenterX(),
(float) area.getMaxY(), gp.getColor1(),
(float) area.getCenterX(), (float) area.getMinY(),
gp.getColor2());
}
else if (orientation == PlotOrientation.HORIZONTAL) {
p = new GradientPaint((float) area.getMinX(),
(float) area.getCenterY(), gp.getColor1(),
(float) area.getMaxX(), (float) area.getCenterY(),
gp.getColor2());
}
}
Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
this.backgroundAlpha));
g2.setPaint(p);
g2.fill(area);
g2.setComposite(originalComposite);
}
Fills the specified area with the background paint. If the background
paint is an instance of GradientPaint, the gradient will
run in the direction suggested by the plot's orientation. |
protected void fireChangeEvent() {
notifyListeners(new PlotChangeEvent(this));
}
|
public float getBackgroundAlpha() {
return this.backgroundAlpha;
}
Returns the alpha transparency of the plot area background. |
public Image getBackgroundImage() {
return this.backgroundImage;
}
Returns the background image that is used to fill the plot's background
area. |
public int getBackgroundImageAlignment() {
return this.backgroundImageAlignment;
}
Returns the background image alignment. Alignment constants are defined
in the org.jfree.ui.Align class in the JCommon class
library. |
public float getBackgroundImageAlpha() {
return this.backgroundImageAlpha;
}
Returns the alpha transparency used to draw the background image. This
is a value in the range 0.0f to 1.0f, where 0.0f is fully transparent
and 1.0f is fully opaque. |
public Paint getBackgroundPaint() {
return this.backgroundPaint;
}
Returns the background color of the plot area. |
public DatasetGroup getDatasetGroup() {
return this.datasetGroup;
}
Returns the dataset group for the plot (not currently used). |
public DrawingSupplier getDrawingSupplier() {
DrawingSupplier result = null;
Plot p = getParent();
if (p != null) {
result = p.getDrawingSupplier();
}
else {
result = this.drawingSupplier;
}
return result;
}
Returns the drawing supplier for the plot. |
public float getForegroundAlpha() {
return this.foregroundAlpha;
}
Returns the alpha-transparency for the plot foreground. |
public RectangleInsets getInsets() {
return this.insets;
}
Returns the insets for the plot area. |
public LegendItemCollection getLegendItems() {
return null;
}
Returns the legend items for the plot. By default, this method returns
null. Subclasses should override to return a
LegendItemCollection . |
public String getNoDataMessage() {
return this.noDataMessage;
}
Returns the string that is displayed when the dataset is empty or
null. |
public Font getNoDataMessageFont() {
return this.noDataMessageFont;
}
Returns the font used to display the 'no data' message. |
public Paint getNoDataMessagePaint() {
return this.noDataMessagePaint;
}
Returns the paint used to display the 'no data' message. |
public Paint getOutlinePaint() {
return this.outlinePaint;
}
Returns the color used to draw the outline of the plot area. |
public Stroke getOutlineStroke() {
return this.outlineStroke;
}
Returns the stroke used to outline the plot area. |
public Plot getParent() {
return this.parent;
}
Returns the parent plot (or null if this plot is not part
of a combined plot). |
abstract public String getPlotType()
Returns a short string describing the plot type.
Note: this gets used in the chart property editing user interface,
but there needs to be a better mechanism for identifying the plot type. |
protected double getRectX(double x,
double w1,
double w2,
RectangleEdge edge) {
double result = x;
if (edge == RectangleEdge.LEFT) {
result = result + w1;
}
else if (edge == RectangleEdge.RIGHT) {
result = result + w2;
}
return result;
}
Adjusts the supplied x-value. |
protected double getRectY(double y,
double h1,
double h2,
RectangleEdge edge) {
double result = y;
if (edge == RectangleEdge.TOP) {
result = result + h1;
}
else if (edge == RectangleEdge.BOTTOM) {
result = result + h2;
}
return result;
}
Adjusts the supplied y-value. |
public Plot getRootPlot() {
Plot p = getParent();
if (p == null) {
return this;
}
else {
return p.getRootPlot();
}
}
|
public void handleClick(int x,
int y,
PlotRenderingInfo info) {
// provides a 'no action' default
}
Handles a 'click' on the plot. Since the plot does not maintain any
information about where it has been drawn, the plot rendering info is
supplied as an argument so that the plot dimensions can be determined. |
public boolean isOutlineVisible() {
return this.outlineVisible;
}
Returns the flag that controls whether or not the plot outline is
drawn. The default value is true. Note that for
historical reasons, the plot's outline paint and stroke can take on
null values, in which case the outline will not be drawn
even if this flag is set to true. |
public boolean isSubplot() {
return (getParent() != null);
}
Returns true if this plot is part of a combined plot
structure (that is, #getParent() returns a non-null
value), and false otherwise. |
public void markerChanged(MarkerChangeEvent event) {
fireChangeEvent();
}
Receives notification of a change to a marker that is assigned to the
plot. |
public void notifyListeners(PlotChangeEvent event) {
Object[] listeners = this.listenerList.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == PlotChangeListener.class) {
((PlotChangeListener) listeners[i + 1]).plotChanged(event);
}
}
}
Notifies all registered listeners that the plot has been modified. |
public void removeChangeListener(PlotChangeListener listener) {
this.listenerList.remove(PlotChangeListener.class, listener);
}
Unregisters an object for notification of changes to the plot. |
public static RectangleEdge resolveDomainAxisLocation(AxisLocation location,
PlotOrientation orientation) {
if (location == null) {
throw new IllegalArgumentException("Null 'location' argument.");
}
if (orientation == null) {
throw new IllegalArgumentException("Null 'orientation' argument.");
}
RectangleEdge result = null;
if (location == AxisLocation.TOP_OR_RIGHT) {
if (orientation == PlotOrientation.HORIZONTAL) {
result = RectangleEdge.RIGHT;
}
else if (orientation == PlotOrientation.VERTICAL) {
result = RectangleEdge.TOP;
}
}
else if (location == AxisLocation.TOP_OR_LEFT) {
if (orientation == PlotOrientation.HORIZONTAL) {
result = RectangleEdge.LEFT;
}
else if (orientation == PlotOrientation.VERTICAL) {
result = RectangleEdge.TOP;
}
}
else if (location == AxisLocation.BOTTOM_OR_RIGHT) {
if (orientation == PlotOrientation.HORIZONTAL) {
result = RectangleEdge.RIGHT;
}
else if (orientation == PlotOrientation.VERTICAL) {
result = RectangleEdge.BOTTOM;
}
}
else if (location == AxisLocation.BOTTOM_OR_LEFT) {
if (orientation == PlotOrientation.HORIZONTAL) {
result = RectangleEdge.LEFT;
}
else if (orientation == PlotOrientation.VERTICAL) {
result = RectangleEdge.BOTTOM;
}
}
// the above should cover all the options...
if (result == null) {
throw new IllegalStateException("resolveDomainAxisLocation()");
}
return result;
}
Resolves a domain axis location for a given plot orientation. |
public static RectangleEdge resolveRangeAxisLocation(AxisLocation location,
PlotOrientation orientation) {
if (location == null) {
throw new IllegalArgumentException("Null 'location' argument.");
}
if (orientation == null) {
throw new IllegalArgumentException("Null 'orientation' argument.");
}
RectangleEdge result = null;
if (location == AxisLocation.TOP_OR_RIGHT) {
if (orientation == PlotOrientation.HORIZONTAL) {
result = RectangleEdge.TOP;
}
else if (orientation == PlotOrientation.VERTICAL) {
result = RectangleEdge.RIGHT;
}
}
else if (location == AxisLocation.TOP_OR_LEFT) {
if (orientation == PlotOrientation.HORIZONTAL) {
result = RectangleEdge.TOP;
}
else if (orientation == PlotOrientation.VERTICAL) {
result = RectangleEdge.LEFT;
}
}
else if (location == AxisLocation.BOTTOM_OR_RIGHT) {
if (orientation == PlotOrientation.HORIZONTAL) {
result = RectangleEdge.BOTTOM;
}
else if (orientation == PlotOrientation.VERTICAL) {
result = RectangleEdge.RIGHT;
}
}
else if (location == AxisLocation.BOTTOM_OR_LEFT) {
if (orientation == PlotOrientation.HORIZONTAL) {
result = RectangleEdge.BOTTOM;
}
else if (orientation == PlotOrientation.VERTICAL) {
result = RectangleEdge.LEFT;
}
}
// the above should cover all the options...
if (result == null) {
throw new IllegalStateException("resolveRangeAxisLocation()");
}
return result;
}
Resolves a range axis location for a given plot orientation. |
public void setBackgroundAlpha(float alpha) {
if (this.backgroundAlpha != alpha) {
this.backgroundAlpha = alpha;
fireChangeEvent();
}
}
Sets the alpha transparency of the plot area background, and notifies
registered listeners that the plot has been modified. |
public void setBackgroundImage(Image image) {
this.backgroundImage = image;
fireChangeEvent();
}
Sets the background image for the plot and sends a
PlotChangeEvent to all registered listeners. |
public void setBackgroundImageAlignment(int alignment) {
if (this.backgroundImageAlignment != alignment) {
this.backgroundImageAlignment = alignment;
fireChangeEvent();
}
}
Sets the alignment for the background image and sends a
PlotChangeEvent to all registered listeners. Alignment options
are defined by the org.jfree.ui.Align class in the JCommon
class library. |
public void setBackgroundImageAlpha(float alpha) {
if (alpha < 0.0f || alpha > 1.0f)
throw new IllegalArgumentException(
"The 'alpha' value must be in the range 0.0f to 1.0f.");
if (this.backgroundImageAlpha != alpha) {
this.backgroundImageAlpha = alpha;
fireChangeEvent();
}
}
Sets the alpha transparency used when drawing the background image. |
public void setBackgroundPaint(Paint paint) {
if (paint == null) {
if (this.backgroundPaint != null) {
this.backgroundPaint = null;
fireChangeEvent();
}
}
else {
if (this.backgroundPaint != null) {
if (this.backgroundPaint.equals(paint)) {
return; // nothing to do
}
}
this.backgroundPaint = paint;
fireChangeEvent();
}
}
Sets the background color of the plot area and sends a
PlotChangeEvent to all registered listeners. |
protected void setDatasetGroup(DatasetGroup group) {
this.datasetGroup = group;
}
Sets the dataset group (not currently used). |
public void setDrawingSupplier(DrawingSupplier supplier) {
this.drawingSupplier = supplier;
fireChangeEvent();
}
Sets the drawing supplier for the plot. The drawing supplier is
responsible for supplying a limitless (possibly repeating) sequence of
Paint, Stroke and Shape objects
that the plot's renderer(s) can use to populate its (their) tables. |
public void setForegroundAlpha(float alpha) {
if (this.foregroundAlpha != alpha) {
this.foregroundAlpha = alpha;
fireChangeEvent();
}
}
Sets the alpha-transparency for the plot and sends a
PlotChangeEvent to all registered listeners. |
public void setInsets(RectangleInsets insets) {
setInsets(insets, true);
}
Sets the insets for the plot and sends a PlotChangeEvent to
all registered listeners. |
public void setInsets(RectangleInsets insets,
boolean notify) {
if (insets == null) {
throw new IllegalArgumentException("Null 'insets' argument.");
}
if (!this.insets.equals(insets)) {
this.insets = insets;
if (notify) {
fireChangeEvent();
}
}
}
Sets the insets for the plot and, if requested, and sends a
PlotChangeEvent to all registered listeners. |
public void setNoDataMessage(String message) {
this.noDataMessage = message;
fireChangeEvent();
}
Sets the message that is displayed when the dataset is empty or
null, and sends a PlotChangeEvent to all registered
listeners. |
public void setNoDataMessageFont(Font font) {
if (font == null) {
throw new IllegalArgumentException("Null 'font' argument.");
}
this.noDataMessageFont = font;
fireChangeEvent();
}
Sets the font used to display the 'no data' message and sends a
PlotChangeEvent to all registered listeners. |
public void setNoDataMessagePaint(Paint paint) {
if (paint == null) {
throw new IllegalArgumentException("Null 'paint' argument.");
}
this.noDataMessagePaint = paint;
fireChangeEvent();
}
Sets the paint used to display the 'no data' message and sends a
PlotChangeEvent to all registered listeners. |
public void setOutlinePaint(Paint paint) {
if (paint == null) {
if (this.outlinePaint != null) {
this.outlinePaint = null;
fireChangeEvent();
}
}
else {
if (this.outlinePaint != null) {
if (this.outlinePaint.equals(paint)) {
return; // nothing to do
}
}
this.outlinePaint = paint;
fireChangeEvent();
}
}
Sets the paint used to draw the outline of the plot area and sends a
PlotChangeEvent to all registered listeners. If you set this
attribute to null, no outline will be drawn. |
public void setOutlineStroke(Stroke stroke) {
if (stroke == null) {
if (this.outlineStroke != null) {
this.outlineStroke = null;
fireChangeEvent();
}
}
else {
if (this.outlineStroke != null) {
if (this.outlineStroke.equals(stroke)) {
return; // nothing to do
}
}
this.outlineStroke = stroke;
fireChangeEvent();
}
}
Sets the stroke used to outline the plot area and sends a
PlotChangeEvent to all registered listeners. If you set this
attribute to null, no outline will be drawn. |
public void setOutlineVisible(boolean visible) {
this.outlineVisible = visible;
fireChangeEvent();
}
Sets the flag that controls whether or not the plot's outline is
drawn, and sends a PlotChangeEvent to all registered listeners. |
public void setParent(Plot parent) {
this.parent = parent;
}
Sets the parent plot. This method is intended for internal use, you
shouldn't need to call it directly. |
public void zoom(double percent) {
// do nothing by default.
}
Performs a zoom on the plot. Subclasses should override if zooming is
appropriate for the type of plot. |