| 
|  |  
|  |  
| 
 
| Show me the pedigree! | 
public static void main(String[] args) {
	//Step 1
	Graph graph = new Graph();
		CsvGraphLoader loader = new CsvGraphLoader("tutorial_data.csv", ",");
		loader.setSettings("PID", "MOM", "DAD");
		loader.load(graph);
	//Step 2
	Sugiyama s = new Sugiyama(graph);
		s.run();
	//Creates a frame
	JFrame frame = new JFrame();
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setSize(800, 600);
	//Step 3
	GraphView2D view = new GraphView2D(s.getLayoutedGraph());
		frame.add(view.getComponent());
	frame.setVisible(true);
}
 [complete source]Import data from database[tutorial_data.csv]
 An example with HSQL: 	Database db = new HSQLDatabase();
	Graph graph = new Graph();
	if (db.connect("user", "pass", "connection-string")) {
	    DatabaseGraphLoader loader = new DatabaseGraphLoader(db,
		    "table");
	    loader.setSettings("pid-column", "mom-column", "dad-column");
	    loader.load(graph);
	    db.close();
	}
 |  
| Complex custom symbols, here a basic haplotype representation.
 | Extend the class Symbol2Dand override the methoddrawSymbol(..). Its parameters are the Gaphics2D object, the  position and size of the node, the fill and border-color and at least the currentNodeobject. This source code draws a rectangle at the bottom of the sex symbol (it can be the border for the haplotype). public class MyHaplotypeSymbol extends Symbol2D {
    private Rectangle2D rectangle = new Rectangle2D.Double();
    public void drawSymbol(Graphics2D g, Point2D.Float position, float size,
        Color border, Color fill, Node node) {
        float top = (float)(-position.getY() + (size / 2f)+0.5);
        float left =(float)(position.getX() - (size / 2f));
        //draws background
        g.setColor(fill);
        rectangle.setFrame(left+1.5, top, size-3, size*3);
        g.fill(rectangle);
        //draws the border
        g.setColor(border);
        rectangle.setFrame(left+1.5, top, size-3, size*3);
        g.draw(rectangle);
    }
    @Override
    public int getPriority() {
        return 0;
    }
}
 Using the Nodeobject you can read the traits withgetUserData(..). The method getPriority()returns the priority of the symbol. Symbols likeSymbolSexMaleandSymbolSexFemalehave a low priority (0), however theSymbolDeceasedhas a higher priority (5). The priorities define the sequence for drawing the symbols. You can use your symbol in combination with ShapeRuleor you can define it as standard symbol: Workaround for bigger symbolsgraphView.getDefaultNodeView().addSymbol(new MyHaplotypeSymbol())
 If you are working with large symbols then spacing is an issue. In the current version of the pedvizapi you must adapt the spacing between the nodes by hand. Helpful methods are:  
rubberBands.setVerticalSpacing(..)rubberBands.setHorizontalGap(..)graphView.getDefaultEdgeView().setGapTop(...)graphView.getDefaultNodeView().setGap(...) [complete source][tutorial_data.csv]
 |  
| Node Styles | In the pedvizapi nodes are defined by rules. A lot of Difference between Node and NodeViewRulesare already implemented, such as forcolors,symbolsandhints. In this tutorial we define a newRule. An individual will be represented by the class Class RuleNode. EveryNodehas his ownNodeViewobject. It will be used for drawing the node on aGraphView. TheNodeViewobject saves informations like the position, fill color, border color and symbols for a specificNode. You don’t have access directly to aNodeView, but across aRule. Every rule must extend the class Ruleand must overwrite the methodapplyRule(..).
This methode will be run for every individual with itsNodeViewas parameter.
You get the specificNodefrom the givenNodeViewby the methodgetNode().
Now you are able to change the node by using setter-methods fromNodeView. class MyFantasticRule extends Rule {
    public void applyRule(NodeView nodeview) {
        // gets a reference to node
        Node node = nodeview.getNode();
        // now you have access to the traits
        Object value = node.getUserData("TRAIT");
        if (value != null) {
            Integer trait = Integer.parseInt(value.toString());
            if (trait > 107)
                nodeview.setColor(Color.red);
			else
                nodeview.setColor(Color.blue);
            // add a wonderful hint
            nodeview.setHintText("trait: " + trait);
    }
}
 The new HintsRulemust be added to theGraphViewwithaddRule(...). 
If you add more rules, they are applied one after another.A rule can overwrite values changed by an earlier rule. [complete source][tutorial_data.csv]
 |  
| Customization | Some usefull hints to customize the visualization. It's only a small overview of the core features. To see pedvizapi in its full strength, check out the demo section and the documentation. 
First of all, change the background color:
	view.setBackground(Color.YELLOW);
The appearance for all nodes and edges you can set in the DefaultNodeView and the DefaultEdgeView object. This must happen before you runs the layout algorithm.
	DefaultEdgeView e = new DefaultEdgeView();
	e.setWidth(0.0005f);
	e.setColor(new Color(100,100,100));
	e.setAlphaForLongLines(0.2f);
	e.setHighlightedColor(Color.black);
	DefaultNodeView n = new DefaultNodeView();
	n.setColor(Color.orange);
	n.addHintAttribute("pid");
	n.addHintAttribute("mom");
	n.addHintAttribute("dad");
	Sugiyama algorithm = new Sugiyama(graph, n, e);
	algorithm.run();
Add a rule to your GraphView object (see: ColorRule,ShapeRuleandHintRule), with it you can change the appearance of particular nodes  (e.g: all sick individuals have a red color, symbols are dependent on sex).	ColorRule rule = new ColorRule("sick", 1", Color.red);
	view.addRule(rule);
	view.addRule(new ShapeRule("sex", "1", new SymbolSexFemale());
	view.addRule(new ShapeRule("sex", "2", new SymbolSexMale());
	view.addRule(new ShapeRule("sex", "-1", new SymbolSexUndesignated());
 [complete source][tutorial_data.csv]
Enable the selection for nodes and register a NodeListenerto react on it: Useful  classes:	view.setSelectionEnabled(true);
	view.addNodeListener(new NodeListener() {
	    public void onNodeEvent(NodeEvent event) {
		switch (event.getType()) {
		case NodeEvent.MOUSE_ENTER:
		    ...
		    break;
		case NodeEvent.MOUSE_LEAVE:
		    ...
		    break;
		case NodeEvent.DESELECTED:
			...
		    break;
		case NodeEvent.SELECTED:
			...
		    break;
		case NodeEvent.ALL_DESELECTED:
		    ...
		    break;
	    }
	});
 NodeEvent,PathHighlighterandLODHighlighter.[complete source]Use the[tutorial_data.csv]
 Filterand theHighlighterclass to find important nodes and highlight them. Also it's possible to hide unimportant stuff.	Node node = graph.getNode(nodeId);
	if (selectedNode != null) {
	    ArrayList nodes = Highlighter.findParentsAndChilds(node, 1);
	    graphView.highlight(nodes);
	} else {
	    graphView.unHighlightAll();
	}
 |  |  
| 
 |  
|  |  
|   |  |