MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / drawPixels

Method drawPixels

ij/src/main/java/ij/gui/TextRoi.java:220–249  ·  view source on GitHub ↗

Renders the text on the image. Draws the text in the foreground color if ip.setColor(Color) has not been called. @see ij.process.ImageProcessor#setFont(Font) @see ij.process.ImageProcessor#setAntialiasedText(boolean) @see ij.process.ImageProcessor#setColor(Color)

(ImageProcessor ip)

Source from the content-addressed store, hash-verified

218 * @see ij.process.ImageProcessor#setColor(Color)
219 */
220 public void drawPixels(ImageProcessor ip) {
221 if (!ip.fillValueSet())
222 ip.setColor(Toolbar.getForegroundColor());
223 ip.setFont(font);
224 ip.setAntialiasedText(getAntiAlias());
225 FontMetrics metrics = ip.getFontMetrics();
226 int fontHeight = metrics.getHeight();
227 int descent = metrics.getDescent();
228 int i = 0;
229 int yy = 0;
230 int xi = (int)Math.round(getXBase());
231 int yi = (int)Math.round(getYBase());
232 while (i<MAX_LINES && theText[i]!=null) {
233 switch (justification) {
234 case LEFT:
235 ip.drawString(theText[i], xi, yi+yy+fontHeight);
236 break;
237 case CENTER:
238 int tw = metrics.stringWidth(theText[i]);
239 ip.drawString(theText[i], xi+(this.width-tw)/2, yi+yy+fontHeight);
240 break;
241 case RIGHT:
242 tw = metrics.stringWidth(theText[i]);
243 ip.drawString(theText[i], xi+this.width-tw, yi+yy+fontHeight);
244 break;
245 }
246 i++;
247 yy += fontHeight;
248 }
249 }
250
251 /** Draws the text on the screen, clipped to the ROI. */
252 public void draw(Graphics g) {

Callers

nothing calls this directly

Calls 13

getForegroundColorMethod · 0.95
fillValueSetMethod · 0.80
getAntiAliasMethod · 0.80
getXBaseMethod · 0.80
getYBaseMethod · 0.80
stringWidthMethod · 0.80
setColorMethod · 0.65
setFontMethod · 0.65
setAntialiasedTextMethod · 0.45
getFontMetricsMethod · 0.45
getHeightMethod · 0.45
roundMethod · 0.45

Tested by

no test coverage detected