java.lang.Object
io.github.jspinak.brobot.tools.history.draw.DrawLine

@Component public class DrawLine extends Object
Utility for drawing straight lines on images.

DrawLine provides flexible line drawing capabilities for creating connections, boundaries, and visual indicators on screenshots and visualizations. Unlike DrawArrow, these lines have no directional indicators, making them suitable for showing relationships, boundaries, or general connections.

Visual Output Structure:

  • Straight line between two points
  • Customizable thickness (1-10+ pixels typical)
  • Various line types (solid, anti-aliased)
  • No directional indicators or endpoints

Configuration Parameters:

  • Thickness: Customizable line width in pixels
  • Line type: 8 (anti-aliased), 4 (4-connected), 16 (anti-aliased)
  • Shift: Fractional bits for sub-pixel precision (typically 0)
  • Color: Fully customizable BGR color values

Use Cases:

  • Drawing borders around regions of interest
  • Connecting related UI elements visually
  • Creating grid lines or visual guides
  • Drawing histogram bars (as in DrawHistogram)
  • Showing non-directional relationships between points
  • Creating custom shapes by combining multiple lines

Relationships:

  • Complements DrawArrow for non-directional connections
  • Used by DrawHistogram to create vertical bars
  • Often combined with DrawPoint to connect marked locations
  • Works with both Location and Point for coordinate flexibility
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    draw(org.bytedeco.opencv.opencv_core.Mat scene, Location start, Location end, org.bytedeco.opencv.opencv_core.Scalar color, int thickness, int lineType, int shift)
    Draws a line between two Location objects.
    void
    draw(org.bytedeco.opencv.opencv_core.Mat scene, org.bytedeco.opencv.opencv_core.Point start, org.bytedeco.opencv.opencv_core.Point end, org.bytedeco.opencv.opencv_core.Scalar color, int thickness, int lineType, int shift)
    Draws a line between two Point objects.

    Methods inherited from class java.lang.Object

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

    • DrawLine

      public DrawLine()
  • Method Details

    • draw

      public void draw(org.bytedeco.opencv.opencv_core.Mat scene, Location start, Location end, org.bytedeco.opencv.opencv_core.Scalar color, int thickness, int lineType, int shift)
      Draws a line between two Location objects.

      Creates a straight line from start to end using Location objects, which automatically handle coordinate calculations. This method is convenient when working with Brobot's Location-based coordinate system.

      Line Type Options:

      • 4: 4-connected line (faster, less smooth)
      • 8: 8-connected line (default, good quality)
      • 16: Anti-aliased line (LINE_AA, smoothest)
      Parameters:
      scene - the background Mat to draw on, typically a screenshot
      start - the starting location of the line
      end - the ending location of the line
      color - the line color in BGR format (e.g., new Scalar(0,255,0) for green)
      thickness - the line thickness in pixels (1 for thin, 5+ for bold)
      lineType - the algorithm for line drawing (4, 8, or 16/LINE_AA)
      shift - number of fractional bits in coordinates (0 for integer precision)
    • draw

      public void draw(org.bytedeco.opencv.opencv_core.Mat scene, org.bytedeco.opencv.opencv_core.Point start, org.bytedeco.opencv.opencv_core.Point end, org.bytedeco.opencv.opencv_core.Scalar color, int thickness, int lineType, int shift)
      Draws a line between two Point objects.

      Direct OpenCV Point-based line drawing for when you have exact pixel coordinates. This overload bypasses Location calculations for maximum performance and precision.

      Common Usage Patterns:

      • Thickness 1-2: Thin lines for subtle connections
      • Thickness 3-5: Standard lines for clear visibility
      • Thickness 6+: Bold lines for emphasis
      • LineType 8: Standard quality for most uses
      • LineType 16: When smooth anti-aliasing is needed
      Parameters:
      scene - the background Mat to draw on
      start - the exact starting point coordinates
      end - the exact ending point coordinates
      color - the line color in BGR format
      thickness - the line thickness in pixels
      lineType - the line drawing algorithm
      shift - fractional bits (typically 0)