return _target;
}
public void paintComponent(Graphics g) {
if (_target != null) {
JCanvas canvas = null;
try {
canvas = (JCanvas) _target.getView();
} catch (ClassCastException ex) {
throw new RuntimeException("Failed to cast "
+ _target.getView() + " to JCanvas.", ex);
}
Dimension viewSize = canvas.getSize();
Rectangle viewRect = new Rectangle(0, 0, viewSize.width,
viewSize.height);
Rectangle myRect = _getInsetBounds();
AffineTransform forward = CanvasUtilities.computeFitTransform(
viewRect, myRect);
// Also invert the current transform on the canvas.
AffineTransform current = canvas.getCanvasPane()
.getTransformContext().getTransform();
AffineTransform inverse;
try {
inverse = forward.createInverse();
inverse.concatenate(current.createInverse());
} catch (NoninvertibleTransformException e) {
throw new RuntimeException(e.toString());
}
Graphics2D g2d = (Graphics2D) g;
g2d.transform(forward);
canvas.paint(g);
g.setColor(Color.red);
Rectangle r = _target.getViewRect();
g.drawRect(r.x, r.y, r.width, r.height);