void saveTextRoi(TextRoi roi) { Font font = roi.getCurrentFont(); String fontName = font.getName(); int size = font.getSize(); int drawStringMode = roi.getDrawStringMode()?1024:0; int style = font.getStyle() + roi.getJustification()*256+drawStringMode; String text = roi.getText(); float angle = (float)roi.getAngle(); int angleLength = 4; int fontNameLength = fontName.length(); int textLength = text.length(); int textRoiDataLength = 16+fontNameLength*2+textLength*2 + angleLength; byte[] data2 = new byte[HEADER_SIZE+HEADER2_SIZE+textRoiDataLength+roiNameSize+roiPropsSize]; System.arraycopy(data, 0, data2, 0, HEADER_SIZE); data = data2; putShort(RoiDecoder.SUBTYPE, RoiDecoder.TEXT); putInt(HEADER_SIZE, size); putInt(HEADER_SIZE+4, style); putInt(HEADER_SIZE+8, fontNameLength); putInt(HEADER_SIZE+12, textLength); for (int i=0; i<fontNameLength; i++) putShort(HEADER_SIZE+16+i*2, fontName.charAt(i)); for (int i=0; i<textLength; i++) putShort(HEADER_SIZE+16+fontNameLength*2+i*2, text.charAt(i)); int hdr2Offset = HEADER_SIZE+textRoiDataLength; //ij.IJ.log("saveTextRoi: "+HEADER_SIZE+" "+textRoiDataLength+" "+fontNameLength+" "+textLength); putFloat(hdr2Offset-angleLength, angle); putHeader2(roi, hdr2Offset); }
void saveTextRoi(TextRoi roi) { Font font = roi.getCurrentFont(); String fontName = font.getName(); int size = font.getSize(); int drawStringMode = roi.getDrawStringMode()?1024:0; int style = font.getStyle() + roi.getJustification()*256+drawStringMode; String text = roi.getText(); float angle = (float)roi.getAngle(); int angleLength = 4; int fontNameLength = fontName.length(); int textLength = text.length(); int textRoiDataLength = 16+fontNameLength*2+textLength*2 + angleLength; byte[] data2 = new byte[HEADER_SIZE+HEADER2_SIZE+textRoiDataLength+roiNameSize+roiPropsSize]; System.arraycopy(data, 0, data2, 0, HEADER_SIZE); data = data2; putShort(RoiDecoder.SUBTYPE, RoiDecoder.TEXT); putInt(HEADER_SIZE, size); putInt(HEADER_SIZE+4, style); putInt(HEADER_SIZE+8, fontNameLength); putInt(HEADER_SIZE+12, textLength); for (int i=0; i<fontNameLength; i++) putShort(HEADER_SIZE+16+i*2, fontName.charAt(i)); for (int i=0; i<textLength; i++) putShort(HEADER_SIZE+16+fontNameLength*2+i*2, text.charAt(i)); int hdr2Offset = HEADER_SIZE+textRoiDataLength; //ij.IJ.log("saveTextRoi: "+HEADER_SIZE+" "+textRoiDataLength+" "+fontNameLength+" "+textLength); putFloat(hdr2Offset-angleLength, angle); putHeader2(roi, hdr2Offset); }
private Overlay createTextOverlay(final Roi roi) { assert roi instanceof TextRoi; final TextRoi tRoi = (TextRoi) roi; final Double bounds = tRoi.getFloatBounds(); final double x = bounds.x; final double y = bounds.y; final TextOverlay overlay = new TextOverlay(getContext(), x, y, tRoi.getText()); switch (tRoi.getJustification()) { case TextRoi.LEFT: overlay.setJustification(Justification.LEFT); break; case TextRoi.CENTER: overlay.setJustification(Justification.CENTER); break; case TextRoi.RIGHT: overlay.setJustification(Justification.RIGHT); break; default: break; } assignPropertiesToOverlay(overlay, roi); return overlay; }
store.setLabelY(roi.getPolygon().getBounds().getY(), roiNum, shape); store.setLabelText(roi.getText().trim(), roiNum, shape); store.setLabelFontSize(new Length(roi.getCurrentFont().getSize(), UNITS.PIXEL), roiNum, shape);
store.setLabelY(roi.getPolygon().getBounds().getY(), roiNum, shape); store.setLabelText(roi.getText().trim(), roiNum, shape); store.setLabelFontSize(new Length(roi.getCurrentFont().getSize(), UNITS.PIXEL), roiNum, shape);