+ }
+
+ /**
+ * Get a unique name in the Plant3D model with a given prefix followed by
+ * an underscore and number.
+ */
+ public String getUniqueName(String prefix) {
+ ParentNode<?> root = getRootNode();
+ if (root instanceof P3DRootNode) {
+ return ((P3DRootNode) root).getUniqueName(prefix);
+ } else {
+ Set<String> names = new HashSet<String>();
+ getComponentNames(names);
+ int i = 1;
+ while (true) {
+ String genName = prefix + "_" + i;
+ if (!names.contains(genName))
+ return genName;
+ i++;
+ }