/** * Determines the value of the z-section. * * @see MouseWheelListener#mouseWheelMoved(MouseWheelEvent) */ public void mouseWheelMoved(MouseWheelEvent e) { if (model.isBigImage()) return; if (e.isAltDown() || e.isShiftDown() || e.isControlDown()) { // zooming if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int v = e.getWheelRotation(); model.zoom(v < 0); // zoom in and out. } return; } // change the z-section. int maxZ = model.getMaxZ(); int maxT = model.getMaxT(); if (maxZ <= 0 && maxT <= 0) return; boolean up = true; if (e.getWheelRotation() > 0) up = false; if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int v = model.getDefaultZ() - e.getWheelRotation(); if (up) { if (v <= maxZ) { model.setSelectedXYPlane(v, -1); if (canvas instanceof BrowserBICanvas) ((BrowserBICanvas) canvas).setPaintedString(v, model.getDefaultT()); } else { if (canvas instanceof BrowserBICanvas) ((BrowserBICanvas) canvas).setPaintedString(-1, -1); } } else { // moving down if (v >= 0) { model.setSelectedXYPlane(v, -1); if (canvas instanceof BrowserBICanvas) ((BrowserBICanvas) canvas).setPaintedString(v, model.getDefaultT()); } else { if (canvas instanceof BrowserBICanvas) ((BrowserBICanvas) canvas).setPaintedString(-1, -1); } } } }
/** * Zooms in and out the image if the <code>Shift</code> key is down, pans if the <code>Alt</code> * key is down. Selects a new z-section and time-point otherwise. * * @see MouseMotionListener#mouseDragged(MouseEvent) */ public void mouseDragged(MouseEvent e) { Point p = e.getPoint(); if (handleKeyDown) { if (e.isShiftDown()) { if (model.isBigImage()) { pan(p, false); return; } if (p.y < pressedPoint.y) model.zoom(true); else if (p.y > pressedPoint.y) model.zoom(false); pressedPoint = p; return; } else if (e.isAltDown()) { pan(p, false); return; } } if (model.isBigImage()) { // panning pan(p, false); return; } int maxZ = model.getMaxZ(); int maxT = model.getMaxT(); if (maxZ <= 0 && maxT <= 0) return; int pressedZ = -1; int pressedT = -1; pressedZ = (p.y * maxZ) / area.height; if (pressedZ < 0) return; pressedZ = maxZ - pressedZ; if (pressedZ > maxZ) pressedZ = -1; pressedT = (p.x * maxT) / area.width; if (pressedT < 0) return; if (pressedT > maxT) return; model.setSelectedXYPlane(pressedZ, pressedT); if (canvas instanceof BrowserBICanvas) ((BrowserBICanvas) canvas).setPaintedString(pressedZ, pressedT); }