Module ij
Package ij.gui

Class TextRoi

java.lang.Object
ij.gui.Roi
ij.gui.TextRoi
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<java.awt.Point>

public class TextRoi
extends Roi
This class is a rectangular ROI containing text.
See Also:
Serialized Form
  • Field Details

  • Constructor Details

    • TextRoi

      public TextRoi​(int x, int y, java.lang.String text)
      Creates a TextRoi using the defaultFont.
    • TextRoi

      public TextRoi​(java.lang.String text, double x, double y, java.awt.Font font)
      Use this constructor as a drop-in replacement for ImageProcessor.drawString().
    • TextRoi

      public TextRoi​(double x, double y, java.lang.String text)
      Creates a TextRoi using sub-pixel coordinates.
    • TextRoi

      public TextRoi​(int x, int y, java.lang.String text, java.awt.Font font)
      Creates a TextRoi using the specified location and Font.
      See Also:
      Roi.setStrokeColor(java.awt.Color), Roi.setNonScalable(boolean), ImagePlus.setOverlay(ij.gui.Overlay)
    • TextRoi

      public TextRoi​(double x, double y, java.lang.String text, java.awt.Font font)
      Creates a TextRoi using the specified sub-pixel location and Font.
    • TextRoi

      public TextRoi​(double x, double y, double width, double height, java.lang.String text, java.awt.Font font)
      Creates a TextRoi using the specified sub-pixel location, size and Font.
    • TextRoi

      public TextRoi​(int x, int y, java.lang.String text, java.awt.Font font, java.awt.Color color)
      Deprecated.
    • TextRoi

      public TextRoi​(int x, int y, ImagePlus imp)
  • Method Details

    • create

      public static TextRoi create​(java.lang.String text, double x, double y, java.awt.Font font)
      Creates a TextRoi using the specified text and location.
    • create

      public static TextRoi create​(double x, double y, java.lang.String text, java.awt.Font font)
      Obsolete.
    • 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. Draws the text in the foreground color if ip.setColor(Color) has not been called.
      Overrides:
      drawPixels in class Roi
      See Also:
      ImageProcessor.setFont(Font), ImageProcessor.setAntialiasedText(boolean), ImageProcessor.setColor(Color)
    • draw

      public void draw​(java.awt.Graphics g)
      Draws the text on the screen, clipped to the ROI.
      Overrides:
      draw in class Roi
    • drawOverlay

      public void drawOverlay​(java.awt.Graphics g)
      Overrides:
      drawOverlay in class Roi
    • getDefaultFontName

      public static java.lang.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.
    • setFont

      public void setFont​(java.awt.Font font)
      Sets the current font.
    • setFontSize

      public void setFontSize​(int size)
      Sets the size of the current font.
    • getCurrentFont

      public java.awt.Font getCurrentFont()
      Returns the current 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 default text tool justification (LEFT, CENTER or RIGHT).
    • getGlobalJustification

      public static int getGlobalJustification()
      Returns the default text tool justification (LEFT, CENTER or RIGHT).
    • setJustification

      public void setJustification​(int justification)
      Sets the 'justification' instance variable (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​(java.lang.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​(java.lang.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.
    • setDefaultFont

      public static void setDefaultFont​(java.awt.Font font)
      Sets the default font.
    • setDefaultFontSize

      public static void setDefaultFontSize​(int size)
      Sets the default font size.
    • setDefaultFillColor

      public static void setDefaultFillColor​(java.awt.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:
      handleMouseUp in class Roi
    • getMacroCode

      public java.lang.String getMacroCode​(java.lang.String cmd, ImagePlus imp)
      Used by the Recorder for recording the text tool.
    • getText

      public java.lang.String getText()
    • setText

      public void setText​(java.lang.String text)
    • isDrawingTool

      public boolean isDrawingTool()
      Description copied from class: Roi
      Returns 'true' if this is an ROI primarily used from drawing (e.g., TextRoi or Arrow).
      Overrides:
      isDrawingTool in class Roi
    • clear

      public void clear​(ImageProcessor ip)
    • setLocation

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

      public java.lang.Object clone()
      Returns a copy of this TextRoi.
      Overrides:
      clone 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).
      Overrides:
      getAngle in class Roi
    • setAngle

      public void setAngle​(double angle)
    • getDrawStringMode

      public boolean getDrawStringMode()
    • setDrawStringMode

      public void setDrawStringMode​(boolean drawStringMode)
    • setPreviousTextRoi

      public void setPreviousTextRoi​(Roi previousRoi)
    • getFont

      public static java.lang.String getFont()
      Deprecated.
      Replaced by getDefaultFontName
    • getSize

      public static int getSize()
      Deprecated.
      Replaced by getDefaultFontSize
    • getStyle

      public static int getStyle()
      Deprecated.
      Replaced by getDefaultFontStyle
    • setCurrentFont

      public void setCurrentFont​(java.awt.Font font)
      Deprecated.
      Replaced by setFont(font)