Class UiRegion


  • public class UiRegion
    extends UiNode
    Represents a region.
    • Constructor Summary

      Constructors 
      Constructor Description
      UiRegion​(UiTopology topology, Region region)
      Constructs a UI region, with a reference to the specified backing region.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Region backingRegion()
      Returns the region instance backing this UI region.
      java.util.Set<RegionId> children()
      Returns the identities of the child regions.
      protected void destroy()
      Removes all external references, and prepares the instance for garbage collection.
      int deviceCount()
      Returns the count of devices in this region.
      java.util.Set<DeviceId> deviceIds()
      Returns the set of device identifiers for this region.
      void deviceRemoved​(DeviceId deviceId)  
      java.util.Set<UiDevice> devices()
      Returns the devices in this region.
      int hostCount()
      Returns the count of devices in this region.
      java.util.Set<HostId> hostIds()
      Returns the set of host identifiers for this region.
      java.util.Set<UiHost> hosts()
      Returns the hosts in this region.
      RegionId id()
      Returns the identity of the region.
      java.lang.String idAsString()
      Returns a string representation of the element identifier.
      boolean isRelevant​(UiModelEvent event)
      Determins whether the specified event is relevant to the view constrained to this region.
      boolean isRoot()
      Returns true if this is the root (default) region.
      java.util.List<java.lang.String> layerOrder()
      Returns the order in which layers should be rendered.
      java.lang.String name()
      Returns a friendly name to be used for display purposes.
      void newDeviceAdded​(DeviceId deviceId)  
      RegionId parent()
      Returns the identity of the parent region.
      UiRegion parentRegion()
      Returns the UI region that is the parent of this region.
      void reconcileDevices​(java.util.Set<DeviceId> devices)
      Make sure we have only these devices in the region.
      void reconcileHosts​(java.util.Set<HostId> hosts)
      Make sure we have only these hosts in the region.
      static java.lang.String safeName​(Region region)
      Guarantees to return a string for the name of the specified region.
      void setChildren​(java.util.Set<RegionId> children)
      Sets the children IDs for this region.
      void setLayerOrder​(java.lang.String... layers)
      Sets the layer order for this region.
      void setParent​(RegionId parentId)
      Sets the parent ID for this region.
      java.lang.String toString()  
      Region.Type type()
      Returns the region's type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • NULL_ID

        public static final RegionId NULL_ID
        The identifier for the null-region. That is, a container for devices, hosts, and links for those that belong to no region.
    • Constructor Detail

      • UiRegion

        public UiRegion​(UiTopology topology,
                        Region region)
        Constructs a UI region, with a reference to the specified backing region.
        Parameters:
        topology - parent topology
        region - backing region
    • Method Detail

      • destroy

        protected void destroy()
        Description copied from class: UiElement
        Removes all external references, and prepares the instance for garbage collection. This default implementation does nothing.
        Overrides:
        destroy in class UiElement
      • setLayerOrder

        public void setLayerOrder​(java.lang.String... layers)
        Sets the layer order for this region. Typically, the UiNode.LAYER_* constants will be used here.
        Parameters:
        layers - the layers
      • id

        public RegionId id()
        Returns the identity of the region.
        Returns:
        region ID
      • parent

        public RegionId parent()
        Returns the identity of the parent region.
        Returns:
        parent region ID
      • isRoot

        public boolean isRoot()
        Returns true if this is the root (default) region.
        Returns:
        true if root region
      • children

        public java.util.Set<RegionId> children()
        Returns the identities of the child regions.
        Returns:
        child region IDs
      • parentRegion

        public UiRegion parentRegion()
        Returns the UI region that is the parent of this region.
        Returns:
        the parent region
      • setParent

        public void setParent​(RegionId parentId)
        Sets the parent ID for this region.
        Parameters:
        parentId - parent ID
      • setChildren

        public void setChildren​(java.util.Set<RegionId> children)
        Sets the children IDs for this region.
        Parameters:
        children - children IDs
      • idAsString

        public java.lang.String idAsString()
        Description copied from class: UiElement
        Returns a string representation of the element identifier.
        Specified by:
        idAsString in class UiElement
        Returns:
        the element unique identifier
      • name

        public java.lang.String name()
        Description copied from class: UiElement
        Returns a friendly name to be used for display purposes. This default implementation returns the result of calling UiElement.idAsString().
        Overrides:
        name in class UiElement
        Returns:
        the friendly name
      • backingRegion

        public Region backingRegion()
        Returns the region instance backing this UI region. If this instance represents the "null-region", the value returned will be null.
        Returns:
        the backing region instance
      • reconcileDevices

        public void reconcileDevices​(java.util.Set<DeviceId> devices)
        Make sure we have only these devices in the region.
        Parameters:
        devices - devices in the region
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • type

        public Region.Type type()
        Returns the region's type.
        Returns:
        region type
      • deviceCount

        public int deviceCount()
        Returns the count of devices in this region.
        Returns:
        the device count
      • deviceIds

        public java.util.Set<DeviceId> deviceIds()
        Returns the set of device identifiers for this region.
        Returns:
        device identifiers for this region
      • devices

        public java.util.Set<UiDevice> devices()
        Returns the devices in this region.
        Returns:
        the devices in this region
      • reconcileHosts

        public void reconcileHosts​(java.util.Set<HostId> hosts)
        Make sure we have only these hosts in the region.
        Parameters:
        hosts - hosts in the region
      • hostIds

        public java.util.Set<HostId> hostIds()
        Returns the set of host identifiers for this region.
        Returns:
        host identifiers for this region
      • hosts

        public java.util.Set<UiHost> hosts()
        Returns the hosts in this region.
        Returns:
        the hosts in this region
      • hostCount

        public int hostCount()
        Returns the count of devices in this region.
        Returns:
        the device count
      • layerOrder

        public java.util.List<java.lang.String> layerOrder()
        Returns the order in which layers should be rendered. Lower layers come earlier in the list. For example, to indicate that nodes in the optical layer should be rendered "below" nodes in the packet layer, this method should return:
         [UiNode.LAYER_OPTICAL, UiNode.LAYER_PACKET, UiNode.LAYER_DEFAULT]
         
        Returns:
        layer ordering
      • safeName

        public static java.lang.String safeName​(Region region)
        Guarantees to return a string for the name of the specified region. If region is null, we return the null region name, else we return the name as configured on the region.
        Parameters:
        region - the region whose name we require
        Returns:
        the region's name
      • isRelevant

        public boolean isRelevant​(UiModelEvent event)
        Determins whether the specified event is relevant to the view constrained to this region.
        Parameters:
        event - UI model event
        Returns:
        true if relevant
      • newDeviceAdded

        public void newDeviceAdded​(DeviceId deviceId)
      • deviceRemoved

        public void deviceRemoved​(DeviceId deviceId)