- java.lang.Object
-
- ij.gui.Roi
-
- ij.gui.Line
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Point>
- Direct Known Subclasses:
Arrow
public class Line extends Roi
This class represents a straight line selection.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLine.PointIteratorDedicated point iterator for thin lines.
-
Field Summary
Fields Modifier and Type Field Description protected doublestartxdprotected doublestartydintx1doublex1dprotected doublex1Rintx2doublex2dprotected doublex2Rinty1doubley1dprotected doubley1Rinty2doubley2dprotected doubley2R-
Fields inherited from class ij.gui.Roi
ANGLE, asp_bk, aspect, cachedMask, center, clipboard, clipHeight, clipWidth, clipX, clipY, COMPOSITE, constrain, CONSTRUCTING, defaultColor, defaultFillColor, FERET_ARRAY_POINTOFFSET, FERET_ARRAYSIZE, fillColor, flattenScale, FREELINE, FREEROI, HANDLE_SIZE, handleColor, hyperstackPosition, ic, ignoreClipRect, imp, instanceColor, LINE, lineWidth, mag, MOVING, MOVING_HANDLE, nonScalable, NORMAL, NOT_PASTING, oldHeight, oldWidth, oldX, oldY, onePixelWide, OVAL, overlay, pasteMode, POINT, POLYGON, POLYLINE, previousRoi, RECTANGLE, RESIZING, ROIColor, stroke, strokeColor, TRACED_ROI, type, updateFullWindow, wideLine, xMax, yMax
-
-
Constructor Summary
Constructors Constructor Description 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(int ox1, int oy1, int ox2, int oy2)Creates a new straight line selection using the specified starting and ending offscreen integer coordinates.Line(int ox1, int oy1, int ox2, int oy2, ImagePlus imp)Deprecated.replaced by Line(int, int, int, int)Line(int sx, int sy, ImagePlus imp)Starts the process of creating a new user-generated straight line selection.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intclipRectMargin()booleancontains(int x, int y)Returns whether the center of pixel (x,y) is contained in the Roi.static Linecreate(double x1, double y1, double x2, double y2)Creates a new straight line selection using the specified starting and ending offscreen coordinates.voiddraw(Graphics g)Draws this line on the image.protected voiddrawLine(int sx, int sy)voiddrawPixels(ImageProcessor ip)If the width of this line is less than or equal to one, draws the line.doublegetAngle()Overridden by PolygonRoi (angle between first two points), TextRoi (text angle) and Line (line angle).FloatPolygongetFloatPoints()Returns, as a FloatPolygon, the two points that define this line.FloatPolygongetFloatPolygon()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.FloatPolygongetFloatPolygon(double strokeWidth)ObsoletedoublegetLength()Returns the length of this line.double[]getPixels()Returns the pixel values along this line.PolygongetPoints()Returns, as a Polygon, the two points that define this line.PolygongetPolygon()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.doublegetRawLength()Returns the length of this line in pixels.FloatPolygongetRotationCenter()static intgetWidth()Returns the default line width.protected voidgrow(int sx, int sy)protected voidhandleMouseDown(int sx, int sy)protected voidhandleMouseUp(int screenX, int screenY)intisHandle(int sx, int sy)Returns a handle number if the specified screen coordinates are inside or near a handle, otherwise returns -1.Iterator<Point>iterator()Required by theIterableinterface.protected voidmouseDownInHandle(int handle, int sx, int sy)voidmouseMoved(MouseEvent e)protected voidmoveHandle(int sx, int sy)voidnudgeCorner(int key)Nudge end point of line by one pixel.voidsetLocation(double x, double y)Sets the x coordinate of the leftmost and y coordinate of the topmost end pointvoidsetLocation(int x, int y)Set the location of the ROI in image coordinates.voidsetStrokeWidth(float width)Sets the width of the line used to draw this ROI.static voidsetWidth(int w)Sets the default line width.voidshowStatus()intsize()Returns the number of points in this selection; equivalent to getPolygon().npoints.booleansubPixelResolution()Always returns true.-
Methods inherited from class ij.gui.Roi
abortModification, abortPaste, addRoiListener, clone, containsPoint, convertLineToArea, convertToPolygon, copyAttributes, create, drawOverlay, drawPixels, enableSubPixelResolution, endPaste, equals, getAngle, getAntiAlias, getBoundingRect, getBounds, getColor, getContainedFloatPoints, getContainedPoints, getContourCentroid, getConvexHull, getCornerDiameter, getCPosition, getCurrentPasteMode, getDebugInfo, getDefaultFillColor, getDefaultGroup, getDefaultHandleSize, getDefaultStrokeWidth, getDrawOffset, getFeretsDiameter, getFeretValues, getFillColor, getFloatAngle, getFloatBounds, getFloatConvexHull, getFloatHeight, getFloatPolygon, getFloatWidth, getGroup, getGroupName, getGroupNames, getHandleSize, getHashCode, getImage, getImageID, getInterpolatedPolygon, getInterpolatedPolygon, getInterpolatedPolygon, getInverse, getListeners, getMagnification, getMask, getName, getPasteMode, getPosition, getPreviousRoi, getProperties, getProperty, getPropertyCount, getPrototypeOverlay, getRoundRectArcSize, getScaledStroke, getScaleStrokeWidth, getState, getStatistics, getStroke, getStrokeColor, getStrokeWidth, getTPosition, getType, getTypeAsString, getXBase, getYBase, getZPosition, handleMouseDrag, hasHyperStackPosition, isActiveOverlayRoi, isArea, isCursor, isDrawingTool, isInteger, isLine, isLineOrPoint, isVisible, lineCircleIntersection, magnificationForSubPixel, magnificationForSubPixel, mouseDragged, mouseReleased, notifyListeners, nudge, offScreenX, offScreenXD, offScreenY, offScreenYD, removeRoiListener, resetDefaultHandleSize, saveGroupNames, screenX, screenXD, screenY, screenYD, setAntiAlias, setBounds, setColor, setCornerDiameter, setDefaultColor, setDefaultFillColor, setDefaultGroup, setDefaultStrokeWidth, setDrawOffset, setFillColor, setFlattenScale, setGroup, setGroupName, setGroupNames, setHandleSize, setIgnoreClipRect, setImage, setInstanceColor, setIsCursor, setLineWidth, setName, setNonScalable, setPasteMode, setPosition, setPosition, setPosition, setPreviousRoi, setProperties, setProperty, setPrototypeOverlay, setRenderingHint, setRotationCenter, setRoundRectArcSize, setStroke, setStrokeColor, setStrokeWidth, setUnscalableStrokeWidth, startPaste, temporarilyHide, toFloat, toInt, toInt, toIntR, toString, translate, update, updateClipRect, updateWideLine, useLineSubpixelConvention, xor
-
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
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 Detail
-
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)Deprecated.replaced by Line(int, int, int, int)
-
-
Method Detail
-
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.
-
mouseMoved
public void mouseMoved(MouseEvent e)
- Overrides:
mouseMovedin classRoi
-
handleMouseUp
protected void handleMouseUp(int screenX, int screenY)- Overrides:
handleMouseUpin classRoi
-
drawLine
protected void drawLine(int sx, int sy)
-
moveHandle
protected void moveHandle(int sx, int sy)- Overrides:
moveHandlein classRoi
-
mouseDownInHandle
protected void mouseDownInHandle(int handle, int sx, int sy)- Overrides:
mouseDownInHandlein classRoi
-
showStatus
public void showStatus()
- Overrides:
showStatusin classRoi
-
getAngle
public double getAngle()
Description copied from class:RoiOverridden by PolygonRoi (angle between first two points), TextRoi (text angle) and Line (line angle).
-
getLength
public double getLength()
Returns the length of this line.
-
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 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 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.- Overrides:
getPolygonin classRoi- 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.- Overrides:
getFloatPolygonin classRoi- See Also:
getFloatPoints()
-
getFloatPolygon
public FloatPolygon getFloatPolygon(double strokeWidth)
Obsolete
-
size
public int size()
Returns the number of points in this selection; equivalent to getPolygon().npoints.
-
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.- Overrides:
drawPixelsin classRoi- See Also:
ImageProcessor.setColor(java.awt.Color),ImageProcessor.setLineWidth(int)
-
contains
public boolean contains(int x, int y)Description copied from class:RoiReturns 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.
-
handleMouseDown
protected void handleMouseDown(int sx, int sy)- Overrides:
handleMouseDownin classRoi
-
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.
-
getWidth
public static int getWidth()
Returns the default line width. Use getStrokeWidth()to get the width of a Line instance.- See Also:
Roi.getStrokeWidth()
-
setWidth
public static void setWidth(int w)
Sets the default line width. Use setStrokeWidth() to set the width of a Line instance.- See Also:
setStrokeWidth(float)
-
setStrokeWidth
public void setStrokeWidth(float width)
Description copied from class:RoiSets 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.- Overrides:
setStrokeWidthin classRoi- See Also:
Roi.setDefaultStrokeWidth(double),Roi.setUnscalableStrokeWidth(double),Roi.setStrokeColor(Color),ImagePlus.setOverlay(ij.gui.Overlay)
-
clipRectMargin
protected int clipRectMargin()
- Overrides:
clipRectMarginin classRoi
-
nudgeCorner
public void nudgeCorner(int key)
Nudge end point of line by one pixel.- Overrides:
nudgeCornerin classRoi
-
subPixelResolution
public boolean subPixelResolution()
Always returns true.- Overrides:
subPixelResolutionin classRoi
-
setLocation
public void setLocation(int x, int y)Description copied from class:RoiSet the location of the ROI in image coordinates.- Overrides:
setLocationin classRoi
-
setLocation
public void setLocation(double x, double y)Sets the x coordinate of the leftmost and y coordinate of the topmost end point- Overrides:
setLocationin classRoi
-
getRotationCenter
public FloatPolygon getRotationCenter()
- Overrides:
getRotationCenterin classRoi
-
iterator
public Iterator<Point> iterator()
Description copied from class:RoiRequired by theIterableinterface. Use to iterate over the contained coordinates. Usage example:for (Point p : roi) { // process p }Author: Wilhelm Burger- Specified by:
iteratorin interfaceIterable<Point>- Overrides:
iteratorin classRoi- See Also:
Roi.getContainedPoints(),Roi.getContainedFloatPoints()
-
-