• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is there a better way of zooming

 
Kieran Murray
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,

The code below zooms OK but the cursor position and the object being moved quickly move out of sychronisation.

Is there a better way of doing this.

The value of the integer p comes from the user and then the canvas zooms up.

public void zoomup(int p) {
// This keeps the center of the component in place.
cx = this.getWidth() / 2;
cy = this.getHeight() / 2;
at.setToTranslation(cx, cy); //Reset atf
at.scale(p, p);
at.translate(-cx, -cy);
repaint();
}

Kind regards,

Kieran
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!