ij.gui
Class Line

java.lang.Object
  extended by ij.gui.AbstractRoi
      extended by ij.gui.AttributeRoi
          extended by ij.gui.Roi
              extended by ij.gui.Line
All Implemented Interfaces:
RoiBeans, RoiConstance, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Arrow

public class Line
extends Roi

This class represents a straight line selection.

See Also:
Serialized Form

Field Summary
protected  double startxd
           
protected  double startyd
           
 int x1
           
 double x1d
           
protected  double x1R
           
 int x2
           
 double x2d
           
protected  double x2R
           
 int y1
           
 double y1d
           
protected  double y1R
           
 int y2
           
 double y2d
           
protected  double y2R
           
 
Fields inherited from class ij.gui.Roi
asp_bk, aspect, cachedMask, center, clipboard, clipHeight, clipHeightd, clipWidth, clipWidthd, clipX, clipXd, clipY, clipYd, constrain, defaultFillColor, handleColor, ic, imageID, instanceColor, lineWidth, mag, nonScalable, oldHeight, oldHeightd, oldWidth, oldWidthd, oldX, oldXd, oldY, oldYd, onePixelWide, overlay, pasteMode, previousRoi, roundRect, updateFullWindow
 
Fields inherited from class ij.gui.AttributeRoi
drawDoubleClick, fillColor, fillDoubleClick, imp, ROIColor, stroke, strokeColor, type, wideLine, xMax, yMax
 
Fields inherited from interface ij.gui.RoiConstance
ADD_TO_ROI, ANGLE, COMPOSITE, CONSTRUCTING, DRAW_HANDLE, EVT_HANDLE_SIZE, FILL_HANDLE, FREELINE, FREEROI, HANDLE_SIZE, LINE, MOVING, MOVING_HANDLE, MOVING_ROUNDRECT_HANDLE, NO_MODS, NORMAL, NOT_PASTING, OVAL, POINT, POLYGON, POLYLINE, RECTANGLE, RESIZING, SUBTRACT_FROM_ROI, TRACED_ROI
 
Constructor Summary
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 sx, int sy, ImagePlus imp)
          Starts the process of creating a new user-generated straight line selection.
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)
 
Method Summary
protected  int clipRectMargin()
           
 boolean contains(int x, int y)
           
 void draw(java.awt.Graphics g)
          Draws this line on the image.
 void drawPixels(ImageProcessor ip)
          Draws the selection outline on the specified ImageProcessor.
 java.awt.Rectangle getBounds()
          Return the bounding rectangle of this line.
 double getLength()
          Returns the length of this line.
 double[] getPixels()
          Returns the pixel values along this line.
 java.awt.Polygon getPolygon()
          Returns the outline of this selection as a Polygon, or null if this is a straight line selection.
 double getRawLength()
          Returns the length of this line in pixels.
static int getWidth()
           
protected  void grow(int sx, int sy)
           
 int isHandle(int sx, int sy)
          Returns a handle number if the specified screen coordinates are inside or near a handle, otherwise returns -1.
protected  void mouseDownInHandle(int handle, int sx, int sy)
           
protected  void moveHandle(int sx, int sy)
           
 void nudgeCorner(int key)
          Nudge end point of line by one pixel.
 void setStrokeWidth(float width)
          Sets the width of the line used to draw this ROI.
static void setWidth(int w)
           
 
Methods inherited from class ij.gui.Roi
abortPaste, clone, drawfillOverlay, drawHandle, drawOverlay, drawPixels, drawPixels, drawRoiHandle, drawStroke, endPaste, equals, fillRoiHandle, getBoundingRect, getCornerDiameter, getCurrentPasteMode, getDrawOffset, getFloatBounds, getFloatPolygon, getHandleSize, getMagnification, getMask, getPasteMode, getPrototypeOverlay, getRoundRectArcSize, getScaledStroke, getState, getTypeAsString, handleMouseDown, handleMouseDrag, handleMouseUp, isArea, isDrawingTool, isLine, isVisible, nudge, screenX, screenXD, screenY, screenYD, setCornerDiameter, setDrawOffset, setImage, setInstanceColor, setLineWidth, setLocation, setNonScalable, setPasteMode, setPrototypeOverlay, setRoundRectArcSize, showStatus, startPaste, subPixelResolution, temporarilyHide, toFloat, toInt, toInt, toIntR, toString, update, updateClipRect, updateWideLine
 
Methods inherited from class ij.gui.AttributeRoi
copyAttributes, getAngle, getColor, getConvexHull, getCPosition, getDefaultFillColor, getFeretsDiameter, getFeretValues, getFillColor, getImage, getImageID, getName, getPosition, getStroke, getStrokeColor, getStrokeWidth, getTPosition, getType, getZPosition, setColor, setDefaultFillColor, setFillColor, setName, setPosition, setPosition, setStroke, setStrokeColor, setStrokeWidth
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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

grow

protected void grow(int sx,
                    int sy)
Overrides:
grow in class Roi

moveHandle

protected void moveHandle(int sx,
                          int sy)
Overrides:
moveHandle in class Roi

mouseDownInHandle

protected void mouseDownInHandle(int handle,
                                 int sx,
                                 int sy)
Overrides:
mouseDownInHandle in class Roi

draw

public void draw(java.awt.Graphics g)
Draws this line on the image.

Specified by:
draw in interface RoiBeans
Overrides:
draw in class Roi

getLength

public double getLength()
Returns the length of this line.

Specified by:
getLength in interface RoiBeans
Overrides:
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.


getPolygon

public java.awt.Polygon getPolygon()
Description copied from class: Roi
Returns the outline of this selection as a Polygon, or null if this is a straight line selection.

Specified by:
getPolygon in interface RoiBeans
Overrides:
getPolygon in class Roi
See Also:
ImageProcessor.setRoi(java.awt.Rectangle), ImageProcessor.drawPolygon(java.awt.Polygon), ImageProcessor.fillPolygon(java.awt.Polygon)

drawPixels

public void drawPixels(ImageProcessor ip)
Description copied from class: Roi
Draws the selection outline on the specified ImageProcessor.

Specified by:
drawPixels in interface RoiBeans
Overrides:
drawPixels in class Roi
See Also:
ImageProcessor.setColor(java.awt.Color), ImageProcessor.setLineWidth(int)

contains

public boolean contains(int x,
                        int y)
Specified by:
contains in interface RoiBeans
Overrides:
contains 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.

Specified by:
isHandle in interface RoiBeans
Overrides:
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: AttributeRoi
Sets the width of the line used to draw this ROI.

Specified by:
setStrokeWidth in interface RoiBeans
Overrides:
setStrokeWidth in class AttributeRoi
See Also:
AttributeRoi.setStrokeColor(Color), ImagePlus.setOverlay(ij.gui.Overlay)

getBounds

public java.awt.Rectangle getBounds()
Return the bounding rectangle of this line.

Specified by:
getBounds in interface RoiBeans
Overrides:
getBounds in class Roi

clipRectMargin

protected int clipRectMargin()
Overrides:
clipRectMargin in class Roi

nudgeCorner

public void nudgeCorner(int key)
Nudge end point of line by one pixel.

Specified by:
nudgeCorner in interface RoiBeans
Overrides:
nudgeCorner in class Roi