JComponent comp = (JComponent) e.getComponent();
AffineTransform vt = canvas.viewTransform();
if (c == 'c' || c == 'C') {
Rectangle vb = comp.getBounds();
Rectangle2D db = canvas.dataBounds();
double xmargin = vb.width/vt.getScaleX()-db.getWidth();
double ymargin = vb.height/vt.getScaleY()-db.getHeight();
double tx = db.getMinX()-(xmargin/2);
double ty = db.getMinY()-(ymargin/2);