}
@Override
public void paint(Graphics2D graphics) {
// Determine the paint bounds
Bounds paintBounds = new Bounds(0, 0, getWidth(), getHeight());
Rectangle clipBounds = graphics.getClipBounds();
if (clipBounds != null) {
paintBounds = paintBounds.intersect(new Bounds(clipBounds));
}
for (NodeView nodeView : nodeViews) {
Bounds nodeViewBounds = nodeView.getBounds();
// Only paint node views that intersect the current clip rectangle
if (nodeViewBounds.intersects(paintBounds)) {
// Create a copy of the current graphics context and
// translate to the node view's coordinate system
Graphics2D nodeViewGraphics = (Graphics2D)graphics.create();
nodeViewGraphics.translate(nodeViewBounds.x, nodeViewBounds.y);