addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
super.mouseMoved(e);
Rect w = getModel().getDisplayRect();
getCCModel().updateView(
// (mapToScrX(w.getX()+w.getWidth())-mapToScrX(w.getX()))/w.getWidth(),
// (mapToScrY(w.getY()+w.getHeight())-mapToScrY(w.getY()))/w.getHeight()
getScreenWidth()/w.getWidth(),
getScreenHeight()/w.getHeight()
);
repaint();
}
});
addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if(!e.isControlDown()) {
double r = e.getWheelRotation();
r=0.10*r*(getModel().getDisplayRect().getWidth());
getModel().getDisplayRect().setX(getModel().getDisplayRect().getX()-r/2);
getModel().getDisplayRect().setY(getModel().getDisplayRect().getY()-r/2);
getModel().getDisplayRect().setWidth(getModel().getDisplayRect().getWidth()+r);
getModel().getDisplayRect().setHeight(getModel().getDisplayRect().getHeight()+r);
Rect w = getModel().getDisplayRect();
// System.out.print("scr: "+(mapToScrX(w.getX()+w.getWidth())-mapToScrX(w.getX())));
// System.out.println(" vp: "+w.getWidth());
getCCModel().updateView(
// (mapToScrX(w.getX()+w.getWidth())-mapToScrX(w.getX()))/w.getWidth(),
// (mapToScrY(w.getY()+w.getHeight())-mapToScrY(w.getY()))/w.getHeight()
getScreenWidth()/w.getWidth(),
getScreenHeight()/w.getHeight()
);
repaint();
}
}