public void drawItem(Graphics2D g2,
XYItemRendererState state,
Rectangle2D dataArea,
PlotRenderingInfo info,
XYPlot plot,
ValueAxis horizontalAxis,
ValueAxis verticalAxis,
XYDataset dataset,
int series,
int item,
CrosshairState crosshairState,
int pass) {
// setup for collecting optional entity info...
EntityCollection entities = null;
if (info != null) {
entities = info.getOwner().getEntityCollection();
}
SignalsDataset signalData = (SignalsDataset) dataset;
Number x = signalData.getX(series, item);
Number y = signalData.getY(series, item);
int type = signalData.getType(series, item);
//double level = signalData.getLevel(series, item);
double xx = horizontalAxis.valueToJava2D(
x.doubleValue(), dataArea, plot.getDomainAxisEdge()
);
double yy = verticalAxis.valueToJava2D(
y.doubleValue(), dataArea, plot.getRangeAxisEdge()
);
Paint p = getItemPaint(series, item);
Stroke s = getItemStroke(series, item);
g2.setPaint(p);
g2.setStroke(s);
int direction = 1;
if ((type == SignalsDataset.ENTER_LONG)
|| (type == SignalsDataset.EXIT_SHORT)) {
yy = yy + this.markOffset;
direction = -1;
}
else {
yy = yy - this.markOffset;
}
GeneralPath path = new GeneralPath();
if ((type == SignalsDataset.ENTER_LONG)
|| (type == SignalsDataset.ENTER_SHORT)) {
path.moveTo((float) xx, (float) yy);
path.lineTo(
(float) (xx + this.shapeWidth / 2),
(float) (yy - direction * this.shapeHeight / 3)
);
path.lineTo(
(float) (xx + this.shapeWidth / 6),
(float) (yy - direction * this.shapeHeight / 3)
);
path.lineTo(
(float) (xx + this.shapeWidth / 6),
(float) (yy - direction * this.shapeHeight)
);
path.lineTo(
(float) (xx - this.shapeWidth / 6),
(float) (yy - direction * this.shapeHeight)
);
path.lineTo(
(float) (xx - this.shapeWidth / 6),
(float) (yy - direction * this.shapeHeight / 3)
);
path.lineTo(
(float) (xx - this.shapeWidth / 2),
(float) (yy - direction * this.shapeHeight / 3)
);
path.lineTo((float) xx, (float) yy);
}
else {
path.moveTo((float) xx, (float) yy);
path.lineTo(
(float) xx, (float) (yy - direction * this.shapeHeight)
);
Ellipse2D.Double ellipse = new Ellipse2D.Double(
xx - this.shapeWidth / 2,
yy + (direction == 1 ? -this.shapeHeight
: this.shapeHeight - this.shapeWidth),
this.shapeWidth,
this.shapeWidth
);
path.append(ellipse, false);
}
g2.fill(path);
g2.setPaint(Color.black);
g2.draw(path);
// add an entity for the item...
if (entities != null) {
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(
path, dataset, series, item, tip, url
);
entities.add(entity);
}
}
Draws the visual representation of a single data item. |