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

Method saveLabel

ij/src/main/java/ij/gui/GenericDialog.java:312–325  ·  view source on GitHub ↗

Saves the label for given component, for macro recording and for accessing the component in macros.

(Object component, String label)

Source from the content-addressed store, hash-verified

310
311 /** Saves the label for given component, for macro recording and for accessing the component in macros. */
312 private void saveLabel(Object component, String label) {
313 if (labels==null)
314 labels = new Hashtable();
315 if (label.length()>0)
316 label = Macro.trimKey(label.trim());
317 if (label.length()>0 && hasLabel(label)) { // not a unique label?
318 label += "_0";
319 for (int n=1; hasLabel(label); n++) { // while still not a unique label
320 label = label.substring(0, label.lastIndexOf('_')); //remove counter
321 label += "_"+n;
322 }
323 }
324 labels.put(component, label);
325 }
326
327 /** Returns whether the list of labels for macro recording or macro creation contains a given label. */
328 private boolean hasLabel(String label) {

Callers 9

addNumericFieldMethod · 0.95
addStringFieldMethod · 0.95
addDirectoryFieldMethod · 0.95
addFileFieldMethod · 0.95
addCheckboxMethod · 0.95
addCheckboxGroupMethod · 0.95
addRadioButtonGroupMethod · 0.95
addChoiceMethod · 0.95
addSliderMethod · 0.95

Calls 6

trimKeyMethod · 0.95
hasLabelMethod · 0.95
substringMethod · 0.80
lengthMethod · 0.65
trimMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected