| Method from org.jfree.chart.renderer.xy.AbstractXYItemRenderer Detail: |
public void addAnnotation(XYAnnotation annotation) {
// defer argument checking
addAnnotation(annotation, Layer.FOREGROUND);
}
Adds an annotation and sends a RendererChangeEvent to all
registered listeners. The annotation is added to the foreground
layer. |
public void addAnnotation(XYAnnotation annotation,
Layer layer) {
if (annotation == null) {
throw new IllegalArgumentException("Null 'annotation' argument.");
}
if (layer.equals(Layer.FOREGROUND)) {
this.foregroundAnnotations.add(annotation);
fireChangeEvent();
}
else if (layer.equals(Layer.BACKGROUND)) {
this.backgroundAnnotations.add(annotation);
fireChangeEvent();
}
else {
// should never get here
throw new RuntimeException("Unknown layer.");
}
}
Adds an annotation to the specified layer and sends a
RendererChangeEvent to all registered listeners. |
protected void addEntity(EntityCollection entities,
Shape area,
XYDataset dataset,
int series,
int item,
double entityX,
double entityY) {
if (!getItemCreateEntity(series, item)) {
return;
}
Shape hotspot = area;
if (hotspot == null) {
double w = this.defaultEntityRadius * 2;
if (getPlot().getOrientation() == PlotOrientation.VERTICAL) {
hotspot = new Ellipse2D.Double(
entityX - this.defaultEntityRadius,
entityY - this.defaultEntityRadius, w, w);
}
else {
hotspot = new Ellipse2D.Double(
entityY - this.defaultEntityRadius,
entityX - this.defaultEntityRadius, w, w);
}
}
String tip = null;
XYToolTipGenerator generator = getToolTipGenerator(series, item);
if (generator != null) {
tip = generator.generateToolTip(dataset, series, item);
}
String url = null;
if (getURLGenerator() != null) {
url = getURLGenerator().generateURL(dataset, series, item);
}
XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item,
tip, url);
entities.add(entity);
}
Adds an entity to the collection. |
protected Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2,
PlotOrientation orientation,
Rectangle2D dataArea,
Rectangle2D markerArea,
RectangleInsets markerOffset,
LengthAdjustmentType labelOffsetType,
RectangleAnchor anchor) {
Rectangle2D anchorRect = null;
if (orientation == PlotOrientation.HORIZONTAL) {
anchorRect = markerOffset.createAdjustedRectangle(markerArea,
LengthAdjustmentType.CONTRACT, labelOffsetType);
}
else if (orientation == PlotOrientation.VERTICAL) {
anchorRect = markerOffset.createAdjustedRectangle(markerArea,
labelOffsetType, LengthAdjustmentType.CONTRACT);
}
return RectangleAnchor.coordinates(anchorRect, anchor);
}
Calculates the (x, y) coordinates for drawing a marker label. |
protected Object clone() throws CloneNotSupportedException {
AbstractXYItemRenderer clone = (AbstractXYItemRenderer) super.clone();
// 'plot' : just retain reference, not a deep copy
if (this.itemLabelGenerator != null
&& this.itemLabelGenerator instanceof PublicCloneable) {
PublicCloneable pc = (PublicCloneable) this.itemLabelGenerator;
clone.itemLabelGenerator = (XYItemLabelGenerator) pc.clone();
}
clone.itemLabelGeneratorList
= (ObjectList) this.itemLabelGeneratorList.clone();
if (this.baseItemLabelGenerator != null
&& this.baseItemLabelGenerator instanceof PublicCloneable) {
PublicCloneable pc = (PublicCloneable) this.baseItemLabelGenerator;
clone.baseItemLabelGenerator = (XYItemLabelGenerator) pc.clone();
}
if (this.toolTipGenerator != null
&& this.toolTipGenerator instanceof PublicCloneable) {
PublicCloneable pc = (PublicCloneable) this.toolTipGenerator;
clone.toolTipGenerator = (XYToolTipGenerator) pc.clone();
}
clone.toolTipGeneratorList
= (ObjectList) this.toolTipGeneratorList.clone();
if (this.baseToolTipGenerator != null
&& this.baseToolTipGenerator instanceof PublicCloneable) {
PublicCloneable pc = (PublicCloneable) this.baseToolTipGenerator;
clone.baseToolTipGenerator = (XYToolTipGenerator) pc.clone();
}
if (clone.legendItemLabelGenerator instanceof PublicCloneable) {
clone.legendItemLabelGenerator = (XYSeriesLabelGenerator)
ObjectUtilities.clone(this.legendItemLabelGenerator);
}
if (clone.legendItemToolTipGenerator instanceof PublicCloneable) {
clone.legendItemToolTipGenerator = (XYSeriesLabelGenerator)
ObjectUtilities.clone(this.legendItemToolTipGenerator);
}
if (clone.legendItemURLGenerator instanceof PublicCloneable) {
clone.legendItemURLGenerator = (XYSeriesLabelGenerator)
ObjectUtilities.clone(this.legendItemURLGenerator);
}
clone.foregroundAnnotations = (List) ObjectUtilities.deepClone(
this.foregroundAnnotations);
clone.backgroundAnnotations = (List) ObjectUtilities.deepClone(
this.backgroundAnnotations);
if (clone.legendItemLabelGenerator instanceof PublicCloneable) {
clone.legendItemLabelGenerator = (XYSeriesLabelGenerator)
ObjectUtilities.clone(this.legendItemLabelGenerator);
}
if (clone.legendItemToolTipGenerator instanceof PublicCloneable) {
clone.legendItemToolTipGenerator = (XYSeriesLabelGenerator)
ObjectUtilities.clone(this.legendItemToolTipGenerator);
}
if (clone.legendItemURLGenerator instanceof PublicCloneable) {
clone.legendItemURLGenerator = (XYSeriesLabelGenerator)
ObjectUtilities.clone(this.legendItemURLGenerator);
}
return clone;
}
Returns a clone of the renderer. |
public void drawAnnotations(Graphics2D g2,
Rectangle2D dataArea,
ValueAxis domainAxis,
ValueAxis rangeAxis,
Layer layer,
PlotRenderingInfo info) {
Iterator iterator = null;
if (layer.equals(Layer.FOREGROUND)) {
iterator = this.foregroundAnnotations.iterator();
}
else if (layer.equals(Layer.BACKGROUND)) {
iterator = this.backgroundAnnotations.iterator();
}
else {
// should not get here
throw new RuntimeException("Unknown layer.");
}
while (iterator.hasNext()) {
XYAnnotation annotation = (XYAnnotation) iterator.next();
annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis,
0, info);
}
}
Draws all the annotations for the specified layer. |
public void drawDomainGridLine(Graphics2D g2,
XYPlot plot,
ValueAxis axis,
Rectangle2D dataArea,
double value) {
Range range = axis.getRange();
if (!range.contains(value)) {
return;
}
PlotOrientation orientation = plot.getOrientation();
double v = axis.valueToJava2D(value, dataArea,
plot.getDomainAxisEdge());
Line2D line = null;
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(dataArea.getMinX(), v,
dataArea.getMaxX(), v);
}
else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(v, dataArea.getMinY(), v,
dataArea.getMaxY());
}
Paint paint = plot.getDomainGridlinePaint();
Stroke stroke = plot.getDomainGridlineStroke();
g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT);
g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE);
g2.draw(line);
}
Draws a grid line against the range axis. |
public void drawDomainLine(Graphics2D g2,
XYPlot plot,
ValueAxis axis,
Rectangle2D dataArea,
double value,
Paint paint,
Stroke stroke) {
Range range = axis.getRange();
if (!range.contains(value)) {
return;
}
PlotOrientation orientation = plot.getOrientation();
Line2D line = null;
double v = axis.valueToJava2D(value, dataArea,
plot.getDomainAxisEdge());
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(),
v);
}
else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(v, dataArea.getMinY(), v,
dataArea.getMaxY());
}
g2.setPaint(paint);
g2.setStroke(stroke);
g2.draw(line);
}
Draws a line perpendicular to the domain axis. |
public void drawDomainMarker(Graphics2D g2,
XYPlot plot,
ValueAxis domainAxis,
Marker marker,
Rectangle2D dataArea) {
if (marker instanceof ValueMarker) {
ValueMarker vm = (ValueMarker) marker;
double value = vm.getValue();
Range range = domainAxis.getRange();
if (!range.contains(value)) {
return;
}
double v = domainAxis.valueToJava2D(value, dataArea,
plot.getDomainAxisEdge());
PlotOrientation orientation = plot.getOrientation();
Line2D line = null;
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(dataArea.getMinX(), v,
dataArea.getMaxX(), v);
}
else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(v, dataArea.getMinY(), v,
dataArea.getMaxY());
}
final Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, marker.getAlpha()));
g2.setPaint(marker.getPaint());
g2.setStroke(marker.getStroke());
g2.draw(line);
String label = marker.getLabel();
RectangleAnchor anchor = marker.getLabelAnchor();
if (label != null) {
Font labelFont = marker.getLabelFont();
g2.setFont(labelFont);
g2.setPaint(marker.getLabelPaint());
Point2D coordinates = calculateDomainMarkerTextAnchorPoint(
g2, orientation, dataArea, line.getBounds2D(),
marker.getLabelOffset(),
LengthAdjustmentType.EXPAND, anchor);
TextUtilities.drawAlignedString(label, g2,
(float) coordinates.getX(), (float) coordinates.getY(),
marker.getLabelTextAnchor());
}
g2.setComposite(originalComposite);
}
else if (marker instanceof IntervalMarker) {
IntervalMarker im = (IntervalMarker) marker;
double start = im.getStartValue();
double end = im.getEndValue();
Range range = domainAxis.getRange();
if (!(range.intersects(start, end))) {
return;
}
double start2d = domainAxis.valueToJava2D(start, dataArea,
plot.getDomainAxisEdge());
double end2d = domainAxis.valueToJava2D(end, dataArea,
plot.getDomainAxisEdge());
double low = Math.min(start2d, end2d);
double high = Math.max(start2d, end2d);
PlotOrientation orientation = plot.getOrientation();
Rectangle2D rect = null;
if (orientation == PlotOrientation.HORIZONTAL) {
// clip top and bottom bounds to data area
low = Math.max(low, dataArea.getMinY());
high = Math.min(high, dataArea.getMaxY());
rect = new Rectangle2D.Double(dataArea.getMinX(),
low, dataArea.getWidth(),
high - low);
}
else if (orientation == PlotOrientation.VERTICAL) {
// clip left and right bounds to data area
low = Math.max(low, dataArea.getMinX());
high = Math.min(high, dataArea.getMaxX());
rect = new Rectangle2D.Double(low,
dataArea.getMinY(), high - low,
dataArea.getHeight());
}
final Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, marker.getAlpha()));
Paint p = marker.getPaint();
if (p instanceof GradientPaint) {
GradientPaint gp = (GradientPaint) p;
GradientPaintTransformer t = im.getGradientPaintTransformer();
if (t != null) {
gp = t.transform(gp, rect);
}
g2.setPaint(gp);
}
else {
g2.setPaint(p);
}
g2.fill(rect);
// now draw the outlines, if visible...
if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) {
if (orientation == PlotOrientation.VERTICAL) {
Line2D line = new Line2D.Double();
double y0 = dataArea.getMinY();
double y1 = dataArea.getMaxY();
g2.setPaint(im.getOutlinePaint());
g2.setStroke(im.getOutlineStroke());
if (range.contains(start)) {
line.setLine(start2d, y0, start2d, y1);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(end2d, y0, end2d, y1);
g2.draw(line);
}
}
else { // PlotOrientation.HORIZONTAL
Line2D line = new Line2D.Double();
double x0 = dataArea.getMinX();
double x1 = dataArea.getMaxX();
g2.setPaint(im.getOutlinePaint());
g2.setStroke(im.getOutlineStroke());
if (range.contains(start)) {
line.setLine(x0, start2d, x1, start2d);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(x0, end2d, x1, end2d);
g2.draw(line);
}
}
}
String label = marker.getLabel();
RectangleAnchor anchor = marker.getLabelAnchor();
if (label != null) {
Font labelFont = marker.getLabelFont();
g2.setFont(labelFont);
g2.setPaint(marker.getLabelPaint());
Point2D coordinates = calculateDomainMarkerTextAnchorPoint(
g2, orientation, dataArea, rect,
marker.getLabelOffset(), marker.getLabelOffsetType(),
anchor);
TextUtilities.drawAlignedString(label, g2,
(float) coordinates.getX(), (float) coordinates.getY(),
marker.getLabelTextAnchor());
}
g2.setComposite(originalComposite);
}
}
Draws a vertical line on the chart to represent a 'range marker'. |
protected void drawItemLabel(Graphics2D g2,
PlotOrientation orientation,
XYDataset dataset,
int series,
int item,
double x,
double y,
boolean negative) {
XYItemLabelGenerator generator = getItemLabelGenerator(series, item);
if (generator != null) {
Font labelFont = getItemLabelFont(series, item);
Paint paint = getItemLabelPaint(series, item);
g2.setFont(labelFont);
g2.setPaint(paint);
String label = generator.generateLabel(dataset, series, item);
// get the label position..
ItemLabelPosition position = null;
if (!negative) {
position = getPositiveItemLabelPosition(series, item);
}
else {
position = getNegativeItemLabelPosition(series, item);
}
// work out the label anchor point...
Point2D anchorPoint = calculateLabelAnchorPoint(
position.getItemLabelAnchor(), x, y, orientation);
TextUtilities.drawRotatedString(label, g2,
(float) anchorPoint.getX(), (float) anchorPoint.getY(),
position.getTextAnchor(), position.getAngle(),
position.getRotationAnchor());
}
}
|
public void drawRangeLine(Graphics2D g2,
XYPlot plot,
ValueAxis axis,
Rectangle2D dataArea,
double value,
Paint paint,
Stroke stroke) {
Range range = axis.getRange();
if (!range.contains(value)) {
return;
}
PlotOrientation orientation = plot.getOrientation();
Line2D line = null;
double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge());
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(v, dataArea.getMinY(), v,
dataArea.getMaxY());
}
else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(dataArea.getMinX(), v,
dataArea.getMaxX(), v);
}
g2.setPaint(paint);
g2.setStroke(stroke);
g2.draw(line);
}
Draws a line perpendicular to the range axis. |
public void drawRangeMarker(Graphics2D g2,
XYPlot plot,
ValueAxis rangeAxis,
Marker marker,
Rectangle2D dataArea) {
if (marker instanceof ValueMarker) {
ValueMarker vm = (ValueMarker) marker;
double value = vm.getValue();
Range range = rangeAxis.getRange();
if (!range.contains(value)) {
return;
}
double v = rangeAxis.valueToJava2D(value, dataArea,
plot.getRangeAxisEdge());
PlotOrientation orientation = plot.getOrientation();
Line2D line = null;
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(v, dataArea.getMinY(), v,
dataArea.getMaxY());
}
else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(dataArea.getMinX(), v,
dataArea.getMaxX(), v);
}
final Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, marker.getAlpha()));
g2.setPaint(marker.getPaint());
g2.setStroke(marker.getStroke());
g2.draw(line);
String label = marker.getLabel();
RectangleAnchor anchor = marker.getLabelAnchor();
if (label != null) {
Font labelFont = marker.getLabelFont();
g2.setFont(labelFont);
g2.setPaint(marker.getLabelPaint());
Point2D coordinates = calculateRangeMarkerTextAnchorPoint(
g2, orientation, dataArea, line.getBounds2D(),
marker.getLabelOffset(),
LengthAdjustmentType.EXPAND, anchor);
TextUtilities.drawAlignedString(label, g2,
(float) coordinates.getX(), (float) coordinates.getY(),
marker.getLabelTextAnchor());
}
g2.setComposite(originalComposite);
}
else if (marker instanceof IntervalMarker) {
IntervalMarker im = (IntervalMarker) marker;
double start = im.getStartValue();
double end = im.getEndValue();
Range range = rangeAxis.getRange();
if (!(range.intersects(start, end))) {
return;
}
double start2d = rangeAxis.valueToJava2D(start, dataArea,
plot.getRangeAxisEdge());
double end2d = rangeAxis.valueToJava2D(end, dataArea,
plot.getRangeAxisEdge());
double low = Math.min(start2d, end2d);
double high = Math.max(start2d, end2d);
PlotOrientation orientation = plot.getOrientation();
Rectangle2D rect = null;
if (orientation == PlotOrientation.HORIZONTAL) {
// clip left and right bounds to data area
low = Math.max(low, dataArea.getMinX());
high = Math.min(high, dataArea.getMaxX());
rect = new Rectangle2D.Double(low,
dataArea.getMinY(), high - low,
dataArea.getHeight());
}
else if (orientation == PlotOrientation.VERTICAL) {
// clip top and bottom bounds to data area
low = Math.max(low, dataArea.getMinY());
high = Math.min(high, dataArea.getMaxY());
rect = new Rectangle2D.Double(dataArea.getMinX(),
low, dataArea.getWidth(),
high - low);
}
final Composite originalComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, marker.getAlpha()));
Paint p = marker.getPaint();
if (p instanceof GradientPaint) {
GradientPaint gp = (GradientPaint) p;
GradientPaintTransformer t = im.getGradientPaintTransformer();
if (t != null) {
gp = t.transform(gp, rect);
}
g2.setPaint(gp);
}
else {
g2.setPaint(p);
}
g2.fill(rect);
// now draw the outlines, if visible...
if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) {
if (orientation == PlotOrientation.VERTICAL) {
Line2D line = new Line2D.Double();
double x0 = dataArea.getMinX();
double x1 = dataArea.getMaxX();
g2.setPaint(im.getOutlinePaint());
g2.setStroke(im.getOutlineStroke());
if (range.contains(start)) {
line.setLine(x0, start2d, x1, start2d);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(x0, end2d, x1, end2d);
g2.draw(line);
}
}
else { // PlotOrientation.HORIZONTAL
Line2D line = new Line2D.Double();
double y0 = dataArea.getMinY();
double y1 = dataArea.getMaxY();
g2.setPaint(im.getOutlinePaint());
g2.setStroke(im.getOutlineStroke());
if (range.contains(start)) {
line.setLine(start2d, y0, start2d, y1);
g2.draw(line);
}
if (range.contains(end)) {
line.setLine(end2d, y0, end2d, y1);
g2.draw(line);
}
}
}
String label = marker.getLabel();
RectangleAnchor anchor = marker.getLabelAnchor();
if (label != null) {
Font labelFont = marker.getLabelFont();
g2.setFont(labelFont);
g2.setPaint(marker.getLabelPaint());
Point2D coordinates = calculateRangeMarkerTextAnchorPoint(
g2, orientation, dataArea, rect,
marker.getLabelOffset(), marker.getLabelOffsetType(),
anchor);
TextUtilities.drawAlignedString(label, g2,
(float) coordinates.getX(), (float) coordinates.getY(),
marker.getLabelTextAnchor());
}
g2.setComposite(originalComposite);
}
}
Draws a horizontal line across the chart to represent a 'range marker'. |
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof AbstractXYItemRenderer)) {
return false;
}
AbstractXYItemRenderer that = (AbstractXYItemRenderer) obj;
if (!ObjectUtilities.equal(this.itemLabelGenerator,
that.itemLabelGenerator)) {
return false;
}
if (!this.itemLabelGeneratorList.equals(that.itemLabelGeneratorList)) {
return false;
}
if (!ObjectUtilities.equal(this.baseItemLabelGenerator,
that.baseItemLabelGenerator)) {
return false;
}
if (!ObjectUtilities.equal(this.toolTipGenerator,
that.toolTipGenerator)) {
return false;
}
if (!this.toolTipGeneratorList.equals(that.toolTipGeneratorList)) {
return false;
}
if (!ObjectUtilities.equal(this.baseToolTipGenerator,
that.baseToolTipGenerator)) {
return false;
}
if (!ObjectUtilities.equal(this.urlGenerator, that.urlGenerator)) {
return false;
}
if (!this.foregroundAnnotations.equals(that.foregroundAnnotations)) {
return false;
}
if (!this.backgroundAnnotations.equals(that.backgroundAnnotations)) {
return false;
}
if (this.defaultEntityRadius != that.defaultEntityRadius) {
return false;
}
if (!ObjectUtilities.equal(this.legendItemLabelGenerator,
that.legendItemLabelGenerator)) {
return false;
}
if (!ObjectUtilities.equal(this.legendItemToolTipGenerator,
that.legendItemToolTipGenerator)) {
return false;
}
if (!ObjectUtilities.equal(this.legendItemURLGenerator,
that.legendItemURLGenerator)) {
return false;
}
return super.equals(obj);
}
Tests this renderer for equality with another object. |
public void fillDomainGridBand(Graphics2D g2,
XYPlot plot,
ValueAxis axis,
Rectangle2D dataArea,
double start,
double end) {
double x1 = axis.valueToJava2D(start, dataArea,
plot.getDomainAxisEdge());
double x2 = axis.valueToJava2D(end, dataArea,
plot.getDomainAxisEdge());
Rectangle2D band;
if (plot.getOrientation() == PlotOrientation.VERTICAL) {
band = new Rectangle2D.Double(Math.min(x1, x2), dataArea.getMinY(),
Math.abs(x2 - x1), dataArea.getWidth());
}
else {
band = new Rectangle2D.Double(dataArea.getMinX(), Math.min(x1, x2),
dataArea.getWidth(), Math.abs(x2 - x1));
}
Paint paint = plot.getDomainTickBandPaint();
if (paint != null) {
g2.setPaint(paint);
g2.fill(band);
}
}
Fills a band between two values on the axis. This can be used to color
bands between the grid lines. |
public void fillRangeGridBand(Graphics2D g2,
XYPlot plot,
ValueAxis axis,
Rectangle2D dataArea,
double start,
double end) {
double y1 = axis.valueToJava2D(start, dataArea,
plot.getRangeAxisEdge());
double y2 = axis.valueToJava2D(end, dataArea, plot.getRangeAxisEdge());
Rectangle2D band;
if (plot.getOrientation() == PlotOrientation.VERTICAL) {
band = new Rectangle2D.Double(dataArea.getMinX(), Math.min(y1, y2),
dataArea.getWidth(), Math.abs(y2 - y1));
}
else {
band = new Rectangle2D.Double(Math.min(y1, y2), dataArea.getMinY(),
Math.abs(y2 - y1), dataArea.getHeight());
}
Paint paint = plot.getRangeTickBandPaint();
if (paint != null) {
g2.setPaint(paint);
g2.fill(band);
}
}
Fills a band between two values on the range axis. This can be used to
color bands between the grid lines. |
public Range findDomainBounds(XYDataset dataset) {
if (dataset != null) {
return DatasetUtilities.findDomainBounds(dataset, false);
}
else {
return null;
}
}
Returns the lower and upper bounds (range) of the x-values in the
specified dataset. |
public Range findRangeBounds(XYDataset dataset) {
if (dataset != null) {
return DatasetUtilities.findRangeBounds(dataset, false);
}
else {
return null;
}
}
Returns the range of values the renderer requires to display all the
items from the specified dataset. |
public XYItemLabelGenerator getBaseItemLabelGenerator() {
return this.baseItemLabelGenerator;
}
Returns the base item label generator. |
public XYToolTipGenerator getBaseToolTipGenerator() {
return this.baseToolTipGenerator;
}
Returns the base tool tip generator. |
public int getDefaultEntityRadius() {
return this.defaultEntityRadius;
}
Returns the radius of the circle used for the default entity area
when no area is specified. |
public DrawingSupplier getDrawingSupplier() {
DrawingSupplier result = null;
XYPlot p = getPlot();
if (p != null) {
result = p.getDrawingSupplier();
}
return result;
}
Returns the drawing supplier from the plot. |
public XYItemLabelGenerator getItemLabelGenerator() {
return this.itemLabelGenerator;
} Deprecated! As - of version 1.0.6, this override setting should not be
used. You can use the base setting instead
(#getBaseItemLabelGenerator() ).
Returns the item label generator override. |
public XYItemLabelGenerator getItemLabelGenerator(int series,
int item) {
// return the generator for ALL series, if there is one...
if (this.itemLabelGenerator != null) {
return this.itemLabelGenerator;
}
// otherwise look up the generator table
XYItemLabelGenerator generator
= (XYItemLabelGenerator) this.itemLabelGeneratorList.get(series);
if (generator == null) {
generator = this.baseItemLabelGenerator;
}
return generator;
}
Returns the label generator for a data item. This implementation simply
passes control to the #getSeriesItemLabelGenerator(int) method.
If, for some reason, you want a different generator for individual
items, you can override this method. |
public LegendItem getLegendItem(int datasetIndex,
int series) {
LegendItem result = null;
XYPlot xyplot = getPlot();
if (xyplot != null) {
XYDataset dataset = xyplot.getDataset(datasetIndex);
if (dataset != null) {
String label = this.legendItemLabelGenerator.generateLabel(
dataset, series);
String description = label;
String toolTipText = null;
if (getLegendItemToolTipGenerator() != null) {
toolTipText = getLegendItemToolTipGenerator().generateLabel(
dataset, series);
}
String urlText = null;
if (getLegendItemURLGenerator() != null) {
urlText = getLegendItemURLGenerator().generateLabel(
dataset, series);
}
Shape shape = lookupSeriesShape(series);
Paint paint = lookupSeriesPaint(series);
Paint outlinePaint = lookupSeriesOutlinePaint(series);
Stroke outlineStroke = lookupSeriesOutlineStroke(series);
result = new LegendItem(label, description, toolTipText,
urlText, shape, paint, outlineStroke, outlinePaint);
result.setSeriesKey(dataset.getSeriesKey(series));
result.setSeriesIndex(series);
result.setDataset(dataset);
result.setDatasetIndex(datasetIndex);
}
}
return result;
}
Returns a default legend item for the specified series. Subclasses
should override this method to generate customised items. |
public XYSeriesLabelGenerator getLegendItemLabelGenerator() {
return this.legendItemLabelGenerator;
}
Returns the legend item label generator. |
public XYSeriesLabelGenerator getLegendItemToolTipGenerator() {
return this.legendItemToolTipGenerator;
}
Returns the legend item tool tip generator. |
public XYSeriesLabelGenerator getLegendItemURLGenerator() {
return this.legendItemURLGenerator;
}
Returns the legend item URL generator. |
public LegendItemCollection getLegendItems() {
if (this.plot == null) {
return new LegendItemCollection();
}
LegendItemCollection result = new LegendItemCollection();
int index = this.plot.getIndexOf(this);
XYDataset dataset = this.plot.getDataset(index);
if (dataset != null) {
int seriesCount = dataset.getSeriesCount();
for (int i = 0; i < seriesCount; i++) {
if (isSeriesVisibleInLegend(i)) {
LegendItem item = getLegendItem(index, i);
if (item != null) {
result.add(item);
}
}
}
}
return result;
}
Returns a (possibly empty) collection of legend items for the series
that this renderer is responsible for drawing. |
public int getPassCount() {
return 1;
}
Returns the number of passes through the data that the renderer requires
in order to draw the chart. Most charts will require a single pass, but
some require two passes. |
public XYPlot getPlot() {
return this.plot;
}
Returns the plot that the renderer is assigned to. |
public XYItemLabelGenerator getSeriesItemLabelGenerator(int series) {
return (XYItemLabelGenerator) this.itemLabelGeneratorList.get(series);
}
Returns the item label generator for a series. |
public XYToolTipGenerator getSeriesToolTipGenerator(int series) {
return (XYToolTipGenerator) this.toolTipGeneratorList.get(series);
}
Returns the tool tip generator for a series. |
public XYToolTipGenerator getToolTipGenerator() {
return this.toolTipGenerator;
} Deprecated! As - of version 1.0.6, this override setting should not be
used. You can use the base setting instead
(#getBaseToolTipGenerator() ).
Returns the override tool tip generator. |
public XYToolTipGenerator getToolTipGenerator(int series,
int item) {
// return the generator for ALL series, if there is one...
if (this.toolTipGenerator != null) {
return this.toolTipGenerator;
}
// otherwise look up the generator table
XYToolTipGenerator generator
= (XYToolTipGenerator) this.toolTipGeneratorList.get(series);
if (generator == null) {
generator = this.baseToolTipGenerator;
}
return generator;
}
Returns the tool tip generator for a data item. If, for some reason,
you want a different generator for individual items, you can override
this method. |
public XYURLGenerator getURLGenerator() {
return this.urlGenerator;
}
Returns the URL generator for HTML image maps. |
public XYItemRendererState initialise(Graphics2D g2,
Rectangle2D dataArea,
XYPlot plot,
XYDataset data,
PlotRenderingInfo info) {
XYItemRendererState state = new XYItemRendererState(info);
return state;
}
Initialises the renderer and returns a state object that should be
passed to all subsequent calls to the drawItem() method.
This method will be called before the first item is rendered, giving the
renderer an opportunity to initialise any state information it wants to
maintain. The renderer can do nothing if it chooses. |
public static boolean isPointInRect(Rectangle2D rect,
double x,
double y) {
// TODO: For JFreeChart 1.2.0, this method should go in the
// ShapeUtilities class
return (x >= rect.getMinX() && x < = rect.getMaxX()
&& y >= rect.getMinY() && y < = rect.getMaxY());
}
Returns true if the specified point (x, y) falls within or
on the boundary of the specified rectangle. |
public boolean removeAnnotation(XYAnnotation annotation) {
boolean removed = this.foregroundAnnotations.remove(annotation);
removed = removed & this.backgroundAnnotations.remove(annotation);
fireChangeEvent();
return removed;
}
|
public void removeAnnotations() {
this.foregroundAnnotations.clear();
this.backgroundAnnotations.clear();
fireChangeEvent();
}
|
public void setBaseItemLabelGenerator(XYItemLabelGenerator generator) {
this.baseItemLabelGenerator = generator;
fireChangeEvent();
}
Sets the base item label generator and sends a
RendererChangeEvent to all registered listeners. |
public void setBaseToolTipGenerator(XYToolTipGenerator generator) {
this.baseToolTipGenerator = generator;
fireChangeEvent();
}
|
public void setDefaultEntityRadius(int radius) {
this.defaultEntityRadius = radius;
}
Sets the radius of the circle used for the default entity area
when no area is specified. |
public void setItemLabelGenerator(XYItemLabelGenerator generator) {
this.itemLabelGenerator = generator;
fireChangeEvent();
} Deprecated! As - of version 1.0.6, this override setting should not be
used. You can use the base setting instead
(#setBaseItemLabelGenerator(XYItemLabelGenerator) ).
Sets the item label generator for ALL series and sends a
RendererChangeEvent to all registered listeners. |
public void setLegendItemLabelGenerator(XYSeriesLabelGenerator generator) {
if (generator == null) {
throw new IllegalArgumentException("Null 'generator' argument.");
}
this.legendItemLabelGenerator = generator;
fireChangeEvent();
}
Sets the legend item label generator and sends a
RendererChangeEvent to all registered listeners. |
public void setLegendItemToolTipGenerator(XYSeriesLabelGenerator generator) {
this.legendItemToolTipGenerator = generator;
fireChangeEvent();
}
Sets the legend item tool tip generator and sends a
RendererChangeEvent to all registered listeners. |
public void setLegendItemURLGenerator(XYSeriesLabelGenerator generator) {
this.legendItemURLGenerator = generator;
fireChangeEvent();
}
Sets the legend item URL generator and sends a
RendererChangeEvent to all registered listeners. |
public void setPlot(XYPlot plot) {
this.plot = plot;
}
Sets the plot that the renderer is assigned to. |
public void setSeriesItemLabelGenerator(int series,
XYItemLabelGenerator generator) {
this.itemLabelGeneratorList.set(series, generator);
fireChangeEvent();
}
Sets the item label generator for a series and sends a
RendererChangeEvent to all registered listeners. |
public void setSeriesToolTipGenerator(int series,
XYToolTipGenerator generator) {
this.toolTipGeneratorList.set(series, generator);
fireChangeEvent();
}
Sets the tool tip generator for a series and sends a
RendererChangeEvent to all registered listeners. |
public void setToolTipGenerator(XYToolTipGenerator generator) {
this.toolTipGenerator = generator;
fireChangeEvent();
} Deprecated! As - of version 1.0.6, this override setting should not be
used. You can use the base setting instead
(#setBaseToolTipGenerator(XYToolTipGenerator) ).
Sets the tool tip generator for ALL series and sends a
RendererChangeEvent to all registered listeners. |
public void setURLGenerator(XYURLGenerator urlGenerator) {
this.urlGenerator = urlGenerator;
fireChangeEvent();
}
Sets the URL generator for HTML image maps and sends a
RendererChangeEvent to all registered listeners. |
protected void updateCrosshairValues(CrosshairState crosshairState,
double x,
double y,
double transX,
double transY,
PlotOrientation orientation) {
updateCrosshairValues(crosshairState, x, y, 0, 0, transX, transY,
orientation);
} Deprecated! Use - #updateCrosshairValues(CrosshairState, double,
double, int, int, double, double, PlotOrientation) -- see bug
report 1086307.
Considers the current (x, y) coordinate and updates the crosshair point
if it meets the criteria (usually means the (x, y) coordinate is the
closest to the anchor point so far). |
protected void updateCrosshairValues(CrosshairState crosshairState,
double x,
double y,
int domainAxisIndex,
int rangeAxisIndex,
double transX,
double transY,
PlotOrientation orientation) {
if (orientation == null) {
throw new IllegalArgumentException("Null 'orientation' argument.");
}
if (crosshairState != null) {
// do we need to update the crosshair values?
if (this.plot.isDomainCrosshairLockedOnData()) {
if (this.plot.isRangeCrosshairLockedOnData()) {
// both axes
crosshairState.updateCrosshairPoint(x, y, domainAxisIndex,
rangeAxisIndex, transX, transY, orientation);
}
else {
// just the domain axis...
crosshairState.updateCrosshairX(x, domainAxisIndex);
}
}
else {
if (this.plot.isRangeCrosshairLockedOnData()) {
// just the range axis...
crosshairState.updateCrosshairY(y, rangeAxisIndex);
}
}
}
}
Considers the current (x, y) coordinate and updates the crosshair point
if it meets the criteria (usually means the (x, y) coordinate is the
closest to the anchor point so far). |