It's true. Once one of these is in place, adding custom functionality becomes really simple. Check out this idea I had for highlighting the xTraced data points:

To do this, I added a custom method to the xTrace Pane called paintDataHighlights
:
def paintDataHighlights(self, graphics, entities):
from java.awt import BasicStroke
graphics.stroke = BasicStroke(4)
for entity in entities:
graphics.color = system.gui.color(255, 255, 0, 100)
if entity.size:
graphics.fillRect(entity.location.x, entity.location.y, entity.size.width, entity.size.height)
graphics.color = entity.foreground
graphics.drawRect(entity.location.x, entity.location.y, entity.size.width, entity.size.height)
else:
ovalRadius = 6
ovalDianmeter = 2 * ovalRadius
graphics.fillOval(entity.location.x - ovalRadius, entity.location.y - ovalRadius, ovalDianmeter, ovalDianmeter)
graphics.color = entity.foreground
graphics.drawOval(entity.location.x - ovalRadius, entity.location.y - ovalRadius, ovalDianmeter, ovalDianmeter)
Then, I added a size parameter to the xtraceLabel
class in the getXTraceLabels
custom method:
from java.awt import Point # for storing coordinate data
from java.awt import Dimension # For storing length and width properties
# Create a class to package up all the information into easy to use fields
class xtraceLabel():
def __init__(self, text, foreground, location, size):
self.text = text
self.foreground = foreground
self.location = location
self.size = size
Additionally, the xTraceLabels.append
line at the end of the method was changed in the following way:
# Don't store dimensional data for points
if hasattr(entity.area, 'currentPoint'):
size = None
# Store the height and widht of each bar chart bar
else:
size = Dimension(int(entity.area.width), int(entity.area.height))
# Create an instance of the xtraceLabel class, store the extrapolated data in it, and add it to the labels list
xTraceLabels.append(xtraceLabel(text, foreground, location, size))
Finally, this line of code was added just before the paintXTraceLabel
call in the repaint event handler to call the paintDataHighlights
custom method:
event.source.paintDataHighlights(event.graphics, plotLabels)