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

Method addChar

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

This method is used by the text tool to add typed characters to displayed text selections.

(char c)

Source from the content-addressed store, hash-verified

159 /** This method is used by the text tool to add typed
160 characters to displayed text selections. */
161 public void addChar(char c) {
162 if (imp==null) return;
163 if (!(c>=' ' || c=='\b' || c=='\n')) return;
164 int cline = 0;
165 if (firstChar) {
166 theText[cline] = new String("");
167 for (int i=1; i<MAX_LINES; i++)
168 theText[i] = null;
169 } else {
170 for (int i=0; i<theText.length && theText[i] != null; i++)
171 cline = i; //add the character to the last line
172 }
173 if ((int)c=='\b') {
174 // backspace
175 if (theText[cline].length()>0)
176 theText[cline] = theText[cline].substring(0, theText[cline].length()-1);
177 else if (cline>0) {
178 theText[cline] = null;
179 cline--;
180 }
181 if (angle!=0.0)
182 imp.draw();
183 else
184 imp.draw(clipX, clipY, clipWidth, clipHeight);
185 firstChar = false;
186 return;
187 } else if ((int)c=='\n') {
188 // newline
189 if (cline<(MAX_LINES-1)) cline++;
190 theText[cline] = "";
191 updateBounds();
192 updateText();
193 } else {
194 char[] chr = {c};
195 theText[cline] += new String(chr);
196 updateBounds();
197 updateText();
198 firstChar = false;
199 return;
200 }
201 }
202
203 Font getScaledFont() {
204 if (font==null)

Callers 1

keyPressedMethod · 0.80

Calls 5

updateBoundsMethod · 0.95
updateTextMethod · 0.95
substringMethod · 0.80
lengthMethod · 0.65
drawMethod · 0.45

Tested by

no test coverage detected