Пример #1
0
 void ajustarYCentrar(JComponent porAjustar, JComponent ajustador) {
   // Se agregan 30 de alto y 6 de ancho por adornos de la ventana
   porAjustar.setSize(
       ajustador.getMinimumSize().getSize().width + 16,
       ajustador.getMinimumSize().getSize().height + 44);
   int x = Math.round(Principal.sysAncho / 2) - Math.round(porAjustar.getBounds().width / 2);
   int y = Math.round(Principal.sysAlto / 2) - Math.round(porAjustar.getBounds().height / 2);
   porAjustar.setLocation(x, y);
 }
Пример #2
0
 public void mouseDragged(
     ViewPanel v, int mod, int buttonNumber, int jpx, int jpy, MouseEvent e) {
   if (buttonNumber == 3 || ((mod == META_MOD || mod == META_SHIFT_MOD) && buttonNumber == 1)) {
     Camera c = application.vsm.getActiveCamera();
     double a = (c.focal + Math.abs(c.altitude)) / c.focal;
     if (mod == META_SHIFT_MOD) {
       application.cam.setXspeed(0);
       application.cam.setYspeed(0);
       application.cam.setZspeed(
           (c.altitude > 0)
               ? (long) ((lastJPY - jpy) * (a / 50.0f))
               : (long) ((lastJPY - jpy) / (a * 50)));
       // 50 is just a speed factor (too fast otherwise)
     } else {
       application.cam.setXspeed(
           (c.altitude > 0)
               ? (long) ((jpx - lastJPX) * (a / 50.0f))
               : (long) ((jpx - lastJPX) / (a * 50)));
       application.cam.setYspeed(
           (c.altitude > 0)
               ? (long) ((lastJPY - jpy) * (a / 50.0f))
               : (long) ((lastJPY - jpy) / (a * 50)));
       application.cam.setZspeed(0);
     }
   }
 }
Пример #3
0
 public void mouseWheelMoved(
     ViewPanel v, short wheelDirection, int jpx, int jpy, MouseWheelEvent e) {
   Camera c = application.vsm.getActiveCamera();
   double a = (c.focal + Math.abs(c.altitude)) / c.focal;
   if (wheelDirection == WHEEL_UP) {
     c.altitudeOffset(-a * 5);
     application.vsm.repaint();
   } else {
     // wheelDirection == WHEEL_DOWN
     c.altitudeOffset(a * 5);
     application.vsm.repaint();
   }
 }