public void setNote(Address addr, String category, String comment) {

		CompoundCmd<Program> cmd = new CompoundCmd<>("Set Note Bookmark");

		if (addr != null) {
			// Add address specified within bookmark
			cmd.add(new BookmarkDeleteCmd(addr, BookmarkType.NOTE));
			cmd.add(new BookmarkEditCmd(addr, BookmarkType.NOTE, category, comment));
		}
		else {

			// Create address set with first address only
			AddressSet set = new AddressSet();
			AddressRangeIterator iter = currentSelection.getAddressRanges();
			while (iter.hasNext()) {
				Address minAddr = iter.next().getMinAddress();
				set.addRange(minAddr, minAddr);
			}

			// Add a bookmark at the first address of each address range in
			//   the current selection
			cmd.add(new BookmarkDeleteCmd(set, BookmarkType.NOTE));
			cmd.add(new BookmarkEditCmd(set, BookmarkType.NOTE, category, comment));
		}
		tool.execute(cmd, currentProgram);
	}
Called when a new bookmark is to be added; called from the add bookmark dialog

@param addr bookmark address. If null a Note bookmark will set at the start address of each
           range in the current selection
@param category bookmark category
@param comment comment text
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/bookmark/BookmarkPlugin.java