Class DynastyTree
- java.lang.Object
-
- romanemperorsscraper.scraping.dynasties.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DynastyTree.KinshipDegree
-
Field Summary
Fields Modifier and Type Field Description private Dynasty
dynasty
private Person
founderNode
private org.graphstream.graph.Graph
graph
private java.util.HashSet<java.lang.String>
graphNodeIds
-
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 themvoid
addPersonToGraph(PersonNameUrl personNameUrl)
Crate and add the Node of the person to the GraphDynasty
getDynasty()
org.graphstream.graph.Graph
getGraph()
void
removeNode(java.lang.String nodeId)
Remove the specific node
-
-
-
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 datafounderPageData
- PersonPageData object which represent the founder of the dynastydynasty
- 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 relationshipsecondPersonNameUrl
- PersonPageData object of the second personkinshipDegree
- KinshipDegree object which represent the relationship between the firstPersonPageData and the secondPersonNameUrloffsetX
- the horizontal distance between the firstNode and the second oneoffsetY
- 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
-
-