Module ij
Package ij.gui

Class Line

All Implemented Interfaces:, java.lang.Cloneable, java.lang.Iterable<java.awt.Point>
Direct Known Subclasses:

public class Line
extends Roi
This class represents a straight line selection.
See Also:
Serialized Form
  • Field Details

    • x1

      public int x1
    • y1

      public int y1
    • x2

      public int x2
    • y2

      public int y2
    • x1d

      public double x1d
    • y1d

      public double y1d
    • x2d

      public double x2d
    • y2d

      public double y2d
    • x1R

      protected double x1R
    • y1R

      protected double y1R
    • x2R

      protected double x2R
    • y2R

      protected double y2R
    • startxd

      protected double startxd
    • startyd

      protected double startyd
  • Constructor Details

    • Line

      public Line​(int ox1, int oy1, int ox2, int oy2)
      Creates a new straight line selection using the specified starting and ending offscreen integer coordinates.
    • Line

      public Line​(double ox1, double oy1, double ox2, double oy2)
      Creates a new straight line selection using the specified starting and ending offscreen double coordinates.
    • Line

      public Line​(int sx, int sy, ImagePlus imp)
      Starts the process of creating a new user-generated straight line selection. 'sx' and 'sy' are screen coordinates that specify the start of the line. The user will determine the end of the line interactively using rubber banding.
    • Line

      public Line​(int ox1, int oy1, int ox2, int oy2, ImagePlus imp)
      replaced by Line(int, int, int, int)
  • Method Details

    • create

      public static Line create​(double x1, double y1, double x2, double y2)
      Creates a new straight line selection using the specified starting and ending offscreen coordinates.
    • grow

      protected void grow​(int sx, int sy)
      grow in class Roi
    • mouseMoved

      public void mouseMoved​(java.awt.event.MouseEvent e)
      mouseMoved in class Roi
    • handleMouseUp

      protected void handleMouseUp​(int screenX, int screenY)
      handleMouseUp in class Roi
    • drawLine

      protected void drawLine​(int sx, int sy)
    • moveHandle

      protected void moveHandle​(int sx, int sy)
      moveHandle in class Roi
    • mouseDownInHandle

      protected void mouseDownInHandle​(int handle, int sx, int sy)
      mouseDownInHandle in class Roi
    • draw

      public void draw​(java.awt.Graphics g)
      Draws this line on the image.
      draw in class Roi
    • showStatus

      public void showStatus()
      showStatus in class Roi
    • getAngle

      public double getAngle()
      Description copied from class: Roi
      Overridden by PolygonRoi (angle between first two points), TextRoi (text angle) and Line (line angle).
      getAngle in class Roi
    • getLength

      public double getLength()
      Returns the length of this line.
      getLength in class Roi
    • getRawLength

      public double getRawLength()
      Returns the length of this line in pixels.
    • getPixels

      public double[] getPixels()
      Returns the pixel values along this line. The line roi must have an associated ImagePlus
    • getPoints

      public java.awt.Polygon getPoints()
      Returns, as a Polygon, the two points that define this line.
    • getFloatPoints

      public FloatPolygon getFloatPoints()
      Returns, as a FloatPolygon, the two points that define this line.
    • getPolygon

      public java.awt.Polygon getPolygon()
      If the width of this line is less than or equal to one, returns the starting and ending coordinates as a 2-point Polygon, or, if the width is greater than one, returns an outline of the line as a 4-point Polygon.
      getPolygon in class Roi
      See Also:
      getFloatPolygon(), getPoints()
    • getFloatPolygon

      public FloatPolygon getFloatPolygon()
      If the width of this line is less than or equal to one, returns the starting and ending coordinates as a 2-point FloatPolygon, or, if the width is greater than one, returns an outline of the line as a 4-point FloatPolygon.
      getFloatPolygon in class Roi
      See Also:
    • getFloatPolygon

      public FloatPolygon getFloatPolygon​(double strokeWidth)
    • size

      public int size()
      Returns the number of points in this selection; equivalent to getPolygon().npoints.
      size in class Roi
    • drawPixels

      public void drawPixels​(ImageProcessor ip)
      If the width of this line is less than or equal to one, draws the line. Otherwise draws the outline of the area of this line
      drawPixels in class Roi
      See Also:
      ImageProcessor.setColor(java.awt.Color), ImageProcessor.setLineWidth(int)
    • contains

      public boolean contains​(int x, int y)
      Description copied from class: Roi
      Returns whether the center of pixel (x,y) is contained in the Roi. The position of a pixel center determines whether a pixel is selected. Points exactly at the left (right) border are considered outside (inside); points exactly on horizontal borders are considered outside (inside) at the border with the lower (higher) y. This convention is opposite to that of the java.awt.Shape class.
      contains in class Roi
    • handleMouseDown

      protected void handleMouseDown​(int sx, int sy)
      handleMouseDown in class Roi
    • isHandle

      public int isHandle​(int sx, int sy)
      Returns a handle number if the specified screen coordinates are inside or near a handle, otherwise returns -1.
      isHandle in class Roi
    • getWidth

      public static int getWidth()
    • setWidth

      public static void setWidth​(int w)
    • setStrokeWidth

      public void setStrokeWidth​(float width)
      Description copied from class: Roi
      Sets the width of the line used to draw this ROI. Set the width to 0.0 and the ROI will be drawn using a a 1 pixel stroke width regardless of the magnification.
      setStrokeWidth in class Roi
      See Also:
      Roi.setDefaultStrokeWidth(double), Roi.setStrokeColor(Color), ImagePlus.setOverlay(ij.gui.Overlay)
    • clipRectMargin

      protected int clipRectMargin()
      clipRectMargin in class Roi
    • nudgeCorner

      public void nudgeCorner​(int key)
      Nudge end point of line by one pixel.
      nudgeCorner in class Roi
    • subPixelResolution

      public boolean subPixelResolution()
      Always returns true.
      subPixelResolution in class Roi
    • setLocation

      public void setLocation​(int x, int y)
      Description copied from class: Roi
      Set the location of the ROI in image coordinates.
      setLocation in class Roi
    • setLocation

      public void setLocation​(double x, double y)
      Sets the x coordinate of the leftmost and y coordinate of the topmost end point
      setLocation in class Roi
    • getRotationCenter

      public FloatPolygon getRotationCenter()
      getRotationCenter in class Roi
    • iterator

      public java.util.Iterator<java.awt.Point> iterator()
      Description copied from class: Roi
      Required by the Iterable interface. Use to iterate over the contained coordinates. Usage example:
       for (Point p : roi) {
         // process p
      Author: Wilhelm Burger
      Specified by:
      iterator in interface java.lang.Iterable<java.awt.Point>
      iterator in class Roi
      See Also:
      Roi.getContainedPoints(), Roi.getContainedFloatPoints()