ScaledGraphics : problem with Zoom [message #236372] |
Wed, 27 June 2007 01:05 |
Eclipse User |
|
|
|
Originally posted by: ben.tiscali.fr
Hi guys,
I have a problem with my source code. I can't write the whole code source
here cause 1)the code is very specific to my data, 2)my boss don't want to
:p
So i have a SystemeFigure class :
public class SystemeFigure extends Figure implements java.io.Serializable{
....
}
in which i put some kind of Shape (Rectangle or Ellipse).
I'm also able to move these shapes, or to detect when the mouse come in
(the "selected shape" change colour, and a tooltip appears).
It works well.
Now i'm trying to setup a zoom in order to scale the shapes. So i
redefined the method called paintClientArea (I have found this solution on
a website).
protected void paintClientArea(Graphics graphics) {
if (getChildren().isEmpty())
return;
boolean optimizeClip = getBorder() == null || getBorder().isOpaque();
ScaledGraphics g = new ScaledGraphics(graphics);
if (!optimizeClip)
g.clipRect(getBounds().getCropped(getInsets()));
g.translate(getBounds().x + getInsets().left, getBounds().y +
getInsets().top);
g.scale(zoom);
g.pushState();
paintChildren(g);
g.popState();
g.dispose();
graphics.restoreState();
}
It's almost work : when i click on ZoomIn or ZoomOut button, the size of
shapes increase (or decrase). But i can't anymore move them. The position
seems to be the same whereas it's not the same place (cause of zoom) at
screen. ToolTip confirm : they appears at the old position of the shape.
Any ideas ?
ps : sorry for my english
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03225 seconds