/** * Converts an Obvious tree to an infovis tree. * @param tree tree to convert * @return the converted infovis tree */ private infovis.Tree convertToIvtkTree(Tree<Node, Edge> tree) { if (tree.getEdges().size() != 0 && tree.getNodes().size() != 0) { Schema nodeSchema = tree.getNodes().iterator().next().getSchema() .getDataSchema(); Schema edgeSchema = tree.getEdges().iterator().next().getSchema() .getDataSchema(); Tree<Node, Edge> ivtkTree = new IvtkObviousTree(nodeSchema, edgeSchema); ObviousLib.fillTree(tree, ivtkTree); return (infovis.Tree) ivtkTree.getUnderlyingImpl(infovis.Tree.class); } else { throw new ObviousRuntimeException("Empty tree!"); } }
/** * Converts an Obvious network to an infovis graph. * @param network network to convert * @return the converted infovis network */ private infovis.Graph convertToIvtkGraph(Network network) { if (network.getEdges().size() != 0 && network.getNodes().size() != 0) { Schema nodeSchema = network.getNodeTable().getSchema().getDataSchema(); Schema edgeSchema = network.getEdgeTable().getSchema().getDataSchema(); Network ivtkNetwork = new IvtkObviousNetwork(nodeSchema, edgeSchema); ObviousLib.fillNetwork(network, ivtkNetwork); NetworkListener listnr = new ObviousLinkNetworkListener(network); NetworkListener listnr2 = new ObviousLinkNetworkListener(ivtkNetwork); ivtkNetwork.addNetworkListener(listnr); network.addNetworkListener(listnr2); return (infovis.Graph) ivtkNetwork.getUnderlyingImpl(infovis.Graph.class); } else { throw new ObviousRuntimeException("Empty graph!"); } }
/** * Converts an Obvious Table to an infovis table. * @param table table to convert * @return the converted infovis table */ private infovis.Table convertToIvtkTable(Table table) { Table ivtkObviousTable = new IvtkObviousTable( table.getSchema().getDataSchema()); ObviousLib.fillTable(table, ivtkObviousTable); TableListener listnr = new ObviousLinkListener(table); TableListener listnr2 = new ObviousLinkListener(ivtkObviousTable); ivtkObviousTable.addTableListener(listnr); table.addTableListener(listnr2); return (infovis.Table) ivtkObviousTable.getUnderlyingImpl( infovis.Table.class); }