Class DynastyTree


  • public class DynastyTree
    extends java.lang.Object
    Class used to create and represent a Dynasty's genealogical tree graph.
    Author:
    Matteo Collica, Radu Ionut Barbalata, Sara Lazzaroni
    See Also:
    Dynasty, DynastyTreeFrame
    • Constructor Summary

      Constructors 
      Constructor Description
      DynastyTree​(org.openqa.selenium.WebDriver webDriver, PersonPageData founderPageData, Dynasty dynasty)
      Construct the graph of the dynasty starting from the Founder
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean addPersonConnection​(PersonPageData firstPersonPageData, PersonNameUrl secondPersonNameUrl, DynastyTree.KinshipDegree kinshipDegree, int offsetX, int offsetY)
      This method creates the connection between two nodes, represented by a PersonPageData (the first) and a PersonNameUrl (the second one) object, taking in account the relationship between them
      void addPersonToGraph​(PersonNameUrl personNameUrl)
      Crate and add the Node of the person to the Graph
      Dynasty getDynasty()  
      org.graphstream.graph.Graph getGraph()  
      void removeNode​(java.lang.String nodeId)
      Remove the specific node
      • Methods inherited from class java.lang.Object

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

      • graph

        private final org.graphstream.graph.Graph graph
      • graphNodeIds

        private java.util.HashSet<java.lang.String> graphNodeIds
      • dynasty

        private final Dynasty dynasty
      • founderNode

        private final Person founderNode
    • Constructor Detail

      • DynastyTree

        public DynastyTree​(org.openqa.selenium.WebDriver webDriver,
                           PersonPageData founderPageData,
                           Dynasty dynasty)
        Construct the graph of the dynasty starting from the Founder
        Parameters:
        webDriver - the Web Driver instance to be used to scrape data
        founderPageData - PersonPageData object which represent the founder of the dynasty
        dynasty - Dynasty object contain the principal information about the dynasty than we create
    • Method Detail

      • addPersonToGraph

        public void addPersonToGraph​(PersonNameUrl personNameUrl)
        Crate and add the Node of the person to the Graph
        Parameters:
        personNameUrl - PersonNameUrl object whose url will represent the NodeID
      • addPersonConnection

        public boolean addPersonConnection​(PersonPageData firstPersonPageData,
                                           PersonNameUrl secondPersonNameUrl,
                                           DynastyTree.KinshipDegree kinshipDegree,
                                           int offsetX,
                                           int offsetY)
        This method creates the connection between two nodes, represented by a PersonPageData (the first) and a PersonNameUrl (the second one) object, taking in account the relationship between them
        Parameters:
        firstPersonPageData - PersonPageData object of the person that defines the relationship
        secondPersonNameUrl - PersonPageData object of the second person
        kinshipDegree - KinshipDegree object which represent the relationship between the firstPersonPageData and the secondPersonNameUrl
        offsetX - the horizontal distance between the firstNode and the second one
        offsetY - the vertical distance between the firstNode and the second one
        Returns:
        true if the second node isn't in the graph, false otherwise
      • removeNode

        public void removeNode​(java.lang.String nodeId)
        Remove the specific node
        Parameters:
        nodeId - the ID of the node to be removed
      • getDynasty

        public Dynasty getDynasty()
        Returns:
        the Dynasty object related to this DynastyTree instance
      • getGraph

        public org.graphstream.graph.Graph getGraph()
        Returns:
        the Graph object related to this DynastyTree instance