コード例 #1
0
 private void kochPanelMouseClicked(MouseEvent event) {
   if (Math.abs(event.getX() - startPressedX) < 1.0
       && Math.abs(event.getY() - startPressedY) < 1.0) {
     double originalPointClickedX = (event.getX() - zoomTranslateX) / zoom;
     double originalPointClickedY = (event.getY() - zoomTranslateY) / zoom;
     if (event.getButton() == MouseButton.PRIMARY) {
       zoom *= 2.0;
     } else if (event.getButton() == MouseButton.SECONDARY) {
       zoom /= 2.0;
     }
     zoomTranslateX = (int) (event.getX() - originalPointClickedX * zoom);
     zoomTranslateY = (int) (event.getY() - originalPointClickedY * zoom);
     kochManager.drawEdges();
   }
 }
コード例 #2
0
 private void resetZoom() {
   int kpSize = Math.min(kpWidth, kpHeight);
   zoom = kpSize;
   zoomTranslateX = (kpWidth - kpSize) / 2.0;
   zoomTranslateY = (kpHeight - kpSize) / 2.0;
 }