| Method from org.jfree.chart.annotations.CategoryPointerAnnotation Detail: |
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
Returns a clone of the annotation. |
public void draw(Graphics2D g2,
CategoryPlot plot,
Rectangle2D dataArea,
CategoryAxis domainAxis,
ValueAxis rangeAxis) {
PlotOrientation orientation = plot.getOrientation();
RectangleEdge domainEdge = Plot.resolveDomainAxisLocation(
plot.getDomainAxisLocation(), orientation);
RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation(
plot.getRangeAxisLocation(), orientation);
CategoryDataset dataset = plot.getDataset();
int catIndex = dataset.getColumnIndex(getCategory());
int catCount = dataset.getColumnCount();
double j2DX = domainAxis.getCategoryMiddle(catIndex, catCount,
dataArea, domainEdge);
double j2DY = rangeAxis.valueToJava2D(getValue(), dataArea, rangeEdge);
if (orientation == PlotOrientation.HORIZONTAL) {
double temp = j2DX;
j2DX = j2DY;
j2DY = temp;
}
double startX = j2DX + Math.cos(this.angle) * this.baseRadius;
double startY = j2DY + Math.sin(this.angle) * this.baseRadius;
double endX = j2DX + Math.cos(this.angle) * this.tipRadius;
double endY = j2DY + Math.sin(this.angle) * this.tipRadius;
double arrowBaseX = endX + Math.cos(this.angle) * this.arrowLength;
double arrowBaseY = endY + Math.sin(this.angle) * this.arrowLength;
double arrowLeftX = arrowBaseX
+ Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth;
double arrowLeftY = arrowBaseY
+ Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth;
double arrowRightX = arrowBaseX
- Math.cos(this.angle + Math.PI / 2.0) * this.arrowWidth;
double arrowRightY = arrowBaseY
- Math.sin(this.angle + Math.PI / 2.0) * this.arrowWidth;
GeneralPath arrow = new GeneralPath();
arrow.moveTo((float) endX, (float) endY);
arrow.lineTo((float) arrowLeftX, (float) arrowLeftY);
arrow.lineTo((float) arrowRightX, (float) arrowRightY);
arrow.closePath();
g2.setStroke(this.arrowStroke);
g2.setPaint(this.arrowPaint);
Line2D line = new Line2D.Double(startX, startY, endX, endY);
g2.draw(line);
g2.fill(arrow);
// draw the label
g2.setFont(getFont());
g2.setPaint(getPaint());
double labelX = j2DX
+ Math.cos(this.angle) * (this.baseRadius + this.labelOffset);
double labelY = j2DY
+ Math.sin(this.angle) * (this.baseRadius + this.labelOffset);
/* Rectangle2D hotspot = */ TextUtilities.drawAlignedString(getText(),
g2, (float) labelX, (float) labelY, getTextAnchor());
// TODO: implement the entity for the annotation
}
|
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof CategoryPointerAnnotation)) {
return false;
}
if (!super.equals(obj)) {
return false;
}
CategoryPointerAnnotation that = (CategoryPointerAnnotation) obj;
if (this.angle != that.angle) {
return false;
}
if (this.tipRadius != that.tipRadius) {
return false;
}
if (this.baseRadius != that.baseRadius) {
return false;
}
if (this.arrowLength != that.arrowLength) {
return false;
}
if (this.arrowWidth != that.arrowWidth) {
return false;
}
if (!this.arrowPaint.equals(that.arrowPaint)) {
return false;
}
if (!ObjectUtilities.equal(this.arrowStroke, that.arrowStroke)) {
return false;
}
if (this.labelOffset != that.labelOffset) {
return false;
}
return true;
}
Tests this annotation for equality with an arbitrary object. |
public double getAngle() {
return this.angle;
}
Returns the angle of the arrow. |
public double getArrowLength() {
return this.arrowLength;
}
Returns the arrow length. |
public Paint getArrowPaint() {
return this.arrowPaint;
}
Returns the paint used for the arrow. |
public Stroke getArrowStroke() {
return this.arrowStroke;
}
Returns the stroke used to draw the arrow line. |
public double getArrowWidth() {
return this.arrowWidth;
}
|
public double getBaseRadius() {
return this.baseRadius;
}
|
public double getLabelOffset() {
return this.labelOffset;
}
Returns the label offset. |
public double getTipRadius() {
return this.tipRadius;
}
|
public int hashCode() {
int result = 193;
long temp = Double.doubleToLongBits(this.angle);
result = 37 * result + (int) (temp ^ (temp > > > 32));
temp = Double.doubleToLongBits(this.tipRadius);
result = 37 * result + (int) (temp ^ (temp > > > 32));
temp = Double.doubleToLongBits(this.baseRadius);
result = 37 * result + (int) (temp ^ (temp > > > 32));
temp = Double.doubleToLongBits(this.arrowLength);
result = 37 * result + (int) (temp ^ (temp > > > 32));
temp = Double.doubleToLongBits(this.arrowWidth);
result = 37 * result + (int) (temp ^ (temp > > > 32));
result = 37 * result + HashUtilities.hashCodeForPaint(this.arrowPaint);
result = 37 * result + this.arrowStroke.hashCode();
temp = Double.doubleToLongBits(this.labelOffset);
result = 37 * result + (int) (temp ^ (temp > > > 32));
return result;
}
Returns a hash code for this instance. |
public void setAngle(double angle) {
this.angle = angle;
}
Sets the angle of the arrow. |
public void setArrowLength(double length) {
this.arrowLength = length;
}
|
public void setArrowPaint(Paint paint) {
if (paint == null) {
throw new IllegalArgumentException("Null 'paint' argument.");
}
this.arrowPaint = paint;
}
Sets the paint used for the arrow. |
public void setArrowStroke(Stroke stroke) {
if (stroke == null) {
throw new IllegalArgumentException("Null 'stroke' not permitted.");
}
this.arrowStroke = stroke;
}
Sets the stroke used to draw the arrow line. |
public void setArrowWidth(double width) {
this.arrowWidth = width;
}
|
public void setBaseRadius(double radius) {
this.baseRadius = radius;
}
|
public void setLabelOffset(double offset) {
this.labelOffset = offset;
}
Sets the label offset (from the arrow base, continuing in a straight
line, in Java2D units). |
public void setTipRadius(double radius) {
this.tipRadius = radius;
}
|