Package ij.gui
Class TextRoi
- java.lang.Object
-
- ij.gui.Roi
-
- ij.gui.TextRoi
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Point>
public class TextRoi extends Roi
This class is a rectangular ROI containing text.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intCENTERstatic intLEFTstatic intRIGHT-
Fields inherited from class ij.gui.Roi
ANGLE, asp_bk, aspect, cachedMask, center, clipboard, clipHeight, clipWidth, clipX, clipY, COMPOSITE, constrain, CONSTRUCTING, FERET_ARRAY_POINTOFFSET, FERET_ARRAYSIZE, fillColor, flattenScale, FREELINE, FREEROI, HANDLE_SIZE, handleColor, 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, RECTANGLE, RESIZING, ROIColor, stroke, strokeColor, TRACED_ROI, type, updateFullWindow, wideLine, xMax, yMax
-
-
Constructor Summary
Constructors Constructor Description TextRoi(double x, double y, double width, double height, String text, Font font)Creates a TextRoi using the specified sub-pixel location, size and Font.TextRoi(double x, double y, String text)Creates a TextRoi using sub-pixel coordinates.TextRoi(double x, double y, String text, Font font)Creates a TextRoi using the specified sub-pixel location and Font.TextRoi(int x, int y, ImagePlus imp)TextRoi(int x, int y, String text)Creates a TextRoi.TextRoi(int x, int y, String text, Font font)Creates a TextRoi using the specified location and Font.TextRoi(int x, int y, String text, Font font, Color color)Deprecated.TextRoi(String text, double x, double y, Font font)Use this constructor as a drop-in replacement for ImageProcessor.drawString().
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddChar(char c)This method is used by the text tool to add typed characters to displayed text selections.voidclear(ImageProcessor ip)Objectclone()Returns a copy of this TextRoi.voiddraw(Graphics g)Draws the text on the screen, clipped to the ROI.voiddrawOverlay(Graphics g)voiddrawPixels(ImageProcessor ip)Renders the text on the image.doublegetAngle()Overridden by PolygonRoi (angle between first two points), TextRoi (text angle) and Line (line angle).booleangetAntialiased()Returns the state of the 'antiAlias' instance variable.FontgetCurrentFont()Returns the current (instance) font.static StringgetDefaultFontName()Returns the name of the default font.static intgetDefaultFontSize()Returns the default font size.static intgetDefaultFontStyle()Returns the default font style.booleangetDrawStringMode()static StringgetFont()Deprecated.Replaced by getDefaultFontNamestatic intgetGlobalJustification()Returns the global (default) justification (LEFT, CENTER or RIGHT).intgetJustification()Returns the value of the 'justification' instance variable (LEFT, CENTER or RIGHT).StringgetMacroCode(String cmd, ImagePlus imp)Used by the Recorder for recording the text tool.static intgetSize()Deprecated.Replaced by getDefaultFontSizestatic intgetStyle()Deprecated.Replaced by getDefaultFontStyleStringgetText()protected voidhandleMouseUp(int screenX, int screenY)static booleanisAntialiased()Returns the state of the global 'antialiasedText' variable, which is used by the "Fonts" widget.booleanisDrawingTool()Returns 'true' if this is an ROI primarily used from drawing (e.g., TextRoi or Arrow).voidsetAngle(double angle)voidsetAntialiased(boolean antiAlias)Sets the 'antiAlias' instance variable.static voidsetAntialiasedText(boolean antialiased)Sets the state of the global 'antialiasedText' variable.voidsetCurrentFont(Font font)Set the current (instance) font.static voidsetDefaultAngle(double angle)Sets the default angle.static voidsetDefaultFillColor(Color fillColor)Sets the default fill (background) color.voidsetDrawStringMode(boolean drawStringMode)static voidsetFont(String fontName, int fontSize, int fontStyle)Sets the global font face, size and style that will be used by TextROIs interactively created using the text tool.static voidsetFont(String fontName, int fontSize, int fontStyle, boolean antialiased)Sets the font face, size, style and antialiasing mode that will be used by TextROIs interactively created using the text tool.static voidsetGlobalJustification(int justification)Sets the 'justification' instance variable (must be LEFT, CENTER or RIGHT)voidsetJustification(int justification)Sets the 'justification' instance variable (must be LEFT, CENTER or RIGHT)voidsetPreviousRoi(Roi previousRoi)-
Methods inherited from class ij.gui.Roi
abortModification, abortPaste, addRoiListener, clipRectMargin, contains, containsPoint, convertToPolygon, copyAttributes, drawPixels, enableSubPixelResolution, endPaste, equals, getAngle, getAntiAlias, getBoundingRect, getBounds, getColor, getContainedFloatPoints, getContainedPoints, getContourCentroid, getConvexHull, getCornerDiameter, getCPosition, getCurrentPasteMode, getDebugInfo, getDefaultFillColor, getDrawOffset, getFeretsDiameter, getFeretValues, getFillColor, getFloatAngle, getFloatBounds, getFloatConvexHull, getFloatHeight, getFloatPolygon, getFloatPolygon, getFloatWidth, getHashCode, getImage, getImageID, getInterpolatedPolygon, getInterpolatedPolygon, getInterpolatedPolygon, getInverse, getLength, getMagnification, getMask, getName, getPasteMode, getPolygon, getPosition, getProperties, getProperty, getPropertyCount, getPrototypeOverlay, getRotationCenter, getRoundRectArcSize, getScaledStroke, getState, getStatistics, getStroke, getStrokeColor, getStrokeWidth, getTPosition, getType, getTypeAsString, getXBase, getYBase, getZPosition, grow, handleMouseDown, handleMouseDrag, hasHyperStackPosition, isActiveOverlayRoi, isArea, isCursor, isHandle, isInteger, isLine, isVisible, iterator, lineCircleIntersection, mouseDownInHandle, mouseDragged, mouseMoved, mouseReleased, moveHandle, notifyListeners, nudge, nudgeCorner, removeRoiListener, screenX, screenXD, screenY, screenYD, setAntiAlias, setColor, setCornerDiameter, setDrawOffset, setFillColor, setFlattenScale, setIgnoreClipRect, setImage, setInstanceColor, setIsCursor, setLineWidth, setLocation, setLocation, setName, setNonScalable, setPasteMode, setPosition, setPosition, setPosition, setProperties, setProperty, setPrototypeOverlay, setRenderingHint, setRotationCenter, setRoundRectArcSize, setStroke, setStrokeColor, setStrokeWidth, setStrokeWidth, showStatus, size, startPaste, subPixelResolution, temporarilyHide, toFloat, toInt, toInt, toIntR, toString, update, updateClipRect, updateWideLine
-
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
-
LEFT
public static final int LEFT
- See Also:
- Constant Field Values
-
CENTER
public static final int CENTER
- See Also:
- Constant Field Values
-
RIGHT
public static final int RIGHT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TextRoi
public TextRoi(int x, int y, String text)Creates a TextRoi.
-
TextRoi
public TextRoi(String text, double x, double y, Font font)
Use this constructor as a drop-in replacement for ImageProcessor.drawString().
-
TextRoi
public TextRoi(double x, double y, String text)Creates a TextRoi using sub-pixel coordinates.
-
TextRoi
public TextRoi(int x, int y, String text, Font font)Creates a TextRoi using the specified location and Font.
-
TextRoi
public TextRoi(double x, double y, String text, Font font)Creates a TextRoi using the specified sub-pixel location and Font.
-
TextRoi
public TextRoi(double x, double y, double width, double height, String text, Font font)Creates a TextRoi using the specified sub-pixel location, size and Font.
-
TextRoi
public TextRoi(int x, int y, ImagePlus imp)
-
-
Method Detail
-
addChar
public void addChar(char c)
This method is used by the text tool to add typed characters to displayed text selections.
-
drawPixels
public void drawPixels(ImageProcessor ip)
Renders the text on the image.- Overrides:
drawPixelsin classRoi- See Also:
ImageProcessor.setColor(java.awt.Color),ImageProcessor.setLineWidth(int)
-
draw
public void draw(Graphics g)
Draws the text on the screen, clipped to the ROI.
-
drawOverlay
public void drawOverlay(Graphics g)
- Overrides:
drawOverlayin classRoi
-
getDefaultFontName
public static String getDefaultFontName()
Returns the name of the default font. Use getCurrentFont().getName() to get the name of the font that this TextRoi is using.
-
getDefaultFontSize
public static int getDefaultFontSize()
Returns the default font size. Use getCurrentFont().getSize() to get the size of the font that this TextRoi is using.
-
getDefaultFontStyle
public static int getDefaultFontStyle()
Returns the default font style. Use getCurrentFont().getStyle() to get the style of the font that this TextRoi is using.
-
setCurrentFont
public void setCurrentFont(Font font)
Set the current (instance) font.
-
getCurrentFont
public Font getCurrentFont()
Returns the current (instance) font.
-
isAntialiased
public static boolean isAntialiased()
Returns the state of the global 'antialiasedText' variable, which is used by the "Fonts" widget.
-
setAntialiasedText
public static void setAntialiasedText(boolean antialiased)
Sets the state of the global 'antialiasedText' variable.
-
setAntialiased
public void setAntialiased(boolean antiAlias)
Sets the 'antiAlias' instance variable.
-
getAntialiased
public boolean getAntialiased()
Returns the state of the 'antiAlias' instance variable.
-
setGlobalJustification
public static void setGlobalJustification(int justification)
Sets the 'justification' instance variable (must be LEFT, CENTER or RIGHT)
-
getGlobalJustification
public static int getGlobalJustification()
Returns the global (default) justification (LEFT, CENTER or RIGHT).
-
setJustification
public void setJustification(int justification)
Sets the 'justification' instance variable (must be LEFT, CENTER or RIGHT)
-
getJustification
public int getJustification()
Returns the value of the 'justification' instance variable (LEFT, CENTER or RIGHT).
-
setFont
public static void setFont(String fontName, int fontSize, int fontStyle)
Sets the global font face, size and style that will be used by TextROIs interactively created using the text tool.
-
setFont
public static void setFont(String fontName, int fontSize, int fontStyle, boolean antialiased)
Sets the font face, size, style and antialiasing mode that will be used by TextROIs interactively created using the text tool.
-
setDefaultFillColor
public static void setDefaultFillColor(Color fillColor)
Sets the default fill (background) color.
-
setDefaultAngle
public static void setDefaultAngle(double angle)
Sets the default angle.
-
handleMouseUp
protected void handleMouseUp(int screenX, int screenY)- Overrides:
handleMouseUpin classRoi
-
getMacroCode
public String getMacroCode(String cmd, ImagePlus imp)
Used by the Recorder for recording the text tool.
-
getText
public String getText()
-
isDrawingTool
public boolean isDrawingTool()
Description copied from class:RoiReturns 'true' if this is an ROI primarily used from drawing (e.g., TextRoi or Arrow).- Overrides:
isDrawingToolin classRoi
-
clear
public void clear(ImageProcessor ip)
-
getAngle
public double getAngle()
Description copied from class:RoiOverridden by PolygonRoi (angle between first two points), TextRoi (text angle) and Line (line angle).
-
setAngle
public void setAngle(double angle)
-
getDrawStringMode
public boolean getDrawStringMode()
-
setDrawStringMode
public void setDrawStringMode(boolean drawStringMode)
-
setPreviousRoi
public void setPreviousRoi(Roi previousRoi)
-
getFont
public static String getFont()
Deprecated.Replaced by getDefaultFontName
-
getSize
public static int getSize()
Deprecated.Replaced by getDefaultFontSize
-
getStyle
public static int getStyle()
Deprecated.Replaced by getDefaultFontStyle
-
-