Class DefaultGUIRegistry
- java.lang.Object
-
- repast.simphony.engine.environment.DefaultGUIRegistry
-
- All Implemented Interfaces:
GUIRegistry
public class DefaultGUIRegistry extends Object implements GUIRegistry
A default implementation of a GUI registry.- Author:
- Jerry Vos, Eric Tatara
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<JComponent,IDisplay>
compDisplayMap
Maps String display name to IDisplay object.protected HashMap<JComponent,String>
componentNameTable
protected Hashtable<JComponent,GUIRegistryType>
componentTypeTable
protected Map<String,IDisplay>
displayNameTable
protected Hashtable<GUIRegistryType,ArrayList<JComponent>>
typeComponentTable
-
Constructor Summary
Constructors Constructor Description DefaultGUIRegistry()
Constructs the GUI Registry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addComponent(JComponent component, GUIRegistryType type, String name)
Adds a component with the given type and name.void
addDisplay(String name, GUIRegistryType type, IDisplay display)
Adds an IDisplay to this GUIRegistry.IDisplay
getDisplayForComponent(JComponent comp)
Gets the IDisplay associated with the specified component.IDisplay
getDisplayForName(String displayName)
Get the IDisplay associated with the specified display name;List<IDisplay>
getDisplays()
Gets the list of IDisplay-s registered with this GUIRegistry.String
getName(JComponent component)
Retrieves the name of a given component.Collection<Pair<GUIRegistryType,Collection<JComponent>>>
getTypesAndComponents()
Retrieves the (type, components) pairs that were registered with this registry.boolean
removeComponent(JComponent component)
Removes a component from the registry.
-
-
-
Field Detail
-
typeComponentTable
protected Hashtable<GUIRegistryType,ArrayList<JComponent>> typeComponentTable
-
componentTypeTable
protected Hashtable<JComponent,GUIRegistryType> componentTypeTable
-
componentNameTable
protected HashMap<JComponent,String> componentNameTable
-
compDisplayMap
protected Map<JComponent,IDisplay> compDisplayMap
Maps String display name to IDisplay object. Only stores unique names.
-
-
Method Detail
-
addComponent
public void addComponent(JComponent component, GUIRegistryType type, String name)
Adds a component with the given type and name. The type is not meant to be "JPanel" or "JTable," but to be along the lines of "Graph" or "Display." The name can be null.- Specified by:
addComponent
in interfaceGUIRegistry
- Parameters:
component
- the component to addtype
- the type of the componentname
- the name of the component (can be null)
-
removeComponent
public boolean removeComponent(JComponent component)
Removes a component from the registry.- Specified by:
removeComponent
in interfaceGUIRegistry
- Parameters:
component
- the component to remove- Returns:
- true if something was removed (false if this didn't contain the component
-
getName
public String getName(JComponent component)
Retrieves the name of a given component. This may return null if the name was null or if the component does not exist in the registry.- Specified by:
getName
in interfaceGUIRegistry
- Parameters:
component
- the component who's name to retrieve- Returns:
- the specified component's name
-
getTypesAndComponents
public Collection<Pair<GUIRegistryType,Collection<JComponent>>> getTypesAndComponents()
Retrieves the (type, components) pairs that were registered with this registry.- Specified by:
getTypesAndComponents
in interfaceGUIRegistry
- Returns:
- a collection of (type, components) pairs
-
addDisplay
public void addDisplay(String name, GUIRegistryType type, IDisplay display)
Adds an IDisplay to this GUIRegistry. If the display is added, there is NO need to add the component associated with the IDisplay as well.- Specified by:
addDisplay
in interfaceGUIRegistry
- Parameters:
display
- the renderer to add
-
getDisplays
public List<IDisplay> getDisplays()
Gets the list of IDisplay-s registered with this GUIRegistry.- Specified by:
getDisplays
in interfaceGUIRegistry
- Returns:
- the list of IDisplays-s registered with this GUIRegistry.
-
getDisplayForComponent
public IDisplay getDisplayForComponent(JComponent comp)
Gets the IDisplay associated with the specified component.- Specified by:
getDisplayForComponent
in interfaceGUIRegistry
- Parameters:
comp
- the component whose IDisplay we want to get- Returns:
- the IDisplay associated with the specified component.
-
getDisplayForName
public IDisplay getDisplayForName(String displayName)
Get the IDisplay associated with the specified display name;- Specified by:
getDisplayForName
in interfaceGUIRegistry
- Parameters:
displayName
- the display name- Returns:
- the IDisplay with the provided name
-
-