public void setAngle(double angle) { this.angle = angle; if (angle!=0.0) setAntialiased(true); }
public void setAngle(double angle) { this.angle = angle; if (angle!=0.0) setAntialiased(true); }
/** Use this constructor as a drop-in replacement for ImageProcessor.drawString(). */ public TextRoi(String text, double x, double y, Font font) { super(x, y, 1, 1); drawStringMode = true; if (text!=null && text.contains("\n")) { String[] lines = Tools.split(text, "\n"); int count = Math.min(lines.length, MAX_LINES); for (int i=0; i<count; i++) theText[i] = lines[i]; } else theText[0] = text; instanceFont = font; if (instanceFont==null) instanceFont = new Font(name, style, size); ImageJ ij = IJ.getInstance(); Graphics g = ij!=null?ij.getGraphics():null; if (g==null) return; FontMetrics metrics = g.getFontMetrics(instanceFont); g.dispose(); bounds = null; width = (int)stringWidth(theText[0],metrics,g); height = (int)(metrics.getHeight()); this.x = (int)x; this.y = (int)(y - height); setAntialiased(true); justification = LEFT; }
/** Use this constructor as a drop-in replacement for ImageProcessor.drawString(). */ public TextRoi(String text, double x, double y, Font font) { super(x, y, 1, 1); drawStringMode = true; if (text!=null && text.contains("\n")) { String[] lines = Tools.split(text, "\n"); int count = Math.min(lines.length, MAX_LINES); for (int i=0; i<count; i++) theText[i] = lines[i]; } else theText[0] = text; instanceFont = font; if (instanceFont==null) instanceFont = new Font(name, style, size); ImageJ ij = IJ.getInstance(); Graphics g = ij!=null?ij.getGraphics():null; if (g==null) return; FontMetrics metrics = g.getFontMetrics(instanceFont); g.dispose(); bounds = null; width = (int)stringWidth(theText[0],metrics,g); height = (int)(metrics.getHeight()); this.x = (int)x; this.y = (int)(y - height); setAntialiased(true); justification = LEFT; }
/** Sets the font face, size, style and antialiasing mode that will be used by TextROIs interactively created using the text tool. */ public static void setFont(String fontName, int fontSize, int fontStyle, boolean antialiased) { name = fontName; size = fontSize; style = fontStyle; globalJustification = LEFT; antialiasedText = antialiased; newFont = true; ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null) { Roi roi = imp.getRoi(); if (roi instanceof TextRoi) { ((TextRoi)roi).setAntialiased(antialiased); ((TextRoi)roi).setCurrentFont(new Font(name, style, size)); imp.draw(); } } }
/** Sets the font face, size, style and antialiasing mode that will be used by TextROIs interactively created using the text tool. */ public static void setFont(String fontName, int fontSize, int fontStyle, boolean antialiased) { name = fontName; size = fontSize; style = fontStyle; globalJustification = LEFT; antialiasedText = antialiased; newFont = true; ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null) { Roi roi = imp.getRoi(); if (roi instanceof TextRoi) { ((TextRoi)roi).setAntialiased(antialiased); ((TextRoi)roi).setCurrentFont(new Font(name, style, size)); imp.draw(); } } }
void makeText() { String text = getFirstString(); int x = (int)getNextArg(); int y = (int)getLastArg(); ImagePlus imp = getImage(); Font font = this.font; boolean nullFont = font==null; if (nullFont) font = imp.getProcessor().getFont(); TextRoi roi = new TextRoi(x, y, text, font); if (!nullFont) roi.setAntialiased(antialiasedText); imp.setRoi(roi); }
void makeText() { String text = getFirstString(); int x = (int)getNextArg(); int y = (int)getLastArg(); ImagePlus imp = getImage(); Font font = this.font; boolean nullFont = font==null; if (nullFont) font = imp.getProcessor().getFont(); TextRoi roi = new TextRoi(x, y, text, font); if (!nullFont) roi.setAntialiased(antialiasedText); imp.setRoi(roi); }
double overlayDrawString(ImagePlus imp) { addDrawingToOverlay(imp); String text = getFirstString(); int x = (int)getNextArg(); int y = (int)getNextArg(); double angle = 0.0; if (interp.nextToken()==',') angle = getLastArg(); else interp.getRightParen(); Font font = this.font; boolean nullFont = font==null; if (nullFont) font = imp.getProcessor().getFont(); TextRoi roi = new TextRoi(text, x, y, font); // use drawString() compatible constructor if (!nullFont && !antialiasedText) roi.setAntialiased(false); roi.setAngle(angle); roi.setJustification(justification); addRoi(imp, roi); return Double.NaN; }
double overlayDrawString(ImagePlus imp) { addDrawingToOverlay(imp); String text = getFirstString(); int x = (int)getNextArg(); int y = (int)getNextArg(); double angle = 0.0; if (interp.nextToken()==',') angle = getLastArg(); else interp.getRightParen(); Font font = this.font; boolean nullFont = font==null; if (nullFont) font = imp.getProcessor().getFont(); TextRoi roi = new TextRoi(text, x, y, font); // use drawString() compatible constructor if (!nullFont && !antialiasedText) roi.setAntialiased(false); roi.setAngle(angle); roi.setJustification(justification); addRoi(imp, roi); return Double.NaN; }
textRoi.setJustification(justification); textRoi.setFillColor(fillColor); textRoi.setAntialiased(antialiased);
textRoi.setJustification(justification); textRoi.setFillColor(fillColor); textRoi.setAntialiased(antialiased);
if (justification!=troi.getJustification()) troi.setJustification(justification); troi.setAntialiased(antialias); } else roi.setStrokeWidth((float)strokeWidth);
if (justification!=troi.getJustification()) troi.setJustification(justification); troi.setAntialiased(antialias); } else roi.setStrokeWidth((float)strokeWidth);