Tooltips with small shapes.

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Martin Smith

Tooltips with small shapes.

Post by Martin Smith » Sun Jun 02, 2002 6:02 am

I was wondering if it would be possible to add an optional invisible edge to small shapes so that there is a margin of error for tooltips ? I am creating charts with lines and shapes. The shapes are very small due (shapeScale 1 or 2 ) to a large number of plot points per lines. When trying to show a tooltip the user has to be very accurate to get the tooltip to show up.

In looking at the code the tooltip takes its area from the following line.

Shape tooltipArea = renderer.drawItem(g2, dataArea, info, this, (ValueAxis)horizontalAxis, (ValueAxis)verticalAxis, data, series, item, transRangeZero, crosshairInfo);

My thinking is a method on the renderer that gets the tooltip area, this method could basically be something like the following.

public Shape getTooltipArea( Rectangle2D theDataArea, XYDataset theData, int theSeries, int theItem){

Shape aShape = null;


if (plotShapes ) {
// handle cases where tooltipShapeScale is default of zero.
int aShapeScale = Math.max( tooltipShapeScale,shapeScale);
Number anX1 = theData.getXValue(theSeries, theItem);
Number aY1 = theData.getYValue(theSeries, theItem);
if (y1!=null) {
double aTransX1 = horizontalAxis.translateValueToJava2D(anX1.doubleValue(), theDataArea);
double aTransY1 = verticalAxis.translateValueToJava2D(aY1.doubleValue(), theDataArea);
aShape = plot.getShape(theSeries, theItem, aTransX1, aTransY1, aShapeScale);
}
return aShape;
}



Martin Smith

David Gilbert

Re: Tooltips with small shapes.

Post by David Gilbert » Sun Jun 02, 2002 6:33 am

Hi Martin,

Thanks - that is a good suggestion.

Regards,

DG.

Locked