Search this API

y.layout.genealogy
Class FamilyTreeLayouter

java.lang.Object
  extended by y.layout.CanonicMultiStageLayouter
      extended by y.layout.genealogy.FamilyTreeLayouter
All Implemented Interfaces:
Layouter

public class FamilyTreeLayouter
extends CanonicMultiStageLayouter

This class implements a layout algorithm for genealogical data (family trees).

To be suitable for this layouter the graphs have to be organized in the following way: Individuals as well as their marriage or partnership are represented by nodes, in the following referred to as INDI nodes for individuals and FAM nodes for family nodes, corresponding to the INDI and FAM entries in Gedcom encoded genealogical data (GEDCOM is a widely used format to store genealogical data, see http://www.phpgedview.net/ged551-5.pdf for the most recent specifications).

In order to determine whether a node represents an individual or a partnership, the data provider DP_KEY_FAMILY_TYPE has to be registered, otherwise an IllegalArgumentException will be thrown. That data provider should return:

All other values will be interpreted as if the node represents an individual.

A FAM node is linked to the INDI nodes representing husband and wife by ingoing edges and to INDI nodes representing the children by outgoing edges. Two nodes of the same type (INDI or FAM) which are linked directly together will cause a WrongGraphStructure exception. A FAM node with more than two parents will also cause a WrongGraphStructure exception.

The layout is calculated basically in two steps: The top layouter can be accessed by getTopLayouter() and setTopLayouter(y.layout.Layouter). By default, an IncrementalHierarchicLayouter is used.


Field Summary
static int ALIGN_BOTTOM
           
static int ALIGN_CENTER
           
static int ALIGN_TOP
           
static int DO_NOT_SORT_BY_SEX
          Disables sorting the individuals according to their sex.
static String DP_KEY_FAMILY_TYPE
          Data provider key which defines a data provider for nodes which returns a String which defines the type of the node as defined in TYPE_FAMILY, TYPE_MALE, TYPE_FEMALE.
static int FEMALE_ALWAYS_FIRST
          Places female individuals before their male siblings and partners.
static int FEMALE_FIRST
          Places female individuals before their male siblings and partners if possible.
static int MALE_ALWAYS_FIRST
          Places female individuals before their male siblings and partners.
static int MALE_FIRST
          Places female individuals before their male siblings and partners if possible.
static String TYPE_FAMILY
          Returned by the DataProvider DP_KEY_FAMILY_TYPE for nodes which represent a family.
static String TYPE_FEMALE
          Returned by the DataProvider DP_KEY_FAMILY_TYPE for nodes which represent a female individual.
static String TYPE_MALE
          Returned by the DataProvider DP_KEY_FAMILY_TYPE for nodes which represent a male individual.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
FamilyTreeLayouter()
          Creates a new instance of this
 
Method Summary
 boolean canLayoutCore(LayoutGraph graph)
          Returns true if the given graph can be laid out by this algorithm.
protected  void doLayoutCore(LayoutGraph graph)
          Main layout routine that assigns new layout information to the given graph.
 int getAlignment()
          Gets the vertical alignment of the individual nodes
 double getOffsetForFamilyNodes()
          Gets the offset by which a family node will be shifted down if its parents are not direct neighbours.
 int getSortFamilyMembers()
          Gets the policy the individuals of a family will be sorted by their sex.
 double getSpacingBetweenFamilyMembers()
          Gets the (horizontal) space between two nodes representing members of the same family.
 Layouter getTopLayouter()
          Returns the layouter which is responsible for the layout between the family groups.
 boolean isFamilyNodesAlwaysBelow()
          Determines whether family/marriage nodes will be placed between the partners or below them.
 boolean isPartnerlessBelow()
          Determines the treatment of individuals who have only children but no partners.
 void setAlignment(int alignment)
          Sets the vertical alignment of the individual nodes
 void setFamilyNodesAlwaysBelow(boolean fnab)
          Determines whether family/marriage nodes will be placed between the partners or below them.
 void setOffsetForFamilyNodes(double vSpace)
          Sets the offset by which a family node will be shifted down if its parents are not direct neighbours.
 void setPartnerlessBelow(boolean pb)
          Determines the treatment of individuals who have only children but no partners.
 void setSortFamilyMembers(int sortFamilyMembers)
          Sets the policy the individuals of a family will be sorted by their sex.
 void setSpacingBetweenFamilyMembers(double hSpace)
          Sets the (horizontal) space between two nodes representing members of the same family.
 void setTopLayouter(Layouter topLayouter)
          Sets the layouter which is responsible for the layout between the family groups.
 
Methods inherited from class y.layout.CanonicMultiStageLayouter
appendStage, calcLayout, calcLayout, canLayout, checkGroupNodeSize, checkNodeSize, doLayout, doLayout, enableOnlyCore, getComponentLayouter, getGroupNodeHider, getLabelLayouter, getLayoutOrientation, getOrientationLayouter, getParallelEdgeLayouter, getSelfLoopLayouter, getSubgraphLayouter, isComponentLayouterEnabled, isGroupNodeHidingEnabled, isLabelLayouterEnabled, isOrientationLayouterEnabled, isParallelEdgeLayouterEnabled, isSelfLoopLayouterEnabled, isSubgraphLayouterEnabled, prependStage, removeStage, setComponentLayouter, setComponentLayouterEnabled, setGroupNodeHider, setGroupNodeHidingEnabled, setLabelLayouter, setLabelLayouterEnabled, setLayoutOrientation, setOrientationLayouter, setOrientationLayouterEnabled, setParallelEdgeLayouter, setParallelEdgeLayouterEnabled, setSelfLoopLayouter, setSelfLoopLayouterEnabled, setSubgraphLayouter, setSubgraphLayouterEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DP_KEY_FAMILY_TYPE

public static final String DP_KEY_FAMILY_TYPE
Data provider key which defines a data provider for nodes which returns a String which defines the type of the node as defined in TYPE_FAMILY, TYPE_MALE, TYPE_FEMALE. Nodes for which null is returned will be treated like nodes which represent individuals.

See Also:
Constant Field Values

TYPE_FAMILY

public static final String TYPE_FAMILY
Returned by the DataProvider DP_KEY_FAMILY_TYPE for nodes which represent a family.

See Also:
Constant Field Values

TYPE_MALE

public static final String TYPE_MALE
Returned by the DataProvider DP_KEY_FAMILY_TYPE for nodes which represent a male individual.

See Also:
Constant Field Values

TYPE_FEMALE

public static final String TYPE_FEMALE
Returned by the DataProvider DP_KEY_FAMILY_TYPE for nodes which represent a female individual.

See Also:
Constant Field Values

ALIGN_TOP

public static final int ALIGN_TOP
See Also:
getAlignment(), setAlignment(int), Constant Field Values

ALIGN_CENTER

public static final int ALIGN_CENTER
See Also:
getAlignment(), setAlignment(int), Constant Field Values

ALIGN_BOTTOM

public static final int ALIGN_BOTTOM
See Also:
getAlignment(), setAlignment(int), Constant Field Values

DO_NOT_SORT_BY_SEX

public static final int DO_NOT_SORT_BY_SEX
Disables sorting the individuals according to their sex.

See Also:
getSortFamilyMembers(), setSortFamilyMembers(int), Constant Field Values

FEMALE_FIRST

public static final int FEMALE_FIRST
Places female individuals before their male siblings and partners if possible.

See Also:
getSortFamilyMembers(), setSortFamilyMembers(int), Constant Field Values

FEMALE_ALWAYS_FIRST

public static final int FEMALE_ALWAYS_FIRST
Places female individuals before their male siblings and partners.

See Also:
getSortFamilyMembers(), setSortFamilyMembers(int), Constant Field Values

MALE_FIRST

public static final int MALE_FIRST
Places female individuals before their male siblings and partners if possible.

See Also:
getSortFamilyMembers(), setSortFamilyMembers(int), Constant Field Values

MALE_ALWAYS_FIRST

public static final int MALE_ALWAYS_FIRST
Places female individuals before their male siblings and partners.

See Also:
getSortFamilyMembers(), setSortFamilyMembers(int), Constant Field Values
Constructor Detail

FamilyTreeLayouter

public FamilyTreeLayouter()
Creates a new instance of this

Method Detail

getTopLayouter

public Layouter getTopLayouter()
Returns the layouter which is responsible for the layout between the family groups. If no layouter is set, a new instance of IncrementalHierarchicLayouter is created.

Returns:
the top layouter

setTopLayouter

public void setTopLayouter(Layouter topLayouter)
Sets the layouter which is responsible for the layout between the family groups.

Parameters:
topLayouter - the top layouter to set.

setSpacingBetweenFamilyMembers

public void setSpacingBetweenFamilyMembers(double hSpace)
Sets the (horizontal) space between two nodes representing members of the same family.

Parameters:
hSpace - The space to set.

getSpacingBetweenFamilyMembers

public double getSpacingBetweenFamilyMembers()
Gets the (horizontal) space between two nodes representing members of the same family.

Returns:
The space between two family members.

setOffsetForFamilyNodes

public void setOffsetForFamilyNodes(double vSpace)
Sets the offset by which a family node will be shifted down if its parents are not direct neighbours.

Parameters:
vSpace - The offset for the family node

getOffsetForFamilyNodes

public double getOffsetForFamilyNodes()
Gets the offset by which a family node will be shifted down if its parents are not direct neighbours.

Returns:
The offset for the family node

setPartnerlessBelow

public void setPartnerlessBelow(boolean pb)
Determines the treatment of individuals who have only children but no partners. If set to true, the family node will be placed centered below the individual node. Thus, a direct male inheritance line for example will be depicted in a more obvious way.

Parameters:
pb - if true, FAM nodes which have only one parent will be placed below the individual

isPartnerlessBelow

public boolean isPartnerlessBelow()
Determines the treatment of individuals who have only children but no partners. If set to true, the family node will be placed centered below the individual node. Thus, a direct male inheritance line for example will be depicted in a more obvious way.

Returns:
true if FAM nodes which have only one parent will be placed below the individual

setFamilyNodesAlwaysBelow

public void setFamilyNodesAlwaysBelow(boolean fnab)
Determines whether family/marriage nodes will be placed between the partners or below them.

Parameters:
fnab - true, if FAM nodes are to be placed below the partners.

isFamilyNodesAlwaysBelow

public boolean isFamilyNodesAlwaysBelow()
Determines whether family/marriage nodes will be placed between the partners or below them.

Returns:
true, if FAM nodes are to be placed below the partners.

getAlignment

public int getAlignment()
Gets the vertical alignment of the individual nodes

Returns:
the vertical alignment, one of ALIGN_TOP, ALIGN_CENTER, ALIGN_BOTTOM.

setAlignment

public void setAlignment(int alignment)
Sets the vertical alignment of the individual nodes

Throws:
IllegalArgumentException - if the given value is not defined.
Parameters:
alignment - the vertical alignment, one of ALIGN_TOP, ALIGN_CENTER, ALIGN_BOTTOM.

canLayoutCore

public boolean canLayoutCore(LayoutGraph graph)
Returns true if the given graph can be laid out by this algorithm. Calling doLayout with the given graph as it's argument will only succeed if this method returns true.

Specified by:
canLayoutCore in class CanonicMultiStageLayouter

getSortFamilyMembers

public int getSortFamilyMembers()
Gets the policy the individuals of a family will be sorted by their sex. Default is no sorting (DO_NOT_SORT_BY_SEX).

Returns:
The policy the individuals of a family will be sorted by their sex.
See Also:
setSortFamilyMembers(int)

setSortFamilyMembers

public void setSortFamilyMembers(int sortFamilyMembers)
Sets the policy the individuals of a family will be sorted by their sex. Default is no sorting (DO_NOT_SORT_BY_SEX).

Parameters:
sortFamilyMembers - The sorting policy of the family members.
See Also:
getSortFamilyMembers()

doLayoutCore

protected void doLayoutCore(LayoutGraph graph)
Main layout routine that assigns new layout information to the given graph.

Specified by:
doLayoutCore in class CanonicMultiStageLayouter
Throws:
IllegalStateException - If the data provider DP_KEY_FAMILY_TYPE is not registered
WrongGraphStructure - If a family node has more than two parents, or two nodes of the same type are linked together
Parameters:
graph - The graph to run the layout on

© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.