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

Method getTextRoi

ij/src/main/java/ij/io/RoiDecoder.java:482–513  ·  view source on GitHub ↗
(Roi roi, int version)

Source from the content-addressed store, hash-verified

480 }
481
482 Roi getTextRoi(Roi roi, int version) {
483 Rectangle r = roi.getBounds();
484 int hdrSize = RoiEncoder.HEADER_SIZE;
485 int size = getInt(hdrSize);
486 int styleAndJustification = getInt(hdrSize+4);
487 int style = styleAndJustification&255;
488 int justification = (styleAndJustification>>8) & 3;
489 boolean drawStringMode = (styleAndJustification&1024)!=0;
490 int nameLength = getInt(hdrSize+8);
491 int textLength = getInt(hdrSize+12);
492 char[] name = new char[nameLength];
493 char[] text = new char[textLength];
494 for (int i=0; i<nameLength; i++)
495 name[i] = (char)getShort(hdrSize+16+i*2);
496 for (int i=0; i<textLength; i++)
497 text[i] = (char)getShort(hdrSize+16+nameLength*2+i*2);
498 double angle = version>=225?getFloat(hdrSize+16+nameLength*2+textLength*2):0f;
499 Font font = new Font(new String(name), style, size);
500 TextRoi roi2 = null;
501 if (roi.subPixelResolution()) {
502 Rectangle2D fb = roi.getFloatBounds();
503 roi2 = new TextRoi(fb.getX(), fb.getY(), fb.getWidth(), fb.getHeight(), new String(text), font);
504 } else
505 roi2 = new TextRoi(r.x, r.y, r.width, r.height, new String(text), font);
506 roi2.setStrokeColor(roi.getStrokeColor());
507 roi2.setFillColor(roi.getFillColor());
508 roi2.setName(getRoiName());
509 roi2.setJustification(justification);
510 roi2.setDrawStringMode(drawStringMode);
511 roi2.setAngle(angle);
512 return roi2;
513 }
514
515 Roi getImageRoi(Roi roi, int opacity, int size, int options) {
516 if (size<=0)

Callers 1

getRoiMethod · 0.95

Calls 15

getIntMethod · 0.95
getShortMethod · 0.95
getFloatMethod · 0.95
getRoiNameMethod · 0.95
setJustificationMethod · 0.95
setDrawStringModeMethod · 0.95
setAngleMethod · 0.95
getStrokeColorMethod · 0.80
getFillColorMethod · 0.80
getBoundsMethod · 0.65
getXMethod · 0.65
getYMethod · 0.65

Tested by

no test coverage detected