public void draw(Graphics2D g2,
XYPlot plot,
Rectangle2D dataArea,
ValueAxis domainAxis,
ValueAxis rangeAxis,
int rendererIndex,
PlotRenderingInfo info) {
// if we don't have at least 2 (x, y) coordinates, just return
if (this.polygon.length < 4) {
return;
}
PlotOrientation orientation = plot.getOrientation();
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
plot.getDomainAxisLocation(), orientation);
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
plot.getRangeAxisLocation(), orientation);
GeneralPath area = new GeneralPath();
double x = domainAxis.valueToJava2D(this.polygon[0], dataArea,
domainEdge);
double y = rangeAxis.valueToJava2D(this.polygon[1], dataArea,
rangeEdge);
if (orientation == PlotOrientation.HORIZONTAL) {
area.moveTo((float) y, (float) x);
for (int i = 2; i < this.polygon.length; i += 2) {
x = domainAxis.valueToJava2D(this.polygon[i], dataArea,
domainEdge);
y = rangeAxis.valueToJava2D(this.polygon[i + 1], dataArea,
rangeEdge);
area.lineTo((float) y, (float) x);
}
area.closePath();
}
else if (orientation == PlotOrientation.VERTICAL) {
area.moveTo((float) x, (float) y);
for (int i = 2; i < this.polygon.length; i += 2) {
x = domainAxis.valueToJava2D(this.polygon[i], dataArea,
domainEdge);
y = rangeAxis.valueToJava2D(this.polygon[i + 1], dataArea,
rangeEdge);
area.lineTo((float) x, (float) y);
}
area.closePath();
}
if (this.fillPaint != null) {
g2.setPaint(this.fillPaint);
g2.fill(area);
}
if (this.stroke != null && this.outlinePaint != null) {
g2.setPaint(this.outlinePaint);
g2.setStroke(this.stroke);
g2.draw(area);
}
addEntity(info, area, rendererIndex, getToolTipText(), getURL());
}
Draws the annotation. This method is usually called by the
XYPlot class, you shouldn't need to call it directly. |
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
// now try to reject equality
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof XYPolygonAnnotation)) {
return false;
}
XYPolygonAnnotation that = (XYPolygonAnnotation) obj;
if (!Arrays.equals(this.polygon, that.polygon)) {
return false;
}
if (!ObjectUtilities.equal(this.stroke, that.stroke)) {
return false;
}
if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) {
return false;
}
if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) {
return false;
}
// seem to be the same
return true;
}
Tests this annotation for equality with an arbitrary object. |