/** Set the current (instance) font. */ public void setCurrentFont(Font font) { instanceFont = font; updateBounds(null); }
/** Set the current (instance) font. */ public void setCurrentFont(Font font) { instanceFont = font; updateBounds(null); }
private void init(String text, Font font) { 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]; if (font==null) font = new Font(name, style, size); instanceFont = font; firstChar = false; if (width==1 && height==1) { ImageJ ij = IJ.getInstance(); Graphics g = ij!=null?ij.getGraphics():null; if (g!=null) updateBounds(g); } }
private void init(String text, Font font) { 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]; if (font==null) font = new Font(name, style, size); instanceFont = font; firstChar = false; if (width==1 && height==1) { ImageJ ij = IJ.getInstance(); Graphics g = ij!=null?ij.getGraphics():null; if (g!=null) updateBounds(g); } }
updateBounds(null); updateText(); } else { char[] chr = {c}; theText[cline] += new String(chr); updateBounds(null); updateText(); firstChar = false;
updateBounds(null); updateText(); } else { char[] chr = {c}; theText[cline] += new String(chr); updateBounds(null); updateText(); firstChar = false;
Java2.setAntialiasedText(g, antialiased); if (newFont || width==1) updateBounds(g); double mag = getMagnification(); int xi = (int)Math.round(getXBase()); g.setFont(font); Graphics2D g2d = (Graphics2D)g; updateBounds(g); int sx = nonScalable?xi:screenXD(getXBase()); int sy = nonScalable?yi:screenYD(getYBase());
Java2.setAntialiasedText(g, antialiased); if (newFont || width==1) updateBounds(g); double mag = getMagnification(); int xi = (int)Math.round(getXBase()); g.setFont(font); Graphics2D g2d = (Graphics2D)g; updateBounds(g); int sx = nonScalable?xi:screenXD(getXBase()); int sy = nonScalable?yi:screenYD(getYBase());
protected void handleMouseUp(int screenX, int screenY) { super.handleMouseUp(screenX, screenY); if (width<5 && height<5 && imp!=null && previousRoi==null) { int ox = ic!=null?ic.offScreenX(screenX):screenX; int oy = ic!=null?ic.offScreenY(screenY):screenY; TextRoi roi = new TextRoi(ox, oy, line1a); roi.setStrokeColor(Toolbar.getForegroundColor()); roi.firstChar = true; imp.setRoi(roi); return; } else if (firstMouseUp) { updateBounds(null); updateText(); firstMouseUp = false; } if (width<5 || height<5) imp.deleteRoi(); }
protected void handleMouseUp(int screenX, int screenY) { super.handleMouseUp(screenX, screenY); if (width<5 && height<5 && imp!=null && previousRoi==null) { int ox = ic!=null?ic.offScreenX(screenX):screenX; int oy = ic!=null?ic.offScreenY(screenY):screenY; TextRoi roi = new TextRoi(ox, oy, line1a); roi.setStrokeColor(Toolbar.getForegroundColor()); roi.firstChar = true; imp.setRoi(roi); return; } else if (firstMouseUp) { updateBounds(null); updateText(); firstMouseUp = false; } if (width<5 || height<5) imp.deleteRoi(); }
/** Draws the text on the screen, clipped to the ROI. */ public void draw(Graphics g) { if (IJ.debugMode) IJ.log("draw: "+theText[0]+" "+width+","+height); if (Interpreter.isBatchMode() && ic!=null && ic.getDisplayList()!=null) return; if (newFont || width==1) updateBounds(g); Color c = getStrokeColor(); setStrokeColor(getColor()); super.draw(g); // draw the rectangle setStrokeColor(c); double mag = getMagnification(); int sx = screenXD(getXBase()); int sy = screenYD(getYBase()); int swidth = (int)((bounds!=null?bounds.width:width)*mag); int sheight = (int)((bounds!=null?bounds.height:height)*mag); Rectangle r = null; if (angle!=0.0) drawText(g); else { r = g.getClipBounds(); g.setClip(sx, sy, swidth, sheight); drawText(g); if (r!=null) g.setClip(r.x, r.y, r.width, r.height); } }
/** Draws the text on the screen, clipped to the ROI. */ public void draw(Graphics g) { if (IJ.debugMode) IJ.log("draw: "+theText[0]+" "+width+","+height); if (Interpreter.isBatchMode() && ic!=null && ic.getDisplayList()!=null) return; if (newFont || width==1) updateBounds(g); Color c = getStrokeColor(); setStrokeColor(getColor()); super.draw(g); // draw the rectangle setStrokeColor(c); double mag = getMagnification(); int sx = screenXD(getXBase()); int sy = screenYD(getYBase()); int swidth = (int)((bounds!=null?bounds.width:width)*mag); int sheight = (int)((bounds!=null?bounds.height:height)*mag); Rectangle r = null; if (angle!=0.0) drawText(g); else { r = g.getClipBounds(); g.setClip(sx, sy, swidth, sheight); drawText(g); if (r!=null) g.setClip(r.x, r.y, r.width, r.height); } }