Class CursorOverlay

java.lang.Object
pl.polsl.rtsa.controller.CursorOverlay

public class CursorOverlay extends Object
Draws interactive cursor overlays on the time-domain plot.

Features:

  • Dashed crosshair lines at cursor position
  • Snap-to-signal: red dot when the cursor is close to the waveform
  • Tooltip with precise time and voltage values
  • Coordinate math matches TimeDomainRen exactly
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final javafx.scene.paint.Color
     
    private static final javafx.scene.paint.Color
     
    private static final double
     
    private static final javafx.scene.paint.Color
     
    private static final javafx.scene.paint.Color
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    drawCrosshair(javafx.scene.canvas.GraphicsContext gc, double x, double y, double ml, double mt, double pw, double ph)
    Draws a dashed crosshair (horizontal + vertical) through the given point.
    void
    drawTimeDomain(javafx.scene.canvas.GraphicsContext gc, double[] samples, double vMin, double vMax, double tStart, double tEnd, double sampleRate, double pw, double ph, double ml, double mt, double cx, double cy)
    Draw cursor overlay on the time-domain canvas.
    private void
    drawTooltip(javafx.scene.canvas.GraphicsContext gc, double x, double y, double ml, double mt, double pw, double ph, String line1, String line2)
    Draws a semi-transparent tooltip box with two text lines, clamped inside the plot area.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CROSSHAIR_COLOR

      private static final javafx.scene.paint.Color CROSSHAIR_COLOR
    • DOT_COLOR

      private static final javafx.scene.paint.Color DOT_COLOR
    • TOOLTIP_BG

      private static final javafx.scene.paint.Color TOOLTIP_BG
    • TOOLTIP_TEXT

      private static final javafx.scene.paint.Color TOOLTIP_TEXT
    • SNAP_DISTANCE

      private static final double SNAP_DISTANCE
      See Also:
  • Constructor Details

    • CursorOverlay

      public CursorOverlay()
  • Method Details

    • drawTimeDomain

      public void drawTimeDomain(javafx.scene.canvas.GraphicsContext gc, double[] samples, double vMin, double vMax, double tStart, double tEnd, double sampleRate, double pw, double ph, double ml, double mt, double cx, double cy)
      Draw cursor overlay on the time-domain canvas.
      Parameters:
      gc - graphics context (same as the canvas being drawn on)
      samples - voltage samples
      vMin - /vMax visible voltage range (V)
      tStart - /tEnd visible time range (s)
      sampleRate - sampling rate (Hz)
      pw - plot-area width (px, excluding margins)
      ph - plot-area height (px, excluding margins)
      ml - left margin (px)
      mt - top margin (px)
      cx - cursor X in canvas coordinates
      cy - cursor Y in canvas coordinates
    • drawCrosshair

      private void drawCrosshair(javafx.scene.canvas.GraphicsContext gc, double x, double y, double ml, double mt, double pw, double ph)
      Draws a dashed crosshair (horizontal + vertical) through the given point.
      Parameters:
      gc - graphics context
      x - crosshair centre X (canvas coordinates)
      y - crosshair centre Y (canvas coordinates)
      ml - left margin (px)
      mt - top margin (px)
      pw - plot width (px)
      ph - plot height (px)
    • drawTooltip

      private void drawTooltip(javafx.scene.canvas.GraphicsContext gc, double x, double y, double ml, double mt, double pw, double ph, String line1, String line2)
      Draws a semi-transparent tooltip box with two text lines, clamped inside the plot area.
      Parameters:
      gc - graphics context
      x - anchor X position
      y - anchor Y position
      ml - left margin (px)
      mt - top margin (px)
      pw - plot width (px)
      ph - plot height (px)
      line1 - first text line (e.g. time)
      line2 - second text line (e.g. voltage)