public class NameGenerator
extends Object
Modifier and Type | Field and Description |
---|---|
private static String |
BASE_NAME
Base name used for the label names
|
private Set<String> |
nameSet
Set to store all the label names that have been used
|
private long |
nextDigit
Next digit to concatenate with the base name to generate a new label
name.
|
Constructor and Description |
---|
NameGenerator()
Default constructor that creates a new name generator with an empty
set of used names.
|
NameGenerator(Graph graph)
Creates a new name generator with the names from the specified graph
excluded as possible names to generate.
|
Modifier and Type | Method and Description |
---|---|
void |
addName(String name)
Adds the specified name to the set of names to excluded when
generating label names.
|
void |
addNames(Graph graph)
Adds the defining and bound label names from the specified graph to
the list of names to exclude when generating new names.
|
void |
clear()
Clears the set of names that have been used so far and resets the
name generation sequence.
|
String |
generateName()
Generates and returns a label name that has not been used.
|
Set<String> |
getNames()
Returns a copy of the set of names that have been generated or
manually added to the exclusion set.
|
boolean |
isGenericName(String name)
Looks for several cases: is the name null, the empty string, a single "*" or a set referent with *
|
boolean |
isUseableName(String name)
Returns true if the specified name is a label name that has not been
generated and hasn't been manually added to the set of names to
exclude.
|
private static final String BASE_NAME
private long nextDigit
private Set<String> nameSet
public NameGenerator()
public NameGenerator(Graph graph)
graph
- All the label names from the graph are added as to the
set of names to exclude.public void addName(String name)
name
- Name to add to the exclusion setpublic void addNames(Graph graph)
graph
- Graph to traverse to look for label namespublic boolean isUseableName(String name)
name
- Name to testpublic boolean isGenericName(String name)
name
- public void clear()
public Set<String> getNames()
public String generateName()