Class ViewMap


  • public class ViewMap
    extends Object
    A representation of a view (which in turn a graphical representation of an inventory object or a function in the domain of the inventory system) as a set of java objects. In general terms, a ViewMap instance is a group of nodes and connections between those nodes, as well as auxiliary components, such as comments, or groups of nodes. This map does not contain rendering information, such as dimensions or positions, but it is rather a description of the internal structure of the view, which can be used by the consumer to perform analysis on the information contained by the view.
    Author:
    Charles Edward Bedon Cortazar <charles.bedon@kuwaiba.org>
    • Constructor Detail

      • ViewMap

        public ViewMap()
    • Method Detail

      • addNode

        public void addNode​(AbstractViewNode node)
        Adds a node to the map.
        Parameters:
        node - The node to be added. If the node is already in the map, nothing will be done.
      • addEdge

        public void addEdge​(AbstractViewEdge edge)
        Adds an edge to the map.
        Parameters:
        edge - The edge to be added. If the edge is already in the map, nothing will be done.
      • attachSourceNode

        public void attachSourceNode​(AbstractViewEdge edge,
                                     AbstractViewNode sourceNode)
        Sets the source node of a connection (edge). If the edge already has a source node, it will be disconnected.
        Parameters:
        edge - The edge to be connected to the node.
        sourceNode - The node to be connected to the edge.
      • attachTargetNode

        public void attachTargetNode​(AbstractViewEdge edge,
                                     AbstractViewNode targetNode)
        Sets the target node of a connection (edge). If the edge already has a target node, it will be disconnected.
        Parameters:
        edge - The edge to be connected to the node.
        targetNode - The node to be connected to the edge.
      • getNode

        public AbstractViewNode getNode​(Object identifier)
        Gets the object behind a node whose identifier is the one provider.
        Parameters:
        identifier - The object to search.
        Returns:
        The node or null if such identifier does not belong to any node.
      • getEdge

        public AbstractViewEdge getEdge​(Object identifier)
        Gets the object behind a node whose identifier is the one provider.
        Parameters:
        identifier - The object to search.
        Returns:
        The node or null if such identifier does not belong to any node.
      • getEdgeSource

        public AbstractViewNode getEdgeSource​(AbstractViewEdge edge)
        Gets the registered source node for a given edge.
        Parameters:
        edge - The edge.
        Returns:
        The related source node or null if none was registered.
      • getEdgeTarget

        public AbstractViewNode getEdgeTarget​(AbstractViewEdge edge)
        Gets the registered target node for a given edge.
        Parameters:
        edge - The edge.
        Returns:
        The related target node or null if none was registered.
      • getNodes

        public List<AbstractViewNode> getNodes()
        Returns the available nodes.
        Returns:
        The nodes in the map.
      • getEdges

        public List<AbstractViewEdge> getEdges()
        Returns the available edges.
        Returns:
        The edges in the map.
      • getProperties

        public Properties getProperties()
        Returns the extra information associated to the view that uses this map. This can be stuff like the coordinates of the center of a map, or the zoom of an object view.
        Returns:
        The set of properties set for this map.
      • clear

        public void clear()
        Removes all the entries in the lists and hashmaps.
      • findNode

        public AbstractViewNode findNode​(Object identifier)
        Tries to match a node in the view with a business object provided as parameter. The identifier is compared with the business object behind each one of the existing nodes using its equals method, thus being able to support multiple types of comparisons.
        Parameters:
        identifier - The business object to be matched against.
        Returns:
        The view node if existent, null otherwise.
      • findEdge

        public AbstractViewEdge findEdge​(Object identifier)
        Tries to match an edge in the view with a business object provided as parameter. The identifier is compared with the business object behind each one of the existing edges using its equals method, thus being able to support multiple types of comparisons.
        Parameters:
        identifier - The business object to be matched against.
        Returns:
        The view edge if existent, null otherwise.