Hi,
I'm using some of your example code to allow someone to add a label to a point on a plotted graph. The only difference in my code is that the plot is scrolling off to the left as more points come in. Thus, the added label will move as the plot adjusts - cool.
The problem I'm having is that when the label gets near the axis, it will cross the X-Axis and appear in the area where a legend would go - totally outside of the plot.
The question I have is how can I stop this? How can I tell the label (type Marker) that when it gets to the Axis to stop displaying.
Here's the code for the creation of the label (it's basically modified code from your own example):
if (found) {
// create marker object at place it at the nearest point
Marker amarker = new Marker(getChartObjScale(), MARKER_BOX,
nearestPoint.getX(), nearestPoint.getY(), 10.0,
PHYS_POS);
chartview.addChartObject(amarker);
rNumericLabelCntr += 1.0;
// Add a numeric label the identifies the marker
pointLabel = new StringLabel(getChartObjScale(),
textCoordsFont, name, nearestPoint
.getX(), nearestPoint.getY(), PHYS_POS,
DECIMALFORMAT, 0, 0.0);
pointLabel.setTextBoxColor(Color.WHITE);
pointLabel.setTextBgColor(Color.WHITE);
pointLabel.setTextBgMode(true);
// Nudge text to the right and up so that it does not write over marker
pointLabel.setTextNudge(5, -5);
chartview.addChartObject(pointLabel);
chartview.repaint();
}
Thanx - Joe!