Class PlotMouseHandler
- All Implemented Interfaces:
MouseListener,MouseMotionListener,MouseWheelListener,EventListener
PlotCanvas.
This class was extracted from PlotCanvas to keep that class
focused on coordinate geometry, painting, and data management. All
MouseListener, MouseMotionListener, and
MouseWheelListener logic lives here.
Responsibilities
- Legend and extra-text dragging (
mousePressed(java.awt.event.MouseEvent),mouseDragged(java.awt.event.MouseEvent),mouseReleased(java.awt.event.MouseEvent)) - Mouse-move feedback: coordinate readout, histogram bin info, XY curve
summaries, bar-plot hit testing, 2D histogram bin info
(
mouseMoved(java.awt.event.MouseEvent)) - Scroll-wheel zoom (
mouseWheelMoved(java.awt.event.MouseWheelEvent))
Canvas coupling
The handler holds a reference back to its owning PlotCanvas for
coordinate transforms, data access, and repaint requests. It does
not hold any state that could not be reconstructed from the
canvas.
- Author:
- heddle (original), refactored for extraction
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPlotMouseHandler(PlotCanvas canvas) Creates aPlotMouseHandlerbound to the given canvas. -
Method Summary
Modifier and TypeMethodDescriptionvoidNo action.voidHandles drag events: moves the legend or the extra-text label if either is in the "dragging" state.voidNo action.voidNo action.voidHandles mouse-move events, updating the feedback pane with coordinate readouts and curve-specific information.voidPrimes the legend or extra-text label for dragging when the pointer tool is active and the mouse is pressed inside one of them.voidEnds any active drag on mouse release.voidZooms the canvas in or out using the scroll wheel.
-
Constructor Details
-
PlotMouseHandler
Creates aPlotMouseHandlerbound to the given canvas.- Parameters:
canvas- the owningPlotCanvas(non-null)
-
-
Method Details
-
mouseDragged
Handles drag events: moves the legend or the extra-text label if either is in the "dragging" state.- Specified by:
mouseDraggedin interfaceMouseMotionListener- Parameters:
e- the mouse event
-
mouseMoved
Handles mouse-move events, updating the feedback pane with coordinate readouts and curve-specific information.Delegates to specialised private helpers depending on the current data type (2D histogram, bar plot, XY curves, 1D histogram).
- Specified by:
mouseMovedin interfaceMouseMotionListener- Parameters:
e- the mouse event
-
mousePressed
Primes the legend or extra-text label for dragging when the pointer tool is active and the mouse is pressed inside one of them.- Specified by:
mousePressedin interfaceMouseListener- Parameters:
e- the mouse event
-
mouseReleased
Ends any active drag on mouse release.- Specified by:
mouseReleasedin interfaceMouseListener- Parameters:
e- the mouse event
-
mouseClicked
No action.- Specified by:
mouseClickedin interfaceMouseListener
-
mouseEntered
No action.- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
No action.- Specified by:
mouseExitedin interfaceMouseListener
-
mouseWheelMoved
Zooms the canvas in or out using the scroll wheel.Base zoom factor is
1.12per notch. Holding Ctrl/Meta gives finer control (1.04); holding Shift gives coarser control (1.20). The computed factor is clamped to[0.2, 5.0]as a safety net against runaway zooming.- Specified by:
mouseWheelMovedin interfaceMouseWheelListener- Parameters:
e- the mouse-wheel event
-